Closed rob-luke closed 1 year ago
@agramfort and @larsoner I am a bit stumped about what to do here. Nilearn has removed the ability to use /
in design matrix columns. These columns represent experimental conditions and so I have previously just used the annotation name. However, annotation names commonly include /
in them. Any fresh ideas of how I can tackle this problem?
I will pin nilearn to previous version rather than main until I know how to fix this.
To me this seems like a bug / regression in nilearn. It's entirely possible they haven't considered spaces or /
or number-first names to be widespread use cases, but clearly they are at least for us. I would open an issue and see if it's possible for them to fix -- to me it seems like they should sanitize the strings when doing whatever processing they need to do, and then restore them afterward...
If they don't like this solution, it's what I'd probably implement at the MNE-NIRS end.
We now know that we can not use the /
symbol in the design matrix. So I will try and write some sort of sanitisation approach as suggested by larsoner and will use ___
to equal /
.
Whats the problem?
Nilearn recently changed the requirements for design matrix column names in https://github.com/nilearn/nilearn/pull/3025 which disallowed strings containing only numbers and strings with
/
as column names.Getting rid of the numbers is no problem, I prefer meaningful annotation names anyway.
However, I think its common in MNE to use names like
tapping/left
orresponse/right
. See https://mne.tools/dev/auto_tutorials/epochs/40_autogenerate_metadata.html?highlight=hed#keeping-only-the-first-events-of-a-groupBut nilearn now requires that the column names pass the following test:
See lines: https://github.com/nilearn/nilearn/blob/ab9c68e502c4b92695cd658f5839a8207fd5e07e/nilearn/glm/first_level/hemodynamic_models.py#L428-L436
Whats the fix?
This PR checks that our design matrix column names are compatible with nilearn, and if they are not then prepends a
t_
to force them to be valid.The problem
This PR also changes
/
to_
in each design matrix column name, but this is not then harmonious with the rest of MNE. Further, it means that in some places of my script I usetapping/left
and other places I will need to usetapping_left
. This solution doesn't seem great, what is a better alternative?