88import nipype .interfaces .freesurfer as fs # freesurfer
99import nipype .interfaces .spm as spm
1010
11+ from nipype import LooseVersion
12+
1113from ...smri .freesurfer .utils import create_getmask_flow
1214
1315def getthreshop (thresh ):
@@ -415,6 +417,11 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
415417 >>> preproc.run() # doctest: +SKIP
416418 """
417419
420+ version = 0
421+ if fsl .Info .version () and \
422+ LooseVersion (fsl .Info .version ()) > LooseVersion ('5.0.6' ):
423+ version = 507
424+
418425 featpreproc = pe .Workflow (name = name )
419426
420427 """
@@ -658,17 +665,6 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
658665
659666 featpreproc .connect (medianval , ('out_stat' , getmeanscale ), meanscale , 'op_string' )
660667
661- """
662- Perform temporal highpass filtering on the data
663- """
664-
665- if highpass :
666- highpass = pe .MapNode (interface = fsl .ImageMaths (suffix = '_tempfilt' ),
667- iterfield = ['in_file' ],
668- name = 'highpass' )
669- featpreproc .connect (inputnode , ('highpass' , highpass_operand ), highpass , 'op_string' )
670- featpreproc .connect (meanscale , 'out_file' , highpass , 'in_file' )
671- featpreproc .connect (highpass , 'out_file' , outputnode , 'highpassed_files' )
672668
673669 """
674670 Generate a mean functional image from the first run
@@ -681,6 +677,37 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
681677
682678 featpreproc .connect (meanscale , ('out_file' , pickfirst ), meanfunc3 , 'in_file' )
683679 featpreproc .connect (meanfunc3 , 'out_file' , outputnode , 'mean' )
680+
681+ """
682+ Perform temporal highpass filtering on the data
683+ """
684+
685+ if highpass :
686+ highpass = pe .MapNode (interface = fsl .ImageMaths (suffix = '_tempfilt' ),
687+ iterfield = ['in_file' ],
688+ name = 'highpass' )
689+ featpreproc .connect (inputnode , ('highpass' , highpass_operand ), highpass , 'op_string' )
690+ featpreproc .connect (meanscale , 'out_file' , highpass , 'in_file' )
691+
692+ if version < 507 :
693+ featpreproc .connect (highpass , 'out_file' , outputnode , 'highpassed_files' )
694+ else :
695+ """
696+ Add back the mean removed by the highpass filter operation as of FSL 5.0.7
697+ """
698+ meanfunc4 = pe .MapNode (interface = fsl .ImageMaths (op_string = '-Tmean' ,
699+ suffix = '_mean' ),
700+ iterfield = ['in_file' ],
701+ name = 'meanfunc4' )
702+
703+ featpreproc .connect (meanscale , 'out_file' , meanfunc4 , 'in_file' )
704+ addmean = pe .MapNode (interface = fsl .BinaryMaths (operation = 'add' ),
705+ iterfield = ['in_file' , 'operand_file' ],
706+ name = 'addmean' )
707+ featpreproc .connect (highpass , 'out_file' , addmean , 'in_file' )
708+ featpreproc .connect (meanfunc4 , 'out_file' , addmean , 'operand_file' )
709+ featpreproc .connect (addmean , 'out_file' , outputnode , 'highpassed_files' )
710+
684711 return featpreproc
685712
686713
0 commit comments