mne-tools / mne-python

MNE: Magnetoencephalography (MEG) and Electroencephalography (EEG) in Python
https://mne.tools
BSD 3-Clause "New" or "Revised" License
2.7k stars 1.31k forks source link

raw.plot() bottom cannot be >= top #8304

Closed vagechirkov closed 3 years ago

vagechirkov commented 4 years ago

Dear all,

I faced the following bug during plotting raw fif data:


----> 3 mne.viz.plot_raw(raw)

<decorator-gen-145> in plot_raw(raw, events, duration, start, n_channels, bgcolor, color, bad_color, event_color, scalings, remove_dc, order, show_options, title, show, block, highpass, lowpass, filtorder, clipping, show_first_samp, proj, group_by, butterfly, decim, noise_cov, event_id, show_scrollbars, show_scalebars, verbose)

/home/cdm/miniconda3/envs/meg_spikes/lib/python3.6/site-packages/mne/viz/raw.py in plot_raw(raw, events, duration, start, n_channels, bgcolor, color, bad_color, event_color, scalings, remove_dc, order, show_options, title, show, block, highpass, lowpass, filtorder, clipping, show_first_samp, proj, group_by, butterfly, decim, noise_cov, event_id, show_scrollbars, show_scalebars, verbose)
    428 
    429     _prepare_mne_browse_raw(params, title, bgcolor, color, bad_color, inds,
--> 430                             n_channels)
    431 
    432     # plot event_line first so it's in the back

/home/cdm/miniconda3/envs/meg_spikes/lib/python3.6/site-packages/mne/viz/raw.py in _prepare_mne_browse_raw(params, title, bgcolor, color, bad_color, inds, n_channels)
    663     _set_window_title(params['fig'], title or "Raw")
    664     # most of the axes setup is done in _prepare_mne_browse
--> 665     _prepare_mne_browse(params, xlabel='Time (s)')
    666     ax = params['ax']
    667     ax_hscroll = params['ax_hscroll']

/home/cdm/miniconda3/envs/meg_spikes/lib/python3.6/site-packages/mne/viz/utils.py in _prepare_mne_browse(params, xlabel)
    661         right=1 - _inch_to_rel_dist(fig, r_border),
    662         bottom=_inch_to_rel_dist(fig, b_border, horiz=False),
--> 663         top=1 - _inch_to_rel_dist(fig, t_border, horiz=False)
    664     )
    665     # Main axes must be a `subplot` for `subplots_adjust` to work (so user can

/home/cdm/miniconda3/envs/meg_spikes/lib/python3.6/site-packages/matplotlib/figure.py in subplots_adjust(self, left, bottom, right, top, wspace, hspace)
   2383                                  "tight_layout: setting "
   2384                                  "constrained_layout==False. ")
-> 2385         self.subplotpars.update(left, bottom, right, top, wspace, hspace)
   2386         for ax in self.axes:
   2387             if not isinstance(ax, SubplotBase):

/home/cdm/miniconda3/envs/meg_spikes/lib/python3.6/site-packages/matplotlib/figure.py in update(self, left, bottom, right, top, wspace, hspace)
    203             if ((bottom if bottom is not None else self.bottom)
    204                     >= (top if top is not None else self.top)):
--> 205                 raise ValueError('bottom cannot be >= top')
    206         if left is not None:
    207             self.left = left

ValueError: bottom cannot be >= top

After its appearance in one environment, this bug appeared in all Anaconda environments. Unfortunately, I cannot reproduce the original reason for its appearance.

Solution

I think that the constant (MNE_BROWSE_RAW_SIZE) has been accidentally corrupted, and this crashed the plotting function. I have manually set config:

mne.utils.set_config('MNE_BROWSE_RAW_SIZE', '14.4,8.05', use_env=False)

I hope this report will help to avoid this problem.

Best regards, Valerii

larsoner commented 4 years ago

Thanks for the report -- we could sanity check the values we get from the config better and warn if they're unusable.