<jupyter_start><jupyter_text>Time-frequency analysis using multitaper methodThis examples computes induced power and intertrialcoherence (ITC) using a multitaper method on a somato sensory MEG data.The power plot is rendered so that baseline is mean zero.<jupyter_code># Authors: <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

import numpy as np

import mne
from mne import io
from mne.time_frequency import tfr_multitaper
from mne.datasets import somato

print(__doc__)<jupyter_output><empty_output><jupyter_text>Load real somatosensory sample data.<jupyter_code>data_path = somato.data_path()
raw_fname = data_path + '/MEG/somato/sef_raw_sss.fif'
event_id, tmin, tmax = 1, -1., 3.

# Setup for reading the raw data
raw = io.Raw(raw_fname)
baseline = (None, 0)
events = mne.find_events(raw, stim_channel='STI 014')

# Pick a good channel for somatosensory responses.
picks = [raw.info['ch_names'].index('MEG 1142'), ]

epochs = mne.Epochs(raw, events, event_id, tmin, tmax, picks=picks,
                    baseline=baseline, reject=dict(grad=4000e-13))<jupyter_output><empty_output><jupyter_text>Calculate power<jupyter_code>freqs = np.arange(5., 50., 2.)  # define frequencies of interest
n_cycles = freqs / 2.  # 0.5 second time windows for all frequencies

# Choose time x (full) bandwidth product
time_bandwidth = 4.0  # With 0.5 s time windows, this gives 8 Hz smoothing

power, itc = tfr_multitaper(epochs, freqs=freqs, n_cycles=n_cycles,
                            use_fft=True, time_bandwidth=time_bandwidth,
                            return_itc=True, n_jobs=1)

# Plot results (with baseline correction only for power)
power.plot([0], baseline=(-0.5, 0), mode='mean', title='MEG 1142 - Power')
itc.plot([0], title='MEG 1142 - Intertrial Coherence')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10831937465103295, 'fraction_numerical': 0.024567280848687884, 'mean_word_length': 4.582554517133956, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '404426', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 661, 'n_tokens_neox': 612, 'n_words': 170, 'path': '0.14/_downloads/plot_time_frequency_multitaper_sensors.ipynb', 'repo_name': 'drammock/mne-tools.github.io', 'size': '1816'}