Last active
August 29, 2015 13:56
-
-
Save teonbrooks/9102945 to your computer and use it in GitHub Desktop.
EDF concatenated file stim channel fix using the .mat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy as sp | |
import mne | |
mat = sp.io.loadmat('trig_s2.mat') | |
triggers, latency, urevent, duration, epoch = zip(*np.ravel(mat['triggers'])) | |
latency = np.array(latency).ravel() | |
triggers = np.array(triggers, int).ravel() | |
raw = mne.fiff.edf.read_raw_edf(raw.info,'s2_2.edf', preload=True) | |
stim_channel = np.zeros(raw.last_samp+1) | |
stim_channel[latency] = triggers | |
picks = mne.fiff.pick_types(meg=False, stim=True) | |
raw._data[picks] = stim_channel | |
raw.save('s2_2_stim_fixed.fif', verbose=False) | |
raw_fixed = mne.fiff.Raw('s2_2_stim_fixed.fif') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment