Skip to content
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

ENH: Enable orthogonalization in SPM models via SpecifyModel #2870

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
19 changes: 16 additions & 3 deletions nipype/algorithms/modelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,19 @@ class SpecifyModel(BaseInterface):
- amplitudes : lists of amplitudes for each event. This will be ignored by
SPM's Level1Design.

The following two (tmod, pmod) will be ignored by any Level1Design class
other than SPM:
The following three (tmod, pmod, orth) will be ignored by any Level1Design class other than SPM:

- tmod : lists of conditions that should be temporally modulated. Should
default to None if not being used.
- pmod : list of Bunch corresponding to conditions
- name : name of parametric modulator
- param : values of the modulator
- poly : degree of modulation
- orth : lists of instructions to orthogonolise parametric regressors or
not. Same as in SPM, use 'Yes' to indicate orthogonalisation, and 'No'
to explicitly prevent it. Use None for conditions where it is not being
used. Note that by default SPM will orthogonalise parametric regressors
in the order in which they are entered.
Copy link
Member

Choose a reason for hiding this comment

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

can we enable the option where order does not matter? this was the fix in spm12. it's not actually fine to create orthogonalization options where order is important.

Copy link
Member

Choose a reason for hiding this comment

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

it's possible this is the default, in which case the sentence above should be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

default == independent orthogonalization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I know in SPM12 order still matters bcs orthogonalisation is done with respect to regressors entered previously. SPM8 was doing orthogonalisation automatically and switching it off required a hacky solution, while SPM12 does it by default, but now you can instruct it not to do it. I know this type of orthogonalisation is not necessarily OK, here I am simply implementing this option to switch it off.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@gllmflndn - is there a way to enable this programmatically?


Alternatively, you can provide information through event files.

Expand Down Expand Up @@ -369,7 +373,7 @@ class SpecifyModel(BaseInterface):
None])
>>> evs_run3 = Bunch(conditions=['cond1', 'cond2'], onsets=[[20, 120], [80, 160]], \
durations=[[0], [0]], pmod=[Bunch(name=['amp'], poly=[2], param=[[1, 2]]), \
None])
None], orth=['No', None])
>>> s.inputs.subject_info = [evs_run2, evs_run3]

"""
Expand Down Expand Up @@ -414,6 +418,15 @@ def _generate_standard_design(self,
if hasattr(info, 'tmod') and info.tmod and \
len(info.tmod) > cid:
sessinfo[i]['cond'][cid]['tmod'] = info.tmod[cid]

if hasattr(info, 'orth') and info.orth and\
len(info.orth) > cid:
if info.orth[cid] == 'Yes':
sessinfo[i]['cond'][cid]['orth'] = 1
elif info.orth[cid] == 'No':
sessinfo[i]['cond'][cid]['orth'] = 0
hstojic marked this conversation as resolved.
Show resolved Hide resolved
elif info.orth[cid] is not None:
raise ValueError("Unknown orthogonalization option {0}. Must be one of 'Yes', 'No', or None.".format(info.orth[cid]))

if hasattr(info, 'pmod') and info.pmod and \
len(info.pmod) > cid:
Expand Down