diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py index c7241feb7b..5ede5fa1f8 100644 --- a/nipype/interfaces/fsl/model.py +++ b/nipype/interfaces/fsl/model.py @@ -47,6 +47,13 @@ class Level1DesignInputSpec(BaseInterfaceInputSpec): mandatory=True, desc=("name of basis function and options e.g., " "{'dgamma': {'derivs': True}}")) + orthogonalization = traits.Dict(traits.Int, traits.Dict(traits.Int, + traits.Either(traits.Bool,traits.Int)), + mandatory=False, + desc=("which regressors to make orthogonal e.g., " + "{1: {0:0,1:0,2:0}, 2: {0:1,1:1,2:0}} to make the second " + "regressor in a 2-regressor model orthogonal to the first."), + default={}) model_serial_correlations = traits.Bool( desc="Option to model serial correlations using an \ autoregressive estimator (order 1). Setting this option is only \ @@ -123,8 +130,8 @@ def _create_ev_file(self, evfname, evinfo): f.close() def _create_ev_files( - self, cwd, runinfo, runidx, ev_parameters, contrasts, - do_tempfilter, basis_key): + self, cwd, runinfo, runidx, ev_parameters, orthogonalization, + contrasts, do_tempfilter, basis_key): """Creates EV files from condition and regressor information. Parameters: @@ -138,6 +145,8 @@ def _create_ev_files( ev_parameters : dict A dictionary containing the model parameters for the given design type. + orthogonalization : dict + A dictionary of dictionaries specifying orthogonal EVs. contrasts : list of lists Information on contrasts to be evaluated """ @@ -208,7 +217,11 @@ def _create_ev_files( # add ev orthogonalization for i in range(1, num_evs[0] + 1): for j in range(0, num_evs[0] + 1): - ev_txt += ev_ortho.substitute(c0=i, c1=j) + try: + orthogonal = int(orthogonalization[i][j]) + except (KeyError, TypeError, ValueError, IndexError): + orthogonal = 0 + ev_txt += ev_ortho.substitute(c0=i, c1=j, orthogonal=orthogonal) ev_txt += "\n" # add contrast info to fsf file if isdefined(contrasts): @@ -321,6 +334,7 @@ def _run_interface(self, runtime): if info['hpf'] == np.inf: do_tempfilter = 0 num_evs, cond_txt = self._create_ev_files(cwd, info, i, ev_parameters, + self.inputs.orthogonalization, self.inputs.contrasts, do_tempfilter, basis_key) nim = load(func_files[i]) diff --git a/nipype/interfaces/fsl/tests/test_Level1Design_functions.py b/nipype/interfaces/fsl/tests/test_Level1Design_functions.py index 1c5dc26032..d8f48942bc 100644 --- a/nipype/interfaces/fsl/tests/test_Level1Design_functions.py +++ b/nipype/interfaces/fsl/tests/test_Level1Design_functions.py @@ -11,11 +11,13 @@ def test_level1design(): runidx = 0 contrasts = Undefined do_tempfilter = False + orthogonalization = {} ev_parameters = {"temporalderiv":False} for key, val in [('hrf', 3), ('dgamma', 3), ('gamma', 2), ('none', 0)]: output_num, output_txt = Level1Design._create_ev_files(l, os.getcwd(), runinfo, runidx, ev_parameters, + orthogonalization, contrasts, do_tempfilter, key) diff --git a/nipype/interfaces/script_templates/feat_ev_ortho.tcl b/nipype/interfaces/script_templates/feat_ev_ortho.tcl index 8198c49657..f2b0912cdb 100644 --- a/nipype/interfaces/script_templates/feat_ev_ortho.tcl +++ b/nipype/interfaces/script_templates/feat_ev_ortho.tcl @@ -1,2 +1,2 @@ # Orthogonalise EV $c0 wrt EV $c1 -set fmri(ortho$c0.$c1) 0 +set fmri(ortho$c0.$c1) $orthogonal