-
Notifications
You must be signed in to change notification settings - Fork 92
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
[BUG, MRG] Fix coordinate frames #982
Conversation
Codecov Report
@@ Coverage Diff @@
## main #982 +/- ##
=======================================
Coverage 94.99% 95.00%
=======================================
Files 25 25
Lines 3678 3665 -13
=======================================
- Hits 3494 3482 -12
+ Misses 184 183 -1
Continue to review full report at Codecov.
|
Ok, everything should pass and that's all I wanted to change. I just added an error for consistency where previously there would have been a cryptic empty dictionary error if there were not meg landmarks in the |
# MNE-Python, if written with :func:`mne_bids.write_raw_bids`, must have | ||
# an :attr:`mne_bids.BIDSPath.space` specified, and will be read in with | ||
# the montage channel locations set to the coordinate frame 'unknown'. |
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 this true? Or perhaps it can just be made a little bit more clear.
Maybe it would also help to provide a direct link to the specification for that matter?
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.
If it's not in MNE_TO_BIDS_FRAMES
and there is no BIDSPath.space
then it won't be written. It could default to 'Other' that's a -1 from me, I don't think Other
should be in BIDS.
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.
You get
warn("Coordinate frame could not be inferred from the raw object "
"and the BIDSPath.space was none, skipping the writing of "
"channel positions")
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.
It's linked at the top, we could add it there, but the whole narrative is trying to get them not to save data in a template coordinate frame if possible so handing a list of template coordinate frames that close to the beginning of the example seems counterproductive
mne_bids/dig.py
Outdated
raise ValueError('All HPI, electrodes, and fiducials must be in the ' | ||
'same coordinate frame. Found: "{}"' | ||
.format(coord_frame)) | ||
if raw.get_montage() is None or raw.get_montage().get_positions() is None: |
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.
Why would montage not be None, but positions are None?
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 got an error in the tests that positions were none I thought, let me double check
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.
Okay I might be wrong. Maybe it's a downstream consequence of mne
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.
Minor changes, but otw lgtm
tell me when I should look here again. |
Ok, I added @adam2392 's comments, if you could review @agramfort that would be really helpful |
The narrative and code is really lengthy at the end to describe all the coordinate frame transforms. I think in the future we could refactor What might be worth doing eventually is to download all the templates, find fiducials on their T1s and save them somewhere in |
Seems like a good GSoC issue :p. Would be a pretty valuable contribution. |
I guess it wouldn't be too hard but the only thing is that you'd have to infer whether the channels.tsv coordinates were in surface RAS, voxels or scanner RAS. You could also have a keyword to specific with |
@adam2392 look okay now? |
I opened an issue on |
Good to go? It would be nice to get this in as |
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.
Anyone, feel free to merge once CI goes green!
Ok, all green |
Thanks, @alexrockhill! |
Fixes leftovers from #980.
mne_bids.utils._get_landmarks
because the tests for the same coordinate frame are done forraw.get_montage
so it's better not to duplicate theseI think this cleans up a lot of loose threads but there is a lot of added narrative so if @hoechenberger or @agramfort or both want to read through it and make sure it's all necessary that would be really helpful. Other than that, I am much more confident that everything works now.
cc @adam2392 also because you work with this a lot too
Merge checklist
Maintainer, please confirm the following before merging: