|
16 | 16 |
|
17 | 17 | ################################################################################################### |
18 | 18 |
|
| 19 | +import os.path |
| 20 | + |
19 | 21 | # General imports |
20 | 22 | import numpy as np |
21 | 23 | import matplotlib.pyplot as plt |
|
26 | 28 | from mne import io |
27 | 29 | from mne.datasets import sample |
28 | 30 | from mne.viz import plot_topomap |
29 | | -from mne.time_frequency import psd_welch |
30 | 31 |
|
31 | 32 | # FOOOF imports |
32 | 33 | from fooof import FOOOFGroup |
|
52 | 53 | ################################################################################################### |
53 | 54 |
|
54 | 55 | # Get the data path for the MNE example data |
55 | | -raw_fname = sample.data_path() + '/MEG/sample/sample_audvis_filt-0-40_raw.fif' |
56 | | -event_fname = sample.data_path() + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif' |
| 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') |
57 | 58 |
|
58 | 59 | # Load the example MNE data |
59 | 60 | raw = mne.io.read_raw_fif(raw_fname, preload=True, verbose=False) |
@@ -110,15 +111,16 @@ def check_nans(data, nan_policy='zero'): |
110 | 111 | # frequency representations - meaning we have to calculate power spectra. |
111 | 112 | # |
112 | 113 | # To do so, we will leverage the time frequency tools available with MNE, |
113 | | -# in the `time_frequency` module. In particular, we can use the ``psd_welch`` |
114 | | -# function, that takes in MNE data objects and calculates and returns power spectra. |
| 114 | +# in the `time_frequency` module. In particular, we can use the ``compute_psd`` |
| 115 | +# method, that takes in MNE data objects and calculates and returns power spectra. |
115 | 116 | # |
116 | 117 |
|
117 | 118 | ################################################################################################### |
118 | 119 |
|
119 | | -# Calculate power spectra across the the continuous data |
120 | | -spectra, freqs = psd_welch(raw, fmin=1, fmax=40, tmin=0, tmax=250, |
121 | | - n_overlap=150, n_fft=300) |
| 120 | +# Calculate power spectra across the continuous data |
| 121 | +psd = raw.compute_psd(method="welch", fmin=1, fmax=40, tmin=0, tmax=250, |
| 122 | + n_overlap=150, n_fft=300) |
| 123 | +spectra, freqs = psd.get_data(return_freqs=True) |
122 | 124 |
|
123 | 125 | ################################################################################################### |
124 | 126 | # Fitting Power Spectrum Models |
|
0 commit comments