- MNE-Python version: 0.23.0
- operating system: Ubuntu 18.04.5 LTS
-IDE: Pycharm-community
import matplotlib
import matplotlib.pyplot as plt
import mne
import numpy
matplotlib.use('Qt5Agg')
mne.set_log_level('warning')
# Load raw data
data_path = '/MNE/BrainVision/3.vhdr'
raw = mne.io.read_raw_brainvision(data_path, preload=True, verbose=False)
raw.info['line_freq'] = 50.
#raw.ch_names[28] = "AFz"
#raw.ch_names[60] = "Fpz"
raw.set_channel_types({'EOGr': 'eog', 'EOGl': 'eog'})
# Set montage
montage = mne.channels.make_standard_montage('easycap-M1')
raw.set_montage(montage, on_missing = 'ignore', match_case=False, verbose=False)
# Re-reference
raw.set_eeg_reference('average', projection=False, verbose=False)
raw.filter(l_freq=1, h_freq=45, fir_design='firwin', verbose=False)
# Construct epochs
# read events
events, event_id = mne.events_from_annotations(raw, verbose=False)
raw.info["events"] = events
raw.info["events_id"] = event_id
# Epoching
tmin, tmax = -1., 1. # in s
baseline = None
epochs = mne.Epochs(
raw, events=events,
event_id=[event_id['Stimulus/A']], tmin=tmin,
tmax=tmax, baseline=baseline, verbose=False)
#Save
root = '/MNE/BrainVision'
epochs.save(pathlib.Path(root) / 'epochs-epo.fif', overwrite = True)
Greeting,
After running the above code (which simply load brain vision EEG data ‘.vhdr’, set montage, reref, epoch, and save it ), I get the below error:
Traceback (most recent call last):
File “”, line 1, in
File “”, line 22, in save
File “/MNE/BrainVision/venv/lib/python3.6/site-packages/mne/epochs.py”, line 1814, in save
_save_split(this_epochs, fname, part_idx, n_parts, fmt)
File “/MNE/BrainVision/venv/lib/python3.6/site-packages/mne/epochs.py”, line 99, in _save_split
_save_part(fid, epochs, fmt, n_parts, next_fname, next_idx)
File “/MNE/BrainVision/venv/lib/python3.6/site-packages/mne/epochs.py”, line 112, in _save_part
write_meas_info(fid, info)
File “/MNE/BrainVision/venv/lib/python3.6/site-packages/mne/io/meas_info.py”, line 1584, in write_meas_info
if event.get(‘channels’) is not None:
AttributeError: ‘numpy.ndarray’ object has no attribute ‘get’
Could you please help what the source of problem might be…
Sincerely
Emanuel