Skip to content

Commit 3db3bb2

Browse files
committed
Merge pull request nipy#438 from chrisfilo/fix/slicer_position
Fix/slicer position
2 parents f8dd221 + d2a8b03 commit 3db3bb2

File tree

10 files changed

+62
-51
lines changed

10 files changed

+62
-51
lines changed

nipype/interfaces/slicer/diffusion/denoising.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ class jointLMMSEInputSpec(CommandLineInputSpec):
1010
re = InputMultiPath(traits.Int, desc="Estimation radius.", sep=",", argstr="--re %s")
1111
rf = InputMultiPath(traits.Int, desc="Filtering radius.", sep=",", argstr="--rf %s")
1212
ng = traits.Int(desc="The number of the closest gradients that are used to jointly filter a given gradient direction (0 to use all).", argstr="--ng %d")
13-
inputVolume = File(position="0", desc="Input DWI volume.", exists=True, argstr="--inputVolume %s")
14-
outputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Output DWI volume.", argstr="--outputVolume %s")
13+
inputVolume = File(position=-2, desc="Input DWI volume.", exists=True, argstr="%s")
14+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output DWI volume.", argstr="%s")
1515

1616

1717
class jointLMMSEOutputSpec(TraitedSpec):
18-
outputVolume = File(position="1", desc="Output DWI volume.", exists=True)
18+
outputVolume = File(position=-1, desc="Output DWI volume.", exists=True)
1919

2020

2121
class jointLMMSE(SlicerCommandLine):
@@ -55,12 +55,12 @@ class dwiNoiseFilterInputSpec(CommandLineInputSpec):
5555
maxnstd = traits.Int(desc="Maximum allowed noise standard deviation.", argstr="--maxnstd %d")
5656
hrf = traits.Float(desc="How many histogram bins per unit interval.", argstr="--hrf %f")
5757
uav = traits.Bool(desc="Use absolute value in case of negative square.", argstr="--uav ")
58-
inputVolume = File(position="0", desc="Input DWI volume.", exists=True, argstr="--inputVolume %s")
59-
outputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Output DWI volume.", argstr="--outputVolume %s")
58+
inputVolume = File(position=-2, desc="Input DWI volume.", exists=True, argstr="%s")
59+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output DWI volume.", argstr="%s")
6060

6161

6262
class dwiNoiseFilterOutputSpec(TraitedSpec):
63-
outputVolume = File(position="1", desc="Output DWI volume.", exists=True)
63+
outputVolume = File(position=-1, desc="Output DWI volume.", exists=True)
6464

6565

6666
class dwiNoiseFilter(SlicerCommandLine):

nipype/interfaces/slicer/diffusion/utilities.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99
class ResampleDTIInputSpec(CommandLineInputSpec):
10-
inputVolume = File(position="0", desc="Input volume to be resampled", exists=True, argstr="--inputVolume %s")
11-
outputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Resampled Volume", argstr="--outputVolume %s")
10+
inputVolume = File(position=-2, desc="Input volume to be resampled", exists=True, argstr="%s")
11+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Resampled Volume", argstr="%s")
1212
Reference = File(desc="Reference Volume (spacing,size,orientation,origin)", exists=True, argstr="--Reference %s")
1313
transformationFile = File(exists=True, argstr="--transformationFile %s")
1414
defField = File(desc="File containing the deformation field (3D vector image containing vectors with 3 components)", exists=True, argstr="--defField %s")
@@ -36,7 +36,7 @@ class ResampleDTIInputSpec(CommandLineInputSpec):
3636

3737

3838
class ResampleDTIOutputSpec(TraitedSpec):
39-
outputVolume = File(position="1", desc="Resampled Volume", exists=True)
39+
outputVolume = File(position=-1, desc="Resampled Volume", exists=True)
4040

4141

4242
class ResampleDTI(SlicerCommandLine):
@@ -67,17 +67,17 @@ class ResampleDTI(SlicerCommandLine):
6767

6868

6969
class DiffusionTensorEstimationInputSpec(CommandLineInputSpec):
70-
inputVolume = File(position="0", desc="Input DWI volume", exists=True, argstr="--inputVolume %s")
70+
inputVolume = File(position=-3, desc="Input DWI volume", exists=True, argstr="%s")
7171
mask = File(desc="Mask where the tensors will be computed", exists=True, argstr="--mask %s")
72-
outputTensor = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Estimated DTI volume", argstr="--outputTensor %s")
73-
outputBaseline = traits.Either(traits.Bool, File(), position="2", hash_files=False, desc="Estimated baseline volume", argstr="--outputBaseline %s")
72+
outputTensor = traits.Either(traits.Bool, File(), position=-2, hash_files=False, desc="Estimated DTI volume", argstr="%s")
73+
outputBaseline = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Estimated baseline volume", argstr="%s")
7474
enumeration = traits.Enum("LS", "WLS", desc="LS: Least Squares, WLS: Weighted Least Squares", argstr="--enumeration %s")
7575
shiftNeg = traits.Bool(desc="Shift eigenvalues so all are positive (accounts for bad tensors related to noise or acquisition error)", argstr="--shiftNeg ")
7676

