Skip to content

Commit e09fc2d

Browse files
committed
Add header option for camino.dti.DTMetric
1 parent 83a925a commit e09fc2d

File tree

1 file changed

+29
-7
lines changed
  • nipype/interfaces/camino

1 file changed

+29
-7
lines changed

nipype/interfaces/camino/dti.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99
from nipype.interfaces.base import (CommandLineInputSpec, CommandLine, traits,
1010
TraitedSpec, File, StdOutCommandLine,
11-
StdOutCommandLineInputSpec)
11+
StdOutCommandLineInputSpec, isdefined)
1212
from nipype.utils.filemanip import split_filename
1313
import os
1414

@@ -65,7 +65,7 @@ def _gen_outfilename(self):
6565
_, name , _ = split_filename(self.inputs.in_file)
6666
return name + '_DT.Bdouble'
6767

68-
class DTMetricInputSpec(StdOutCommandLineInputSpec):
68+
class DTMetricInputSpec(CommandLineInputSpec):
6969
eigen_data = File(exists=True, argstr='-inputfile %s', mandatory=True,
7070
desc='voxel-order data filename')
7171

@@ -88,10 +88,19 @@ class DTMetricInputSpec(StdOutCommandLineInputSpec):
8888
'"char", "short", "int", "long", "float" or "double".'
8989
'Default is double data type'))
9090

91+
data_header = File(argstr='-header %s', exists=True,
92+
desc=('A Nifti .nii or .nii.gz file containing the header information. '
93+
'Usually this will be the header of the raw data file from which '
94+
'the diffusion tensors were reconstructed.'))
95+
96+
outputfile = File(argstr='-outputfile %s', genfile=True,
97+
desc=('Output name. Output will be a .nii.gz file if data_header is provided and'
98+
'in voxel order with outputdatatype datatype (default: double) otherwise.'))
99+
91100
class DTMetricOutputSpec(TraitedSpec):
92101
metric_stats = File(exists=True, desc='Diffusion Tensor statistics of the chosen metric')
93102

94-
class DTMetric(StdOutCommandLine):
103+
class DTMetric(CommandLine):
95104
"""
96105
Computes tensor metric statistics based on the eigenvalues l1 >= l2 >= l3
97106
typically obtained from ComputeEigensystem.
@@ -138,11 +147,24 @@ def _list_outputs(self):
138147
return outputs
139148

140149
def _gen_outfilename(self):
141-
_, name , _ = split_filename(self.inputs.eigen_data)
142-
metric = self.inputs.metric
143-
datatype= self.inputs.outputdatatype
144-
return name + '_' + metric + '.B' + datatype
150+
return self._gen_outputfile()
145151

152+
def _gen_outputfile(self):
153+
outputfile = self.inputs.outputfile
154+
if not isdefined(outputfile):
155+
outputfile = self._gen_filename('outputfile')
156+
return outputfile
157+
158+
def _gen_filename(self, name):
159+
if name == 'outputfile':
160+
_, name , _ = split_filename(self.inputs.eigen_data)
161+
metric = self.inputs.metric
162+
datatype= self.inputs.outputdatatype
163+
if isdefined(self.inputs.data_header):
164+
filename = name + '_' + metric + '.nii.gz'
165+
else:
166+
filename = name + '_' + metric + '.B' + datatype
167+
return filename
146168

147169
class ModelFitInputSpec(StdOutCommandLineInputSpec):
148170
def _gen_model_options(): #@NoSelf

0 commit comments

Comments
 (0)