Skip to content

added support for orthogonalization #1774

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 1 commit into from
Jan 6, 2017
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
20 changes: 17 additions & 3 deletions nipype/interfaces/fsl/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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:
Expand All @@ -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
"""
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions nipype/interfaces/fsl/tests/test_Level1Design_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/script_templates/feat_ev_ortho.tcl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Orthogonalise EV $c0 wrt EV $c1
set fmri(ortho$c0.$c1) 0
set fmri(ortho$c0.$c1) $orthogonal