7777

7878
class DiffusionTensorEstimationOutputSpec(TraitedSpec):
79-
outputTensor = File(position="1", desc="Estimated DTI volume", exists=True)
80-
outputBaseline = File(position="2", desc="Estimated baseline volume", exists=True)
79+
outputTensor = File(position=-2, desc="Estimated DTI volume", exists=True)
80+
outputBaseline = File(position=-1, desc="Estimated baseline volume", exists=True)
8181

8282

8383
class DiffusionTensorEstimation(SlicerCommandLine):
@@ -114,16 +114,16 @@ class DiffusionTensorEstimation(SlicerCommandLine):
114114

115115

116116
class DiffusionWeightedMaskingInputSpec(CommandLineInputSpec):
117-
inputVolume = File(position="0", desc="Input DWI volume", exists=True, argstr="--inputVolume %s")
118-
outputBaseline = traits.Either(traits.Bool, File(), position="2", hash_files=False, desc="Estimated baseline volume", argstr="--outputBaseline %s")
119-
thresholdMask = traits.Either(traits.Bool, File(), position="3", hash_files=False, desc="Otsu Threshold Mask", argstr="--thresholdMask %s")
117+
inputVolume = File(position=-4, desc="Input DWI volume", exists=True, argstr="%s")
118+
outputBaseline = traits.Either(traits.Bool, File(), position=-2, hash_files=False, desc="Estimated baseline volume", argstr="%s")
119+
thresholdMask = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Otsu Threshold Mask", argstr="%s")
120120
otsuomegathreshold = traits.Float(desc="Control the sharpness of the threshold in the Otsu computation. 0: lower threshold, 1: higher threhold", argstr="--otsuomegathreshold %f")
121121
removeislands = traits.Bool(desc="Remove Islands in Threshold Mask?", argstr="--removeislands ")
122122

123123

124124
class DiffusionWeightedMaskingOutputSpec(TraitedSpec):
125-
outputBaseline = File(position="2", desc="Estimated baseline volume", exists=True)
126-
thresholdMask = File(position="3", desc="Otsu Threshold Mask", exists=True)
125+
outputBaseline = File(position=-2, desc="Estimated baseline volume", exists=True)
126+
thresholdMask = File(position=-1, desc="Otsu Threshold Mask", exists=True)
127127

128128

129129
class DiffusionWeightedMasking(SlicerCommandLine):
@@ -154,13 +154,13 @@ class DiffusionWeightedMasking(SlicerCommandLine):
154154

155155

156156
class DiffusionTensorMathematicsInputSpec(CommandLineInputSpec):
157-
inputVolume = File(position="0", desc="Input DTI volume", exists=True, argstr="--inputVolume %s")
158-
outputScalar = traits.Either(traits.Bool, File(), position="2", hash_files=False, desc="Scalar volume derived from tensor", argstr="--outputScalar %s")
157+
inputVolume = File(position=-3, desc="Input DTI volume", exists=True, argstr="%s")
158+
outputScalar = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Scalar volume derived from tensor", argstr="%s")
159159
enumeration = traits.Enum("Trace", "Determinant", "RelativeAnisotropy", "FractionalAnisotropy", "Mode", "LinearMeasure", "PlanarMeasure", "SphericalMeasure", "MinEigenvalue", "MidEigenvalue", "MaxEigenvalue", "MaxEigenvalueProjectionX", "MaxEigenvalueProjectionY", "MaxEigenvalueProjectionZ", "RAIMaxEigenvecX", "RAIMaxEigenvecY", "RAIMaxEigenvecZ", "D11", "D22", "D33", "ParallelDiffusivity", "PerpendicularDffusivity", desc="An enumeration of strings", argstr="--enumeration %s")
160160

161161

162162
class DiffusionTensorMathematicsOutputSpec(TraitedSpec):
163-
outputScalar = File(position="2", desc="Scalar volume derived from tensor", exists=True)
163+
outputScalar = File(position=-1, desc="Scalar volume derived from tensor", exists=True)
164164

165165

