I think that is a BUG?

  • MNE version: e.g. 1.3.1
  • operating system: Windows 10

code:
itc.plot_topo(title=‘Inter-coherence’, vmin=0., vmax=0.5, cmap=‘Reds’)

TypeError: plot_tfr_topomap() got an unexpected keyword argument ‘title’




Interactive operation!


This is reason

Hello,

As pointed out by @zuferlot, this argument was deprecated in version 1.2 and removed in version 1.3.
The plotting function returns a matplotlib figure. You should now add your title and any other customization to the figure directly with the matplotlib API.

Mathieu

But all my operations are performed on the MNE GUI, how can I modify the graphics generated by the MNE GUI through the matplotlib API? There doesn’t seem to be a similar solution

When you say “GUI”, do you mean MNELAB? GitHub - cbrnr/mnelab: MNELAB – a GUI for MNE

No, I am using python. when I plot the spectrum with MNE, this graphicsis interactive with the mouse. When I drag and drop this graph, it automatically calls plot_tfr_topomap() and presents the results of the time-frequency analysis of the dragged region. During this interaction with the graphicsis ,I cannot use the matplotlib API in my program to modify the automatically generated graphicsis.

Thank you for the clarification. I can reproduce with:

import numpy as np

import mne
from mne.datasets import somato
from mne.time_frequency import tfr_morlet

data_path = somato.data_path()
subject = "01"
task = "somato"
raw_fname = data_path / f"sub-{subject}" / "meg" / f"sub-{subject}_task-{task}_meg.fif"

# Setup for reading the raw data
raw = mne.io.read_raw_fif(raw_fname)
# crop and resample just to reduce computation time
raw.crop(120, 360).load_data().resample(200)
events = mne.find_events(raw, stim_channel="STI 014")

# picks MEG gradiometers
picks = mne.pick_types(raw.info, meg="grad", eeg=False, eog=True, stim=False)

# Construct Epochs
event_id, tmin, tmax = 1, -1.0, 3.0
epochs = mne.Epochs(
    raw,
    events,
    event_id,
    tmin,
    tmax,
    picks=picks,
    baseline=(None, 0),
    reject=dict(grad=4000e-13, eog=350e-6),
    preload=True,
)

freqs = np.logspace(*np.log10([6, 35]), num=8)
n_cycles = freqs / 2.0  # different number of cycle per frequency
power, itc = tfr_morlet(
    epochs,
    freqs=freqs,
    n_cycles=n_cycles,
    use_fft=True,
    return_itc=True,
    decim=3,
    n_jobs=None,
)

power.plot_topo(baseline=(-0.5, 0), mode="logratio", title="Average power")

And it is a bug due to the deprecation and removal of the argument. I will try to fix it today, and with some luck it will be in for version 1.4 which will be out soon.

Mathieu

1 Like

Thank you!

PR: Fix call to plot_tfr_topomap from interactive AverageTFR.plot_topo function by mscheltienne · Pull Request #11683 · mne-tools/mne-python · GitHub

Mathieu

Oh! By the way, I found this bug more than once. In other words, this bug doesn’t only occur with plot_tfr_topomap(). This bug occurs when using interactive image drawing, and this is at least the third time I’ve encountered it. But since I didn’t pay much attention to it before, I forgot what other drawing functions could have this bug. Sorry.

I did a grep through the codebase, so hopefully that PR fixes all your issues. If not, please report them!

Thanks,
Mathieu