diff --git a/CHANGES b/CHANGES index b02e7f2b28..333b5e777a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ Release 0.12.0-rc1 (April 20, 2016) ============ +* FIX: Selecting "gamma" in FSL Level1Design now does what the name says (https://github.com/nipy/nipype/pull/1500) * ENH: Added grad_dev input to fsl.dti.bedpostx5 interface(https://github.com/nipy/nipype/pull/1493) * ENH: ResourceMultiProc plugin to support resource allocation (https://github.com/nipy/nipype/pull/1372) * ENH: Added dcm2niix interface (https://github.com/nipy/nipype/pull/1435) diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index 3d07fa21de..be07bf0df7 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -124,8 +124,8 @@ def _create_ev_file(self, evfname, evinfo): f.close() def _create_ev_files( - self, cwd, runinfo, runidx, usetd, contrasts, no_bases, - do_tempfilter): + self, cwd, runinfo, runidx, usetd, contrasts, + do_tempfilter, basis_key): """Creates EV files from condition and regressor information. Parameters: @@ -144,7 +144,9 @@ def _create_ev_files( """ conds = {} evname = [] - ev_hrf = load_template('feat_ev_hrf.tcl') + if basis_key == "dgamma": + basis_key = "hrf" + ev_template = load_template('feat_ev_'+basis_key+'.tcl') ev_none = load_template('feat_ev_none.tcl') ev_ortho = load_template('feat_ev_ortho.tcl') ev_txt = '' @@ -174,13 +176,13 @@ def _create_ev_files( evinfo.insert(j, [onset, cond['duration'][j], amp]) else: evinfo.insert(j, [onset, cond['duration'][0], amp]) - if no_bases: - ev_txt += ev_none.substitute(ev_num=num_evs[0], + if basis_key == "none": + ev_txt += ev_template.substitute(ev_num=num_evs[0], ev_name=name, tempfilt_yn=do_tempfilter, cond_file=evfname) else: - ev_txt += ev_hrf.substitute(ev_num=num_evs[0], + ev_txt += ev_template.substitute(ev_num=num_evs[0], ev_name=name, tempfilt_yn=do_tempfilter, temporalderiv=usetd, @@ -296,12 +298,9 @@ def _run_interface(self, runtime): if isdefined(self.inputs.model_serial_correlations): prewhiten = int(self.inputs.model_serial_correlations) usetd = 0 - no_bases = False basis_key = list(self.inputs.bases.keys())[0] if basis_key in ['dgamma', 'gamma']: usetd = int(self.inputs.bases[basis_key]['derivs']) - if basis_key == 'none': - no_bases = True session_info = self._format_session_info(self.inputs.session_info) func_files = self._get_func_files(session_info) n_tcon = 0 @@ -319,7 +318,7 @@ def _run_interface(self, runtime): do_tempfilter = 0 num_evs, cond_txt = self._create_ev_files(cwd, info, i, usetd, self.inputs.contrasts, - no_bases, do_tempfilter) + do_tempfilter, basis_key) nim = load(func_files[i]) (_, _, _, timepoints) = nim.shape fsf_txt = fsf_header.substitute(run_num=i, diff --git a/nipype/interfaces/fsl/tests/test_Level1Design.py b/nipype/interfaces/fsl/tests/test_Level1Design.py new file mode 100644 index 0000000000..89e77fdca0 --- /dev/null +++ b/nipype/interfaces/fsl/tests/test_Level1Design.py @@ -0,0 +1,20 @@ +import os +from nose.tools import assert_true +from ...base import Undefined +from ..model import Level1Design + +def test_level1design(): + l = Level1Design() + runinfo = dict(cond=[{'name': 'test_condition', 'onset': [0, 10], 'duration':[10, 10]}],regress=[]) + runidx = 0 + contrasts = Undefined + usetd = False + do_tempfilter = False + output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"hrf") + yield assert_true, "set fmri(convolve1) 3" in output_txt + output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"dgamma") + yield assert_true, "set fmri(convolve1) 3" in output_txt + output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"gamma") + yield assert_true, "set fmri(convolve1) 2" in output_txt + output_num, output_txt = Level1Design._create_ev_files(l,os.getcwd(),runinfo,runidx,usetd,contrasts,do_tempfilter,"none") + yield assert_true, "set fmri(convolve1) 0" in output_txt