Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7df066d

Browse filesBrowse files
committed
CompositeTransformUtil, new ANTs interface
1 parent 502fc63 commit 7df066d
Copy full SHA for 7df066d

File tree

1 file changed

+56
-0
lines changed
Filter options

1 file changed

+56
-0
lines changed

‎nipype/interfaces/ants/registration.py

Copy file name to clipboardExpand all lines: nipype/interfaces/ants/registration.py
+56Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,3 +1596,59 @@ def _list_outputs(self):
15961596
outputs['forward_warp_field'] = out_base + '1Warp.nii.gz'
15971597
outputs['inverse_warp_field'] = out_base + '1InverseWarp.nii.gz'
15981598
return outputs
1599+
1600+
class CompositeTransformUtilInputSpec(ANTSCommandInputSpec):
1601+
process = traits.Enum('assemble', 'disassemble', argstr='--%s',
1602+
position=1, usedefault=True,
1603+
desc='What to do with the transform inputs (assemble or disassemble)',
1604+
)
1605+
in_file = InputMultiPath(File(exists=True), mandatory=True, argstr='%s...',
1606+
position=2, desc='Input transform file(s)')
1607+
output_prefix = Str("transform", usedefault=True, argstr='%s',
1608+
position=3, desc="A prefix that is prepended to all output files")
1609+
1610+
class CompositeTransformUtilOutputSpec(TraitedSpec):
1611+
affine_transform = File(exists=True, desc="Affine transform component",
1612+
mandatory=True, position=2)
1613+
displacement_field = File(desc="Displacement field component")
1614+
1615+
class CompositeTransformUtil(ANTSCommand):
1616+
"""
1617+
ANTs utility which can combine or break apart transform files into their individual
1618+
constituent components.
1619+
1620+
Examples
1621+
--------
1622+
1623+
>>> from nipype.interfaces.ants import CompositeTransformUtil
1624+
>>> tran = CompositeTransformUtil()
1625+
>>> tran.inputs.process = 'disassemble'
1626+
>>> tran.inputs.in_file = 'output_Composite.h5'
1627+
>>> tran.cmdline
1628+
'CompositeTransformUtil --disassemble output_Composite.h5 transform'
1629+
>>> tran.run() # doctest: +SKIP
1630+
"""
1631+
1632+
_cmd = 'CompositeTransformUtil'
1633+
input_spec = CompositeTransformUtilInputSpec
1634+
output_spec = CompositeTransformUtilOutputSpec
1635+
1636+
def _num_threads_update(self):
1637+
"""
1638+
CompositeTransformUtil ignores environment variables,
1639+
so override environment update from ANTSCommand class
1640+
"""
1641+
pass
1642+
1643+
def _format_arg(self, name, spec, value):
1644+
if name == 'output_prefix' and self.inputs.process == 'assemble':
1645+
value = ''
1646+
return super(CompositeTransformUtil, self)._format_arg(name, spec, value)
1647+
1648+
def _list_outputs(self):
1649+
outputs = self.output_spec().get()
1650+
outputs['affine_transform'] = os.path.abspath(
1651+
'00_'+self.inputs.output_prefix+'_AffineTransform.mat')
1652+
outputs['displacement_field'] = os.path.abspath(
1653+
'01_'+self.inputs.output_prefix+'_DisplacementFieldTransform.nii.gz')
1654+
return outputs

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.