# Time Frequency Analysis (wavelet) ```python %matplotlib qt ``` ```python import mne import matplotlib.pyplot as plt import pandas as pd import numpy as np from mne.time_frequency import tfr_morlet, psd_multitaper data_path = '/Users/kevinhsu/Documents/D/000_experiment/compounding_VR/2013_megdata' sid = 1 epochs_file = data_path + '/%.3dnn_raw_epo.fif' % sid epochs = mne.read_epochs(epochs_file) epochs ``` Reading /Users/kevinhsu/Documents/D/000_experiment/compounding_VR/2013_megdata/001nn_raw_epo.fif ... Isotrak not found Found the data of interest: t = -100.00 ... 700.00 ms 0 CTF compensation matrices available 287 matching events found Applying baseline correction (mode: mean) Not setting metadata 0 projection items activated <EpochsFIF | 287 events (all good), -0.1 - 0.7 sec, baseline [-0.1, 0], ~275.7 MB, data loaded, 'pseudo': 143 'words': 144> ```python epochs.plot_psd(fmin=2., fmax=40.) ``` Using multitaper spectrum estimation with 7 DPSS windows ![](https://i.imgur.com/pbxftqg.png) ```python # define frequencies of interest (log-spaced) #freqs = np.logspace(*np.log10([6, 35]), num=8) freqs = np.arange(2., 30., 3.) n_cycles = freqs / 2. # 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=1) ``` ```python power.plot_topo(baseline=(-0.1, 0), mode='logratio', title='Average power') ``` Applying baseline correction (mode: logratio) ![](https://i.imgur.com/l1CQSrC.png) ```python power.plot_topomap(ch_type='mag', tmin=0.1, tmax=0.2, fmin=5, fmax=7, baseline=(-0.1, 0), mode='logratio', title='Theta', show=False) ``` Applying baseline correction (mode: logratio) ![](https://i.imgur.com/oP1eRNM.png) ```python power.plot_topomap(ch_type='mag', tmin=0.1, tmax=0.2, fmin=8, fmax=12, baseline=(-0.1, 0), mode='logratio', title='Alpha', show=False) ``` Applying baseline correction (mode: logratio) ![](https://i.imgur.com/CQiBO6X.png) ```python ```