166166
class DiffusionTensorMathematics(SlicerCommandLine):

nipype/interfaces/slicer/filtering/arithmetic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88

99
class CastInputSpec(CommandLineInputSpec):
10-
InputVolume = File(position="0", desc="Input volume, the volume to cast.", exists=True, argstr="--InputVolume %s")
11-
OutputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Output volume, cast to the new type.", argstr="--OutputVolume %s")
10+
InputVolume = File(position=-2, desc="Input volume, the volume to cast.", exists=True, argstr="%s")
11+
OutputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output volume, cast to the new type.", argstr="%s")
1212
type = traits.Enum("Char", "UnsignedChar", "Short", "UnsignedShort", "Int", "UnsignedInt", "Float", "Double", desc="Type for the new output volume.", argstr="--type %s")
1313

1414

1515
class CastOutputSpec(TraitedSpec):
16-
OutputVolume = File(position="1", desc="Output volume, cast to the new type.", exists=True)
16+
OutputVolume = File(position=-1, desc="Output volume, cast to the new type.", exists=True)
1717

1818

1919
class Cast(SlicerCommandLine):
@@ -45,14 +45,14 @@ class Cast(SlicerCommandLine):
4545

4646

4747
class AddInputSpec(CommandLineInputSpec):
48-
inputVolume1 = File(position="0", desc="Input volume 1", exists=True, argstr="--inputVolume1 %s")
49-
inputVolume2 = File(position="1", desc="Input volume 2", exists=True, argstr="--inputVolume2 %s")
50-
outputVolume = traits.Either(traits.Bool, File(), position="2", hash_files=False, desc="Volume1 + Volume2", argstr="--outputVolume %s")
48+
inputVolume1 = File(position=-3, desc="Input volume 1", exists=True, argstr="%s")
49+
inputVolume2 = File(position=-2, desc="Input volume 2", exists=True, argstr="%s")
50+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Volume1 + Volume2", argstr="%s")
5151
order = traits.Enum("0", "1", "2", "3", desc="Interpolation order if two images are in different coordinate frames or have different sampling.", argstr="--order %s")
5252

5353

5454
class AddOutputSpec(TraitedSpec):
55-
outputVolume = File(position="2", desc="Volume1 + Volume2", exists=True)
55+
outputVolume = File(position=-1, desc="Volume1 + Volume2", exists=True)
5656

5757

5858
class Add(SlicerCommandLine):

nipype/interfaces/slicer/filtering/checkerboard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
class CheckerBoardInputSpec(CommandLineInputSpec):
1010
checkerPattern = InputMultiPath(traits.Int, desc="The pattern of input 1 and input 2 in the output image. The user can specify the number of checkers in each dimension. A checkerPattern of 2,2,1 means that images will alternate in every other checker in the first two dimensions. The same pattern will be used in the 3rd dimension.", sep=",", argstr="--checkerPattern %s")
11-
inputVolume1 = File(position="0", desc="First Input volume", exists=True, argstr="--inputVolume1 %s")
12-
inputVolume2 = File(position="1", desc="Second Input volume", exists=True, argstr="--inputVolume2 %s")
13-
outputVolume = traits.Either(traits.Bool, File(), position="2", hash_files=False, desc="Output filtered", argstr="--outputVolume %s")
11+
inputVolume1 = File(position=-3, desc="First Input volume", exists=True, argstr="%s")
12+
inputVolume2 = File(position=-2, desc="Second Input volume", exists=True, argstr="%s")
13+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output filtered", argstr="%s")
1414

1515

1616
class CheckerBoardOutputSpec(TraitedSpec):
17-
outputVolume = File(position="2", desc="Output filtered", exists=True)
17+
outputVolume = File(position=-1, desc="Output filtered", exists=True)
1818

1919

2020
class CheckerBoard(SlicerCommandLine):

nipype/interfaces/slicer/filtering/denoising.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ class CurvatureAnisotropicDiffusionInputSpec(CommandLineInputSpec):
1010
conductance = traits.Float(desc="Conductance controls the sensitivity of the conductance term. As a general rule, the lower the value, the more strongly the filter preserves edges. A high value will cause diffusion (smoothing) across edges. Note that the number of iterations controls how much smoothing is done within regions bounded by edges.", argstr="--conductance %f")
1111
iterations = traits.Int(desc="The more iterations, the more smoothing. Each iteration takes the same amount of time. If it takes 10 seconds for one iteration, then it will take 100 seconds for 10 iterations. Note that the conductance controls how much each iteration smooths across edges.", argstr="--iterations %d")
1212
timeStep = traits.Float(desc="The time step depends on the dimensionality of the image. In Slicer the images are 3D and the default (.0625) time step will provide a stable solution.", argstr="--timeStep %f")
13-
inputVolume = File(position="0", desc="Input volume to be filtered", exists=True, argstr="--inputVolume %s")
14-
outputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Output filtered", argstr="--outputVolume %s")
13+
inputVolume = File(position=-2, desc="Input volume to be filtered", exists=True, argstr="%s")
14+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output filtered", argstr="%s")
1515

