Skip to content

Commit ab39971

Browse files
authored
Merge pull request #4 from rmarkello/afni_deconvolve
Afni deconvolve
2 parents 7f15322 + f3839ae commit ab39971

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
Eval, FWHMx,
2222
MaskTool, Merge, Notes, Refit, Resample, TCat, TStat, To3D,
2323
Unifize, ZCutUp, GCOR,)
24+
from .model import(Deconvolve)

nipype/interfaces/afni/model.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
4949
' with a multi-column 1D time series file.',
5050
argstr='-input %s',
5151
mandatory=True,
52-
copyfile=False)
52+
copyfile=False,
53+
sep=" ")
5354
mask = File(
5455
desc='filename of 3D mask dataset; '
5556
'Only data time series from within the mask '
@@ -88,13 +89,13 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
8889
'This method is just a faster and simpler way to '
8990
'include a lot of baseline regressors in one step. ',
9091
argstr='ortvec %s')
91-
x1d = File(
92+
x1D = File(
9293
desc='save out X matrix',
9394
argstr='-x1D %s')
94-
x1d_stop = traits.Bool(
95+
x1D_stop = traits.Bool(
9596
desc='stop running after writing .xmat.1D file',
9697
argstr='-x1D_stop')
97-
bucket = File(
98+
out_file = File(
9899
desc='output statistics file',
99100
argstr='-bucket %s')
100101
jobs = traits.Int(
@@ -138,24 +139,24 @@ class DeconvolveInputSpec(AFNICommandInputSpec):
138139
Str(desc='model')),
139140
desc='Generate the k-th response model from a set of stimulus times'
140141
' given in file \'tname\'.',
141-
argstr='-stim_times %d %s %s')
142+
argstr='-stim_times %d %s %s...')
142143
stim_label = traits.List(
143144
traits.Tuple(traits.Int(desc='k-th input stimulus'),
144145
Str(desc='stimulus label')),
145146
desc='label for kth input stimulus',
146-
argstr='-stim_label %d %s',
147+
argstr='-stim_label %d %s...',
147148
requires=['stim_times'])
148149
gltsym = traits.List(
149150
Str(desc='symbolic general linear test'),
150151
desc='general linear tests (i.e., contrasts) using symbolic '
151152
'conventions',
152-
argstr='-gltsym %s')
153+
argstr='-gltsym %s...')
153154
glt_labels = traits.List(
154155
traits.Tuple(traits.Int(desc='k-th general linear test'),
155156
Str(desc='GLT label')),
156157
desc='general linear test (i.e., contrast) labels',
157-
argstr='-glt_label %d %s',
158-
requires=['glt_sym'])
158+
argstr='-glt_label %d %s...',
159+
requires=['gltsym'])
159160

160161

161162
class Deconvolve(AFNICommand):
@@ -169,20 +170,29 @@ class Deconvolve(AFNICommand):
169170
170171
>>> from nipype.interfaces import afni
171172
>>> deconvolve = afni.Deconvolve()
172-
>>> deconvolve.inputs.in_file = 'functional.nii'
173-
>>> deconvolve.inputs.bucket = 'output.nii'
173+
>>> deconvolve.inputs.in_files = ['functional.nii', 'functional2.nii']
174+
>>> deconvolve.inputs.out_file = 'output.nii'
174175
>>> deconvolve.inputs.x1D = 'output.1D'
175-
>>> stim_times = [(1, 'stims1.txt', 'SPMG1(4)'), (2, 'stims2.txt', 'SPMG2(4)')]
176+
>>> stim_times = [(1, 'timeseries.txt', 'SPMG1(4)'), (2, 'timeseries.txt', 'SPMG2(4)')]
176177
>>> deconvolve.inputs.stim_times = stim_times
177178
>>> deconvolve.cmdline # doctest: +ALLOW_UNICODE
178-
'3dDeconvolve -input functional.nii -bucket output.nii -x1D output -stim_times 1 stims1.txt SPMG1(4) 2 stims2.txt SPMG2(4)'
179+
'3dDeconvolve -input functional.nii functional2.nii -num_stimts 2 -bucket output.nii -stim_times 1 timeseries.txt SPMG1(4) -stim_times 2 timeseries.txt SPMG2(4) -x1D output.1D'
179180
>>> res = deconvolve.run() # doctest: +SKIP
180181
"""
181182

182183
_cmd = '3dDeconvolve'
183184
input_spec = DeconvolveInputSpec
184185
output_spec = AFNICommandOutputSpec
185186

187+
def _parse_inputs(self, skip=None):
188+
if skip is None:
189+
skip = []
190+
if len(self.inputs.stim_times) and not isdefined(self.inputs.num_stimts):
191+
self.inputs.num_stimts = len(self.inputs.stim_times)
192+
if len(self.inputs.gltsym) and not isdefined(self.inputs.num_glt):
193+
self.inputs.num_glt = len(self.inputs.gltsym)
194+
return super(Deconvolve, self)._parse_inputs(skip)
195+
186196
def _list_outputs(self):
187197
outputs = self.output_spec().get()
188198
if isdefined(self.inputs.x1D):
@@ -191,23 +201,5 @@ def _list_outputs(self):
191201
else:
192202
outputs['x1D'] = self.inputs.x1D
193203

194-
outputs['bucket'] = self.inputs.bucket
204+
outputs['out_file'] = self.inputs.out_file
195205
return outputs
196-
197-
def _format_arg(self, name, trait_spec, value):
198-
"""
199-
Argument num_glt is defined automatically from the number of contrasts
200-
desired (defined by the length of glt_sym). No effort has been made to
201-
make this compatible with glt.
202-
"""
203-
if name in ['stim_times', 'stim_labels']:
204-
arg = ''
205-
for st in value:
206-
arg += trait_spec.argstr % value
207-
arg = arg.rstrip()
208-
return arg
209-
210-
if name == 'stim_times':
211-
self.inputs.num_stimts = len(value)
212-
elif name == 'glt_sym':
213-
self.inputs.num_glt = len(value)

0 commit comments

Comments
 (0)