Skip to content

Commit 5d238c0

Browse files
committed
added apply_xfm workflow
1 parent ac3286d commit 5d238c0

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

nipype/workflows/dmri/dtitk/tensor_registration.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
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
5858
registration. Remember to move origin and reslice prior to applying xfm to
59-
another file
59+
another file!
6060
6161
Example
6262
-------
@@ -135,3 +135,45 @@ def diffeomorphic_tensor_pipeline(name='DiffeoTen',
135135
wf.connect(reslice_node_moving, 'out_file', outputnode, 'moving_resliced')
136136

137137
return wf
138+
139+
140+
def apply_diffeo(name='ApplyDiffeo', params={'array_size': (128, 128, 64)}):
141+
142+
"""
143+
Workflow that applies a dtitk diffeomorphic registration to a scalar volume
144+
by moving the origin and reslicing, then applying the transform.
145+
146+
Example
147+
-------
148+
149+
>>> from nipype.workflows.dmri.dtitk.tensor_registration import apply_diffeo
150+
>>> app_diffeo = diffeomorphic_tensor_pipeline()
151+
>>> app_diffeo.inputs.inputnode.moving_file = 'im1.nii'
152+
>>> app_diffeo.inputs.inputnode.xfm_file = 'im_warp.df.nii'
153+
>>> app_diffeo.run() # doctest: +SKIP
154+
155+
156+
"""
157+
inputnode = pe.Node(niu.IdentityInterface(
158+
fields=['moving_file', 'xfm_file']),
159+
name='inputnode')
160+
outputnode = pe.Node(niu.IdentityInterface(
161+
fields=['out_file']),
162+
name='outputnode')
163+
origin_node = pe.Node(dtitk.TVAdjustVoxSp(origin=(0, 0, 0)),
164+
name='origin_node')
165+
reslice_node_pow2 = pe.Node(dtitk.TVResample(
166+
origin=(0, 0, 0),
167+
array_size=params['array_size']),
168+
name='reslice_node_pow2')
169+
apply_xfm_node = pe.Node(dtitk.DiffeoScalarVol(), name='apply_xfm_node')
170+
171+
wf = pe.Workflow(name=name)
172+
173+
wf.connect(inputnode, 'moving_file', origin_node, 'in_file')
174+
wf.connect(origin_node, 'out_file', reslice_node_pow2, 'in_file')
175+
wf.connect(reslice_node_pow2, 'out_file', apply_xfm_node, 'in_file')
176+
wf.connect(inputnode, 'xfm_file', apply_xfm_node, 'transform')
177+
wf.connect(apply_xfm_node, 'out_file', outputnode, 'out_file')
178+
179+
return wf

0 commit comments

Comments
 (0)