Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for MNE plot_topomap deprecation #119

Merged
merged 4 commits into from
Dec 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions yasa/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ def topoplot(
kwargs["res"] = 256
if "names" not in kwargs:
kwargs["names"] = chan
if "show_names" not in kwargs:
kwargs["show_names"] = True
if "mask_params" not in kwargs:
kwargs["mask_params"] = dict(marker=None)

Expand All @@ -462,17 +460,37 @@ def topoplot(
# Start the plot
with sns.axes_style("white"):
fig, ax = plt.subplots(figsize=figsize, dpi=dpi)
im, _ = mne.viz.plot_topomap(
data=data.iloc[:, 0][chan],
pos=Info,
vmin=vmin,
vmax=vmax,
mask=data.iloc[:, 1][chan],
cmap=cmap,
show=False,
axes=ax,
**kwargs,
)

# vmin, vmax and show_names have been deprecated in MNE v1.3
mne_version = float(mne.__version__[:3])

if mne_version >= 1.3:
if "show_names" in kwargs:
kwargs.pop("show_names")
im, _ = mne.viz.plot_topomap(
data=data.iloc[:, 0][chan],
pos=Info,
vlim=(vmin, vmax),
mask=data.iloc[:, 1][chan],
cmap=cmap,
show=False,
axes=ax,
**kwargs,
)
else:
if "show_names" not in kwargs:
kwargs["show_names"] = True
im, _ = mne.viz.plot_topomap(
data=data.iloc[:, 0][chan],
pos=Info,
vmin=vmin,
vmax=vmax,
mask=data.iloc[:, 1][chan],
cmap=cmap,
show=False,
axes=ax,
**kwargs,
)

if title is not None:
ax.set_title(title)
Expand Down