<jupyter_start><jupyter_text>Reading epochs from a raw FIF fileThis script shows how to read the epochs from a raw file givena list of events. For illustration, we compute the evoked responsesfor both MEG and EEG data by averaging all the epochs.<jupyter_code># Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#
# License: BSD (3-clause)

import mne
from mne import io
from mne.datasets import sample

print(__doc__)

data_path = sample.data_path()<jupyter_output><empty_output><jupyter_text>Set parameters<jupyter_code>raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
event_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw-eve.fif'
event_id, tmin, tmax = 1, -0.2, 0.5

# Setup for reading the raw data
raw = io.read_raw_fif(raw_fname)
events = mne.read_events(event_fname)

# Set up pick list: EEG + MEG - bad channels (modify to your needs)
raw.info['bads'] += ['MEG 2443', 'EEG 053']  # bads + 2 more
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=True, eog=True,
                       exclude='bads')

# Read epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
                    picks=picks, baseline=(None, 0), preload=True,
                    reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))

evoked = epochs.average()  # average epochs to get the evoked response<jupyter_output><empty_output><jupyter_text>Show result<jupyter_code>evoked.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11925976696367376, 'fraction_numerical': 0.023303632625085675, 'mean_word_length': 4.367647058823529, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '18347', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 568, 'n_tokens_neox': 531, 'n_words': 135, 'path': '0.13/_downloads/plot_read_epochs.ipynb', 'repo_name': 'drammock/mne-tools.github.io', 'size': '1529'}