Skip to content

Commit 3abf131

Browse files
authored
Merge pull request #1500 from TheChymera/ld
fixed fsl.Level1Design gamma convoluion
2 parents b830827 + f75efb6 commit 3abf131

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Release 0.12.0-rc1 (April 20, 2016)
22
============
33

4+
* FIX: Selecting "gamma" in FSL Level1Design now does what the name says (https://github.com/nipy/nipype/pull/1500)
45
* ENH: Added grad_dev input to fsl.dti.bedpostx5 interface(https://github.com/nipy/nipype/pull/1493)
56
* ENH: ResourceMultiProc plugin to support resource allocation (https://github.com/nipy/nipype/pull/1372)
67
* ENH: Added dcm2niix interface (https://github.com/nipy/nipype/pull/1435)

nipype/interfaces/fsl/model.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def _create_ev_file(self, evfname, evinfo):
124124
f.close()
125125

126126
def _create_ev_files(
127-
self, cwd, runinfo, runidx, usetd, contrasts, no_bases,
128-
do_tempfilter):
127+
self, cwd, runinfo, runidx, usetd, contrasts,
128+
do_tempfilter, basis_key):
129129
"""Creates EV files from condition and regressor information.
130130
131131
Parameters:
@@ -144,7 +144,9 @@ def _create_ev_files(
144144
"""
145145
conds = {}
146146
evname = []
147-
ev_hrf = load_template('feat_ev_hrf.tcl')
147+
if basis_key == "dgamma":
148+
basis_key = "hrf"
149+
ev_template = load_template('feat_ev_'+basis_key+'.tcl')
148150
ev_none = load_template('feat_ev_none.tcl')
149151
ev_ortho = load_template('feat_ev_ortho.tcl')
150152
ev_txt = ''
@@ -174,13 +176,13 @@ def _create_ev_files(
174176
evinfo.insert(j, [onset, cond['duration'][j], amp])
175177
else:
176178
evinfo.insert(j, [onset, cond['duration'][0], amp])
177-
if no_bases:
178-
ev_txt += ev_none.substitute(ev_num=num_evs[0],
179+
if basis_key == "none":
180+
ev_txt += ev_template.substitute(ev_num=num_evs[0],
179181
ev_name=name,
180182
tempfilt_yn=do_tempfilter,
181183
cond_file=evfname)
182184
else:
183-
ev_txt += ev_hrf.substitute(ev_num=num_evs[0],
185+
ev_txt += ev_template.substitute(ev_num=num_evs[0],
184186
ev_name=name,
185187
tempfilt_yn=do_tempfilter,
186188
temporalderiv=usetd,
@@ -296,12 +298,9 @@ def _run_interface(self, runtime):
296298
if isdefined(self.inputs.model_serial_correlations):
297299
prewhiten = int(self.inputs.model_serial_correlations)
298300
usetd = 0
299-
no_bases = False
300301
basis_key = list(self.inputs.bases.keys())[0]
301302
if basis_key in ['dgamma', 'gamma']:
302303
usetd = int(self.inputs.bases[basis_key]['derivs'])
303-
if basis_key == 'none':
304-
no_bases = True
305304
session_info = self._format_session_info(self.inputs.session_info)
306305
func_files = self._get_func_files(session_info)
307306
n_tcon = 0
@@ -319,7 +318,7 @@ def _run_interface(self, runtime):
319318
do_tempfilter = 0
320319
num_evs, cond_txt = self._create_ev_files(cwd, info, i, usetd,
321320
self.inputs.contrasts,
322-
no_bases, do_tempfilter)
321+
do_tempfilter, basis_key)
323322
nim = load(func_files[i])
324323
(_, _, _, timepoints) = nim.shape
325324
fsf_txt = fsf_header.substitute(run_num=i,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
from nose.tools import assert_true
3+
from ...base import Undefined
4+
from ..model import Level1Design
5+
6+
def test_level1design():
7+
l = Level1Design()
8+
runinfo = dict(cond=[{'name': 'test_condition', 'onset': [0, 10], 'duration':[10, 10]}],regress=[])
9+
runidx = 0
10+
contrasts = Undefined
11+
usetd = False
12+
do_tempfilter = False
13+
output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"hrf")
14+
yield assert_true, "set fmri(convolve1) 3" in output_txt
15+
output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"dgamma")
16+
yield assert_true, "set fmri(convolve1) 3" in output_txt
17+
output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"gamma")
18+
yield assert_true, "set fmri(convolve1) 2" in output_txt
19+
output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"none")
20+
yield assert_true, "set fmri(convolve1) 0" in output_txt

0 commit comments

Comments
 (0)