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

AverageTFR.plot_topo color scale bug #11247

Open
drammock opened this issue Oct 14, 2022 · 1 comment
Open

AverageTFR.plot_topo color scale bug #11247

drammock opened this issue Oct 14, 2022 · 1 comment

Comments

@drammock
Copy link
Member

drammock commented Oct 14, 2022

MWE adapted from #10920

import numpy as np
import mne

data_path = mne.datasets.sample.data_path()
subjects_dir = data_path / 'subjects'
raw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_raw.fif'

# Read the raw data
raw = mne.io.read_raw_fif(raw_fname)
raw.info['bads'] = ['MEG 2443']  # bad MEG channel

# Set up the epoching
events = mne.find_events(raw)

# pick data channel types
raw.pick(['meg', 'eeg', 'eog'])

# create epochs, leave room for cutting out edge artifact
epochs = mne.Epochs(raw, events, event_id=dict(left_aud=1),
                    tmin=-0.5, tmax=0.5, baseline=(None, 0),
                    preload=True, proj=False,
                    reject=dict(grad=4000e-13, mag=4e-12,
                                eeg=1e-4, eog=150e-6))

# done with eog now
del raw
epochs.pick(['meg', 'eeg'])

# set average reference
epochs.set_eeg_reference('average', projection=True)

# focus on alpha and beta oscillations
freqs = np.logspace(*np.log10([8, 35]), num=6)

# select subset of trials for speed
epochs = epochs[:10]

# time-frequency decomposition
average_tfr = mne.time_frequency.tfr_morlet(
    epochs, freqs=freqs, n_cycles=freqs / 2, return_itc=False,
    average=True)

average_tfr.plot_topo()

plotting average_tfr.plot_topo(picks=slice(0, 2)) or slice(0, 5) or even slice(0, 40) yields (partial) topo plots where at least some of the sensors have visible activity. I'm assuming some sort of bad color normalization (across sensors) is the cause, but that's a wild guess.

@mmagnuski
Copy link
Member

Part of the scaling problem may be due to very high response (10-fold judging from the colormap) on one MEG channel (MEG2313):

average_tfr.plot_topo(baseline=(None, 0), mode='percent')

image
image

Setting the vmax to something much lower than max value makes it better:

average_tfr.plot_topo(baseline=(None, 0), mode='percent',
                      vmin=-2.5, vmax=2.5)

image

maybe the automatic vmax choice in mne could be not max but something like 95th percentile of the data to be more robust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants