Skip to content

Commit 7e0bbfe

Browse files
ShotgunosineDylan
authored andcommitted
[ENH] add cat_matvec afni interface
1 parent eed080e commit 7e0bbfe

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
TShift, Volreg, Warp, QwarpPlusMinus, Qwarp)
2020
from .svm import (SVMTest, SVMTrain)
2121
from .utils import (AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket,
22-
Calc, Cat, Copy,
22+
Calc, Cat, CatMatvec, Copy,
2323
Edge3, Eval, FWHMx, MaskTool, Merge, Notes, NwarpApply,
2424
Refit, Resample, TCat, TStat, To3D, Unifize, ZCutUp, GCOR,
2525
Zcat, Zeropad)

nipype/interfaces/afni/utils.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,64 @@ class Cat(AFNICommand):
517517
input_spec = CatInputSpec
518518
output_spec = AFNICommandOutputSpec
519519

520+
class CatMatvecInputSpec(AFNICommandInputSpec):
521+
in_file = traits.List(
522+
traits.Tuple(traits.Str(), traits.Str()),
523+
descr="list of tuples of mfiles and associated opkeys",
524+
mandatory=True,
525+
argstr="%s",
526+
position=-2)
527+
out_file = File(
528+
descr="File to write concattenated matvecs to",
529+
argstr=" > %s",
530+
position=-1,
531+
mandatory=True)
532+
matrix = traits.Bool(
533+
descr="indicates that the resulting matrix will"
534+
"be written to outfile in the 'MATRIX(...)' format (FORM 3)."
535+
"This feature could be used, with clever scripting, to input"
536+
"a matrix directly on the command line to program 3dWarp.",
537+
argstr="-MATRIX",
538+
xor=['oneline','fourXfour'])
539+
oneline = traits.Bool(
540+
descr="indicates that the resulting matrix"
541+
"will simply be written as 12 numbers on one line.",
542+
argstr="-ONELINE",
543+
xor=['matrix','fourXfour'])
544+
fourxfour = traits.Bool(
545+
descr="Output matrix in augmented form (last row is 0 0 0 1)"
546+
"This option does not work with -MATRIX or -ONELINE",
547+
argstr="-4x4",
548+
xor=['matrix','oneline'])
549+
550+
class CatMatvec(AFNICommand):
551+
"""Catenates 3D rotation+shift matrix+vector transformations.
552+
553+
For complete details, see the `cat_matvec Documentation.
554+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/cat_matvec.html>`_
555+
556+
Examples
557+
========
558+
559+
>>> from nipype.interfaces import afni
560+
>>> cmv = afni.CatMatvec()
561+
>>> cmv.inputs.in_file = [('structural.BRIK::WARP_DATA','I')]
562+
>>> cmv.inputs.out_file = 'warp.anat.Xat.1D'
563+
>>> cmv.cmdline # doctest: +ALLOW_UNICODE
564+
'cat_matvec structural.BRIK::WARP_DATA -I > warp.anat.Xat.1D'
565+
>>> res = cmv.run() # doctest: +SKIP
566+
567+
568+
"""
569+
570+
_cmd = 'cat_matvec'
571+
input_spec = CatMatvecInputSpec
572+
output_spec = AFNICommandOutputSpec
573+
574+
def _format_arg(self, name, spec, value):
575+
if name == 'in_file':
576+
return spec.argstr%(' '.join([i[0]+' -'+i[1] for i in value]))
577+
return super(CatMatvec, self)._format_arg(name, spec, value)
520578

521579
class CopyInputSpec(AFNICommandInputSpec):
522580
in_file = File(

0 commit comments

Comments
 (0)