@@ -1588,6 +1588,108 @@ class NwarpApply(AFNICommandBase):
15881588 input_spec = NwarpApplyInputSpec
15891589 output_spec = AFNICommandOutputSpec
15901590
1591+
1592+ class NwarpCatInputSpec (AFNICommandInputSpec ):
1593+ in_files = traits .List (
1594+ traits .Either (
1595+ traits .File (), traits .Tuple (
1596+ traits .Enum ('IDENT' , 'INV' , 'SQRT' , 'SQRTINV' ), traits .File ())),
1597+ descr = "list of tuples of 3D warps and associated functions" ,
1598+ mandatory = True ,
1599+ argstr = "%s" ,
1600+ position = - 1 )
1601+ space = traits .String (
1602+ desc = 'string to attach to the output dataset as its atlas space '
1603+ 'marker.' ,
1604+ argstr = '-space %s' )
1605+ inv_warp = traits .Bool (
1606+ desc = 'invert the final warp before output' ,
1607+ argstr = '-iwarp' )
1608+ interp = traits .Enum (
1609+ 'linear' , 'quintic' , 'wsinc5' ,
1610+ desc = 'specify a different interpolation method than might '
1611+ 'be used for the warp' ,
1612+ argstr = '-interp %s' ,
1613+ default = 'wsinc5' )
1614+ expad = traits .Int (
1615+ desc = 'Pad the nonlinear warps by the given number of voxels voxels in '
1616+ 'all directions. The warp displacements are extended by linear '
1617+ 'extrapolation from the faces of the input grid..' ,
1618+ argstr = '-expad %d' )
1619+ out_file = File (
1620+ name_template = '%s_Nwarp' ,
1621+ desc = 'output image file name' ,
1622+ argstr = '-prefix %s' ,
1623+ name_source = 'in_file' )
1624+ verb = traits .Bool (
1625+ desc = 'be verbose' ,
1626+ argstr = '-verb' )
1627+
1628+
1629+ class NwarpCat (AFNICommand ):
1630+ """Catenates (composes) 3D warps defined on a grid, OR via a matrix.
1631+
1632+ .. note::
1633+
1634+ * All transformations are from DICOM xyz (in mm) to DICOM xyz.
1635+
1636+ * Matrix warps are in files that end in '.1D' or in '.txt'. A matrix
1637+ warp file should have 12 numbers in it, as output (for example), by
1638+ '3dAllineate -1Dmatrix_save'.
1639+
1640+ * Nonlinear warps are in dataset files (AFNI .HEAD/.BRIK or NIfTI .nii)
1641+ with 3 sub-bricks giving the DICOM order xyz grid displacements in mm.
1642+
1643+ * If all the input warps are matrices, then the output is a matrix
1644+ and will be written to the file 'prefix.aff12.1D'.
1645+ Unless the prefix already contains the string '.1D', in which case
1646+ the filename is just the prefix.
1647+
1648+ * If 'prefix' is just 'stdout', then the output matrix is written
1649+ to standard output.
1650+ In any of these cases, the output format is 12 numbers in one row.
1651+
1652+ * If any of the input warps are datasets, they must all be defined on
1653+ the same 3D grid!
1654+ And of course, then the output will be a dataset on the same grid.
1655+ However, you can expand the grid using the '-expad' option.
1656+
1657+ * The order of operations in the final (output) warp is, for the
1658+ case of 3 input warps:
1659+
1660+ OUTPUT(x) = warp3( warp2( warp1(x) ) )
1661+
1662+ That is, warp1 is applied first, then warp2, et cetera.
1663+ The 3D x coordinates are taken from each grid location in the
1664+ first dataset defined on a grid.
1665+
1666+ For complete details, see the `3dNwarpCat Documentation.
1667+ <https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dNwarpCat.html>`_
1668+
1669+ Examples
1670+ ========
1671+
1672+ >>> from nipype.interfaces import afni
1673+ >>> nwarpcat = afni.NwarpCat()
1674+ >>> nwarpcat.inputs.in_files = ['Q25_warp+tlrc.HEAD', ('IDENT', 'structural.nii')]
1675+ >>> nwarpcat.inputs.out_file = 'Fred_total_WARP'
1676+ >>> nwarpcat.cmdline # doctest: +ALLOW_UNICODE
1677+ "3dNwarpCat -prefix Fred_total_WARP Q25_warp+tlrc.HEAD 'IDENT(structural.nii)'"
1678+ >>> res = nwarpcat.run() # doctest: +SKIP
1679+
1680+ """
1681+ _cmd = '3dNwarpCat'
1682+ input_spec = NwarpCatInputSpec
1683+ output_spec = AFNICommandOutputSpec
1684+
1685+ def _format_arg (self , name , spec , value ):
1686+ if name == 'in_files' :
1687+ return spec .argstr % (' ' .join (["'" + v [0 ] + "(" + v [1 ] + ")'"
1688+ if isinstance (v , tuple ) else v
1689+ for v in value ]))
1690+ return super (NwarpCat , self )._format_arg (name , spec , value )
1691+
1692+
15911693class OneDToolPyInputSpec (AFNIPythonCommandInputSpec ):
15921694 in_file = File (
15931695 desc = 'input file to OneDTool' ,
0 commit comments