Skip to content

Commit 25f7490

Browse files
committed
Outline for AFNI 3dDeconvolve interface
Added outline of classes for AFNI's 3dDeconvolve (inputspec, outputspec, and command). Nothing is there yet, but it's something to build off of.
1 parent 94a11f0 commit 25f7490

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed

nipype/interfaces/afni/model.py

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# -*- coding: utf-8 -*-
2+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
3+
# vi: set ft = python sts = 4 ts = 4 sw = 4 et:
4+
"""AFNI modeling interfaces
5+
6+
Examples
7+
--------
8+
See the docstrings of the individual classes for examples.
9+
.. testsetup::
10+
# Change directory to provide relative paths for doctests
11+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
12+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
13+
>>> os.chdir(datadir)
14+
"""
15+
from __future__ import print_function, division, unicode_literals, absolute_import
16+
from builtins import str, bytes
17+
18+
import os
19+
import os.path as op
20+
import re
21+
import numpy as np
22+
23+
from ...utils.filemanip import (load_json, save_json, split_filename)
24+
from ..base import (
25+
CommandLineInputSpec, CommandLine, Directory, TraitedSpec,
26+
traits, isdefined, File, InputMultiPath, Undefined, Str)
27+
from ...external.due import BibTeX
28+
29+
from .base import (
30+
AFNICommandBase, AFNICommand, AFNICommandInputSpec, AFNICommandOutputSpec)
31+
32+
class DeconvolveInputSpec(AFNICommandInputSpec):
33+
in_files = InputMultiPath(
34+
File(
35+
exists=True),
36+
desc='fname = filename of 3D+time input dataset '
37+
' [more than one filename can be given] '
38+
' here, and these datasets will be] '
39+
' [auto-catenated in time; if you do this,] '
40+
' [\'-concat\' is not needed and is ignored.] '
41+
'** You can input a 1D time series file here, '
42+
' but the time axis should run along the '
43+
' ROW direction, not the COLUMN direction as '
44+
' in the -input1D option. You can automatically '
45+
' transpose a 1D file on input using the \\\' '
46+
' operator at the end of the filename, as in '
47+
' -input fred.1D\\\' '
48+
' * This is the only way to use 3dDeconvolve '
49+
' with a multi-column 1D time series file.',
50+
argstr='-input %s',
51+
mandatory=True,
52+
copyfile=False)
53+
mask = File(
54+
desc='filename of 3D mask dataset; '
55+
'Only data time series from within the mask '
56+
'will be analyzed; results for voxels outside '
57+
'the mask will be set to zero.',
58+
argstr='-mask %s',
59+
exists=True)
60+
automask = traits.Bool(
61+
usedefault=True,
62+
argstr='-automask',
63+
desc='Build a mask automatically from input data '
64+
'(will be slow for long time series datasets)')
65+
censor = File(
66+
desc=' cname = filename of censor .1D time series '
67+
'* This is a file of 1s and 0s, indicating which '
68+
' time points are to be included (1) and which are '
69+
' to be excluded (0). '
70+
'* Option \'-censor\' can only be used once!',
71+
argstr='-censor %s',
72+
exists=True)
73+
polort = traits.Int(
74+
desc='pnum = degree of polynomial corresponding to the '
75+
' null hypothesis [default: pnum = 1]',
76+
argstr='-polort %d')
77+
ortvec = traits.Tuple(
78+
File(
79+
desc='filename',
80+
exists=True),
81+
Str(
82+
desc='label'),
83+
desc='This option lets you input a rectangular array '
84+
'of 1 or more baseline vectors from file \'fff\', '
85+
'which will get the label \'lll\'. Functionally, '
86+
'it is the same as using \'-stim_file\' on each '
87+
'column of \'fff\' separately (plus \'-stim_base\'). '
88+
'This method is just a faster and simpler way to '
89+
'include a lot of baseline regressors in one step. ',
90+
argstr='ortvec %s')
91+
x1d = File(
92+
desc='save out X matrix',
93+
argstr='-x1D %s')
94+
x1d_stop = traits.Bool(
95+
desc='stop running after writing .xmat.1D file',
96+
argstr='-x1D_stop')
97+
bucket = File(
98+
desc='output statistics file',
99+
argstr='-bucket %s')
100+
jobs = traits.Int(
101+
desc='run the program with given number of sub-processes',
102+
argstr='-jobs %d')
103+
stim_times_subtract = traits.Float(
104+
desc='This option means to subtract \'SS\' seconds from each time '
105+
'encountered in any \'-stim_times*\' option. The purpose of this '
106+
'option is to make it simple to adjust timing files for the '
107+
'removal of images from the start of each imaging run.',
108+
argstr='-stim_times_subtract %f')
109+
num_stimts = traits.Int(
110+
desc='number of stimulus timing files',
111+
argstr='-num_stimts %d')
112+
num_glt = traits.Int(
113+
desc='number of general linear tests (i.e., contrasts)',
114+
argstr='-num_glt %d')
115+
global_times = traits.Bool(
116+
desc='use global timing for stimulus timing files',
117+
argstr='-global_times',
118+
xor=['local_times'])
119+
local_times = traits.Bool(
120+
desc='use local timing for stimulus timing files',
121+
argstr='-local_times',
122+
xor=['global_times'])
123+
fout = traits.Bool(
124+
desc='output F-statistic for each stimulus',
125+
argstr='-fout')
126+
rout = traits.Bool(
127+
desc='output the R^2 statistic for each stimulus',
128+
argstr='-rout')
129+
tout = traits.Bool(
130+
desc='output the T-statistic for each stimulus',
131+
argstr='-tout')
132+
vout = traits.Bool(
133+
desc='output the sample variance (MSE) for each stimulus',
134+
argstr='-vout')
135+
stim_times = traits.List(
136+
traits.Tuple(traits.Int(desc='k-th response model'),
137+
File(desc='stimulus timing file',exists=True),
138+
Str(desc='model')),
139+
desc='Generate the k-th response model from a set of stimulus times'
140+
' given in file \'tname\'.',
141+
argstr='-stim_times %d %s %s')
142+
stim_label = traits.List(
143+
traits.Tuple(traits.Int(desc='k-th input stimulus'),
144+
Str(desc='stimulus label')),
145+
desc='label for kth input stimulus',
146+
argstr='-stim_label %d %s',
147+
requires=['stim_times'])
148+
gltsym = traits.List(
149+
Str(desc='symbolic general linear test'),
150+
desc='general linear tests (i.e., contrasts) using symbolic '
151+
'conventions',
152+
argstr='-gltsym %s')
153+
glt_labels = traits.List(
154+
traits.Tuple(traits.Int(desc='k-th general linear test'),
155+
Str(desc='GLT label')),
156+
desc='general linear test (i.e., contrast) labels',
157+
argstr='-glt_label %d %s',
158+
requires=['glt_sym'])
159+
160+
161+
class DeconvolveOutputSpec(TraitedSpec):
162+
pass
163+
164+
165+
class Deconvolve(AFNICommand):
166+
"""Performs OLS regression given a 4D neuroimage file and stimulus timings
167+
168+
For complete details, see the `3dDeconvolve Documentation.
169+
<https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dDeconvolve.html>`_
170+
171+
Examples
172+
========
173+
174+
>>> from nipype.interfaces import afni
175+
>>> deconvolve = afni.Deconvolve()
176+
"""
177+
pass

0 commit comments

Comments
 (0)