decon - Wrapper for AFNI’s 3dDeconvolve program¶
-
class
neural.decon.Decon[source]¶ wrapper for AFNI 3dDeconvolve command
- Properties:
input_dset: listof input datasetsdecon_stims: listofDeconStimobjects that define the different stimuli. Allows for flexible coding of complex stimuli. Alternatively, for simpler stimuli, you can simply use one of the traditional options below (e.g.,stim_filesorstim_times)stim_files: dictwhere keys are used as stimulus labels and the values are taken as 1D filesstim_times: same as stim_files, but used as a stim_times file models: dictof model names to use for each of the listed stimuli (optional)model_default: default model to use for each stim_timesstimulus if nothing is listed inmodelsstim_base: listof names of stimuli (defined either in stim_files or stim_times) that should be considered in the baseline instead of full modelstim_am1: listof names of stimuli defined in stim_times that should use the-stim_times_AM1modelstim_am2: listof names of stimuli defined in stim_times that should use the-stim_times_AM2modelglts: dictwhere keys are GLT labels, and the value is a symbolic statementmask: either a mask file, or “auto”, which will use “-automask” errts: name of file to save residual time series to - Options that are obvious:
- nfirst (default: 3), censor_file, polort (default: ‘A’), tout, vout, rout, prefix
Other options:
opts: list of extra things to put directly in the command (in case none of the above options cover you) partial: dictwith keys of datasets (given ininput_dsets) and values of atupleof (start,end) for each given dataset. Will automatically adjust all stimfiles and such to match. Column-style stimuli only work if there’s only one datasetExample::
decon = neural.decon.Decon() decon.input_dsets = ['dset_run1.nii.gz', 'dset_run2.nii.gz'] decon.censor_file = 'subject_censor.1D' decon.stim_files = { 'motion_1': 'motion_file.1D[0]', 'motion_2': 'motion_file.1D[1]', 'motion_3': 'motion_file.1D[2]', 'motion_4': 'motion_file.1D[3]', 'motion_5': 'motion_file.1D[4]', 'motion_6': 'motion_file.1D[5]' } decon.stim_base = ['motion_%d' % i for i in range(1,7)] decon.stim_times = { 'stim_a': 'stim_a.stimtimes', 'stim_b': 'stim_b.stimtimes', 'stim_c': 'stim_c.stimtimes', } decon.glts ={ 'a-b': '1*stim_a + -1*stim_b', 'ab-c': '0.5*stim_a + 0.5*stim_b + -1*stim_c' } decon.prefix = 'subject_decon.nii.gz' decon.run()
-
command_list()[source]¶ returns the 3dDeconvolve command as a list
The list returned can be run by passing it into a subprocess-like command (e.g., neural.run())
-
class
neural.decon.DeconStim(name, column_file=None, times_file=None, model='GAM', base=False, AM1=False, AM2=False)[source]¶ encapsulates the definition of any arbitrary stimulus, along with all of its 3dDeconvolve options
- Attributes:
name: Label used for the stimulus You only need to define one of the following to define the stimulus: :column: A
listof numbers (usually the length of the runs) that is placed directly in the 3dDeconvolvematrix. This can be a series of 1’s and 0’s, a 1D-file that has already been convolved with an HRF, or a covariate like motion parameterscolumn_file: The filename of a file that contains a matrix column times: Definition of stimuli using stim_timesapproach. Either alistor alistoflist``s (one for each run) containing either ``float``s or strings of the stimulus times. For details on how to define the stimulus time, see the documentation of ``3dDeconvolve.times_file: A file containing a stim_timesstimulustimes_model: If using stim_times, which HRF model to usebase: Is this stimulus part of the baseline? ( True/False)AM1: Does this stimulus use an “AM1” model? ( True/False)AM2: Does this stimulus use an “AM2” model? ( True/False)reps: Number of reps in associated fMRI run (helpful when manipulating the stims) TR: TR of the associated fMRI run
-
blank_stim(type=None, fill=0)[source]¶ Makes a blank version of stim. If a type is not given, returned as same type as current stim. If a column stim, will fill in blanks with
fill
-
neural.decon.smooth_decon_to_fwhm(decon, fwhm, cache=True)[source]¶ takes an input
Deconobject and uses3dBlurToFWHMto make the output as close as possible tofwhmreturns the final measured fwhm. IfcacheisTrue, will save the blurred input file (and use it again in the future)
-
neural.decon.stack_decon_stims(stim_list)[source]¶ take a
list(in order of runs) ofdict``s of stim_name:DeconStim and stack them together. returns a single ``dictof stim_name:decon_stimAs in, takes: [
# Run 1 { “stim1”: decon_stim1a, “stim2”: decon_stim2a }, # Run 2 { “stim1”: decon_stim1b, “stim2”: decon_stim2b, “stim3”: decon_stim3 }]
- And makes:
- { “stim1”: decon_stim1, “stim2”: decon_stim2, “stim3”: decon_stim3 }
If a stimulus is not present in a run, it will fill that run with an empty stimulus