diff --git a/examples/analyses/plot_mne_example.py b/examples/analyses/plot_mne_example.py index 1e46dafb9..deef1f7a4 100644 --- a/examples/analyses/plot_mne_example.py +++ b/examples/analyses/plot_mne_example.py @@ -5,7 +5,7 @@ Parameterizing neural power spectra with MNE, doing a topographical analysis. This tutorial requires that you have `MNE `_ -installed. +installed. This tutorial needs mne >= 1.2. If you don't already have MNE, you can follow instructions to get it `here `_. @@ -23,10 +23,7 @@ # Import MNE, as well as the MNE sample dataset import mne -from mne import io from mne.datasets import sample -from mne.viz import plot_topomap -from mne.time_frequency import psd_welch # FOOOF imports from fooof import FOOOFGroup @@ -52,8 +49,7 @@ ################################################################################################### # Get the data path for the MNE example data -raw_fname = sample.data_path() + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' -event_fname = sample.data_path() + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif' +raw_fname = sample.data_path() / 'MEG' / 'sample' / 'sample_audvis_filt-0-40_raw.fif' # Load the example MNE data raw = mne.io.read_raw_fif(raw_fname, preload=True, verbose=False) @@ -61,7 +57,7 @@ ################################################################################################### # Select EEG channels from the dataset -raw = raw.pick_types(meg=False, eeg=True, eog=False, exclude='bads') +raw = raw.pick(['eeg'], exclude='bads') ################################################################################################### @@ -110,15 +106,16 @@ def check_nans(data, nan_policy='zero'): # frequency representations - meaning we have to calculate power spectra. # # To do so, we will leverage the time frequency tools available with MNE, -# in the `time_frequency` module. In particular, we can use the ``psd_welch`` -# function, that takes in MNE data objects and calculates and returns power spectra. +# in the `time_frequency` module. In particular, we can use the ``compute_psd`` +# method, that takes in MNE data objects and calculates and returns power spectra. # ################################################################################################### -# Calculate power spectra across the the continuous data -spectra, freqs = psd_welch(raw, fmin=1, fmax=40, tmin=0, tmax=250, - n_overlap=150, n_fft=300) +# Calculate power spectra across the continuous data +psd = raw.compute_psd(method="welch", fmin=1, fmax=40, tmin=0, tmax=250, + n_overlap=150, n_fft=300) +spectra, freqs = psd.get_data(return_freqs=True) ################################################################################################### # Fitting Power Spectrum Models @@ -193,7 +190,7 @@ def check_nans(data, nan_policy='zero'): ################################################################################################### # Plot the topography of alpha power -plot_topomap(alpha_pw, raw.info, cmap=cm.viridis, contours=0); +mne.viz.plot_topomap(alpha_pw, raw.info, cmap=cm.viridis, contours=0, size=4) ################################################################################################### # @@ -214,8 +211,7 @@ def check_nans(data, nan_policy='zero'): band_power = check_nans(get_band_peak_fg(fg, band_def)[:, 1]) # Create a topomap for the current oscillation band - mne.viz.plot_topomap(band_power, raw.info, cmap=cm.viridis, contours=0, - axes=axes[ind], show=False); + mne.viz.plot_topomap(band_power, raw.info, cmap=cm.viridis, contours=0, axes=axes[ind]) # Set the plot title axes[ind].set_title(label + ' power', {'fontsize' : 20}) @@ -268,7 +264,7 @@ def check_nans(data, nan_policy='zero'): ################################################################################################### # Plot the topography of aperiodic exponents -plot_topomap(exps, raw.info, cmap=cm.viridis, contours=0) +mne.viz.plot_topomap(exps, raw.info, cmap=cm.viridis, contours=0, size=4) ################################################################################################### # @@ -297,6 +293,3 @@ def check_nans(data, nan_policy='zero'): # In this example, we have seen how to apply power spectrum models to data that is # managed and processed with MNE. # - -################################################################################################### -# diff --git a/requirements-docs.txt b/requirements-docs.txt index 1f36fc9f5..e43038411 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -10,7 +10,7 @@ matplotlib tqdm # Requirements for running the examples -mne +mne > 1.2 # Requirements for running the motivations neurodsp >= 2.0.0 \ No newline at end of file