Skip to content

Commit 2a9f532

Browse files
authored
Merge pull request #1711 from mgxd/enh/eddy
enh: additional eddy inputs
2 parents bbc93ae + 8e8f231 commit 2a9f532

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,19 @@ class EddyInputSpec(FSLCommandInputSpec):
432432
desc='Detect and replace outlier slices')
433433
num_threads = traits.Int(1, usedefault=True, nohash=True,
434434
desc="Number of openmp threads to use")
435+
is_shelled = traits.Bool(False, argstr='--data_is_shelled',
436+
desc="Override internal check to ensure that "
437+
"date are acquired on a set of b-value "
438+
"shells")
439+
field = traits.Str(argstr='--field=%s',
440+
desc="NonTOPUP fieldmap scaled in Hz - filename has "
441+
"to be provided without an extension. TOPUP is "
442+
"strongly recommended")
443+
field_mat = File(exists=True, argstr='--field_mat=%s',
444+
desc="Matrix that specifies the relative locations of "
445+
"the field specified by --field and first volume "
446+
"in file --imain")
447+
use_cuda = traits.Bool(False, desc="Run eddy using cuda gpu")
435448

436449

437450
class EddyOutputSpec(TraitedSpec):
@@ -463,13 +476,13 @@ class Eddy(FSLCommand):
463476
>>> eddy.inputs.in_bvec = 'bvecs.scheme'
464477
>>> eddy.inputs.in_bval = 'bvals.scheme'
465478
>>> eddy.cmdline # doctest: +ELLIPSIS +ALLOW_UNICODE
466-
'eddy --acqp=epi_acqp.txt --bvals=bvals.scheme --bvecs=bvecs.scheme \
479+
'eddy_openmp --acqp=epi_acqp.txt --bvals=bvals.scheme --bvecs=bvecs.scheme \
467480
--imain=epi.nii --index=epi_index.txt --mask=epi_mask.nii \
468481
--out=.../eddy_corrected'
469482
>>> res = eddy.run() # doctest: +SKIP
470483
471484
"""
472-
_cmd = 'eddy'
485+
_cmd = 'eddy_openmp'
473486
input_spec = EddyInputSpec
474487
output_spec = EddyOutputSpec
475488

@@ -478,7 +491,8 @@ class Eddy(FSLCommand):
478491
def __init__(self, **inputs):
479492
super(Eddy, self).__init__(**inputs)
480493
self.inputs.on_trait_change(self._num_threads_update, 'num_threads')
481-
494+
if isdefined(self.inputs.use_cuda):
495+
self._use_cuda()
482496
if not isdefined(self.inputs.num_threads):
483497
self.inputs.num_threads = self._num_threads
484498
else:
@@ -493,6 +507,12 @@ def _num_threads_update(self):
493507
self.inputs.environ['OMP_NUM_THREADS'] = str(
494508
self.inputs.num_threads)
495509

510+
def _use_cuda(self):
511+
if self.inputs.use_cuda:
512+
_cmd = 'eddy_cuda'
513+
else:
514+
_cmd = 'eddy_openmp'
515+
496516
def _format_arg(self, name, spec, value):
497517
if name == 'in_topup_fieldcoef':
498518
return spec.argstr % value.split('_fieldcoef')[0]

nipype/interfaces/fsl/tests/test_auto_Eddy.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ def test_Eddy_inputs():
88
environ=dict(nohash=True,
99
usedefault=True,
1010
),
11+
field=dict(argstr='--field=%s',
12+
),
13+
field_mat=dict(argstr='--field_mat=%s',
14+
),
1115
flm=dict(argstr='--flm=%s',
1216
),
1317
fwhm=dict(argstr='--fwhm=%s',
@@ -34,9 +38,11 @@ def test_Eddy_inputs():
3438
mandatory=True,
3539
),
3640
in_topup_fieldcoef=dict(argstr='--topup=%s',
37-
requires=[u'in_topup_movpar'],
41+
requires=['in_topup_movpar'],
42+
),
43+
in_topup_movpar=dict(requires=['in_topup_fieldcoef'],
3844
),
39-
in_topup_movpar=dict(requires=[u'in_topup_fieldcoef'],
45+
is_shelled=dict(argstr='--data_is_shelled',
4046
),
4147
method=dict(argstr='--resamp=%s',
4248
),
@@ -55,6 +61,7 @@ def test_Eddy_inputs():
5561
),
5662
terminal_output=dict(nohash=True,
5763
),
64+
use_cuda=dict(),
5865
)
5966
inputs = Eddy.input_spec()
6067

0 commit comments

Comments
 (0)