Skip to content

Commit 37335d9

Browse files
ShotgunosineDylan
authored andcommitted
[ENH] add 3dDot and 3dABoverlap interfaces
1 parent 8136172 commit 37335d9

File tree

2 files changed

+127
-2
lines changed

2 files changed

+127
-2
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
Seg, SkullStrip, TCorr1D, TCorrMap, TCorrelate,
1919
TShift, Volreg, Warp, QwarpPlusMinus, Qwarp)
2020
from .svm import (SVMTest, SVMTrain)
21-
from .utils import (AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket,
22-
Calc, Cat, CatMatvec, Copy,
21+
from .utils import (ABoverlap, AFNItoNIFTI, Autobox, Axialize, BrickStat, Bucket,
22+
Calc, Cat, CatMatvec, Copy, Dot,
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: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,61 @@
2929
from .base import (
3030
AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec)
3131

32+
class ABoverlapInputSpec(AFNICommandInputSpec):
33+
in_file_a = File(
34+
desc='input file A',
35+
argstr='%s',
36+
position=-3,
37+
mandatory=True,
38+
exists=True,
39+
copyfile=False)
40+
in_file_b = File(
41+
desc='input file B',
42+
argstr='%s',
43+
position=-2,
44+
mandatory=True,
45+
exists=True,
46+
copyfile=False)
47+
out_file = File(
48+
desc='collect output to a file',
49+
argstr=' |& tee %s',
50+
position=-1)
51+
no_automask = traits.Bool(
52+
desc='consider input datasets as masks',
53+
argstr='-no_automask')
54+
quiet = traits.Bool(
55+
desc='be as quiet as possible (without being entirely mute)',
56+
argstr='-quiet')
57+
verb = traits.Bool(
58+
desc='print out some progress reports (to stderr)',
59+
argstr='-verb')
60+
61+
62+
class ABoverlap(AFNICommand):
63+
"""Output (to screen) is a count of various things about how
64+
the automasks of datasets A and B overlap or don't overlap.
65+
66+
For complete details, see the `3dABoverlap Documentation.
67+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dABoverlap.html>`_
68+
69+
Examples
70+
========
71+
72+
>>> from nipype.interfaces import afni
73+
>>> aboverlap = afni.ABoverlap()
74+
>>> aboverlap.inputs.in_file_a = 'functional.nii'
75+
>>> aboverlap.inputs.in_file_b = 'structural.nii'
76+
>>> aboverlap.inputs.out_file = 'out.mask_ae_overlap.txt'
77+
>>> aboverlap.cmdline # doctest: +ALLOW_UNICODE
78+
'3dABoverlap functional.nii structural.nii |& tee out.mask_ae_overlap.txt'
79+
>>> res = aboverlap.run() # doctest: +SKIP
80+
81+
"""
82+
83+
_cmd = '3dABoverlap'
84+
input_spec = ABoverlapInputSpec
85+
output_spec = AFNICommandOutputSpec
86+
3287

3388
class AFNItoNIFTIInputSpec(AFNICommandInputSpec):
3489
in_file = File(
@@ -646,6 +701,76 @@ class Copy(AFNICommand):
646701
input_spec = CopyInputSpec
647702
output_spec = AFNICommandOutputSpec
648703

704+
class DotInputSpec(AFNICommandInputSpec):
705+
in_files = traits.List(
706+
(File()),
707+
desc="list of input files, possibly with subbrick selectors",
708+
argstr="%s ...",
709+
position=-2)
710+
out_file = File(
711+
desc='collect output to a file',
712+
argstr=' |& tee %s',
713+
position=-1)
714+
mask = File(
715+
desc='Use this dataset as a mask',
716+
argstr='-mask %s')
717+
mrange = traits.Tuple((traits.Float(),traits.Float()),
718+
desc='Means to further restrict the voxels from \'mset\' so that'
719+
'only those mask values within this range (inclusive) willbe used.',
720+
argstr='-mrange %s %s')
721+
demean = traits.Bool(
722+
desc='Remove the mean from each volume prior to computing the correlation',
723+
argstr='-demean')
724+
docor = traits.Bool(
725+
desc='Return the correlation coefficient (default).',
726+
argstr='-docor')
727+
dodot = traits.Bool(
728+
desc='Return the dot product (unscaled).',
729+
argstr='-dodot')
730+
docoef = traits.Bool(
731+
desc='Return the least square fit coefficients {{a,b}} so that dset2 is approximately a + b*dset1',
732+
argstr='-docoef')
733+
dosums = traits.Bool(
734+
desc='Return the 6 numbers xbar=<x> ybar=<y> <(x-xbar)^2> <(y-ybar)^2> <(x-xbar)(y-ybar)> and the correlation coefficient.',
735+
argstr='-dosums')
736+
dodice = traits.Bool(
737+
desc='Return the Dice coefficient (the Sorensen-Dice index).',
738+
argstr='-dodice')
739+
doeta2 = traits.Bool(
740+
desc='Return eta-squared (Cohen, NeuroImage 2008).',
741+
argstr='-doeta2')
742+
full = traits.Bool(
743+
desc='Compute the whole matrix. A waste of time, but handy for parsing.',
744+
argstr='-full')
745+
show_labels = traits.Bool(
746+
desc='Print sub-brick labels to help identify what is being correlated. This option is useful when'
747+
'you have more than 2 sub-bricks at input.',
748+
argstr='-show_labels')
749+
upper = traits.Bool(
750+
desc='Compute upper triangular matrix',
751+
argstr='-upper')
752+
753+
class Dot(AFNICommand):
754+
"""Correlation coefficient between sub-brick pairs.
755+
All datasets in in_files list will be concatenated.
756+
You can use sub-brick selectors in the file specification.
757+
Note: This program is not efficient when more than two subbricks are input.
758+
For complete details, see the `3ddot Documentation.
759+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3ddot.html>`_
760+
761+
>>> from nipype.interfaces import afni
762+
>>> dot = afni.Dot()
763+
>>> dot.inputs.in_files = ['functional.nii[0]', 'structural.nii']
764+
>>> dot.inputs.dodice = True
765+
>>> dot.inputs.out_file = 'out.mask_ae_dice.txt'
766+
>>> dot.cmdline # doctest: +ALLOW_UNICODE
767+
'3dDot -dodice functional.nii[0] structural.nii |& tee out.mask_ae_dice.txt'
768+
>>> res = copy3d.run() # doctest: +SKIP
769+
770+
"""
771+
_cmd='3dDot'
772+
input_spec = DotInputSpec
773+
output_spec = AFNICommandOutputSpec
649774

650775
class Edge3InputSpec(AFNICommandInputSpec):
651776
in_file = File(

0 commit comments

Comments
 (0)