You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: Standard electrode position computation #5269
I have recently finished a little pet project of mine, in which I compute all 345 standard EEG electrode positions of the 10-05 (5%) system. Although that's nothing new per se and the data are available e.g., from Robert Oostenveld, I thought that it would be nice for MNE to have the actual computations, which then yield the data to be used as part of the code. Currently, there are only a bunch of data files in mne/channels/data which is not as transparent as the code would be.
... as I started to hint at on gitter yesterday, this also relates to the issues about montages, layouts, and digitization, see #5190#3987
What do you think?
This is the repository containing the computations I am talking about.
Here is a short notebook showing an initial integration with MNE.
I think it would be nice to generate as many standard montage positions on the fly as possible rather than storing them in text files. We could basically change it so that they are calculated on the fly, and we only use the text file ones for validation (essentially they become test files, in principle you could git mv them but it's probably not worth doing so).
Other than that I completely agree with your point, however it seems like a major undertaking to implement this all at once.
Perhaps we could start by implementing the code to calculate the standard 10-20, 10-10, and 10-05 positions. Then whenever read_montage() is called with e.g., kind='standard_1010', we would calculate the positions on the fly ... but when kind='biosemi16', we fall back on the files until someone implements an on-the-fly calculation for biosemi.
Another point is that for all positions that we calculate ourselves (as opposed to reading from a file) will not need to be rescaled into MNE standards --> which will solve the two important rescaling issues I referenced in the original post.
Any specific objections @agramfort ? Or a general reluctance?
Please include SO1, SO2, M1, M2, A1, A2
Do you have a documentation as to how these are defined with respect to the 1020/1010/1005 system @jona-sassenhagen ? LPA and RPA in my implementation are the same position as T9/T10 ... the two mastoids are very close to TP9 / TP10
Can you open a PR to see what it would imply in terms of code change?
In terms of code change, I thought we could start very slowly with the following schema:
a user calls read_montage with kind specified as e.g., standard_1005
in read_montage we have an if/else clause that if the kind is in list_of_positions_we_can_compute_instead_of_reading_from_file
... then, generate montage from computed values
with such a setup we can leave the code untouched for all positions that we cannot compute yet but it also allows a gradual transition to computing everything and not reading from files anymore.
One thing that I wouldn't know how to do is how to prevent MNE from rescaling the montages that we know are in the right format (because we computed them) ...
@agramfort I did not start yet because I wanted to get a round of feedback before beginning. So feel free to suggest. And maybe @larsoner can help me with preventing the scaling.
I have reactions:
- if it's not broken don't fix it. So if there clear issues that one could
fix with this?
- if not, can it allow to remove a lot of lines ie a PR will mostly red
lines which would be a win in future maintenance.
if it's not broken don't fix it. So if there clear issues that one could
Benefit to me would be, I wouldn't have to think about where my loc files are stored anymore. This actually simplifies things a lot, because it removes context dependence: I can simply tell everyone that to get channel locations, they should execute this line, regardless of their specific 10/20 setup.
if not, can it allow to remove a lot of lines ie a PR will mostly red
lines which would be a win in future maintenance.
In principle, we could drop a lot of the loc files we have, which would in fact be 100s of lines of code. But we should not remove API, cause this works only for standard montages and people need to be able to set up their nonstandard ones.
I don't quite see the advantage of this either. Why don't we just include the 10/5 montage file with all 345 channels? We only need this file to get all possible subsets of 10/5 montages, including 10/20. Having the actual calculation is then not necessary, because I don't think you can cram in more than these 345 electrodes anyway.
We have multiple loc files right now - a whole directory of them. We need a few lines for testing, but many of the loc files can be simply dropped.
What I would really like is if we could have, in the raw constructor, an option to go montage=“10/20”, and it would automatically fill in channel names. That would really simplify reading in standard EEG files for newcomers.
________________________________
From: Clemens Brunner <[email protected]>
Sent: Monday, June 11, 2018 9:48:51 AM
To: mne-tools/mne-python
Cc: jona-sassenhagen; Mention
Subject: Re: [mne-tools/mne-python] Feature: Standard electrode position computation (#5269)
I don't quite see the advantage of this either. Why don't we just include the 10/5 montage file with all 345 channels? We only need this file to get all possible subsets of 10/5 montages, including 10/20. Having the actual calculation is then not necessary, because I don't think you can cram in more than these 345 electrodes anyway.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#5269 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AEHyImwwT8bkrgbllNbImFqd2uFm57eTks5t7iDjgaJpZM4UeJqi>.
We can replace all montage files that are a subset of 10/05 or 10/20 with one file containing the 345 labels and locations of the 10/05 system. Passing a montage as string in the constructor already works, so all we need is the file. Also, currently there are only 2 files with 10/20 montages, so I'm not sure if any other montage file could be dropped...
We can replace all montage files that are a subset of 10/05 or 10/20 with one file containing the 345 labels and locations of the 10/05 system. Passing a montage as string in the constructor already works, so all we need is the file.
If people can just write "10/20" there, I think that would be very beginner friendly.
Also, currently there are only 2 files with 10/20 montages, so I'm not sure if any other montage file could be dropped...
There's many more, e.g., all of the standard_* ones, and one of the easycap ones.
FileNotFoundError: [Errno 2] No such file or directory: ''
So:
fix montages from the standard folder for eeglab reader
give a log message when people read in EEG files with only 10/20 channel names and no montage that they can just give "standard_1005" as their montage and they will get the channel locations
I like the idea to make things easier for newbies. I think specifying the name of a montage as a string in mne.channels.read_montage was a step in the right direction, but this should be extended for all mne.io.read_raw_* functions, so I'd modify your first bullet point to "check all readers if they accept strings for their montage argument".
Giving log messages is great, let's not do anything automatically here. However, maybe this message can also be triggered if not all channel names are found in standard_1005, but only some names match?
@jona-sassenhagen yes, it's a good improvement and I can reopen this issue with its original purpose at some other time. Before doing more intense work on the way we handle our coordinates, the crucial #5190 should be fixed through #5085.
@sappelhoff how about for now we add a link in the montage code somewhere to the separate repo? That way if we hit a use case where we need to calculate, we can refer to that?
Activity
larsoner commentedon Jun 7, 2018
I think it would be nice to generate as many standard montage positions on the fly as possible rather than storing them in text files. We could basically change it so that they are calculated on the fly, and we only use the text file ones for validation (essentially they become test files, in principle you could
git mvthem but it's probably not worth doing so).sappelhoff commentedon Jun 8, 2018
What do you mean by
git mving them?Other than that I completely agree with your point, however it seems like a major undertaking to implement this all at once.
Perhaps we could start by implementing the code to calculate the standard 10-20, 10-10, and 10-05 positions. Then whenever
read_montage()is called with e.g.,kind='standard_1010', we would calculate the positions on the fly ... but whenkind='biosemi16', we fall back on the files until someone implements an on-the-fly calculation for biosemi.Another point is that for all positions that we calculate ourselves (as opposed to reading from a file) will not need to be rescaled into MNE standards --> which will solve the two important rescaling issues I referenced in the original post.
agramfort commentedon Jun 8, 2018
jona-sassenhagen commentedon Jun 9, 2018
Loving the idea.
jona-sassenhagen commentedon Jun 9, 2018
Please include SO1, SO2, M1, M2, A1, A2.
sappelhoff commentedon Jun 10, 2018
Any specific objections @agramfort ? Or a general reluctance?
Do you have a documentation as to how these are defined with respect to the 1020/1010/1005 system @jona-sassenhagen ? LPA and RPA in my implementation are the same position as T9/T10 ... the two mastoids are very close to TP9 / TP10
In terms of code change, I thought we could start very slowly with the following schema:
read_montagewithkindspecified as e.g., standard_1005read_montagewe have an if/else clause that if thekindis inlist_of_positions_we_can_compute_instead_of_reading_from_filewith such a setup we can leave the code untouched for all positions that we cannot compute yet but it also allows a gradual transition to computing everything and not reading from files anymore.
One thing that I wouldn't know how to do is how to prevent MNE from rescaling the montages that we know are in the right format (because we computed them) ...
agramfort commentedon Jun 10, 2018
I meant "no objection". Sorry
agramfort commentedon Jun 10, 2018
@sappelhoff would it change code outside montage.py? any documentation? example?
sappelhoff commentedon Jun 10, 2018
@agramfort I did not start yet because I wanted to get a round of feedback before beginning. So feel free to suggest. And maybe @larsoner can help me with preventing the scaling.
agramfort commentedon Jun 10, 2018
jona-sassenhagen commentedon Jun 10, 2018
Benefit to me would be, I wouldn't have to think about where my loc files are stored anymore. This actually simplifies things a lot, because it removes context dependence: I can simply tell everyone that to get channel locations, they should execute this line, regardless of their specific 10/20 setup.
In principle, we could drop a lot of the loc files we have, which would in fact be 100s of lines of code. But we should not remove API, cause this works only for standard montages and people need to be able to set up their nonstandard ones.
cbrnr commentedon Jun 11, 2018
I don't quite see the advantage of this either. Why don't we just include the 10/5 montage file with all 345 channels? We only need this file to get all possible subsets of 10/5 montages, including 10/20. Having the actual calculation is then not necessary, because I don't think you can cram in more than these 345 electrodes anyway.
jona-sassenhagen commentedon Jun 11, 2018
cbrnr commentedon Jun 11, 2018
We can replace all montage files that are a subset of 10/05 or 10/20 with one file containing the 345 labels and locations of the 10/05 system. Passing a montage as string in the constructor already works, so all we need is the file. Also, currently there are only 2 files with 10/20 montages, so I'm not sure if any other montage file could be dropped...
jona-sassenhagen commentedon Jun 11, 2018
If people can just write "10/20" there, I think that would be very beginner friendly.
There's many more, e.g., all of the standard_* ones, and one of the easycap ones.
25 remaining items
jona-sassenhagen commentedon Aug 5, 2018
Hm ... ok, I think I see the problem.
This works:
mne.io.read_raw_brainvision(fname, montage="standard_1005")but this doesn't:
mne.io.read_raw_eeglab(fname, montage="standard_1005")gives
FileNotFoundError: [Errno 2] No such file or directory: ''So:
fix montages from the standard folder for eeglab reader
give a log message when people read in EEG files with only 10/20 channel names and no montage that they can just give "standard_1005" as their montage and they will get the channel locations
cbrnr commentedon Aug 6, 2018
I like the idea to make things easier for newbies. I think specifying the name of a montage as a string in
mne.channels.read_montagewas a step in the right direction, but this should be extended for allmne.io.read_raw_*functions, so I'd modify your first bullet point to "check all readers if they accept strings for theirmontageargument".Giving log messages is great, let's not do anything automatically here. However, maybe this message can also be triggered if not all channel names are found in
standard_1005, but only some names match?agramfort commentedon Aug 6, 2018
jona-sassenhagen commentedon Aug 6, 2018
@sappelhoff ok if we repurpose the issue for that ..?
sappelhoff commentedon Aug 6, 2018
@jona-sassenhagen yes, it's a good improvement and I can reopen this issue with its original purpose at some other time. Before doing more intense work on the way we handle our coordinates, the crucial #5190 should be fixed through #5085.
larsoner commentedon Apr 23, 2019
@sappelhoff how about for now we add a link in the
montagecode somewhere to the separate repo? That way if we hit a use case where we need to calculate, we can refer to that?sappelhoff commentedon Apr 24, 2019
sounds good, perhaps link to it in some of the documentation pages? Or did you mean as a comment somewhere in the code?
larsoner commentedon Apr 24, 2019
Either (or both) is fine by me
sappelhoff commentedon Apr 24, 2019
looping in @drammock who is working hard on the docs: Would you know a good place in the documentation where we could refer to a repository for computing standard EEG electrode positions on a sphere? (talking about: https://github.com/sappelhoff/eeg_positions) ... perhaps reading the OP will aso provide you with the background for responding to this,
Possible locations for adding the link with a brief (2 sentences) description:
Similar pages that we have:
sappelhoff commentedon Apr 25, 2019
Okay, a minimal note with a link is added to the docs. It'll be merged with #5944
larsoner commentedon Apr 25, 2019
This now lives in #5944 so I'll close