Skip to content

Commit 3efd884

Browse files
committed
multiple fixes and new features
* ApplyTopup is now called with correct arguments when the reversed encoding image is only one b0 * Added documentation * Deprecated old workflows in nipype.workflows.dmri.fsl (added warnings in both documentation and code) * Updated CHANGES
1 parent 0ad0736 commit 3efd884

File tree

3 files changed

+76
-21
lines changed

3 files changed

+76
-21
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Next Release
22
============
33

4+
* ENH: Deep revision of worflows for correction of dMRI artifacts. New dmri_preprocessing
5+
example.
46
* ENH: New Freesurfer interface: MRIPretess
57
* ENH: New miscelaneous interface: AddCSVRow
68
* ENH: FUGUE interface has been refactored to use the name_template system, 3 examples

nipype/workflows/dmri/fsl/epi.py

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@
44
import nipype.interfaces.utility as niu
55
import nipype.interfaces.fsl as fsl
66
import os
7+
import warnings
78

89
def create_dmri_preprocessing(name='dMRI_preprocessing', use_fieldmap=True, fieldmap_registration=False):
9-
"""Creates a workflow that chains the necessary pipelines to
10+
"""
11+
Creates a workflow that chains the necessary pipelines to
1012
correct for motion, eddy currents, and, if selected, susceptibility
1113
artifacts in EPI dMRI sequences.
1214
13-
.. warning::
15+
.. deprecated:: 0.9.3
16+
Use :func:`nipype.workflows.dmri.preprocess.epi.all_fmb_pipeline` or
17+
:func:`nipype.workflows.dmri.preprocess.epi.all_peb_pipeline` instead.
18+
1419
15-
IMPORTANT NOTICE: this workflow rotates the b-vectors, so please be adviced
16-
that not all the dicom converters ensure the consistency between the resulting
17-
nifti orientation and the b matrix table (e.g. dcm2nii checks it).
20+
.. warning:: This workflow rotates the b-vectors, so please be
21+
advised that not all the dicom converters ensure the consistency between the resulting
22+
nifti orientation and the b matrix table (e.g. dcm2nii checks it).
1823
1924
2025
Example
@@ -54,12 +59,16 @@ def create_dmri_preprocessing(name='dMRI_preprocessing', use_fieldmap=True, fiel
5459
5560
5661
Optional arguments::
62+
5763
use_fieldmap - True if there are fieldmap files that should be used (default True)
5864
fieldmap_registration - True if registration to fieldmap should be performed (default False)
5965
6066
6167
"""
6268

69+
warnings.warn(('This workflow is deprecated from v.1.0.0, use of available '
70+
'nipype.workflows.dmri.preprocess.epi.all_*'), DeprecationWarning)
71+
6372
pipeline = pe.Workflow(name=name)
6473

6574
inputnode = pe.Node(niu.IdentityInterface(
@@ -118,10 +127,12 @@ def create_motion_correct_pipeline(name='motion_correct'):
118127
(Leemans et al. 2009 - http://www.ncbi.nlm.nih.gov/pubmed/19319973),
119128
making use of the rotation matrix obtained by FLIRT.
120129
121-
.. deprecated:: 1.0.0.
122-
Use :func:`nipype.workflows.dmri.preprocess.epi.motion_correct` instead
123130
124-
.. warning:: IMPORTANT NOTICE: this workflow rotates the b-vectors, so please be adviced
131+
.. deprecated:: 0.9.3
132+
Use :func:`nipype.workflows.dmri.preprocess.epi.hmc_pipeline` instead.
133+
134+
135+
.. warning:: This workflow rotates the b-vectors, so please be adviced
125136
that not all the dicom converters ensure the consistency between the resulting
126137
nifti orientation and the b matrix table (e.g. dcm2nii checks it).
127138
@@ -148,6 +159,10 @@ def create_motion_correct_pipeline(name='motion_correct'):
148159
149160
"""
150161

162+
warnings.warn(('This workflow is deprecated from v.1.0.0, use '
163+
'nipype.workflows.dmri.preprocess.epi.hmc_pipeline instead'),
164+
DeprecationWarning)
165+
151166
inputnode = pe.Node(
152167
niu.IdentityInterface(
153168
fields=['in_file', 'ref_num', 'in_bvec']),
@@ -184,7 +199,13 @@ def create_motion_correct_pipeline(name='motion_correct'):
184199

185200

186201
def create_eddy_correct_pipeline(name='eddy_correct'):
187-
"""Creates a pipeline that replaces eddy_correct script in FSL. It takes a
202+
"""
203+
204+
.. deprecated:: 0.9.3
205+
Use :func:`nipype.workflows.dmri.preprocess.epi.ecc_pipeline` instead.
206+
207+
208+
Creates a pipeline that replaces eddy_correct script in FSL. It takes a
188209
series of diffusion weighted images and linearly co-registers them to one
189210
reference image. No rotation of the B-matrix is performed, so this pipeline
190211
should be executed after the motion correction pipeline.
@@ -207,6 +228,10 @@ def create_eddy_correct_pipeline(name='eddy_correct'):
207228
outputnode.eddy_corrected
208229
"""
209230

231+
warnings.warn(('This workflow is deprecated from v.1.0.0, use '
232+
'nipype.workflows.dmri.preprocess.epi.ecc_pipeline instead'),
233+
DeprecationWarning)
234+
210235
inputnode = pe.Node(
211236
niu.IdentityInterface(fields=['in_file', 'ref_num']),
212237
name='inputnode')
@@ -238,6 +263,11 @@ def create_eddy_correct_pipeline(name='eddy_correct'):
238263

239264
def fieldmap_correction(name='fieldmap_correction', nocheck=False):
240265
"""
266+
267+
.. deprecated:: 0.9.3
268+
Use :func:`nipype.workflows.dmri.preprocess.epi.sdc_fmb` instead.
269+
270+
241271
Fieldmap-based retrospective correction of EPI images for the susceptibility distortion
242272
artifact (Jezzard et al., 1995). Fieldmap images are assumed to be already registered
243273
to EPI data, and a brain mask is required.
@@ -247,7 +277,6 @@ def fieldmap_correction(name='fieldmap_correction', nocheck=False):
247277
available as of FSL 5.0.
248278
249279
250-
251280
Example
252281
-------
253282
@@ -283,6 +312,10 @@ def fieldmap_correction(name='fieldmap_correction', nocheck=False):
283312
284313
"""
285314

315+
warnings.warn(('This workflow is deprecated from v.1.0.0, use '
316+
'nipype.workflows.dmri.preprocess.epi.sdc_fmb instead'),
317+
DeprecationWarning)
318+
286319
inputnode = pe.Node(niu.IdentityInterface(
287320
fields=['in_file',
288321
'in_mask',
@@ -361,8 +394,13 @@ def fieldmap_correction(name='fieldmap_correction', nocheck=False):
361394

362395
def topup_correction( name='topup_correction' ):
363396
"""
364-
Corrects for susceptibilty distortion of EPI images when one reverse encoding dataset has
365-
been acquired
397+
398+
.. deprecated:: 0.9.3
399+
Use :func:`nipype.workflows.dmri.preprocess.epi.sdc_peb` instead.
400+
401+
402+
Corrects for susceptibilty distortion of EPI images when one reverse encoding dataset has
403+
been acquired
366404
367405
368406
Example
@@ -375,18 +413,26 @@ def topup_correction( name='topup_correction' ):
375413
>>> nipype_epicorrect.inputs.inputnode.ref_num = 0
376414
>>> nipype_epicorrect.run() # doctest: +SKIP
377415
416+
378417
Inputs::
418+
379419
inputnode.in_file_dir - EPI volume acquired in 'forward' phase encoding
380420
inputnode.in_file_rev - EPI volume acquired in 'reversed' phase encoding
381421
inputnode.encoding_direction - Direction encoding of in_file_dir
382422
inputnode.ref_num - Identifier of the reference volumes (usually B0 volume)
383423
424+
384425
Outputs::
385426
386427
outputnode.epi_corrected
387428
388429
389430
"""
431+
432+
warnings.warn(('This workflow is deprecated from v.1.0.0, use '
433+
'nipype.workflows.dmri.preprocess.epi.sdc_peb instead'),
434+
DeprecationWarning)
435+
390436
pipeline = pe.Workflow(name=name)
391437

392438
inputnode = pe.Node(niu.IdentityInterface(
@@ -436,11 +482,18 @@ def topup_correction( name='topup_correction' ):
436482

437483

438484
def create_epidewarp_pipeline(name='epidewarp', fieldmap_registration=False):
439-
""" Replaces the epidewarp.fsl script (http://www.nmr.mgh.harvard.edu/~greve/fbirn/b0/epidewarp.fsl)
485+
"""
486+
Replaces the epidewarp.fsl script (http://www.nmr.mgh.harvard.edu/~greve/fbirn/b0/epidewarp.fsl)
440487
for susceptibility distortion correction of dMRI & fMRI acquired with EPI sequences and the fieldmap
441488
information (Jezzard et al., 1995) using FSL's FUGUE. The registration to the (warped) fieldmap
442489
(strictly following the original script) is available using fieldmap_registration=True.
443490
491+
492+
.. warning:: This workflow makes use of ``epidewarp.fsl`` a script of FSL deprecated long
493+
time ago. The use of this workflow is not recommended, use
494+
:func:`nipype.workflows.dmri.preprocess.epi.sdc_fmb` instead.
495+
496+
444497
Example
445498
-------
446499
@@ -480,6 +533,9 @@ def create_epidewarp_pipeline(name='epidewarp', fieldmap_registration=False):
480533
481534
"""
482535

536+
warnings.warn(('This workflow reproduces a deprecated FSL script.'),
537+
DeprecationWarning)
538+
483539
inputnode = pe.Node(niu.IdentityInterface(fields=['in_file',
484540
'fieldmap_mag',
485541
'fieldmap_pha',

nipype/workflows/dmri/preprocess/epi.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,25 +519,22 @@ def sdc_peb(name='peb_correction',
519519
topup.inputs.encoding_direction = [epi_params['enc_dir'], altepi_params['enc_dir']]
520520
topup.inputs.readout_times = [epi_params['echospacing']/(1.0*epi_params['acc_factor']),
521521
altepi_params['echospacing']/(1.0*altepi_params['acc_factor'])]
522-
unwarp = pe.Node(fsl.ApplyTOPUP(in_index=[1,2]), name='unwarp')
523-
dwi_comb = pe.Node(niu.Merge(2), name='DWIcomb')
522+
unwarp = pe.Node(fsl.ApplyTOPUP(in_index=[1], method='jac'), name='unwarp')
524523

525524
wf = pe.Workflow(name=name)
526525
wf.connect([
527526
(inputnode, b0_ref, [('in_file','in_file'),
528527
(('ref_num', _checkrnum),'t_min')])
529528
,(inputnode, b0_alt, [('alt_file','in_file'),
530529
(('ref_num', _checkrnum),'t_min')])
531-
,(inputnode, dwi_comb, [('in_file','in1'),
532-
('alt_file','in2') ] )
533-
,(b0_ref, b0_comb, [('roi_file','in1')] )
534-
,(b0_alt, b0_comb, [('roi_file','in2')] )
535-
,(b0_comb, b0_merge, [('out', 'in_files')] )
530+
,(b0_ref, b0_comb, [('roi_file','in1')])
531+
,(b0_alt, b0_comb, [('roi_file','in2')])
532+
,(b0_comb, b0_merge, [('out', 'in_files')])
536533
,(b0_merge, topup, [('merged_file','in_file')])
537534
,(topup, unwarp, [('out_fieldcoef','in_topup_fieldcoef'),
538535
('out_movpar','in_topup_movpar'),
539536
('out_enc_file','encoding_file')])
540-
,(dwi_comb, unwarp, [('out','in_files')])
537+
,(inputnode, unwarp, [('in_file','in_files')])
541538
,(unwarp, outputnode, [('out_corrected','out_file')])
542539
])
543540
return wf

0 commit comments

Comments
 (0)