@@ -757,7 +757,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle',
757757 return featpreproc
758758
759759
760- def create_susan_smooth (name = "susan_smooth" , separate_masks = True ):
760+ def create_susan_smooth (name = "susan_smooth" , separate_masks = True , list_fwhms = False ):
761761 """Create a SUSAN smoothing workflow
762762
763763 Parameters
@@ -767,11 +767,12 @@ def create_susan_smooth(name="susan_smooth", separate_masks=True):
767767
768768 name : name of workflow (default: susan_smooth)
769769 separate_masks : separate masks for each run
770+ list_fwhms : multiple full wide half maximum smoothing kernels
770771
771772 Inputs::
772773
773774 inputnode.in_files : functional runs (filename or list of filenames)
774- inputnode.fwhm : fwhm for smoothing with SUSAN
775+ inputnode.fwhm : fwhm for smoothing with SUSAN (float or list of floats)
775776 inputnode.mask_file : mask used for estimating SUSAN thresholds (but not for smoothing)
776777
777778 Outputs::
@@ -788,6 +789,18 @@ def create_susan_smooth(name="susan_smooth", separate_masks=True):
788789 >>> smooth.run() # doctest: +SKIP
789790
790791 """
792+ def cartesian_product (fwhms , in_files , mask_files , merge_out , median_out ):
793+ if type (in_files ) == str :
794+ in_files = [in_files ]
795+ if type (mask_files ) == str :
796+ mask_files = [mask_files ]
797+ multi_in_files = [in_file for in_file in in_files for fwhm in fwhms ]
798+ multi_mask_files = [mask_file for mask_file in mask_files for fwhm in fwhms ]
799+ multi_fwhms = [fwhm for fwhm in fwhms for in_file in in_files ]
800+ multi_merge_out = [merge for merge in merge_out for fwhm in fwhms ]
801+ multi_median_out = [median for median in median_out for fwhm in fwhms ]
802+
803+ return multi_in_files , multi_mask_files , multi_fwhms , multi_merge_out , multi_median_out
791804
792805 susan_smooth = pe .Workflow (name = name )
793806
@@ -806,10 +819,27 @@ def create_susan_smooth(name="susan_smooth", separate_masks=True):
806819 of the median value for each run and a mask consituting the mean
807820 functional
808821 """
809-
810- smooth = pe .MapNode (interface = fsl .SUSAN (),
811- iterfield = ['in_file' , 'brightness_threshold' , 'usans' ],
812- name = 'smooth' )
822+ if list_fwhms :
823+ multi_inputs = pe .Node (util .Function (input_names = ['fwhms' ,
824+ 'in_files' ,
825+ 'mask_files' ,
826+ 'merge_out' ,
827+ 'median_out' ],
828+ output_names = ['multi_in_files' ,
829+ 'multi_mask_files' ,
830+ 'multi_fwhms' ,
831+ 'multi_merge_out' ,
832+ 'multi_median_out' ],
833+ function = cartesian_product ),
834+ name = 'multi_inputs' )
835+
836+ smooth = pe .MapNode (interface = fsl .SUSAN (),
837+ iterfield = ['in_file' , 'brightness_threshold' , 'usans' , 'fwhm' ],
838+ name = 'smooth' )
839+ else :
840+ smooth = pe .MapNode (interface = fsl .SUSAN (),
841+ iterfield = ['in_file' , 'brightness_threshold' , 'usans' ],
842+ name = 'smooth' )
813843
814844 """
815845 Determine the median value of the functional runs using the mask
@@ -865,10 +895,24 @@ def create_susan_smooth(name="susan_smooth", separate_masks=True):
865895 """
866896 Define a function to get the brightness threshold for SUSAN
867897 """
868- susan_smooth .connect (inputnode , 'fwhm' , smooth , 'fwhm' )
869- susan_smooth .connect (inputnode , 'in_files' , smooth , 'in_file' )
870- susan_smooth .connect (median , ('out_stat' , getbtthresh ), smooth , 'brightness_threshold' )
871- susan_smooth .connect (merge , ('out' , getusans ), smooth , 'usans' )
898+ # if you are going to iterate over multiple values of fwhm
899+ if list_fwhms :
900+ susan_smooth .connect ([
901+ (inputnode , multi_inputs , [('in_files' , 'in_files' ),
902+ ('fwhm' , 'fwhms' ),
903+ ('mask_file' , 'mask_files' )]),
904+ ])
905+ susan_smooth .connect (median , ('out_stat' , getbtthresh ), multi_inputs , 'median_out' )
906+ susan_smooth .connect (merge , ('out' , getusans ), multi_inputs , 'merge_out' )
907+ susan_smooth .connect (multi_inputs , 'multi_fwhms' , smooth , 'fwhm' )
908+ susan_smooth .connect (multi_inputs , 'multi_in_files' , smooth , 'in_file' )
909+ susan_smooth .connect (multi_inputs , 'multi_median_out' , smooth , 'brightness_threshold' )
910+ susan_smooth .connect (multi_inputs , 'multi_merge_out' , smooth , 'usans' )
911+ else :
912+ susan_smooth .connect (inputnode , 'in_files' , smooth , 'in_file' )
913+ susan_smooth .connect (inputnode , 'fwhm' , smooth , 'fwhm' )
914+ susan_smooth .connect (median , ('out_stat' , getbtthresh ), smooth , 'brightness_threshold' )
915+ susan_smooth .connect (merge , ('out' , getusans ), smooth , 'usans' )
872916
873917 outputnode = pe .Node (interface = util .IdentityInterface (fields = ['smoothed_files' ]),
874918 name = 'outputnode' )
0 commit comments