Skip to content

Defect montages shipped with MNE? #4403

Closed

Description

@cbrnr

As mentioned in #4400, these two montages seem to have duplicate channel positions:

  • mne/channels/montages/standard_postfixed.elc
  • mne/channels/montages/standard_primed.elc

Furthermore, we currently have no description for mne/channels/montages/10-5-System_Mastoids_EGI129.csd, which contains a total of 465 locations. The last 129 locations are just numbers. Besides the cumbersome file name, we should make sure that this is a valid and useful montage (this file was also not documented in the docstring of the read_montage function).

EDIT by @larsoner: We should:

  1. Deprecate transform=False -> True for internal consistency.
  2. Make montage.plot do something smart with overlapping locations (newline separation?)

Activity

  1. larsoner commented on Jul 19, 2017

    @larsoner
    Member

    @dengemann any insight on these montages? You added them ages ago (2014)

  2. cbrnr commented on Jul 20, 2017

    @cbrnr
    ContributorAuthor

    Something else I've noticed. The elements in the ch_names list have different types, especially the ones with byte elements could be problematic:

    10-5-System_Mastoids_EGI129 <class 'numpy.bytes_'>
    biosemi128 <class 'numpy.str_'>
    biosemi16 <class 'numpy.str_'>
    biosemi160 <class 'numpy.str_'>
    biosemi256 <class 'numpy.str_'>
    biosemi32 <class 'numpy.str_'>
    biosemi64 <class 'numpy.str_'>
    easycap-M1 <class 'numpy.str_'>
    easycap-M10 <class 'numpy.str_'>
    EGI_256 <class 'numpy.bytes_'>
    GSN-HydroCel-128 <class 'str'>
    GSN-HydroCel-129 <class 'str'>
    GSN-HydroCel-256 <class 'str'>
    GSN-HydroCel-257 <class 'str'>
    GSN-HydroCel-32 <class 'str'>
    GSN-HydroCel-64_1.0 <class 'str'>
    GSN-HydroCel-65_1.0 <class 'str'>
    standard_1005 <class 'str'>
    standard_1020 <class 'str'>
    standard_alphabetic <class 'str'>
    standard_postfixed <class 'str'>
    standard_prefixed <class 'str'>
    standard_primed <class 'str'>
    

    This was fixed in #4427.

  3. added this to the 0.15 milestone on Jul 20, 2017
  4. larsoner commented on Jul 20, 2017

    @larsoner
    Member

    Yes we should also fix those

  5. agramfort commented on Jul 28, 2017

    @agramfort
    SponsorMember

    not fixed by #4427 ?

  6. cbrnr commented on Jul 28, 2017

    @cbrnr
    ContributorAuthor

    Not entirely, there's still the issue with duplicate locations and the weird montage.

  7. jaeilepp commented on Jul 28, 2017

    @jaeilepp
    Contributor

    I guess the things in the original post are still unanswered.

  8. larsoner commented on Aug 5, 2017

    @larsoner
    Member

    @dengemann any time to look in the next week or two to see if you can make sense of these files you added a few years back? It would be good to fix this for 0.15

  9. larsoner commented on Aug 16, 2017

    @larsoner
    Member

    ping @dengemann any insight on these?

  10. dengemann commented on Aug 16, 2017

    @dengemann
    Member
  11. larsoner commented on Aug 16, 2017

    @larsoner
    Member

    So remove both or just one of these:

    • mne/channels/montages/standard_postfixed.elc
    • mne/channels/montages/standard_primed.elc
  12. dengemann commented on Aug 16, 2017

    @dengemann
    Member
  13. larsoner commented on Aug 16, 2017

    @larsoner
    Member

    The mysterious 10-5-System_Mastoids_EGI129.csd file is already gone from our repo, so I'll close this then

  14. 25 remaining items

  15. larsoner commented on Aug 22, 2017

    @larsoner
    Member

    Which label should it use then? The first?

    I was thinking of showing all names, separated by newlines. We'd have to do some testing to figure out the best option.

  16. removed this from the 0.15 milestone on Aug 22, 2017
  17. cbrnr commented on Aug 22, 2017

    @cbrnr
    ContributorAuthor

    Ah OK, might get a bit crowded then. What if there are more than 2 names, like 3 or 4? I guess we could also just leave it as it is. The plot then indicates that there's something wrong with the montage (which I still think is the case, at least for EEG there shouldn't be montages with duplicate names).

  18. cbrnr commented on Sep 20, 2017

    @cbrnr
    ContributorAuthor

    I guess setting transform=True by default can be done in a new PR.

    Besides that, what do we do with the two montages that have multiple labels for identical locations? People will probably start plotting montages because there now is a method for that and notice that something is wrong. I'd either remove these two montages or de-duplicate the labels.

  19. larsoner commented on Sep 20, 2017

    @larsoner
    Member
  20. cbrnr commented on Sep 20, 2017

    @cbrnr
    ContributorAuthor

    Then I propose to issue a warning if plotting such a montage and only plotting the first label. Handling more than one label per position will be difficult since there is already overlap with only one label per location.

  21. larsoner commented on Sep 20, 2017

    @larsoner
    Member

    That sounds reasonable to me.

  22. cbrnr commented on Sep 21, 2017

    @cbrnr
    ContributorAuthor

    Checking for duplicate labels is giving me a headache. First, I need to use scipy.spatial.distance.pdist and scipy.spatial.distance.squareform - MNE does not require SciPy, so how should this be handled? Second, figuring out if there are duplicate labels is easy, but finding their indices and plotting only one label is pretty hard. I'm really not sure if these two defect montages are really worth this effort. In the end, they are defective and I still think we should either remove them completely or remove the duplicate labels from the montages.

  23. larsoner commented on Sep 21, 2017

    @larsoner
    Member

    First, I need to use scipy.spatial.distance.pdist and scipy.spatial.distance.squareform

    We have a standard fast pairwise distance wrapper _compute_nearest(..., return_dists=True).

    MNE does not require SciPy, so how should this be handled?

    SciPy is a hard dependency of MNE

    Second, figuring out if there are duplicate labels is easy, but finding their indices and plotting only one label is pretty hard.

    Does this work?

    use_pos = []
    use_labels = []
    usable = np.ones(len(pos), bool)
    dists = _compute_nearest(pos, pos, return_dists=True)[1]
    for ii in range(len(pos)):
        if usable[ii]:
            use_pos.append(pos[ii])
            use_labels.append(labels[ii])
        usable[dists[ii] < 1e-5] = False
    logger.info('Plotting %d/%d deduplicated labels' % (len(use_pos), len(pos)))
    assert not usable.any()
    
  24. cbrnr commented on Sep 21, 2017

    @cbrnr
    ContributorAuthor

    Thanks @larsoner. If SciPy is a hard dependency then I just use it. MNE's _compute_nearest returns a vector of all zeros, whereas scipy.spatial.distance.cdist works. I think I just found a solution without loops.

  25. larsoner commented on Sep 21, 2017

    @larsoner
    Member

    _compute_nearest returns a vector of all zeros

    Oh right because it gives the neighbor as zero. cdist should be fine

  26. larsoner commented on Sep 21, 2017

    @larsoner
    Member

    One non-(explicit-)loop would be to turn the square distance matrix into a connectivity matrix and do:

    _, components = sparse.csgraph.connected_components(cdist(pos, pos) < 1e-5)
    

    And then unpack the first element of each item in components. Is that what you're doing?

  27. cbrnr commented on Sep 21, 2017

    @cbrnr
    ContributorAuthor

    Here's what I'm doing right now:

    dists = cdist(montage.pos, montage.pos)
    dists[np.tril_indices(dists.shape[0])] = np.nan
    dupes = np.argwhere(np.isclose(dists, 0))
    

    This gives me all duplicates in the rows, column 0 is the index of the first label and column 1 the index of the second (duplicate) label. Now I'm working on integrating all of this into the plot function (which is not that straightforward because Montage objects don't support removal of channels out of the box, but anyway I'll do it manually).

  28. cbrnr commented on Sep 21, 2017

    @cbrnr
    ContributorAuthor

    Let's see if this works in #4592...

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

Metadata

Metadata

Assignees

No one assigned

    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