get_montage and get_coordinates for Raw and Montage objects
See original GitHub issueDescribe the problem
Once a user has set the montage, then getting the montage itself and data from it is not trivial.
Ideally, the users can get the actual xyz coordinates whether its an array, or dictionary via just a get
function.
You have to do things like:
ch_locs = raw.info['chs']['loc'][0:3]
orch_locs = [raw.info['dig'][idx]['r'][0:3] for idx in len(raw.info['dig'])]
In 1., it took me a bit to end up figuring out that the 12 point locations in are not relevant for the most part if I need the xyz coordinates. And the xyz are stored in the first 3 indices. This is at least for iEEG.
Note: In addition, idk if this is on purpose, but the raw.info[‘dig’] can be not in the same order as raw.info[‘ch_names’] especially if there was some reordering done when making ch_pos
for the DigMontage. I don’t think it affects internal code, but it further makes it non-trivial if you need access to the coordinates you want to work w/.
Describe your solution
An implementation at the Raw level for get_montage()
, it simply returns the montage that is set for a Raw object, or returns an error message if no montage.
An implementation at the Montage level for get_coordinates()
, which returns the xyz coordinates in it’s ‘m’ form as a 3D array.
Ideally it looks like this:
montage = raw.montage
ch_locs = montage.get_coordinates()
Describe possible alternatives
get_coordinates
could also be at the Raw level?
Additional context
See related discussion: https://github.com/mne-tools/mne-bids/pull/393
Happy to submit a PR after discussion of if this is valid.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Get_montage that returns a dig montage that could be fed to set_montage is to me the most consistent. I would like to get all dig points etc
I would not do
get_montage
, amontage
is just a way to set channel positions.I would add a
inst.get_channel_positions()
that for example returned adict
of the channel name: pos mapping. It would really just loop overinfo['chs']
to look atloc
but indeed a user should not have to do this.