Member-only story
Visualizing Brain Waves with Python
Using the MNE library
Published in
9 min readJun 4, 2021
What is MNE-Python?
MNE-Python is an open-source Python module for processing, analysis, and visualization of functional neuroimaging data (EEG, MEG, sEEG, ECoG, and fNIRS).
Let’s try it out
First, import the necessary libraries. You will need to install mne-python and numpy prior to running the code below.
import os
import numpy as np
import mne
Here we import MNE’s sample data.
sample_data_folder = mne.datasets.sample.data_path()
sample_data_evk_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis-ave.fif')
evokeds_list = mne.read_evokeds(sample_data_evk_file, baseline=(None, 0),
proj=True, verbose=False)# Show the condition names, and reassure ourselves that baseline correction has been applied.
for e in evokeds_list:
print(f'Condition: {e.comment}, baseline: {e.baseline}')
Out:
Condition: Left Auditory, baseline: (-0.19979521315838786, 0.0)
Condition: Right Auditory, baseline: (-0.19979521315838786, 0.0)
Condition: Left visual, baseline: (-0.19979521315838786, 0.0)
Condition: Right visual, baseline…