@@ -1596,3 +1596,69 @@ def _list_outputs(self):
1596
1596
outputs ['forward_warp_field' ] = out_base + '1Warp.nii.gz'
1597
1597
outputs ['inverse_warp_field' ] = out_base + '1InverseWarp.nii.gz'
1598
1598
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
+ example for assembling transformation files
1632
+
1633
+ >>> from nipype.interfaces.ants import CompositeTransformUtil
1634
+ >>> tran = CompositeTransformUtil()
1635
+ >>> tran.inputs.process = 'assemble'
1636
+ >>> tran.inputs.in_file = ['output_Composite.h5', 'transform1', 'transform2']
1637
+ >>> tran.cmdline
1638
+ 'CompositeTransformUtil --assemble output_Composite.h5 transform1 transform2 '
1639
+ >>> tran.run() # doctest: +SKIP
1640
+ """
1641
+
1642
+ _cmd = 'CompositeTransformUtil'
1643
+ input_spec = CompositeTransformUtilInputSpec
1644
+ output_spec = CompositeTransformUtilOutputSpec
1645
+
1646
+ def _num_threads_update (self ):
1647
+ """
1648
+ CompositeTransformUtil ignores environment variables,
1649
+ so override environment update from ANTSCommand class
1650
+ """
1651
+ pass
1652
+
1653
+ def _format_arg (self , name , spec , value ):
1654
+ if name == 'output_prefix' and self .inputs .process == 'assemble' :
1655
+ value = ''
1656
+ return super (CompositeTransformUtil , self )._format_arg (name , spec , value )
1657
+
1658
+ def _list_outputs (self ):
1659
+ outputs = self .output_spec ().get ()
1660
+ outputs ['affine_transform' ] = os .path .abspath (
1661
+ '00_{}_AffineTransform.mat' .format (self .inputs .output_prefix ))
1662
+ outputs ['displacement_field' ] = os .path .abspath (
1663
+ '01_{}_DisplacementFieldTransform.nii.gz' .format (self .inputs .output_prefix ))
1664
+ return outputs
0 commit comments