Skip to content

Feature: Standard electrode position computation #5269

Closed

Description

@sappelhoff

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.

And a plot:
screenshot from 2018-06-07 12-23-45

Activity

  1. larsoner commented on Jun 7, 2018

    @larsoner
    Member

    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).

  2. sappelhoff commented on Jun 8, 2018

    @sappelhoff
    MemberAuthor

    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 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.

  3. agramfort commented on Jun 8, 2018

    @agramfort
    SponsorMember
  4. jona-sassenhagen commented on Jun 9, 2018

    @jona-sassenhagen
    Contributor

    Loving the idea.

  5. jona-sassenhagen commented on Jun 9, 2018

    @jona-sassenhagen
    Contributor

    Please include SO1, SO2, M1, M2, A1, A2.

  6. sappelhoff commented on Jun 10, 2018

    @sappelhoff
    MemberAuthor

    objection on my side

    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:

    1. a user calls read_montage with kind specified as e.g., standard_1005
    2. 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
    3. ... 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) ...

  7. agramfort commented on Jun 10, 2018

    @agramfort
    SponsorMember

    I meant "no objection". Sorry

  8. agramfort commented on Jun 10, 2018

    @agramfort
    SponsorMember

    @sappelhoff would it change code outside montage.py? any documentation? example?

  9. sappelhoff commented on Jun 10, 2018

    @sappelhoff
    MemberAuthor

    @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.

  10. agramfort commented on Jun 10, 2018

    @agramfort
    SponsorMember
  11. jona-sassenhagen commented on Jun 10, 2018

    @jona-sassenhagen
    Contributor
    • 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.

  12. cbrnr commented on Jun 11, 2018

    @cbrnr
    Contributor

    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.

  13. jona-sassenhagen commented on Jun 11, 2018

    @jona-sassenhagen
    Contributor
  14. cbrnr commented on Jun 11, 2018

    @cbrnr
    Contributor

    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...

  15. jona-sassenhagen commented on Jun 11, 2018

    @jona-sassenhagen
    Contributor

    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.

  16. 25 remaining items

  17. jona-sassenhagen commented on Aug 5, 2018

    @jona-sassenhagen
    Contributor

    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:

    1. fix montages from the standard folder for eeglab reader

    2. 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

  18. cbrnr commented on Aug 6, 2018

    @cbrnr
    Contributor

    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?

  19. agramfort commented on Aug 6, 2018

    @agramfort
    SponsorMember
  20. jona-sassenhagen commented on Aug 6, 2018

    @jona-sassenhagen
    Contributor

    @sappelhoff ok if we repurpose the issue for that ..?

  21. sappelhoff commented on Aug 6, 2018

    @sappelhoff
    MemberAuthor

    @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.

  22. self-assigned this
    on Jan 11, 2019
  23. larsoner commented on Apr 23, 2019

    @larsoner
    Member

    @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?

  24. sappelhoff commented on Apr 24, 2019

    @sappelhoff
    MemberAuthor

    sounds good, perhaps link to it in some of the documentation pages? Or did you mean as a comment somewhere in the code?

  25. larsoner commented on Apr 24, 2019

    @larsoner
    Member

    Either (or both) is fine by me

  26. sappelhoff commented on Apr 25, 2019

    @sappelhoff
    MemberAuthor

    Okay, a minimal note with a link is added to the docs. It'll be merged with #5944

  27. larsoner commented on Apr 25, 2019

    @larsoner
    Member

    This now lives in #5944 so I'll close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions