Skip to content

Commit

Permalink
BUG: Fix bug with clip box setting
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Sep 15, 2023
1 parent 0363fee commit 553b325
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
5 changes: 2 additions & 3 deletions examples/io/elekta_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
Getting averaging info from .fif files
======================================
Parse averaging information defined in Elekta Vectorview/TRIUX DACQ (data
acquisition). Extract and average epochs accordingly. Modify some
averaging parameters and get epochs.
Parse averaging information defined in Elekta Vectorview/TRIUX DACQ (data acquisition).
Extract and average epochs accordingly. Modify some averaging parameters and get epochs.
"""
# Author: Jussi Nurminen (jnu@iki.fi)
#
Expand Down
18 changes: 13 additions & 5 deletions mne/viz/topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,6 @@ def _imshow_tfr_unified(
data_lines.append(
ax.imshow(
tfr[ch_idx],
clip_on=True,
clip_box=tuple(bn.pos),
extent=extent,
aspect="auto",
origin="lower",
Expand All @@ -506,6 +504,7 @@ def _imshow_tfr_unified(
cmap=cmap,
)
)
data_lines[-1].set_clip_box(_pos_to_bbox(bn.pos, ax))


def _plot_timeseries(
Expand Down Expand Up @@ -664,18 +663,17 @@ def _plot_timeseries_unified(
pos = bn.pos
data_lines = bn.data_lines
ax = bn.ax
# XXX These calls could probably be made faster by using collections
for data_, color_, times_ in zip(data, color, times):
data_lines.append(
ax.plot(
bn.x_t + bn.x_s * times_,
bn.y_t + bn.y_s * data_[ch_idx],
linewidth=0.5,
color=color_,
clip_on=True,
clip_box=tuple(pos),
)[0]
)
# Needs to be done afterward for some reason (probable matlotlib bug)
data_lines[-1].set_clip_box(_pos_to_bbox(pos, ax))
if vline:
vline = np.array(vline) * bn.x_s + bn.x_t
ax.vlines(
Expand Down Expand Up @@ -1300,3 +1298,13 @@ def plot_topo_image_epochs(
add_background_image(fig, fig_background)
plt_show(show)
return fig


def _pos_to_bbox(pos, ax):
"""Convert layout position to bbox."""
import matplotlib.transforms as mtransforms

return mtransforms.TransformedBbox(
mtransforms.Bbox.from_bounds(*pos),
ax.transAxes,
)
1 change: 0 additions & 1 deletion tutorials/preprocessing/70_fnirs_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Here we will work with the :ref:`fNIRS motor data <fnirs-motor-dataset>`.
"""

# %%

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion tutorials/time-freq/20_sensors_time_frequency.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
We will use this dataset: :ref:`somato-dataset`. It contains so-called event
related synchronizations (ERS) / desynchronizations (ERD) in the beta band.
""" # noqa: E501
"""
# Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr>
# Stefan Appelhoff <stefan.appelhoff@mailbox.org>
# Richard Höchenberger <richard.hoechenberger@gmail.com>
Expand Down

0 comments on commit 553b325

Please sign in to comment.