-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
BUG: Add estimated fiducials when missing / assumed head coords #11212
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
Conversation
|
any chance to add a test ? 🙏 |
|
@sappelhoff I see you have only modified the CNT reader here. In #11146 I messed with tests for at least curry, fieldtrip, and CNT. More importantly, though, I changed What should the consistency be? Ideally I guess that the Then the question is, how many other readers would this break, and should we also have them set to UNKNOWN in some cases... Then another question -- probably for another PR -- is: are we then consistent between the coord frame we say in Sorry for making this more complicated than it initially seemed, but hopefully this helps continue moving us toward being consistent with all this stuff across all reader! |
|
@sappelhoff I think this is the last blocker for 1.2 release. Do you think you can get to it in the next few days? If not, I can push some commits |
|
I was already afraid that it wouldn't be this simple 😉 My only expertise with this PR was that:
Having that said, I agree that we should work on a more complete fix.
Yes that sounds right to me! Except maybe for data formats that are guaranteed to ship electrode positions in "head" format (but nothing apart from BrainVision comes to mind). The coord system should be "unknown" otherwise.
I am not so clear about the distinction, and why there even needs to be one -- where should I read up on this?
Unfortunately I can't -- I'll be on vacation starting next Sunday and need to wrap up some work things as well. But I can probably read comments and reply ... just not really dig into and write code (not before October 10th) |
Not sure we have proper docs on it. But the TL;DR is that we store electrode information in two places: Moreover, historically the FIF format only allowed EEG points to have the |
* upstream/main: Don't insert superfluous newlines in subprocess log messages (mne-tools#11219) purge _get_args helper func (mne-tools#11215) Standardize topomap args (mne-tools#11123) MAINT: Ensure no datasets are downloaded in tests (mne-tools#11213)
|
@agramfort @sappelhoff this keeps getting slightly more and more hacky, I had to work around this: This is because in this PR, the This all only really matters in the case where we are setting a montage (or equivalently, reading ch pos in a reader) in the UNKNOWN frame that does not have fiducials. I think I managed to convince myself that a better solution in this case is to insert synthetic fiducials when "converting" to the head coordinate frame. Compared to the current approach:
In the long run, a solution where we do this synthetic insertion, then allow/improve the |
to this point, we could fit them to a spheroid (revolved ellipse) instead of a sphere. But allowing people to adjust the fiducials later may be enough / better. |
|
Yeah we could -- but I think the simpler the better here |
|
I agree with @larsoner's proposal, the backward compatibility and the part below convinced me specifically:
If this fixes our current issues and makes problems more obvious to fix in the future, while not changing behavior, I am fine with it! Thanks! |
|
Okay, proposal implemented. Ready for review/merge from my end |
| # These should now be estimated from the data | ||
| # TODO: This is in meters... so clearly wrong. (The estimation is | ||
| # not the problem, the dig are all off like this.) | ||
| assert_allclose(pos['nasion'], [0, 9.97, 0], atol=1e-4) | ||
| assert_allclose(pos['lpa'], -pos['nasion'][[1, 0, 0]]) | ||
| assert_allclose(pos['rpa'], pos['nasion'][[1, 0, 0]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will open a new issue for this once this PR is merged
agramfort
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth running circle full to make sure the examples look good? I am thinking about our tutorials using EEG template MRI.
| return | ||
| # These should now be estimated from the data | ||
| # TODO: This is in meters... so clearly wrong. (The estimation is | ||
| # not the problem, the dig are all off like this.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a file in testing should be fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea if the test file is broken or our reading of it. The associated test appears to be written by @agramfort so maybe they'll be able to figure it out most quickly :)
Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org>
|
Thanks a lot @larsoner |
* upstream/main: (64 commits) MAINT: Better check (mne-tools#11229) MAINT: Fix link and update instantiation note (mne-tools#11228) BUG: Add estimated fiducials when missing / assumed head coords (mne-tools#11212) Fix tfr db (mne-tools#11223) MAINT: Update link (mne-tools#11222) add CPGRL doc section (mne-tools#11216) Don't insert superfluous newlines in subprocess log messages (mne-tools#11219) purge _get_args helper func (mne-tools#11215) Standardize topomap args (mne-tools#11123) MAINT: Ensure no datasets are downloaded in tests (mne-tools#11213) MAINT: Fix Cirrus caching (mne-tools#11211) Fix mesh display in tutorial (mne-tools#11200) MAINT: Add arm64 CI using CirrusCI (mne-tools#11209) Fix spatial colors (mne-tools#11201) MAINT: Fix CircleCI error (mne-tools#11205) [circle deploy] Add regression-based approach to removing EOG artifacts (mne-tools#11046) [DOC, MRG] Minor documentation improvements and remove glossary entry for array-like (mne-tools#11207) Fix `include_tmax` not considered in `mne.io.Raw.crop` to check `tmax` in bounds (mne-tools#11204) MAINT: Fix notebook backend (mne-tools#11206) MRG: Fix displayed Raw duration in Jupyter notebook (mne-tools#11203) ...
I'd argue that the electrode positions as read from the Neuroscan CNT file header are in unknown space, see also the warning here: https://mne.tools/dev/auto_tutorials/io/20_reading_eeg_data.html#import-cnt
In the reader code, I see no indication of "sphere projection" and even if there was one, then we wouldn't know that the sphere corresponds to the "head" coord system.
follow up to:
fixes issue identified in mne-tools/mne-bids#1066 (comment)
Needed for mne-bids, would be nice to have in 1.2 release
CI issues seem unrelated
cc @larsoner