Skip to content

Instantly share code, notes, and snippets.

@teonbrooks
teonbrooks / check_bad_chs
Created February 5, 2014 21:06
Checking Bad Channels
def check_bad_chs(self, threshold=0.05, reject=3e-12, n_chan=5):
"""
Check for flat-line channels or channels that repeatedly exceeded
threshold.
"""
ds = self.load_events(drop_bad_chs=False)
ds = ds[ds['experiment'] == 'fixation']
threshold = ds.n_cases * threshold
epochs = E.load.fiff.mne_epochs(ds, tmin=-.2, tmax=.6,
drop_bad_chs=False, verbose=False,
@teonbrooks
teonbrooks / edf_raw_fix.py
Last active August 29, 2015 13:56
EDF concatenated file stim channel fix using the .mat
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)
@teonbrooks
teonbrooks / test_big_bdf.py
Created September 23, 2014 13:28
A test for mne-python bdf reader for larger files
import os.path as op
import inspect
from nose.tools import assert_equal, assert_true
from numpy.testing import assert_array_almost_equal, assert_array_equal
from numpy.testing import assert_raises
from scipy import io
import numpy as np
from mne.externals.six import iterbytes
import mne
# Make sure that your header, marker, and data file are in the same directory
fname_raw = 'path/to/header_file.vhdr'
# You can specify the EOG channels, and the miscellaneous channels
eog = []
misc = []
# to begin working with MNE, the only thing you need to specify is the header file