Skip to content

Commit e4ce216

Browse files
committed
Merge pull request #794 from satra/fix/eddy
MRG: TOPUP update
2 parents 0dad360 + f271565 commit e4ce216

File tree

10 files changed

+209
-157
lines changed

10 files changed

+209
-157
lines changed

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def set_default_output_type(cls, outputtype):
144144
else:
145145
raise AttributeError('Invalid AFNI outputtype: %s' % outputtype)
146146

147-
def _overload_extension(self, value):
147+
def _overload_extension(self, value, name=None):
148148
path, base, _ = split_filename(value)
149149
return os.path.join(path, base + Info.outputtype_to_ext(self.inputs.outputtype))
150150

nipype/interfaces/afni/preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class AutoTcorrelate(AFNICommand):
367367
output_spec = AFNICommandOutputSpec
368368
_cmd = '3dAutoTcorrelate'
369369

370-
def _overload_extension(self, value):
370+
def _overload_extension(self, value, name=None):
371371
path, base, ext = split_filename(value)
372372
if ext.lower() not in [".1d", ".nii.gz", ".nii"]:
373373
ext = ext + ".1D"
@@ -1924,7 +1924,7 @@ class AFNItoNIFTI(AFNICommand):
19241924
input_spec = AFNItoNIFTIInputSpec
19251925
output_spec = AFNICommandOutputSpec
19261926

1927-
def _overload_extension(self, value):
1927+
def _overload_extension(self, value, name=None):
19281928
path, base, ext = split_filename(value)
19291929
if ext.lower() not in [".1d", ".nii.gz", ".1D"]:
19301930
ext = ext + ".nii"

nipype/interfaces/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,13 +1492,13 @@ def _filename_from_source(self, name):
14921492
_, _, ext = split_filename(retval)
14931493
if trait_spec.keep_extension and ext:
14941494
return retval
1495-
return self._overload_extension(retval)
1495+
return self._overload_extension(retval, name)
14961496
return retval
14971497

14981498
def _gen_filename(self, name):
14991499
raise NotImplementedError
15001500

1501-
def _overload_extension(self, value):
1501+
def _overload_extension(self, value, name=None):
15021502
return value
15031503

15041504
def _list_outputs(self):

nipype/interfaces/fsl/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
239239
use_ext=False, newpath=cwd)
240240
return fname
241241

242-
def _overload_extension(self, value):
242+
def _overload_extension(self, value, name=None):
243243
return value + Info.output_type_to_ext(self.inputs.output_type)
244244

245245

nipype/interfaces/fsl/epi.py

Lines changed: 162 additions & 139 deletions
Large diffs are not rendered by default.

nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,28 @@ def test_ApplyTOPUP_inputs():
1616
ignore_exception=dict(nohash=True,
1717
usedefault=True,
1818
),
19-
in_files=dict(argstr='%s',
19+
in_files=dict(argstr='--imain=%s',
2020
mandatory=True,
21+
sep=',',
2122
),
22-
in_index=dict(argstr='%s',
23+
in_index=dict(argstr='--inindex=%s',
2324
mandatory=True,
25+
sep=',',
2426
),
25-
in_topup=dict(argstr='--topup=%s',
26-
mandatory=True,
27+
in_topup_fieldcoef=dict(argstr='--topup=%s',
28+
copyfile=False,
29+
requires=['in_topup_movpar'],
30+
),
31+
in_topup_movpar=dict(copyfile=False,
32+
requires=['in_topup_fieldcoef'],
2733
),
2834
interp=dict(argstr='--interp=%s',
2935
),
3036
method=dict(argstr='--method=%s',
3137
),
32-
out_base=dict(argstr='--out=%s',
38+
out_corrected=dict(argstr='--out=%s',
39+
name_source=['in_files'],
40+
name_template='%s_corrected',
3341
),
3442
output_type=dict(),
3543
terminal_output=dict(mandatory=True,

nipype/interfaces/fsl/tests/test_auto_TOPUP.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ def test_TOPUP_inputs():
88
config=dict(argstr='--config=%s',
99
usedefault=True,
1010
),
11-
encoding_direction=dict(),
11+
encoding_direction=dict(argstr='--datain=%s',
12+
mandatory=True,
13+
requires=['readout_times'],
14+
xor=['encoding_file'],
15+
),
1216
encoding_file=dict(argstr='--datain=%s',
17+
mandatory=True,
18+
xor=['encoding_direction'],
1319
),
1420
environ=dict(nohash=True,
1521
usedefault=True,
@@ -33,15 +39,31 @@ def test_TOPUP_inputs():
3339
numprec=dict(argstr='--numprec=%s',
3440
),
3541
out_base=dict(argstr='--out=%s',
42+
hash_files=False,
43+
name_source=['in_file'],
44+
name_template='%s_base',
3645
),
3746
out_corrected=dict(argstr='--iout=%s',
47+
hash_files=False,
48+
name_source=['in_file'],
49+
name_template='%s_corrected',
3850
),
3951
out_field=dict(argstr='--fout=%s',
52+
hash_files=False,
53+
name_source=['in_file'],
54+
name_template='%s_field',
4055
),
4156
out_logfile=dict(argstr='--logout=%s',
57+
hash_files=False,
58+
keep_extension=True,
59+
name_source=['in_file'],
60+
name_template='%s_topup.log',
4261
),
4362
output_type=dict(),
44-
readout_times=dict(),
63+
readout_times=dict(mandatory=True,
64+
requires=['encoding_direction'],
65+
xor=['encoding_file'],
66+
),
4567
regrid=dict(argstr='--regrid=%d',
4668
),
4769
scale=dict(argstr='--scale=%d',
@@ -69,7 +91,6 @@ def test_TOPUP_outputs():
6991
out_fieldcoef=dict(),
7092
out_logfile=dict(),
7193
out_movpar=dict(),
72-
out_topup=dict(),
7394
)
7495
outputs = TOPUP.output_spec()
7596

nipype/testing/data/topup_fieldcoef.nii.gz

Whitespace-only changes.

nipype/testing/data/topup_movpar.txt

Whitespace-only changes.

nipype/workflows/dmri/fsl/epi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def topup_correction( name='topup_correction' ):
370370
>>> nipype_epicorrect = topup_correction('nipype_topup')
371371
>>> nipype_epicorrect.inputs.inputnode.in_file_dir = 'epi.nii'
372372
>>> nipype_epicorrect.inputs.inputnode.in_file_rev = 'epi_rev.nii'
373-
>>> nipype_epicorrect.inputs.inputnode.encoding_direction = 'y'
373+
>>> nipype_epicorrect.inputs.inputnode.encoding_direction = ['y', 'y-']
374374
>>> nipype_epicorrect.inputs.inputnode.ref_num = 0
375375
>>> nipype_epicorrect.run() # doctest: +SKIP
376376
@@ -400,7 +400,6 @@ def topup_correction( name='topup_correction' ):
400400
outputnode = pe.Node( niu.IdentityInterface(
401401
fields=['out_fieldcoef',
402402
'out_movpar',
403-
'out_topup',
404403
'out_enc_file',
405404
'epi_corrected'
406405
]), name='outputnode'
@@ -424,10 +423,11 @@ def topup_correction( name='topup_correction' ):
424423
,(combin, merged, [('out', 'in_files')] )
425424
,(merged, topup, [('merged_file','in_file')])
426425
,(inputnode, topup, [('encoding_direction','encoding_direction'),('readout_times','readout_times') ])
427-
,(topup, applytopup, [('out_topup','in_topup'),('out_enc_file','encoding_file')])
426+
,(topup, applytopup, [('out_fieldcoef','in_topup_fieldcoef'),('out_movpar','in_topup_movpar'),
427+
('out_enc_file','encoding_file')])
428428
,(combin2, applytopup, [('out','in_files')] )
429429
,(topup, outputnode, [('out_fieldcoef','out_fieldcoef'),('out_movpar','out_movpar'),
430-
('out_topup','out_topup'),('out_enc_file','out_enc_file') ])
430+
('out_enc_file','out_enc_file') ])
431431
,(applytopup,outputnode, [('out_corrected','epi_corrected')])
432432
])
433433

0 commit comments

Comments
 (0)