Skip to content

Commit d9f3218

Browse files
committed
update mne example
1 parent 3bf4a00 commit d9f3218

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

examples/analyses/plot_mne_example.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Parameterizing neural power spectra with MNE, doing a topographical analysis.
66
77
This tutorial requires that you have `MNE <https://mne-tools.github.io/>`_
8-
installed.
8+
installed. This tutorial needs mne >= 1.2.
99
1010
If you don't already have MNE, you can follow instructions to get it
1111
`here <https://mne-tools.github.io/stable/getting_started.html>`_.
@@ -16,18 +16,14 @@
1616

1717
###################################################################################################
1818

19-
import os.path
20-
2119
# General imports
2220
import numpy as np
2321
import matplotlib.pyplot as plt
2422
from matplotlib import cm, colors, colorbar
2523

2624
# Import MNE, as well as the MNE sample dataset
2725
import mne
28-
from mne import io
2926
from mne.datasets import sample
30-
from mne.viz import plot_topomap
3127

3228
# FOOOF imports
3329
from fooof import FOOOFGroup
@@ -53,16 +49,15 @@
5349
###################################################################################################
5450

5551
# Get the data path for the MNE example data
56-
raw_fname = os.path.join(sample.data_path(), 'MEG', 'sample', 'sample_audvis_filt-0-40_raw.fif')
57-
event_fname = os.path.join(sample.data_path(), 'MEG', 'sample', 'sample_audvis_filt-0-40_raw-eve.fif')
52+
raw_fname = sample.data_path() / 'MEG' / 'sample' / 'sample_audvis_filt-0-40_raw.fif'
5853

5954
# Load the example MNE data
6055
raw = mne.io.read_raw_fif(raw_fname, preload=True, verbose=False)
6156

6257
###################################################################################################
6358

6459
# Select EEG channels from the dataset
65-
raw = raw.pick_types(meg=False, eeg=True, eog=False, exclude='bads')
60+
raw = raw.pick(['eeg'], exclude='bads')
6661

6762
###################################################################################################
6863

@@ -195,7 +190,7 @@ def check_nans(data, nan_policy='zero'):
195190
###################################################################################################
196191

197192
# Plot the topography of alpha power
198-
plot_topomap(alpha_pw, raw.info, cmap=cm.viridis, contours=0);
193+
mne.viz.plot_topomap(alpha_pw, raw.info, cmap=cm.viridis, contours=0, size=4)
199194

200195
###################################################################################################
201196
#
@@ -216,8 +211,7 @@ def check_nans(data, nan_policy='zero'):
216211
band_power = check_nans(get_band_peak_fg(fg, band_def)[:, 1])
217212

218213
# Create a topomap for the current oscillation band
219-
mne.viz.plot_topomap(band_power, raw.info, cmap=cm.viridis, contours=0,
220-
axes=axes[ind], show=False);
214+
mne.viz.plot_topomap(band_power, raw.info, cmap=cm.viridis, contours=0, axes=axes[ind])
221215

222216
# Set the plot title
223217
axes[ind].set_title(label + ' power', {'fontsize' : 20})
@@ -270,7 +264,7 @@ def check_nans(data, nan_policy='zero'):
270264
###################################################################################################
271265

272266
# Plot the topography of aperiodic exponents
273-
plot_topomap(exps, raw.info, cmap=cm.viridis, contours=0)
267+
mne.viz.plot_topomap(exps, raw.info, cmap=cm.viridis, contours=0, size=4)
274268

275269
###################################################################################################
276270
#
@@ -299,6 +293,3 @@ def check_nans(data, nan_policy='zero'):
299293
# In this example, we have seen how to apply power spectrum models to data that is
300294
# managed and processed with MNE.
301295
#
302-
303-
###################################################################################################
304-
#

0 commit comments

Comments
 (0)