简体   繁体   中英

MNE how to save full raw EEG signal with events as a matlab file?

raw, timestamp = ur.MNE_Read_EDF(path)
mne_events, events_dict = ev.MNE_prepare_events(path, timestamp)
epochs = mne.Epochs(raw, mne_events, events_dict, tmin=-0.5, tmax=0.5)
signal = epochs.plot(block=True)

This seems simple but I'm lost. I have raw eeg signal in edf files and events in a csv file. I managed to create epochs by those events and then plot the raw signal with marked events, however I need to transfer it into a file that's accessible in matlab. I can't use scipy.io.savemat for a plot I guess? I can't simply load these files into matlab because somehow it desynchronizes epochs, probably due to averaged sampling frequency. MNE doesn't do this, but further analysis has to be conducted in matlab. Help much appreciated, I can't find an answer on MNE website.

For getting the raw epochs data you could call the .get_data() method of the Epochs class. This will provide your with a 3D numpy array of shape (n_epochs, n_channels, n_times).

To get your events data, you can use the find_events function, which will return events :

Returns:

events : array, shape = (n_events, 3)

All events that were found. The first column contains the event time in samples and the third column contains the event id. For output = 'onset' or 'step', the second column contains the value of the stim channel immediately before the event/step. For output = 'offset', the second column contains the value of the stim channel after the event offset.

Actually, you probably have your event data already in mne_events in your example.

These data can be saved with the scipy.io.savemat function that you mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM