Skip to content

Commit 57bc509

Browse files
committed
Creates nipype wrapper for the AFNI command 3dSynthesize
1 parent 2f422f0 commit 57bc509

File tree

2 files changed

+81
-1
lines changed

2 files changed

+81
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
Refit, Resample, TCat, TCatSubBrick, TStat, To3D, Unifize,
2727
Undump, ZCutUp, GCOR,
2828
Zcat, Zeropad)
29-
from .model import (Deconvolve, Remlfit)
29+
from .model import (Deconvolve, Remlfit, Synthesize)

nipype/interfaces/afni/model.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
154154
x1D_stop = traits.Bool(
155155
desc='stop running after writing .xmat.1D file',
156156
argstr='-x1D_stop')
157+
cbucket = traits.Str(
158+
desc='Name for dataset in which to save the regression '
159+
'coefficients (no statistics). This dataset '
160+
'will be used in a -xrestore run [not yet implemented] '
161+
'instead of the bucket dataset, if possible.',
162+
argstr='-cbucket %s')
157163
out_file = File(
158164
desc='output statistics file',
159165
argstr='-bucket %s')
@@ -231,6 +237,8 @@ class DeconvolveOutputSpec(TraitedSpec):
231237
desc='automatical generated script to run 3dREMLfit', exists=True)
232238
x1D = File(
233239
desc='save out X matrix', exists=True)
240+
cbucket = File(
241+
desc='output regression coefficients file (if generated)')
234242

235243

236244
class Deconvolve(AFNICommand):
@@ -588,3 +596,75 @@ def _list_outputs(self):
588596
outputs[key] = os.path.abspath(self.inputs.get()[key])
589597

590598
return outputs
599+
600+
601+
class SynthesizeInputSpec(AFNICommandInputSpec):
602+
cbucket = File(
603+
desc='Read the dataset output from '
604+
'3dDeconvolve via the \'-cbucket\' option.',
605+
argstr='-cbucket %s',
606+
copyfile=False,
607+
mandatory=True)
608+
matrix = File(
609+
desc='Read the matrix output from '
610+
'3dDeconvolve via the \'-x1D\' option.',
611+
argstr='-matrix %s',
612+
copyfile=False,
613+
mandatory=True)
614+
select = traits.List(
615+
Str(desc='selected columns to synthesize'),
616+
argstr='-select %s',
617+
desc='A list of selected columns from the matrix (and the '
618+
'corresponding coefficient sub-bricks from the '
619+
'cbucket). Valid types include \'baseline\', '
620+
' \'polort\', \'allfunc\', \'allstim\', \'all\', '
621+
'Can also provide \'something\' where something matches '
622+
'a stim_label from 3dDeconvolve, and \'digits\' where digits '
623+
'are the numbers of the select matrix columns by '
624+
'numbers (starting at 0), or number ranges of the form '
625+
'\'3..7\' and \'3-7\'.',
626+
mandatory=True)
627+
out_file = File(
628+
name_template='syn',
629+
desc='output dataset prefix name (default \'syn\')',
630+
argstr='-prefix %s')
631+
dry_run = traits.Bool(
632+
desc='Don\'t compute the output, just '
633+
'check the inputs.',
634+
argstr='-dry')
635+
TR = traits.Float(
636+
desc='TR to set in the output. The default value of '
637+
'TR is read from the header of the matrix file.',
638+
argstr='-TR %f')
639+
cenfill = traits.Enum(
640+
'zero','nbhr','none',
641+
argstr='-cenfill %s',
642+
desc='Determines how censored time points from the '
643+
'3dDeconvolve run will be filled. Valid types '
644+
'are \'zero\', \'nbhr\' and \'none\'.')
645+
646+
647+
class Synthesize(AFNICommand):
648+
"""Reads a '-cbucket' dataset and a '.xmat.1D' matrix from 3dDeconvolve,
649+
and synthesizes a fit dataset using user-selected sub-bricks and
650+
matrix columns.
651+
652+
For complete details, see the `3dSynthesize Documentation.
653+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dSynthesize.html>`_
654+
655+
Examples
656+
========
657+
658+
>>> from nipype.interfaces import afni
659+
>>> synthesize = afni.Synthesize()
660+
>>> synthesize.inputs.cbucket = 'functional.nii'
661+
>>> synthesize.inputs.matrix = 'output.1D'
662+
>>> synthesize.inputs.select = ['baseline']
663+
>>> synthesize.cmdline # doctest: +ALLOW_UNICODE
664+
'3dSynthesize -cbucket functional.nii -matrix output.1D -select baseline'
665+
>>> syn = synthesize.run() # doctest: +SKIP
666+
"""
667+
668+
_cmd = '3dSynthesize'
669+
input_spec = SynthesizeInputSpec
670+
output_spec = AFNICommandOutputSpec

0 commit comments

Comments
 (0)