Skip to content

Commit 917ca39

Browse files
committed
Merge remote-tracking branch 'upstream/master' into rel/0.13.0-rc1
* upstream/master: reverting exception back to TypeError. changes based on feedback from review fix: doctest use properly converted path as basedir Adding testcase for parameterize_dirs==False trying to fix problems with traits4.6 (traits.HasTraits.traits has been modified) enh: test enh: removed old command encode() dir path has prior to computing sha1 made melodic output paths absolute enh: additional eddy inputs
2 parents d2379ef + 7b5201d commit 917ca39

File tree

6 files changed

+67
-11
lines changed

6 files changed

+67
-11
lines changed

nipype/interfaces/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ def __deepcopy__(self, memo):
643643
dup_dict = deepcopy(self.get(), memo)
644644
# access all keys
645645
for key in self.copyable_trait_names():
646-
_ = getattr(self, key)
646+
if key in self.__dict__.keys():
647+
_ = getattr(self, key)
647648
# clone once
648649
dup = self.clone_traits(memo=memo)
649650
for key in self.copyable_trait_names():

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/model.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,12 +1555,13 @@ class MELODIC(FSLCommand):
15551555

15561556
def _list_outputs(self):
15571557
outputs = self.output_spec().get()
1558-
outputs['out_dir'] = self.inputs.out_dir
1559-
if not isdefined(outputs['out_dir']):
1558+
if isdefined(self.inputs.out_dir):
1559+
outputs['out_dir'] = os.path.abspath(self.inputs.out_dir)
1560+
else:
15601561
outputs['out_dir'] = self._gen_filename("out_dir")
15611562
if isdefined(self.inputs.report) and self.inputs.report:
15621563
outputs['report_dir'] = os.path.join(
1563-
self._gen_filename("out_dir"), "report")
1564+
outputs['out_dir'], "report")
15641565
return outputs
15651566

15661567
def _gen_filename(self, name):

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

nipype/pipeline/engine/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def _parameterization_dir(self, param):
391391
- Otherwise, return the parameterization unchanged.
392392
"""
393393
if len(param) > 32:
394-
return sha1(param).hexdigest()
394+
return sha1(param.encode()).hexdigest()
395395
else:
396396
return param
397397

nipype/pipeline/engine/tests/test_engine.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class InputSpec(nib.TraitedSpec):
2323
input1 = nib.traits.Int(desc='a random int')
2424
input2 = nib.traits.Int(desc='a random int')
25-
25+
input_file = nib.traits.File(desc='Random File')
2626

2727
class OutputSpec(nib.TraitedSpec):
2828
output1 = nib.traits.List(nib.traits.Int, desc='outputs')
@@ -626,6 +626,33 @@ def func1(in1):
626626
assert not error_raised
627627

628628

629+
def test_parameterize_dirs_false(tmpdir):
630+
from ....interfaces.utility import IdentityInterface
631+
from ....testing import example_data
632+
633+
input_file = example_data('fsl_motion_outliers_fd.txt')
634+
635+
n1 = pe.Node(EngineTestInterface(), name='Node1')
636+
n1.iterables = ('input_file', (input_file, input_file))
637+
n1.interface.inputs.input1 = 1
638+
639+
n2 = pe.Node(IdentityInterface(fields='in1'), name='Node2')
640+
641+
wf = pe.Workflow(name='Test')
642+
wf.base_dir = str(tmpdir)
643+
wf.config['execution']['parameterize_dirs'] = False
644+
wf.connect([(n1, n2, [('output1', 'in1')])])
645+
646+
error_raised = False
647+
try:
648+
wf.run()
649+
except TypeError as typerr:
650+
from nipype.pipeline.engine.base import logger
651+
logger.info('Exception: %s' % str(typerr))
652+
error_raised = True
653+
assert not error_raised
654+
655+
629656
def test_serial_input(tmpdir):
630657
wd = str(tmpdir)
631658
os.chdir(wd)

0 commit comments

Comments
 (0)