1616

1717
class CurvatureAnisotropicDiffusionOutputSpec(TraitedSpec):
18-
outputVolume = File(position="1", desc="Output filtered", exists=True)
18+
outputVolume = File(position=-1, desc="Output filtered", exists=True)
1919

2020

2121
class CurvatureAnisotropicDiffusion(SlicerCommandLine):

nipype/interfaces/slicer/generate_classes.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def generate_all_classes(modules_list=[], launcher=[]):
9191
crawl_code_struct(all_code, os.getcwd())
9292

9393

94+
9495
def generate_class(module,launcher):
9596
dom = grab_xml(module,launcher)
9697
inputTraits = []
@@ -100,6 +101,8 @@ def generate_class(module,launcher):
100101
#self._outputs_nodes = []
101102

102103
class_string = "\"\"\""
104+
105+
103106

104107
for desc_str in ['title', 'category', 'description', 'version',
105108
'documentation-url', 'license', 'contributor',
@@ -112,6 +115,11 @@ def generate_class(module,launcher):
112115
class_string += "\"\"\""
113116

114117
for paramGroup in dom.getElementsByTagName("parameters"):
118+
indices = paramGroup.getElementsByTagName('index')
119+
max_index = 0
120+
for index in indices:
121+
if int(index.firstChild.nodeValue) > max_index:
122+
max_index = int(index.firstChild.nodeValue)
115123
for param in paramGroup.childNodes:
116124
if param.nodeName in ['label', 'description', '#text', '#comment']:
117125
continue
@@ -132,7 +140,10 @@ def generate_class(module,launcher):
132140
else:
133141
name = param.getElementsByTagName('name')[0].firstChild.nodeValue
134142
name = name.lstrip().rstrip()
135-
traitsParams["argstr"] = "--" + name + " "
143+
if param.getElementsByTagName('index'):
144+
traitsParams["argstr"] = ""
145+
else:
146+
traitsParams["argstr"] = "--" + name + " "
136147

137148
if param.getElementsByTagName('description'):
138149
traitsParams["desc"] = param.getElementsByTagName('description')[0].firstChild.nodeValue.replace('"', "\\\"").replace("\n", ", ")
@@ -151,7 +162,7 @@ def generate_class(module,launcher):
151162

152163
index = param.getElementsByTagName('index')
153164
if index:
154-
traitsParams["position"] = index[0].firstChild.nodeValue
165+
traitsParams["position"] = int(index[0].firstChild.nodeValue)-(max_index+1)
155166

156167
desc = param.getElementsByTagName('description')
157168
if index:

nipype/interfaces/slicer/legacy/diffusion/denoising.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class dwiUNLMInputSpec(CommandLineInputSpec):
1212
hp = traits.Float(desc="This parameter is related to noise; the larger the parameter, the more agressive the filtering. Should be near 1, and only values between 0.8 and 1.2 are allowed", argstr="--hp %f")
1313
ng = traits.Int(desc="The number of the closest gradients that are used to jointly filter a given gradient direction (a maximum of 5 is allowed).", argstr="--ng %d")
1414
re = InputMultiPath(traits.Int, desc="A neighborhood of this size is used to compute the statistics for noise estimation.", sep=",", argstr="--re %s")
15-
inputVolume = File(position="0", desc="Input DWI volume.", exists=True, argstr="--inputVolume %s")
16-
outputVolume = traits.Either(traits.Bool, File(), position="1", hash_files=False, desc="Output DWI volume.", argstr="--outputVolume %s")
15+
inputVolume = File(position=-2, desc="Input DWI volume.", exists=True, argstr="%s")
16+
outputVolume = traits.Either(traits.Bool, File(), position=-1, hash_files=False, desc="Output DWI volume.", argstr="%s")
1717

1818

1919
class dwiUNLMOutputSpec(TraitedSpec):
20-
outputVolume = File(position="1", desc="Output DWI volume.", exists=True)
20+
outputVolume = File(position=-1, desc="Output DWI volume.", exists=True)
2121

2222

2323
class dwiUNLM(SlicerCommandLine):

0 commit comments

Comments
 (0)