Skip to content

Commit

Permalink
Merge pull request mne-tools#2987 from jona-sassenhagen/patch-9
Browse files Browse the repository at this point in the history
MRG safer plotting of bad chance level in plot_diagonal
  • Loading branch information
larsoner committed Mar 7, 2016
2 parents c05f5d7 + a812c10 commit 5761cf5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mne/viz/decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ def plot_gat_times(gat, train_time='diagonal', title=None, xmin=None,
if chance is not False:
if chance is True:
chance = _get_chance_level(gat.scorer_, gat.y_train_)
ax.axhline(float(chance), color='k', linestyle='--',
label="Chance level")
chance = float(chance)
if np.isfinite(chance): # don't plot nan chance level
ax.axhline(chance, color='k', linestyle='--',
label="Chance level")
ax.axvline(0, color='k', label='')

if isinstance(train_time, (str, float)):
Expand Down Expand Up @@ -232,5 +234,5 @@ def _get_chance_level(scorer, y_train):
else:
chance = np.nan
warn('Cannot find chance level from %s, specify chance level'
% scorer.func_name)
% scorer.__name__)
return chance

0 comments on commit 5761cf5

Please sign in to comment.