You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Coordinate Frames of Montage Converted from Unknown to Head Automatically? #7691
When I pass in a montage with `coord_frame = 'unknown'', and check the actual montage, it is all of a sudden in the head coordinate. I believe it is due to this line:
mne-python/mne/channels/montage.py:664
mnt_head = _get_montage_in_head(montage)
Inside function: mne.channels.montage._set_montage. As a result, raw.set_montage(montage) now has all coordinate frames in head frame.
To me dig does not require all points in head coords, correct.
ch['loc'] we could in principle even relax because there is ch['coord_frame'], but it would require a lot of careful changes to get right (e.g., in forward calculation).
Hmm seems that the transformation would definitely impact EEG and MEG. Is it possible to at least as a simple fix, add a flag transform_head = True or something to just allow iEEG data setting montage to get rid of this transformation?
To me dig does *not* require all points in head coords, correct.
ch['loc'] we could in principle even relax because there is
ch['coord_frame'], but it would require a lot of careful changes to get
right (e.g., in forward calculation).
i feel we should consider this as currenlty sEEG/ECoG folks will read in MRI
fake it head and than silently use trans Head<->MRI as Identity to get it
to work.
thoughts?
could we allow ch['loc'] to be not 'head' based on the channel type? Because there is no forward calculation to be done for ECoG data (yet) in MNE. Then you avoid complexity and only check this when setting.
i feel we should consider this as currenlty sEEG/ECoG folks will read in MRI fake it head and than silently use trans Head<->MRI as Identity to get it to work.
The question in my mind is, what should these people see for example with a topomap plot? Do we allow them to be silently in MRI coords when they do their plot? It breaks the uniformity of our topomap transformation, which might be worth it but we need to consider it.
Because there is no forward calculation to be done for ECoG data (yet) in MNE. Then you avoid complexity and only check this when setting.
If you're going to allow non-head for some sensor types (sEEG, ECoG), it's unclear why you wouldn't allow it in general, e.g., for EEG electrodes. Then you need to decide how to handle those cases in forward calculation (which IIRC is always done in head coords).
And unfortunately it's more than just the forward we need to consider. Any function that plots sensor locations or uses sensor locations needs to be checked that things are in the correct coordinate frame or that we aren't (still) implicitly assuming a head coordinate frame. So at a minimum the big things I foresee being problems are:
plot_alignment -- need to be more careful about coordinate frames (actually easiest to fix)
topomap -- do we allow non-head coords? do we use the same transformation we do for head? do will still draw a head outline?
forward -- do we allow computing in the MRI frame?
DigMontage -- do we still require fiducials and/or being in the head coordinate frame, or do we allow people to work with FIFFV_COORD_UNKNOWN for EEG?
If you're going to allow non-head for some sensor types (sEEG, ECoG), it's unclear why you wouldn't allow it in general, e.g., for EEG electrodes.
I am not an intracranial expert but I think it's not kosher in the sEEG/ECoG world to deal with a head space. You have a CT scan with the device coordinates and you transform them to MRI coordinates by aligning with the anatomical MRI so that everything is in MR coordinates.
I agree that supporting a full pipeline for ECoG is going to be challenging. I understood that we needed this only for MNE-BIDS to be able to help convert existing data to BIDS format @agramfort@adam2392 ?
You have a CT scan with the device coordinates and you transform them to MRI coordinates by aligning with the anatomical MRI so that everything is in MR coordinates.
Something similar can happen with EEG+fMRI, so I think we have to think more broadly than special-casing sEEG and ECoG
If you're going to allow non-head for some sensor types (sEEG, ECoG), it's unclear why you wouldn't allow it in general, e.g., for EEG electrodes.
I am not an intracranial expert but I think it's not kosher in the sEEG/ECoG world to deal with a head space. You have a CT scan with the device coordinates and you transform them to MRI coordinates by aligning with the anatomical MRI so that everything is in MR coordinates.
I agree that supporting a full pipeline for ECoG is going to be challenging. I understood that we needed this only for MNE-BIDS to be able to help convert existing data to BIDS format @agramfort@adam2392 ?
Idk what a full pipeline would look like for ECoG/SEEG in mne, but honestly, I'm okay with just coordinate frame support when set_montage is called. Transforming to head seems weird to me. Just having a unified data structure that doesn't get arbitrarily modified/transformed would be a good start. E.g. you create a digMontage from coordinates and you know its in a specific T1 MRI coordinate system, then I think your downstream analysis can happen outside of mne (for now?)
Because of that, to maintain backwards compatibility, why can't we just add a transform_to_head=True parameter to set_montage? This then lets iEEG users just turn it off and stick w/ the mne supported "ras", "mri", "mri_voxel", "fs_tal", "mni_tal" coord systems. If iEEG users want to use the above supported pipelines to do some visualizations, just document that currently you need to "transform_to_head"?
Activity
adam2392 commentedon Apr 28, 2020
Actually for that matter, I'm also having a really hard time making the montages agree after
set_montageandget_montagein this PR: #7667I believe the only change is this
_get_montage_in_head()transformation that is applied.hoechenberger commentedon Apr 29, 2020
Hey @adam2392, this can make your life easier:
https://help.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet
Also you can get syntax highlighting in code blocks if you start them with
"```python" :)
agramfort commentedon Apr 29, 2020
larsoner commentedon Apr 29, 2020
To me dig does not require all points in head coords, correct.
ch['loc']we could in principle even relax because there isch['coord_frame'], but it would require a lot of careful changes to get right (e.g., in forward calculation).adam2392 commentedon Apr 29, 2020
Hmm seems that the transformation would definitely impact EEG and MEG. Is it possible to at least as a simple fix, add a flag
transform_head = Trueor something to just allow iEEG data setting montage to get rid of this transformation?agramfort commentedon Apr 29, 2020
jasmainak commentedon Apr 29, 2020
could we allow
ch['loc']to be not'head'based on the channel type? Because there is no forward calculation to be done for ECoG data (yet) in MNE. Then you avoid complexity and only check this when setting.larsoner commentedon Apr 30, 2020
The question in my mind is, what should these people see for example with a topomap plot? Do we allow them to be silently in MRI coords when they do their plot? It breaks the uniformity of our topomap transformation, which might be worth it but we need to consider it.
If you're going to allow non-head for some sensor types (sEEG, ECoG), it's unclear why you wouldn't allow it in general, e.g., for EEG electrodes. Then you need to decide how to handle those cases in forward calculation (which IIRC is always done in head coords).
And unfortunately it's more than just the forward we need to consider. Any function that plots sensor locations or uses sensor locations needs to be checked that things are in the correct coordinate frame or that we aren't (still) implicitly assuming a head coordinate frame. So at a minimum the big things I foresee being problems are:
plot_alignment-- need to be more careful about coordinate frames (actually easiest to fix)topomap-- do we allow non-head coords? do we use the same transformation we do for head? do will still draw a head outline?forward-- do we allow computing in the MRI frame?DigMontage-- do we still require fiducials and/or being in the head coordinate frame, or do we allow people to work withFIFFV_COORD_UNKNOWNfor EEG?jasmainak commentedon Apr 30, 2020
I am not an intracranial expert but I think it's not kosher in the sEEG/ECoG world to deal with a head space. You have a CT scan with the device coordinates and you transform them to MRI coordinates by aligning with the anatomical MRI so that everything is in MR coordinates.
I agree that supporting a full pipeline for ECoG is going to be challenging. I understood that we needed this only for MNE-BIDS to be able to help convert existing data to BIDS format @agramfort @adam2392 ?
larsoner commentedon Apr 30, 2020
Something similar can happen with EEG+fMRI, so I think we have to think more broadly than special-casing sEEG and ECoG
adam2392 commentedon Apr 30, 2020
Idk what a full pipeline would look like for ECoG/SEEG in mne, but honestly, I'm okay with just coordinate frame support when
set_montageis called. Transforming to head seems weird to me. Just having a unified data structure that doesn't get arbitrarily modified/transformed would be a good start. E.g. you create a digMontage from coordinates and you know its in a specific T1 MRI coordinate system, then I think your downstream analysis can happen outside of mne (for now?)Because of that, to maintain backwards compatibility, why can't we just add a
transform_to_head=Trueparameter toset_montage? This then lets iEEG users just turn it off and stick w/ the mne supported "ras", "mri", "mri_voxel", "fs_tal", "mni_tal" coord systems. If iEEG users want to use the above supported pipelines to do some visualizations, just document that currently you need to "transform_to_head"?larsoner commentedon Oct 1, 2023
I think we have addressed this in MNE-BIDS and MNE-Python but @adam2392 feel free to reopen if I'm mistaken