Skip to content

FIX: DTITK nonlinear workflow origin reslicing #2561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 24, 2018
2 changes: 1 addition & 1 deletion nipype/interfaces/dcm2nii.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Dcm2niixInputSpec(CommandLineInputSpec):
position=-1,
copyfile=False,
mandatory=True,
desc=('A set of filenames to be converted. Note that the current '
desc=('A set of filenames to be converted. Note that the current '
'version (1.0.20180328) of dcm2niix converts any files in the '
'directory. To only convert specific files they should be in an '
'isolated directory'),
Expand Down
2 changes: 1 addition & 1 deletion nipype/tests/test_nipype.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_nipype_info():
assert exception_not_raised


@pytest.mark.skipif(not get_nipype_gitversion(),
@pytest.mark.skipif(not get_nipype_gitversion(),
reason="not able to get version from get_nipype_gitversion")
def test_git_hash():
# removing the first "g" from gitversion
Expand Down
29 changes: 23 additions & 6 deletions nipype/workflows/dmri/dtitk/tensor_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
params={'array_size': (128, 128, 64)}):
"""
Workflow that performs a diffeomorphic registration
(Rigid and Affine follwed by Diffeomorphic)
(Rigid and Affine followed by Diffeomorphic)
Note: the requirements for a diffeomorphic registration specify that
the dimension 0 is a power of 2 so images are resliced prior to
registration
registration. Remember to move origin and reslice prior to applying xfm to
another file!

Example
-------
Expand All @@ -75,7 +76,9 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
fields=['out_file', 'out_file_xfm',
'fixed_resliced', 'moving_resliced']),
name='outputnode')

origin_node_fixed = pe.Node(dtitk.TVAdjustVoxSp(origin=(0, 0, 0)),
name='origin_node_fixed')
origin_node_moving = origin_node_fixed.clone(name='origin_node_moving')
reslice_node_pow2 = pe.Node(dtitk.TVResample(
origin=(0, 0, 0),
array_size=params['array_size']),
Expand All @@ -92,14 +95,23 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
compose_xfm_node = pe.Node(dtitk.ComposeXfm(), name='compose_xfm_node')
apply_xfm_node = pe.Node(dtitk.DiffeoSymTensor3DVol(),
name='apply_xfm_node')
adjust_vs_node_to_input = pe.Node(dtitk.TVAdjustVoxSp(),
name='adjust_vs_node_to_input')
reslice_node_to_input = pe.Node(dtitk.TVResample(),
name='reslice_node_to_input')
input_fa = pe.Node(dtitk.TVtool(in_flag='fa'), name='input_fa')

wf = pe.Workflow(name=name)

# calculate input FA image for origin reference
wf.connect(inputnode, 'fixed_file', input_fa, 'in_file')
# Reslice input images
wf.connect(inputnode, 'fixed_file', reslice_node_pow2, 'in_file')
wf.connect(inputnode, 'fixed_file', origin_node_fixed, 'in_file')
wf.connect(origin_node_fixed, 'out_file', reslice_node_pow2, 'in_file')
wf.connect(reslice_node_pow2, 'out_file',
reslice_node_moving, 'target_file')
wf.connect(inputnode, 'moving_file', reslice_node_moving, 'in_file')
wf.connect(inputnode, 'moving_file', origin_node_moving, 'in_file')
wf.connect(origin_node_moving, 'out_file', reslice_node_moving, 'in_file')
# Rigid registration
wf.connect(reslice_node_pow2, 'out_file', rigid_node, 'fixed_file')
wf.connect(reslice_node_moving, 'out_file', rigid_node, 'moving_file')
Expand All @@ -118,8 +130,13 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
# Apply transform
wf.connect(reslice_node_moving, 'out_file', apply_xfm_node, 'in_file')
wf.connect(compose_xfm_node, 'out_file', apply_xfm_node, 'transform')
# Move origin and reslice to match original fixed input image
wf.connect(apply_xfm_node, 'out_file', adjust_vs_node_to_input, 'in_file')
wf.connect(input_fa, 'out_file', adjust_vs_node_to_input, 'target_file')
wf.connect(adjust_vs_node_to_input, 'out_file', reslice_node_to_input, 'in_file')
wf.connect(input_fa, 'out_file', reslice_node_to_input, 'target_file')
# Send to output
wf.connect(apply_xfm_node, 'out_file', outputnode, 'out_file')
wf.connect(reslice_node_to_input, 'out_file', outputnode, 'out_file')
wf.connect(compose_xfm_node, 'out_file', outputnode, 'out_file_xfm')
wf.connect(reslice_node_pow2, 'out_file', outputnode, 'fixed_resliced')
wf.connect(reslice_node_moving, 'out_file', outputnode, 'moving_resliced')
Expand Down
2 changes: 1 addition & 1 deletion tools/checkspecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def test_specs(self, uri):
and "requires" not in trait.__dict__\
and "xor" not in trait.__dict__:
if trait.trait_type.__class__.__name__ is "Range"\
and trait.default == trait.trait_type._low:
and trait.default == trait.trait_type._low:
continue
bad_specs.append(
[uri, c, 'Inputs', traitname, 'default value is set, no value for usedefault'])
Expand Down