Skip to content

Commit b547aa7

Browse files
authored
Merge pull request #2561 from kesshijordan/fix_dtitk_nonlinear_wf
FIX: DTITK nonlinear workflow origin reslicing
2 parents 67d2657 + 9545859 commit b547aa7

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

nipype/interfaces/dcm2nii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
264264
position=-1,
265265
copyfile=False,
266266
mandatory=True,
267-
desc=('A set of filenames to be converted. Note that the current '
267+
desc=('A set of filenames to be converted. Note that the current '
268268
'version (1.0.20180328) of dcm2niix converts any files in the '
269269
'directory. To only convert specific files they should be in an '
270270
'isolated directory'),

nipype/tests/test_nipype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_nipype_info():
1212
assert exception_not_raised
1313

1414

15-
@pytest.mark.skipif(not get_nipype_gitversion(),
15+
@pytest.mark.skipif(not get_nipype_gitversion(),
1616
reason="not able to get version from get_nipype_gitversion")
1717
def test_git_hash():
1818
# removing the first "g" from gitversion

nipype/workflows/dmri/dtitk/tensor_registration.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
5252
params={'array_size': (128, 128, 64)}):
5353
"""
5454
Workflow that performs a diffeomorphic registration
55-
(Rigid and Affine follwed by Diffeomorphic)
55+
(Rigid and Affine followed by Diffeomorphic)
5656
Note: the requirements for a diffeomorphic registration specify that
5757
the dimension 0 is a power of 2 so images are resliced prior to
58-
registration
58+
registration. Remember to move origin and reslice prior to applying xfm to
59+
another file!
5960
6061
Example
6162
-------
@@ -75,7 +76,9 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
7576
fields=['out_file', 'out_file_xfm',
7677
'fixed_resliced', 'moving_resliced']),
7778
name='outputnode')
78-
79+
origin_node_fixed = pe.Node(dtitk.TVAdjustVoxSp(origin=(0, 0, 0)),
80+
name='origin_node_fixed')
81+
origin_node_moving = origin_node_fixed.clone(name='origin_node_moving')
7982
reslice_node_pow2 = pe.Node(dtitk.TVResample(
8083
origin=(0, 0, 0),
8184
array_size=params['array_size']),
@@ -92,14 +95,23 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
9295
compose_xfm_node = pe.Node(dtitk.ComposeXfm(), name='compose_xfm_node')
9396
apply_xfm_node = pe.Node(dtitk.DiffeoSymTensor3DVol(),
9497
name='apply_xfm_node')
98+
adjust_vs_node_to_input = pe.Node(dtitk.TVAdjustVoxSp(),
99+
name='adjust_vs_node_to_input')
100+
reslice_node_to_input = pe.Node(dtitk.TVResample(),
101+
name='reslice_node_to_input')
102+
input_fa = pe.Node(dtitk.TVtool(in_flag='fa'), name='input_fa')
95103

96104
wf = pe.Workflow(name=name)
97105

106+
# calculate input FA image for origin reference
107+
wf.connect(inputnode, 'fixed_file', input_fa, 'in_file')
98108
# Reslice input images
99-
wf.connect(inputnode, 'fixed_file', reslice_node_pow2, 'in_file')
109+
wf.connect(inputnode, 'fixed_file', origin_node_fixed, 'in_file')
110+
wf.connect(origin_node_fixed, 'out_file', reslice_node_pow2, 'in_file')
100111
wf.connect(reslice_node_pow2, 'out_file',
101112
reslice_node_moving, 'target_file')
102-
wf.connect(inputnode, 'moving_file', reslice_node_moving, 'in_file')
113+
wf.connect(inputnode, 'moving_file', origin_node_moving, 'in_file')
114+
wf.connect(origin_node_moving, 'out_file', reslice_node_moving, 'in_file')
103115
# Rigid registration
104116
wf.connect(reslice_node_pow2, 'out_file', rigid_node, 'fixed_file')
105117
wf.connect(reslice_node_moving, 'out_file', rigid_node, 'moving_file')
@@ -118,8 +130,13 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
118130
# Apply transform
119131
wf.connect(reslice_node_moving, 'out_file', apply_xfm_node, 'in_file')
120132
wf.connect(compose_xfm_node, 'out_file', apply_xfm_node, 'transform')
133+
# Move origin and reslice to match original fixed input image
134+
wf.connect(apply_xfm_node, 'out_file', adjust_vs_node_to_input, 'in_file')
135+
wf.connect(input_fa, 'out_file', adjust_vs_node_to_input, 'target_file')
136+
wf.connect(adjust_vs_node_to_input, 'out_file', reslice_node_to_input, 'in_file')
137+
wf.connect(input_fa, 'out_file', reslice_node_to_input, 'target_file')
121138
# Send to output
122-
wf.connect(apply_xfm_node, 'out_file', outputnode, 'out_file')
139+
wf.connect(reslice_node_to_input, 'out_file', outputnode, 'out_file')
123140
wf.connect(compose_xfm_node, 'out_file', outputnode, 'out_file_xfm')
124141
wf.connect(reslice_node_pow2, 'out_file', outputnode, 'fixed_resliced')
125142
wf.connect(reslice_node_moving, 'out_file', outputnode, 'moving_resliced')

tools/checkspecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def test_specs(self, uri):
287287
and "requires" not in trait.__dict__\
288288
and "xor" not in trait.__dict__:
289289
if trait.trait_type.__class__.__name__ is "Range"\
290-
and trait.default == trait.trait_type._low:
290+
and trait.default == trait.trait_type._low:
291291
continue
292292
bad_specs.append(
293293
[uri, c, 'Inputs', traitname, 'default value is set, no value for usedefault'])

0 commit comments

Comments
 (0)