Skip to content

Commit 4fadedc

Browse files
committed
Merge pull request #1141 from amarinajs/enh-last-volume
NF: allow to select last volume for MC, various DOC tune ups
2 parents 5992452 + 0754fec commit 4fadedc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

nipype/workflows/fmri/fsl/preprocess.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def pickvol(filenames, fileidx, which):
3636
idx = 0
3737
elif which.lower() == 'middle':
3838
idx = int(np.ceil(load(filenames[fileidx]).get_shape()[3]/2))
39+
elif which.lower() == 'last':
40+
idx = load(filenames[fileidx]).get_shape()[3]-1
3941
else:
40-
raise Exception('unknown value for volume selection : %s'%which)
42+
raise Exception('unknown value for volume selection : %s' % which)
4143
return idx
4244

4345
def getbtthresh(medianvals):
@@ -381,7 +383,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
381383
382384
name : name of workflow (default: featpreproc)
383385
highpass : boolean (default: True)
384-
whichvol : which volume of the first run to register to ('first', 'middle', 'mean')
386+
whichvol : which volume of the first run to register to ('first', 'middle', 'last', 'mean')
385387
386388
Inputs::
387389
@@ -467,6 +469,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
467469
run.
468470
"""
469471

472+
470473
img2float = pe.MapNode(interface=fsl.ImageMaths(out_data_type='float',
471474
op_string = '',
472475
suffix='_dtype'),
@@ -475,7 +478,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
475478
featpreproc.connect(inputnode, 'func', img2float, 'in_file')
476479

477480
"""
478-
Extract the first volume of the first run as the reference
481+
Extract the middle (or what whichvol points to) volume of the first run as the reference
479482
"""
480483

481484
if whichvol != 'mean':
@@ -488,7 +491,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
488491

489492

490493
"""
491-
Realign the functional runs to the reference (1st volume of first run)
494+
Realign the functional runs to the reference (`whichvol` volume of first run)
492495
"""
493496

494497
motion_correct = pe.MapNode(interface=fsl.MCFLIRT(save_mats = True,
@@ -518,7 +521,7 @@ def create_featreg_preproc(name='featpreproc', highpass=True, whichvol='middle')
518521
featpreproc.connect(plot_motion, 'out_file', outputnode, 'motion_plots')
519522

520523
"""
521-
Extract the mean volume of the first functional run
524+
Extract the mean volume of the first functional runpreproc
522525
"""
523526

524527
meanfunc = pe.Node(interface=fsl.ImageMaths(op_string = '-Tmean',
@@ -1093,7 +1096,7 @@ def create_fsl_fs_preproc(name='preproc', highpass=True, whichvol='middle'):
10931096
return featpreproc
10941097

10951098
def create_reg_workflow(name='registration'):
1096-
"""Create a FEAT preprocessing workflow together with freesurfer
1099+
"""Create a FEAT preprocessing workflow
10971100
10981101
Parameters
10991102
----------

0 commit comments

Comments
 (0)