Skip to content

Commit 0807cdb

Browse files
committed
tested affine
1 parent d240443 commit 0807cdb

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

nipype/interfaces/dtitk/registration.py

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from ..base import TraitedSpec, CommandLineInputSpec, \
2-
traits, isdefined
1+
from ..base import TraitedSpec, CommandLineInputSpec, traits, isdefined
32
from ...utils.filemanip import fname_presuffix
43
import os
54
from .base import CommandLineDtitk
@@ -44,8 +43,8 @@ class RigidTask(CommandLineDtitk):
4443
4544
>>> import nipype.interfaces.dtitk as dtitk
4645
>>> 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'
4948
>>> node.inputs.similarity_metric = 'EDS'
5049
>>> node.inputs.samplingX = 4
5150
>>> node.inputs.samplingY = 4
@@ -58,13 +57,6 @@ class RigidTask(CommandLineDtitk):
5857
output_spec = RigidOutputSpec
5958
_cmd = 'dti_rigid_reg'
6059

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-
6860
def _list_outputs(self):
6961
outputs = self.output_spec().get()
7062
outputs['out_file_xfm'] = self.inputs.moving_file.replace('.nii.gz',
@@ -73,24 +65,30 @@ def _list_outputs(self):
7365
'_aff.nii.gz')
7466
return outputs
7567

76-
def _gen_fname(self, name):
77-
if name == 'out_file':
78-
return self._gen_outfilename()
79-
8068

8169
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)
9492

9593

9694
class AffineOutputSpec(TraitedSpec):
@@ -100,29 +98,33 @@ class AffineOutputSpec(TraitedSpec):
10098

10199
class AffineTask(CommandLineDtitk):
102100
"""
103-
Performs affine registration between two tensor volumes
104-
105-
Example
106-
-------
101+
Performs affine registration between two tensor volumes
107102
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+
-------
115105
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+
"""
116118
input_spec = AffineInputSpec
117119
output_spec = AffineOutputSpec
118-
_cmd = 'dti_affine_sn'
120+
_cmd = 'dti_affine_reg'
119121

120122
def _list_outputs(self):
121123
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')
126128
return outputs
127129

128130

0 commit comments

Comments
 (0)