Skip to content

[MRG] Do not plot duplicate labels in montage#4592

Merged
larsoner merged 6 commits intomne-tools:masterfrom
cbrnr:plot_defect_montages
Sep 25, 2017
Merged

[MRG] Do not plot duplicate labels in montage#4592
larsoner merged 6 commits intomne-tools:masterfrom
cbrnr:plot_defect_montages

Conversation

@cbrnr
Copy link
Copy Markdown
Contributor

@cbrnr cbrnr commented Sep 21, 2017

Fix #4403.

@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 21, 2017

Can someone please start AppVeyor?

Copy link
Copy Markdown
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

"""Functions to plot EEG sensor montages or digitizer montages."""
from ..utils import check_version
import numpy as np
from scipy.spatial.distance import cdist
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import will need to be nested (to avoid import mne slowdown we nest most of the scipy imports)

logger.info(", ".join([ch_names[d[0]] + "/" + ch_names[d[1]]
for d in dupes]))
logger.info("Plotting {} unique labels.".format(n_chans - n_dupes))
montage.ch_names = [montage.ch_names[i] for i in idx]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make a copy of the montage before modifying it

ch_names = montage.ch_names
montage.pos = montage.pos[idx, :]
montage.selection = np.arange(n_chans - n_dupes)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some simple way to add a test? Check the number of points in some matplotlib object when plotting the montage with dups?

@larsoner
Copy link
Copy Markdown
Member

I don't know why AppVeyor isn't running, I'm not sure of a way to manually trigger it. But it will hopefully run on your next commit. (Even if it doesn't there isn't anything Windows-specific here so I think we'll be okay)

@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 21, 2017

Regarding the test, I don't think that we need to validate this against the plot. We want to test if the number of duplicates is detected correctly, right? A very simple test would be to check some montage files where we know the number of duplicates. Is this too simplistic?

@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 21, 2017

I don't see any errors in the CircleCI log file. This line returns a non-zero exit code:

tail $CIRCLE_ARTIFACTS/log.txt | grep -E "auto_tutorials\s*\[100%\]\s*plot_|Build finished"

Did anything change in the build tools that causes the grep to fail?

@larsoner
Copy link
Copy Markdown
Member

No, if you look at the log just above that one you'll see it's a link-parsing error in SG. There is a fix on the way to SG for that.

@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 21, 2017

I see - weird that it still returns 0 as its exit status. So this means that we can ignore CircleCI until this is fixed, right?

Regarding this PR, how do we handle DigMontage objects? These have no pos attributes - does it even make sense to perform the duplicate checks for DigMontage objects?

@larsoner
Copy link
Copy Markdown
Member

I wouldn't bother for DigMontage

@larsoner
Copy link
Copy Markdown
Member

(and for CircleCI, we just currently make sure the error we get is the SG error and not something else)

@larsoner
Copy link
Copy Markdown
Member

@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 21, 2017

Codecov Report

Merging #4592 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #4592      +/-   ##
==========================================
+ Coverage   87.05%   87.05%   +<.01%     
==========================================
  Files         349      349              
  Lines       66080    66108      +28     
  Branches    10256    10259       +3     
==========================================
+ Hits        57525    57553      +28     
  Misses       5657     5657              
  Partials     2898     2898

@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 22, 2017

What about the test (see my comment above)?

The figure object.
"""
from copy import deepcopy
import numpy as np
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't nest imports of numpy and copy

montage.ch_names = [montage.ch_names[i] for i in idx]
ch_names = montage.ch_names
montage.pos = montage.pos[idx, :]
montage.selection = np.arange(n_chans - n_dupes)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is these lines are not covered by any test then indeed with need a test

@agramfort agramfort added this to the 0.15 milestone Sep 23, 2017
@agramfort
Copy link
Copy Markdown
Member

@cbrnr you need to rebase

@cbrnr cbrnr force-pushed the plot_defect_montages branch from 89fd0e8 to ebeb4c4 Compare September 25, 2017 08:29
@cbrnr
Copy link
Copy Markdown
Contributor Author

cbrnr commented Sep 25, 2017

Done. Let me know if you think the test is adequate.

@cbrnr cbrnr changed the title Do not plot duplicate labels in montage [MRG] Do not plot duplicate labels in montage Sep 25, 2017
def test_plot_montage():
"""Test plotting montages."""
"""Test plotting montages.
"""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going the wrong direction -- single-line docstrings should end with .""" according to pydocstyle

@larsoner
Copy link
Copy Markdown
Member

Thanks @cbrnr will fix the docstring nitpicks later (we have them set to be ignored by pydocstyle for now anyway)

@larsoner larsoner merged commit 42794b4 into mne-tools:master Sep 25, 2017
@cbrnr cbrnr deleted the plot_defect_montages branch September 26, 2017 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants