-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ENH] Add support for the BIDS template coordinate frames #10405
Comments
At least for MEG data, our policy when reading CTF and BTi data -- which have their own coordinate frames -- is to convert these to Neuromag. Then we only need to worry about the HEAD coordinate frame in the end. (IIRC we actually do store some stuff about the original CTF coordinate frame, but I'm not sure we need to generalize that to other systems.) So my inclination would be not to support writing these to FIF, and instead always use our standard coordinate frames. Then |
Okay so then maybe all we need to do is go and collect the fiducials from all those templates so that they can be transformed to head. And then maybe the T1 or downsampled T1 for each could be added to some dataset so that we could add an example to check that coordinates from a BIDS dataset make sense in MNE. Maybe it's own MNE templates data repository? I'd have to look to see if there's already one location where all the templates are stored (and maybe open an issue on BIDS). I think this would mostly be a PR to mne-bids but it would probably be nice to store the coordinate frames names and transforms to head in MNE-Python. |
The fiducials only allow you to determine a rigid transformation. It's likely that you'll probably want a full affine (at least scaling, maybe also shear) to get from one space to another, assuming you're talking about things like different MRI templates (MNI versus Talairach, etc.) |
I thought you could get scaling (at least directionally uniform) with the fiducials. Anyway, I'm not sure how to compute that, that's all done by Freesurfer from individual T1 to Talairach right? We have symmetric diffeomorphic mapping but that would be a lot of data to store. I guess it could go in the template data repository... |
Only in two out of three directions (X and Y), which IMO is worse than giving you zero out of three via a rigid. The
I would check first if there is a standard way of transforming for the (MRI?) space of interest to standard MNI space. My guess is that people live / it's acceptable to use some simple affine transformation for this. And storing 4x4 matrices is trivial and much more permanent / translatable across other platforms / future proof compared to the SDR stuff. I'd really like to avoid having to use SDR if possible. |
... to give a concrete example and sticking to MRI template spaces, I would expect that at least some of these: Have some standard affine 4x4 matrix you can use to get to |
Thinking about it, they could just have the fiducials so that they can be transformed to "head" and then saved. Then you just have to worry about the head->template mri transform. Template to template transforms would be optional; I assume that's not really the goal anyway, you probably just want to work in the template you got the data in so that you don't run into transform of a transform problems. |
It sounds like this requires no changes at the MNE-Python end -- just require at the MNE-BIDS end that they have fiducials properly defined/marked in whatever space their electrodes live in. For convenience, if you want, you could even automagically add them for different templates (like we already have for |
I think the original issue was that they wanted the montage coordinate frame to say it was in the template space so I think we'd just need named integers for the coordinate frame and then raise an error if you try and save the montage with that coordinate frame maybe? I agree the magic transforms would be nice but I think you want it to magically work when you save to disk and load but not to magically transform your montage into different coordinates when you think they're in a template mri space. |
Are we talking about Are we talking about For some datasets like Maybe I still don't quite follow... maybe discussing on Friday would be easier. |
Happy to discuss Friday, that all sounds good and the |
I think you missed / I wasn't clear enough about this point above:
So I'm not sure what you mean by "raw object have the coordinate frame 'MNI152NLin6Sym'". When you do |
The transform only happens if there are fiducials though and because we added |
... true, but they ideally should be present. If they aren't, I think we are right to warn, as many/most viz functions will do the wrong thing / misrepresent the data, and we are right to call them UNKNOWN because this is more or less an unsupported way of using MNE. (Calling them HEAD is misleading, though it might be what
Ahh so you're talking about transforming the
...I think the best way to make this work is to ensure that you can properly get to and from the HEAD coordinate frame. In other words:
|
Ok, now I think we're on the same page. The only question to add to MNE is: can the montage coordinate frame just be a string or does it have to be a signed int supported by MNE? |
It has to be int. Hence I would just leave it as UNKNOWN, but containing LPA/RPA/Nasion is enough to get to/from it and HEAD. The fact that it's |
Okay, good discussion, let's have it all be MNE-BIDS-level tutorial, I agree. |
Hopefully you can convince others that this limited support for coordinate frames is ultimately a good thing and not laziness on our part :) |
Related to mne-tools/mne-bids#961 and mne-tools/mne-bids#962.
Both EEG and iEEG data can be stored in any of the template coordinate frames in BIDS https://bids-specification.readthedocs.io/en/stable/99-appendices/08-coordinate-systems.html#eeg-specific-coordinate-systems. If one of these coordinate frames is used, MNE-Python could have an internal representation for it in
transforms.py
. The question is what would we need? What comes to mind are 1) a mapping in FIF for roundtrip save/load, 2) the fiducials in this coordinate frame to transform it to other coordinate frames and 3) optionally, the template MR image itself for examples (and potentially also the freesurfer recon but that's going to be quite a bit of data).Once this is done, a
montage
object could haveapply_trans
used and be in that coordinate frame to save to BIDS usingmne_bids.write_raw_bids
and then could also be read out usingmne_bids.read_raw_bids
and it would have an official named integer representation and work just like the other coordinate frames.I think the hardest part would be figuring out the representation in the FIF standard. Do you know if this would be easy or very hard @larsoner or @agramfort?
The text was updated successfully, but these errors were encountered: