@@ -49,7 +49,7 @@ class DTIFit(StdOutCommandLine):
49
49
>>> import nipype.interfaces.camino as cmon
50
50
>>> fit = cmon.DTIFit()
51
51
>>> fit.inputs.scheme_file = 'A.scheme'
52
- >>> fit.inputs.in_file = 'tensor_fitted_data.Bfloat '
52
+ >>> fit.inputs.in_file = 'tensor_fitted_data.Bdouble '
53
53
>>> fit.run() # doctest: +SKIP
54
54
"""
55
55
_cmd = 'dtfit'
@@ -65,6 +65,85 @@ 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 ):
69
+ eigen_data = File (exists = True , argstr = '-inputfile %s' , mandatory = True ,
70
+ desc = 'voxel-order data filename' )
71
+
72
+ metric = traits .Enum ('fa' ,'md' ,'rd' ,'l1' , 'l2' , 'l3' , 'tr' , 'ra' , '2dfa' ,'cl' ,'cp' ,'cs' ,
73
+ argstr = '-stat %s' , mandatory = True ,
74
+ desc = ('Specifies the metric to compute. Possible choices are: '
75
+ '"fa", "md", "rd", "l1", "l2", "l3", "tr", "ra", "2dfa", "cl", "cp" or "cs".' ))
76
+
77
+ inputdatatype = traits .Enum ('double' , 'float' , 'long' , 'int' , 'short' , 'char' ,
78
+ argstr = '-inputdatatype %s' , usedefault = True ,
79
+ desc = ('Specifies the data type of the input data. '
80
+ 'The data type can be any of the following strings: '
81
+ '"char", "short", "int", "long", "float" or "double".'
82
+ 'Default is double data type' ))
83
+
84
+ outputdatatype = traits .Enum ('double' , 'float' , 'long' , 'int' , 'short' , 'char' ,
85
+ argstr = '-outputdatatype %s' , usedefault = True ,
86
+ desc = ('Specifies the data type of the output data. '
87
+ 'The data type can be any of the following strings: '
88
+ '"char", "short", "int", "long", "float" or "double".'
89
+ 'Default is double data type' ))
90
+
91
+ class DTMetricOutputSpec (TraitedSpec ):
92
+ metric_stats = File (exists = True , desc = 'Diffusion Tensor statistics of the chosen metric' )
93
+
94
+ class DTMetric (StdOutCommandLine ):
95
+ """
96
+ Computes tensor metric statistics based on the eigenvalues l1 >= l2 >= l3
97
+ typically obtained from ComputeEigensystem.
98
+
99
+ The full list of statistics is:
100
+
101
+ <cl> = (l1 - l2) / l1 , a measure of linearity
102
+ <cp> = (l2 - l3) / l1 , a measure of planarity
103
+ <cs> = l3 / l1 , a measure of isotropy
104
+ with: cl + cp + cs = 1
105
+
106
+ <l1> = first eigenvalue
107
+ <l2> = second eigenvalue
108
+ <l3> = third eigenvalue
109
+
110
+ <tr> = l1 + l2 + l3
111
+ <md> = tr / 3
112
+ <rd> = (l2 + l3) / 2
113
+ <fa> = fractional anisotropy. (Basser et al, J Magn Reson B 1996)
114
+ <ra> = relative anisotropy (Basser et al, J Magn Reson B 1996)
115
+
116
+ <2dfa> = 2D FA of the two minor eigenvalues l2 and l3
117
+ i.e. sqrt( 2 * [(l2 - <l>)^2 + (l3 - <l>)^2] / (l2^2 + l3^2) )
118
+ with: <l> = (l2 + l3) / 2
119
+
120
+ Example
121
+ -------
122
+ Compute the CP planar metric as float data type.
123
+
124
+ >>> import nipype.interfaces.camino as cam
125
+ >>> dtmetric = cam.DTMetric()
126
+ >>> dtmetric.inputs.eigen_data = 'dteig.Bdouble'
127
+ >>> dtmetric.inputs.metric = 'cp'
128
+ >>> dtmetric.inputs.outputdatatype = 'float'
129
+ >>> dtmetric.run() # doctest: +SKIP
130
+ """
131
+ _cmd = 'dtshape'
132
+ input_spec = DTMetricInputSpec
133
+ output_spec = DTMetricOutputSpec
134
+
135
+ def _list_outputs (self ):
136
+ outputs = self .output_spec ().get ()
137
+ outputs ['metric_stats' ] = os .path .abspath (self ._gen_outfilename ())
138
+ return outputs
139
+
140
+ 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
145
+
146
+
68
147
class ModelFitInputSpec (StdOutCommandLineInputSpec ):
69
148
def _gen_model_options (): #@NoSelf
70
149
"""
@@ -134,7 +213,7 @@ class ModelFit(StdOutCommandLine):
134
213
>>> fit = cmon.ModelFit()
135
214
>>> fit.model = 'dt'
136
215
>>> fit.inputs.scheme_file = 'A.scheme'
137
- >>> fit.inputs.in_file = 'tensor_fitted_data.Bfloat '
216
+ >>> fit.inputs.in_file = 'tensor_fitted_data.Bdouble '
138
217
>>> fit.run() # doctest: +SKIP
139
218
"""
140
219
_cmd = 'modelfit'
@@ -381,7 +460,7 @@ class TrackDT(Track):
381
460
382
461
>>> import nipype.interfaces.camino as cmon
383
462
>>> track = cmon.TrackDT()
384
- >>> track.inputs.in_file = 'tensor_fitted_data.Bfloat '
463
+ >>> track.inputs.in_file = 'tensor_fitted_data.Bdouble '
385
464
>>> track.inputs.seed_file = 'seed_mask.nii'
386
465
>>> track.run() # doctest: +SKIP
387
466
"""
@@ -447,7 +526,7 @@ class TrackBayesDirac(Track):
447
526
448
527
>>> import nipype.interfaces.camino as cmon
449
528
>>> track = cmon.TrackBayesDirac()
450
- >>> track.inputs.in_file = 'tensor_fitted_data.Bfloat '
529
+ >>> track.inputs.in_file = 'tensor_fitted_data.Bdouble '
451
530
>>> track.inputs.seed_file = 'seed_mask.nii'
452
531
>>> track.inputs.scheme_file = 'bvecs.scheme'
453
532
>>> track.run() # doctest: +SKIP
@@ -547,7 +626,7 @@ class ComputeMeanDiffusivity(StdOutCommandLine):
547
626
548
627
>>> import nipype.interfaces.camino as cmon
549
628
>>> md = cmon.ComputeMeanDiffusivity()
550
- >>> md.inputs.in_file = 'tensor_fitted_data.Bfloat '
629
+ >>> md.inputs.in_file = 'tensor_fitted_data.Bdouble '
551
630
>>> md.inputs.scheme_file = 'A.scheme'
552
631
>>> md.run() # doctest: +SKIP
553
632
"""
@@ -606,7 +685,7 @@ class ComputeFractionalAnisotropy(StdOutCommandLine):
606
685
607
686
>>> import nipype.interfaces.camino as cmon
608
687
>>> fa = cmon.ComputeFractionalAnisotropy()
609
- >>> fa.inputs.in_file = 'tensor_fitted_data.Bfloat '
688
+ >>> fa.inputs.in_file = 'tensor_fitted_data.Bdouble '
610
689
>>> fa.inputs.scheme_file = 'A.scheme'
611
690
>>> fa.run() # doctest: +SKIP
612
691
"""
@@ -667,7 +746,7 @@ class ComputeTensorTrace(StdOutCommandLine):
667
746
668
747
>>> import nipype.interfaces.camino as cmon
669
748
>>> trace = cmon.ComputeTensorTrace()
670
- >>> trace.inputs.in_file = 'tensor_fitted_data.Bfloat '
749
+ >>> trace.inputs.in_file = 'tensor_fitted_data.Bdouble '
671
750
>>> trace.inputs.scheme_file = 'A.scheme'
672
751
>>> trace.run() # doctest: +SKIP
673
752
"""
@@ -690,11 +769,21 @@ class ComputeEigensystemInputSpec(StdOutCommandLineInputSpec):
690
769
691
770
inputmodel = traits .Enum ('dt' , 'multitensor' , argstr = '-inputmodel %s' , desc = 'Specifies the model that the input data contains parameters for. Possible model types are: "dt" (diffusion-tensor data) and "multitensor"' )
692
771
693
- maxcomponents = traits .Int (argstr = '-maxcomponents %s ' , desc = 'The maximum number of tensor components in a voxel of the input data.' )
772
+ maxcomponents = traits .Int (argstr = '-maxcomponents %d ' , desc = 'The maximum number of tensor components in a voxel of the input data.' )
694
773
695
- inputdatatype = traits .Enum ("double" , "char" , "short" , "int" , "long" , "float" , argstr = '-inputdatatype %s' , desc = 'Specifies the data type of the input file. The data type can be any of the following strings: "char", "short", "int", "long", "float" or "double".' )
774
+ inputdatatype = traits .Enum ('double' , 'float' , 'long' , 'int' , 'short' , 'char' ,
775
+ argstr = '-inputdatatype %s' , usedefault = True ,
776
+ desc = ('Specifies the data type of the input data. '
777
+ 'The data type can be any of the following strings: '
778
+ '"char", "short", "int", "long", "float" or "double".'
779
+ 'Default is double data type' ))
696
780
697
- outputdatatype = traits .Enum ("double" , "char" , "short" , "int" , "long" , "float" , argstr = '-outputdatatype %s' , desc = 'Specifies the data type of the output data. The data type can be any of the following strings: "char", "short", "int", "long", "float" or "double".' )
781
+ outputdatatype = traits .Enum ('double' , 'float' , 'long' , 'int' , 'short' , 'char' ,
782
+ argstr = '-outputdatatype %s' , usedefault = True ,
783
+ desc = ('Specifies the data type of the output data. '
784
+ 'The data type can be any of the following strings: '
785
+ '"char", "short", "int", "long", "float" or "double".'
786
+ 'Default is double data type' ))
698
787
699
788
class ComputeEigensystemOutputSpec (TraitedSpec ):
700
789
eigen = File (exists = True , desc = 'Trace of the diffusion tensor' )
@@ -716,7 +805,7 @@ class ComputeEigensystem(StdOutCommandLine):
716
805
717
806
>>> import nipype.interfaces.camino as cmon
718
807
>>> dteig = cmon.ComputeEigensystem()
719
- >>> dteig.inputs.in_file = 'tensor_fitted_data.Bfloat '
808
+ >>> dteig.inputs.in_file = 'tensor_fitted_data.Bdouble '
720
809
>>> dteig.run() # doctest: +SKIP
721
810
"""
722
811
_cmd = 'dteig'
@@ -730,4 +819,5 @@ def _list_outputs(self):
730
819
731
820
def _gen_outfilename (self ):
732
821
_ , name , _ = split_filename (self .inputs .in_file )
733
- return name + "_Eigen.img" #Need to change to self.inputs.outputdatatype
822
+ datatype = self .inputs .outputdatatype
823
+ return name + '_eig.B' + datatype
0 commit comments