Skip to content

Commit 99b39cd

Browse files
committed
Editing dwi_tool interface.
1 parent 4de51ed commit 99b39cd

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

nipype/interfaces/niftyfit/dwi.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -373,27 +373,26 @@ class DwiToolInputSpec(CommandLineInputSpec):
373373
bvec_file = traits.File(position=3,
374374
exists=True,
375375
desc=desc,
376-
argstr='-bvec %s',
377-
mandatory=True)
376+
argstr='-bvec %s')
378377
b0_file = traits.File(position=4,
379378
exists=True,
380379
desc='The B0 image corresponding to the source DWI',
381-
argstr='-b0 %s',
382-
mandatory=True)
380+
argstr='-b0 %s')
383381
mask_file = traits.File(position=5,
384382
exists=True,
385383
desc='The image mask',
386-
argstr='-mask %s',
387-
mandatory=True)
384+
argstr='-mask %s')
388385

389386
# Output options, with templated output names based on the source image
390387
desc = 'Filename of multi-compartment model parameter map \
391388
(-ivim,-ball,-nod)'
392389
mcmap_file = traits.File(desc=desc,
393390
argstr='-mcmap %s',
394391
genfile=True)
395-
syn_file = traits.File(desc='Filename of synthetic image',
392+
desc = 'Filename of synthetic image. Requires: bvec_file/b0_file.'
393+
syn_file = traits.File(desc=desc,
396394
argstr='-syn %s',
395+
requires=['bvec_file', 'b0_file'],
397396
genfile=True)
398397
mdmap_file = traits.File(desc='Filename of MD map/ADC',
399398
argstr='-mdmap %s',
@@ -404,11 +403,11 @@ class DwiToolInputSpec(CommandLineInputSpec):
404403
v1map_file = traits.File(desc='Filename of PDD map [x,y,z]',
405404
argstr='-v1map %s',
406405
genfile=True)
407-
rgbmap_file = traits.File(desc='Filename of colour FA map',
406+
rgbmap_file = traits.File(desc='Filename of colour FA map.',
408407
argstr='-rgbmap %s',
409408
requires=['dti_flag'],
410409
genfile=True)
411-
logdti_file = traits.File(desc='Filename of output logdti map',
410+
logdti_file = traits.File(desc='Filename of output logdti map.',
412411
argstr='-logdti2 %s',
413412
requires=['dti_flag'],
414413
genfile=True)
@@ -512,7 +511,7 @@ class DwiTool(NiftyFitCommand):
512511
-mask mask.nii.gz -dti -famap .../dwi_famap.nii.gz \
513512
-logdti2 .../dwi_logdti2.nii.gz -mcmap .../dwi_mcmap.nii.gz \
514513
-mdmap .../dwi_mdmap.nii.gz -rgbmap rgb_map.nii.gz -syn .../dwi_syn.nii.gz \
515-
-v1map .../dwi_v1map.nii.gz '
514+
-v1map .../dwi_v1map.nii.gz'
516515
517516
"""
518517
_cmd = get_custom_path('dwi_tool')
@@ -525,8 +524,9 @@ def _format_arg(self, name, trait_spec, value):
525524
if not isdefined(self.inputs.bvec_file) or \
526525
not isdefined(self.inputs.b0_file):
527526
return ""
528-
else:
529-
return trait_spec.argstr % value
527+
if name in ['logdti_file', 'rgbmap_file'] and \
528+
not isdefined(self.inputs.dti_flag):
529+
return ""
530530
return super(DwiTool, self)._format_arg(name, trait_spec, value)
531531

532532
def _gen_filename(self, name):
@@ -561,10 +561,12 @@ def _list_outputs(self):
561561
else:
562562
outputs['mcmap_file'] = self._gen_filename('mcmap_file')
563563

564-
if isdefined(self.inputs.syn_file):
565-
outputs['syn_file'] = self.inputs.syn_file
566-
else:
567-
outputs['syn_file'] = self._gen_filename('syn_file')
564+
if isdefined(self.inputs.bvec_file) and \
565+
isdefined(self.inputs.b0_file):
566+
if isdefined(self.inputs.syn_file):
567+
outputs['syn_file'] = self.inputs.syn_file
568+
else:
569+
outputs['syn_file'] = self._gen_filename('syn_file')
568570

569571
if isdefined(self.inputs.mdmap_file):
570572
outputs['mdmap_file'] = self.inputs.mdmap_file
@@ -581,14 +583,15 @@ def _list_outputs(self):
581583
else:
582584
outputs['v1map_file'] = self._gen_filename('v1map_file')
583585

584-
if isdefined(self.inputs.rgbmap_file):
585-
outputs['rgbmap_file'] = self.inputs.rgbmap_file
586-
else:
587-
outputs['rgbmap_file'] = self._gen_filename('rgbmap_file')
586+
if isdefined(self.inputs.dti_flag):
587+
if isdefined(self.inputs.rgbmap_file):
588+
outputs['rgbmap_file'] = self.inputs.rgbmap_file
589+
else:
590+
outputs['rgbmap_file'] = self._gen_filename('rgbmap_file')
588591

589-
if isdefined(self.inputs.logdti_file):
590-
outputs['logdti_file'] = self.inputs.logdti_file
591-
else:
592-
outputs['logdti_file'] = self._gen_filename('logdti_file')
592+
if isdefined(self.inputs.logdti_file):
593+
outputs['logdti_file'] = self.inputs.logdti_file
594+
else:
595+
outputs['logdti_file'] = self._gen_filename('logdti_file')
593596

594597
return outputs

nipype/interfaces/niftyfit/tests/test_auto_DwiTool.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ def test_DwiTool_inputs():
77
input_map = dict(args=dict(argstr='%s',
88
),
99
b0_file=dict(argstr='-b0 %s',
10-
mandatory=True,
1110
position=4,
1211
),
1312
ball_flag=dict(argstr='-ball',
@@ -23,7 +22,6 @@ def test_DwiTool_inputs():
2322
position=2,
2423
),
2524
bvec_file=dict(argstr='-bvec %s',
26-
mandatory=True,
2725
position=3,
2826
),
2927
diso_val=dict(argstr='-diso %f',
@@ -56,7 +54,6 @@ def test_DwiTool_inputs():
5654
requires=['dti_flag'],
5755
),
5856
mask_file=dict(argstr='-mask %s',
59-
mandatory=True,
6057
position=5,
6158
),
6259
mcmap_file=dict(argstr='-mcmap %s',
@@ -87,6 +84,7 @@ def test_DwiTool_inputs():
8784
),
8885
syn_file=dict(argstr='-syn %s',
8986
genfile=True,
87+
requires=['bvec_file', 'b0_file'],
9088
),
9189
terminal_output=dict(nohash=True,
9290
),

0 commit comments

Comments
 (0)