1
- from ..base import TraitedSpec , CommandLineInputSpec , \
2
- traits , isdefined
1
+ from ..base import TraitedSpec , CommandLineInputSpec , traits , isdefined
3
2
from ...utils .filemanip import fname_presuffix
4
3
import os
5
4
from .base import CommandLineDtitk
@@ -44,8 +43,8 @@ class RigidTask(CommandLineDtitk):
44
43
45
44
>>> import nipype.interfaces.dtitk as dtitk
46
45
>>> node = dtitk.RigidTask()
47
- >>> node.inputs.fixed_file = 'diffusion.nii'
48
- >>> node.inputs.moving_file = 'diffusion.nii'
46
+ >>> node.inputs.fixed_file = 'diffusion.nii.gz '
47
+ >>> node.inputs.moving_file = 'diffusion.nii.gz '
49
48
>>> node.inputs.similarity_metric = 'EDS'
50
49
>>> node.inputs.samplingX = 4
51
50
>>> node.inputs.samplingY = 4
@@ -58,13 +57,6 @@ class RigidTask(CommandLineDtitk):
58
57
output_spec = RigidOutputSpec
59
58
_cmd = 'dti_rigid_reg'
60
59
61
- def _gen_outfilename (self ):
62
- # out_file = self.inputs.out_file
63
- # if not isdefined(out_file) and isdefined(self.inputs.in_file):
64
- out_file = self ._gen_fname (self .inputs .in_file ,
65
- suffix = '.aff' , change_ext = False )
66
- return out_file
67
-
68
60
def _list_outputs (self ):
69
61
outputs = self .output_spec ().get ()
70
62
outputs ['out_file_xfm' ] = self .inputs .moving_file .replace ('.nii.gz' ,
@@ -73,24 +65,30 @@ def _list_outputs(self):
73
65
'_aff.nii.gz' )
74
66
return outputs
75
67
76
- def _gen_fname (self , name ):
77
- if name == 'out_file' :
78
- return self ._gen_outfilename ()
79
-
80
68
81
69
class AffineInputSpec (CommandLineInputSpec ):
82
- in_fixed_tensor = traits .Str (desc = "fixed diffusion tensor image" ,
83
- exists = True , mandatory = False , position = 0 ,
84
- argstr = "%s" )
85
- in_moving_txt = traits .Str (
86
- desc = "moving list of diffusion tensor image paths" , exists = True ,
87
- mandatory = False , position = 1 , argstr = "%s" )
88
- in_similarity_metric = traits .Enum ('EDS' , 'GDS' , 'DDS' , 'NMI' , exists = True ,
89
- mandatory = False , position = 3 ,
90
- argstr = "%s" , desc = "similarity metric" )
91
- in_usetrans_flag = traits .Enum ('--useTrans' , '' , exists = True ,
92
- mandatory = False , position = 4 , argstr = "%s" ,
93
- desc = "initialize using rigid transform??" )
70
+ fixed_file = traits .Str (desc = "fixed diffusion tensor image" ,
71
+ exists = True , mandatory = True ,
72
+ position = 0 , argstr = "%s" )
73
+ moving_file = traits .Str (desc = "diffusion tensor image path" , exists = True ,
74
+ mandatory = True , position = 1 , argstr = "%s" )
75
+ similarity_metric = traits .Enum ('EDS' , 'GDS' , 'DDS' , 'NMI' , exists = True ,
76
+ mandatory = True , position = 2 , argstr = "%s" ,
77
+ desc = "similarity metric" )
78
+ samplingX = traits .Float (mandatory = True , position = 3 , argstr = "%s" ,
79
+ desc = "dist between samp points (mm)" ,
80
+ default_value = 4 )
81
+ samplingY = traits .Float (mandatory = True , position = 4 , argstr = "%s" ,
82
+ desc = "dist between samp points (mm)" ,
83
+ default_value = 4 )
84
+ samplingZ = traits .Float (mandatory = True , position = 5 , argstr = "%s" ,
85
+ desc = "dist between samp points (mm)" ,
86
+ default_value = 4 )
87
+ ftol = traits .Float (mandatory = True , position = 6 , argstr = "%s" ,
88
+ desc = "cost function tolerance" , default_value = 0.01 )
89
+ useInTrans = traits .Float (mandatory = False , position = 7 , argstr = "%s" ,
90
+ desc = "to initialize with existing xfm set as 1" ,
91
+ default_value = 1 )
94
92
95
93
96
94
class AffineOutputSpec (TraitedSpec ):
@@ -100,29 +98,33 @@ class AffineOutputSpec(TraitedSpec):
100
98
101
99
class AffineTask (CommandLineDtitk ):
102
100
"""
103
- Performs affine registration between two tensor volumes
104
-
105
- Example
106
- -------
101
+ Performs affine registration between two tensor volumes
107
102
108
- >>> import nipype.interfaces.dtitk as dtitk
109
- >>> node = dtitk.AffineTask()
110
- >>> node.inputs.in_fixed_tensor = 'diffusion.nii'
111
- >>> node.inputs.in_moving_txt = 'dirs.txt'
112
- >>> node.inputs.in_similarity_metric = 'EDS'
113
- >>> node.run() # doctest: +SKIP
114
- """
103
+ Example
104
+ -------
115
105
106
+ >>> import nipype.interfaces.dtitk as dtitk
107
+ >>> node = dtitk.AffineTask()
108
+ >>> node.inputs.fixed_file = 'diffusion.nii.gz'
109
+ >>> node.inputs.moving_file = 'diffusion.nii.gz'
110
+ >>> node.inputs.similarity_metric = 'EDS'
111
+ >>> node.inputs.samplingX = 4
112
+ >>> node.inputs.samplingY = 4
113
+ >>> node.inputs.samplingZ = 4
114
+ >>> node.inputs.ftol = 0.01
115
+ >>> node.inputs.useInTrans = 1
116
+ >>> node.run() # doctest: +SKIP
117
+ """
116
118
input_spec = AffineInputSpec
117
119
output_spec = AffineOutputSpec
118
- _cmd = 'dti_affine_sn '
120
+ _cmd = 'dti_affine_reg '
119
121
120
122
def _list_outputs (self ):
121
123
outputs = self .output_spec ().get ()
122
- outputs ['out_file_xfm' ] = self .inputs .in_fixed_tensor .replace (
123
- '.nii.gz' , '.aff' )
124
- outputs ['out_file' ] = self .inputs .in_fixed_tensor .replace (
125
- '.nii.gz' , '_aff.nii.gz' )
124
+ outputs ['out_file_xfm' ] = self .inputs .moving_file .replace ('.nii.gz' ,
125
+ '.aff' )
126
+ outputs ['out_file' ] = self .inputs .moving_file .replace ('.nii.gz' ,
127
+ '_aff.nii.gz' )
126
128
return outputs
127
129
128
130
0 commit comments