8
8
"""
9
9
from nipype .interfaces .base import (CommandLineInputSpec , CommandLine , traits ,
10
10
TraitedSpec , File , StdOutCommandLine ,
11
- StdOutCommandLineInputSpec )
11
+ StdOutCommandLineInputSpec , isdefined )
12
12
from nipype .utils .filemanip import split_filename
13
13
import os
14
14
@@ -65,7 +65,7 @@ def _gen_outfilename(self):
65
65
_ , name , _ = split_filename (self .inputs .in_file )
66
66
return name + '_DT.Bdouble'
67
67
68
- class DTMetricInputSpec (StdOutCommandLineInputSpec ):
68
+ class DTMetricInputSpec (CommandLineInputSpec ):
69
69
eigen_data = File (exists = True , argstr = '-inputfile %s' , mandatory = True ,
70
70
desc = 'voxel-order data filename' )
71
71
@@ -88,10 +88,19 @@ class DTMetricInputSpec(StdOutCommandLineInputSpec):
88
88
'"char", "short", "int", "long", "float" or "double".'
89
89
'Default is double data type' ))
90
90
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
+
91
100
class DTMetricOutputSpec (TraitedSpec ):
92
101
metric_stats = File (exists = True , desc = 'Diffusion Tensor statistics of the chosen metric' )
93
102
94
- class DTMetric (StdOutCommandLine ):
103
+ class DTMetric (CommandLine ):
95
104
"""
96
105
Computes tensor metric statistics based on the eigenvalues l1 >= l2 >= l3
97
106
typically obtained from ComputeEigensystem.
@@ -138,11 +147,24 @@ def _list_outputs(self):
138
147
return outputs
139
148
140
149
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 ()
145
151
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
146
168
147
169
class ModelFitInputSpec (StdOutCommandLineInputSpec ):
148
170
def _gen_model_options (): #@NoSelf
0 commit comments