-
Notifications
You must be signed in to change notification settings - Fork 98
[ENH, MRG] Add BIDS Standard Template Transformations #983
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
|
Oh also the T1s are here: https://drive.google.com/drive/folders/1rN-Rb7D6ZTyVKOc2WZ-AM3f3dspIhZtQ?usp=sharing and the script is in the first commit but then I deleted it and committed again so it doesn't accidentally end up merged. |
|
You only transformed from one template to another using fiducials? This seems much less accurate than using flirt or ants to compute a proper full affine |
Unrelated to the PR I suppose: If BIDS doesn't take it, I would still be inclined to store it somewhere easily accessible; maybe Or... are the T1s themselves too big? |
|
There are a lot of them and the largest is 180 MB. I think that could be in a data repository though. |
|
I think because you need to anonymize and upload an individual T1 per subject for subject-specific coordinates and you don't need any anatomical data for the templates the lower bar to entry will make people want to share in template coordinates whether we recommend against it in |
|
744MB total for the T1s as I chose them (there were a few options for one or two that were coordinate-frame-aligned and Talairach isn't a T1, it's an |
This doesn't transform between templates, it just defines a EDIT: I would argue against facilitating transformation between templates as that is going to run into copy-of-a-copy issues and is definitely not best practice; the data should only be transformed from an individual brain to a template brain and if it's not the right template IMO, I don't think you should try and transform again. |
|
Any thoughts on where to put the transforms, is this okay? |
|
Okay as long as it's just to properly define a head coord system this seems fine! |
|
Ok, this drastically reduces the complexity of the ieeg tutorial, so I think it's really good. I tried a few versions (e.g. just providing the |
|
@alexrockhill Is this something we should try to squeeze into 0.10 as well or..? |
It would probably be nice, it's mostly just cleaning up and making things nicer. Last PR though before the release definitely |
|
I think it should all be green now, I tested it thoroughly on my side, I just didn't configure accessing the data directly in the repository |
Codecov Report
@@ Coverage Diff @@
## main #983 +/- ##
==========================================
+ Coverage 95.00% 95.04% +0.04%
==========================================
Files 25 25
Lines 3665 3715 +50
==========================================
+ Hits 3482 3531 +49
- Misses 183 184 +1
Continue to review full report at Codecov.
|
|
Ok, looks good to go, here's the artifact: https://6099-89170358-gh.circle-artifacts.com/0/dev/auto_examples/convert_ieeg_to_bids.html |
|
Ok just a few typos, ready for review if someone has a chance |
|
Looks pretty good to me. Something I wished for when I was still a phd student Haha. |
Yeah, it took a bit of doing but I think well worth it. |
mne_bids/dig.py
Outdated
| raw : mne.io.Raw | ||
| The MNE-Python Raw object with a montage in one of the BIDS standard | ||
| template coordinate frames (modified in place). |
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.
Passing an Info or even simply a DigMontage should suffice to get the trans, right? I think we should support this… or do you think it doesn't make sense, because usually the user will have a Raw (or Epochs or …) that they want to "convert", and they're not looking for just a trans?
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 tried it with the montage originally but it was really cumbersome because you ended up getting, setting and then re-getting the montage in the examples. I'll change it to info though.
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 tried to use info but I forgot it doesn't have the ContainsMixin so you can't get_montage although you can set it. @larsoner or @agramfort, is there a reason info can't get_montage? I'd be happy to add it in a quick PR if not but I assume so.
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.
Or maybe get_montage should moved from the ContainsMixin to the MontageMixin, I'm not sure if that would break everything though
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.
Ok I opened a PR and since there is about to be a release, this will immediately work with the stable branch of MNE (after the release). Since it's a new function, it won't break for anyone but will be a great reminder to upgrade to 1.0.
|
Ok, I realized even if we merge the mixins PR, then it's a pain to depend on 1.0 so soon so I just copied it over. Is there a way to set a reminder to do something at the next release? At 0.11, we should switch it to just Also this should pass all the tests and be good to merge. |
|
I would make a: |
adam2392
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.
I'm not sure if the function template_to_head should be head_to_template. The Return doc string seems mismatched.
| @verbose | ||
| def template_to_head(raw, space, coord_frame='auto', unit='auto', | ||
| verbose=None): | ||
| """Transform a BIDS standard template montage to the head coordinate frame. |
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 head to template or template to head?
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.
The template montage is getting transformed to head and you need a head->mri transform to get it to work with functions that require a raw and a trans. So I think it's better the way it is. The trans is just secondary, the main thing it does is modify the info.
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.
Ah yeah I see. Hard to do the mental gymnastics sometimes...
In that case, I wonder if it's worth adding a Notes section that explicitly warns the user there is literally no way of checking if you do something wrong (e.g. putting in the incorrect name in space parameter). Say someone puts fsaverage5 instead of fsaverage6.
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.
Neither fsaverage5 or fsaverage6 are supported, those are deprecated haha.
You can plot the alignment with the T1 of the template space, if you put the wrong one, it will look off... We can add that later, there's an issue open because mne-bids doesn't support 3D plotting yet so I would have but not this PR
|
Looks good to me. Can't do a thorough review of the code, but the details in the example are nice cuz I remember always having a million questions about these kinds of transformations. |
|
Ok, I think that's a bit uglier with all the |
|
Ok to merge @adam2392? |
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.
I also checked that the new files are also shipped with the source dist.
hoechenberger
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.
Otherwise LGTM!
|
Doc build is failing, apparently due to an issue with MNE-NIRS? /home/circleci/project/examples/convert_nirs_to_bids.py failed leaving traceback:
Traceback (most recent call last):
File "/home/circleci/project/examples/convert_nirs_to_bids.py", line 31, in <module>
import mne_nirs # For convenient downloading of example data
File "/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne_nirs/__init__.py", line 10, in <module>
from . import statistics
File "/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne_nirs/statistics/__init__.py", line 7, in <module>
from ._glm_level_first import (RegressionResults, ContrastResults,
File "/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne_nirs/statistics/_glm_level_first.py", line 19, in <module>
from mne.channels.channels import ContainsMixin
ImportError: cannot import name 'ContainsMixin' from 'mne.channels.channels' (/home/circleci/mne_bids_env/lib/python3.9/site-packages/mne/channels/channels.py)cc @rob-luke @alexrockhill I'm going ahead and merging this one, as the issue with the doc build seems unrelated to your changes. Thank you! |
Should be a quick fix, I just moved that mixin to mne.io.meas_info. |
Would be awesome if you could have a look at this if you have a few minutes to spare! Once the doc build is working again, I can release MNE-BIDS 0.10. |
I went ahead and downloaded all the T1s, marked their fiducials in voxels in
Freeviewand then computed the transforms. I think I'll wait until #982 merges first and then add these with amne_bids.get_template_transwhich will dramatically simplify the end. It was kind of cool to see all the different templates, there are definitely some interesting ones, maybe that will be something to incorporate in the future.Also, I have no idea where to store these but they are 264KB total so I don't think it's too big of a deal where they go. It would be nice to store the T1s as well but then we'd probably have to make sure with their licenses.
Merge checklist
Maintainer, please confirm the following before merging: