Skip to content

fixed fsl.Level1Design gamma convoluion #1500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 9 additions & 10 deletions nipype/interfaces/fsl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ev_none is still needed for the regressors

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 = ''
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions nipype/interfaces/fsl/tests/test_Level1Design.py
Original file line number Diff line number Diff line change
@@ -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