Skip to content

Commit 4d5209c

Browse files
committed
ENH: Added new state saving interface to ANTs
In order to improve registration efficiency, it is important that we can save and restore the state of a registration so that continuation may occur from a previous state.
1 parent 6ee465d commit 4d5209c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

nipype/interfaces/ants/registration.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
205205
desc='image to apply transformation to (generally a coregistered functional)')
206206
moving_image_mask = File(requires=['fixed_image_mask'],
207207
exists=True, desc='mask used to limit metric sampling region of the moving image')
208+
209+
save_state = File(argstr='--save-state %s', exists=False,
210+
desc='Filename for saving the internal restorable state of the registration')
211+
restore_state = File(argstr='--restore-state %s', exists=True,
212+
desc='Filename for restoring the internal restorable state of the registration')
213+
208214
initial_moving_transform = File(argstr='%s', exists=True, desc='',
209215
xor=['initial_moving_transform_com'])
210216
invert_initial_moving_transform = traits.Bool(
@@ -337,7 +343,7 @@ class RegistrationOutputSpec(TraitedSpec):
337343
File(exists=True), desc='Inverse composite transform file')
338344
warped_image = File(desc="Outputs warped image")
339345
inverse_warped_image = File(desc="Outputs the inverse of the warped image")
340-
346+
save_state = File(desc="The saved registration state to be restored")
341347

342348
class Registration(ANTSCommand):
343349

@@ -391,6 +397,8 @@ class Registration(ANTSCommand):
391397
392398
>>> # Test collapse transforms flag
393399
>>> reg4 = copy.deepcopy(reg)
400+
>>> reg.inputs.save_state = 'trans.mat'
401+
>>> reg.inputs.restore_state = 'trans.mat'
394402
>>> reg4.inputs.collapse_output_transforms = True
395403
>>> outputs = reg4._list_outputs()
396404
>>> print outputs #doctest: +ELLIPSIS
@@ -756,4 +764,6 @@ def _list_outputs(self):
756764
outputs['warped_image'] = os.path.abspath(out_filename)
757765
if inv_out_filename:
758766
outputs['inverse_warped_image'] = os.path.abspath(inv_out_filename)
767+
if len(self.inputs.save_state):
768+
outputs['save_state'] = os.path.abspath(self.inputs.save_state)
759769
return outputs

0 commit comments

Comments
 (0)