@@ -110,11 +110,11 @@ def create_reg_workflow(name='registration'):
110110 register = pe .Workflow (name = name )
111111
112112 inputnode = pe .Node (interface = niu .IdentityInterface (fields = ['source_files' ,
113- 'mean_image' ,
114- 'anatomical_image' ,
115- 'target_image' ,
116- 'target_image_brain' ,
117- 'config_file' ]),
113+ 'mean_image' ,
114+ 'anatomical_image' ,
115+ 'target_image' ,
116+ 'target_image_brain' ,
117+ 'config_file' ]),
118118 name = 'inputspec' )
119119 outputnode = pe .Node (interface = niu .IdentityInterface (fields = ['func2anat_transform' ,
120120 'anat2target_transform' ,
@@ -185,7 +185,7 @@ def create_reg_workflow(name='registration'):
185185 convert2itk .inputs .fsl2ras = True
186186 convert2itk .inputs .itk_transform = True
187187 register .connect (mean2anatbbr , 'out_matrix_file' , convert2itk , 'transform_file' )
188- register .connect (inputnode , 'mean_image' ,convert2itk , 'source_file' )
188+ register .connect (inputnode , 'mean_image' , convert2itk , 'source_file' )
189189 register .connect (stripper , 'out_file' , convert2itk , 'reference_file' )
190190
191191 """
@@ -226,7 +226,7 @@ def create_reg_workflow(name='registration'):
226226 reg .plugin_args = {'qsub_args' : '-pe orte 4' ,
227227 'sbatch_args' : '--mem=6G -c 4' }
228228 register .connect (stripper , 'out_file' , reg , 'moving_image' )
229- register .connect (inputnode ,'target_image_brain' , reg ,'fixed_image' )
229+ register .connect (inputnode , 'target_image_brain' , reg , 'fixed_image' )
230230
231231 """
232232 Concatenate the affine and ants transforms into a list
@@ -249,7 +249,7 @@ def create_reg_workflow(name='registration'):
249249 warpmean .inputs .invert_transform_flags = [False , False ]
250250 warpmean .inputs .terminal_output = 'file'
251251
252- register .connect (inputnode ,'target_image_brain' , warpmean ,'reference_image' )
252+ register .connect (inputnode , 'target_image_brain' , warpmean , 'reference_image' )
253253 register .connect (inputnode , 'mean_image' , warpmean , 'input_image' )
254254 register .connect (merge , 'out' , warpmean , 'transforms' )
255255
@@ -265,8 +265,8 @@ def create_reg_workflow(name='registration'):
265265 warpall .inputs .invert_transform_flags = [False , False ]
266266 warpall .inputs .terminal_output = 'file'
267267
268- register .connect (inputnode ,'target_image_brain' ,warpall ,'reference_image' )
269- register .connect (inputnode ,'source_files' , warpall , 'input_image' )
268+ register .connect (inputnode , 'target_image_brain' , warpall , 'reference_image' )
269+ register .connect (inputnode , 'source_files' , warpall , 'input_image' )
270270 register .connect (merge , 'out' , warpall , 'transforms' )
271271
272272 """
@@ -515,6 +515,7 @@ def create_fs_reg_workflow(name='registration'):
515515Get info for a given subject
516516"""
517517
518+
518519def get_subjectinfo (subject_id , base_dir , task_id , model_id ):
519520 """Get info for a given subject
520521
@@ -559,7 +560,7 @@ def get_subjectinfo(subject_id, base_dir, task_id, model_id):
559560 for idx in range (n_tasks ):
560561 taskidx = np .where (taskinfo [:, 0 ] == 'task%03d' % (idx + 1 ))
561562 conds .append ([condition .replace (' ' , '_' ) for condition
562- in taskinfo [taskidx [0 ], 2 ]]) # if 'junk' not in condition])
563+ in taskinfo [taskidx [0 ], 2 ]]) # if 'junk' not in condition])
563564 files = sorted (glob (os .path .join (base_dir ,
564565 subject_id ,
565566 'BOLD' ,
@@ -588,6 +589,7 @@ def get_subjectinfo(subject_id, base_dir, task_id, model_id):
588589Analyzes an open fmri dataset
589590"""
590591
592+
591593def analyze_openfmri_dataset (data_dir , subject = None , model_id = None ,
592594 task_id = None , output_dir = None , subj_prefix = '*' ,
593595 hpcutoff = 120. , use_derivatives = True ,
@@ -661,15 +663,15 @@ def analyze_openfmri_dataset(data_dir, subject=None, model_id=None,
661663 has_contrast = os .path .exists (contrast_file )
662664 if has_contrast :
663665 datasource = pe .Node (nio .DataGrabber (infields = ['subject_id' , 'run_id' ,
664- 'task_id' , 'model_id' ],
665- outfields = ['anat' , 'bold' , 'behav' ,
666- 'contrasts' ]),
667- name = 'datasource' )
666+ 'task_id' , 'model_id' ],
667+ outfields = ['anat' , 'bold' , 'behav' ,
668+ 'contrasts' ]),
669+ name = 'datasource' )
668670 else :
669671 datasource = pe .Node (nio .DataGrabber (infields = ['subject_id' , 'run_id' ,
670- 'task_id' , 'model_id' ],
671- outfields = ['anat' , 'bold' , 'behav' ]),
672- name = 'datasource' )
672+ 'task_id' , 'model_id' ],
673+ outfields = ['anat' , 'bold' , 'behav' ]),
674+ name = 'datasource' )
673675 datasource .inputs .base_directory = data_dir
674676 datasource .inputs .template = '*'
675677
@@ -681,19 +683,19 @@ def analyze_openfmri_dataset(data_dir, subject=None, model_id=None,
681683 'contrasts' : ('models/model%03d/'
682684 'task_contrasts.txt' )}
683685 datasource .inputs .template_args = {'anat' : [['subject_id' ]],
684- 'bold' : [['subject_id' , 'task_id' ]],
685- 'behav' : [['subject_id' , 'model_id' ,
686- 'task_id' , 'run_id' ]],
687- 'contrasts' : [['model_id' ]]}
686+ 'bold' : [['subject_id' , 'task_id' ]],
687+ 'behav' : [['subject_id' , 'model_id' ,
688+ 'task_id' , 'run_id' ]],
689+ 'contrasts' : [['model_id' ]]}
688690 else :
689691 datasource .inputs .field_template = {'anat' : '%s/anatomy/T1_001.nii.gz' ,
690692 'bold' : '%s/BOLD/task%03d_r*/bold.nii.gz' ,
691693 'behav' : ('%s/model/model%03d/onsets/task%03d_'
692694 'run%03d/cond*.txt' )}
693695 datasource .inputs .template_args = {'anat' : [['subject_id' ]],
694- 'bold' : [['subject_id' , 'task_id' ]],
695- 'behav' : [['subject_id' , 'model_id' ,
696- 'task_id' , 'run_id' ]]}
696+ 'bold' : [['subject_id' , 'task_id' ]],
697+ 'behav' : [['subject_id' , 'model_id' ,
698+ 'task_id' , 'run_id' ]]}
697699
698700 datasource .inputs .sort_filelist = True
699701
@@ -736,7 +738,7 @@ def get_contrasts(contrast_file, task_id, conds):
736738 for row in contrast_def :
737739 if row [0 ] != 'task%03d' % task_id :
738740 continue
739- con = [row [1 ], 'T' , ['cond%03d' % (i + 1 ) for i in range (len (conds ))],
741+ con = [row [1 ], 'T' , ['cond%03d' % (i + 1 ) for i in range (len (conds ))],
740742 row [2 :].astype (float ).tolist ()]
741743 contrasts .append (con )
742744 # add auto contrasts for each column
@@ -762,7 +764,7 @@ def get_contrasts(contrast_file, task_id, conds):
762764 name = "art" )
763765
764766 modelspec = pe .Node (interface = model .SpecifyModel (),
765- name = "modelspec" )
767+ name = "modelspec" )
766768 modelspec .inputs .input_units = 'secs'
767769
768770 def check_behav_list (behav , run_id , conds ):
@@ -776,9 +778,9 @@ def check_behav_list(behav, run_id, conds):
776778 return behav_array .reshape (num_elements / num_conds , num_conds ).tolist ()
777779
778780 reshape_behav = pe .Node (niu .Function (input_names = ['behav' , 'run_id' , 'conds' ],
779- output_names = ['behav' ],
780- function = check_behav_list ),
781- name = 'reshape_behav' )
781+ output_names = ['behav' ],
782+ function = check_behav_list ),
783+ name = 'reshape_behav' )
782784
783785 wf .connect (subjinfo , 'TR' , modelspec , 'time_repetition' )
784786 wf .connect (datasource , 'behav' , reshape_behav , 'behav' )
@@ -858,7 +860,7 @@ def sort_copes(copes, varcopes, contrasts):
858860 ('varcopes' , 'inputspec.varcopes' ),
859861 ('n_runs' , 'l2model.num_copes' )]),
860862 (modelfit , fixed_fx , [('outputspec.dof_file' ,
861- 'inputspec.dof_files' ),
863+ 'inputspec.dof_files' ),
862864 ])
863865 ])
864866
@@ -888,9 +890,9 @@ def merge_files(copes, varcopes, zstats):
888890
889891 mergefunc = pe .Node (niu .Function (input_names = ['copes' , 'varcopes' ,
890892 'zstats' ],
891- output_names = ['out_files' , 'splits' ],
892- function = merge_files ),
893- name = 'merge_files' )
893+ output_names = ['out_files' , 'splits' ],
894+ function = merge_files ),
895+ name = 'merge_files' )
894896 wf .connect ([(fixed_fx .get_node ('outputspec' ), mergefunc ,
895897 [('copes' , 'copes' ),
896898 ('varcopes' , 'varcopes' ),
@@ -908,7 +910,7 @@ def split_files(in_files, splits):
908910 output_names = ['copes' , 'varcopes' ,
909911 'zstats' ],
910912 function = split_files ),
911- name = 'split_files' )
913+ name = 'split_files' )
912914 wf .connect (mergefunc , 'splits' , splitfunc , 'splits' )
913915 wf .connect (registration , 'outputspec.transformed_files' ,
914916 splitfunc , 'in_files' )
@@ -932,12 +934,12 @@ def split_files(in_files, splits):
932934
933935 def get_subs (subject_id , conds , run_id , model_id , task_id ):
934936 subs = [('_subject_id_%s_' % subject_id , '' )]
935- subs .append (('_model_id_%d' % model_id , 'model%03d' % model_id ))
937+ subs .append (('_model_id_%d' % model_id , 'model%03d' % model_id ))
936938 subs .append (('task_id_%d/' % task_id , '/task%03d_' % task_id ))
937939 subs .append (('bold_dtype_mcf_mask_smooth_mask_gms_tempfilt_mean_warp' ,
938- 'mean' ))
940+ 'mean' ))
939941 subs .append (('bold_dtype_mcf_mask_smooth_mask_gms_tempfilt_mean_flirt' ,
940- 'affine' ))
942+ 'affine' ))
941943
942944 for i in range (len (conds )):
943945 subs .append (('_flameo%d/cope1.' % i , 'cope%02d.' % (i + 1 )))
@@ -1058,7 +1060,7 @@ def get_subs(subject_id, conds, run_id, model_id, task_id):
10581060 help = "Model index" + defstr )
10591061 parser .add_argument ('-x' , '--subjectprefix' , default = 'sub*' ,
10601062 help = "Subject prefix" + defstr )
1061- parser .add_argument ('-t' , '--task' , default = 1 , #nargs='+',
1063+ parser .add_argument ('-t' , '--task' , default = 1 ,
10621064 type = int , help = "Task index" + defstr )
10631065 parser .add_argument ('--hpfilter' , default = 120. ,
10641066 type = float , help = "High pass filter cutoff (in secs)" + defstr )
0 commit comments