In [1]:
from mne import Epochs, find_events, set_eeg_reference
from time import time, strftime, gmtime
from collections import OrderedDict
from glob import glob
import os
from collections import OrderedDict
from mne import create_info, concatenate_raws
from mne.io import RawArray
from mne.channels import read_montage
import pandas as pd
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
import sys, os
sys.path.append(os.path.join(os.path.dirname(os.getcwd()), 'app','utils','jupyter'))
import utils
%matplotlib
In [2]:
files = ['/home/dano/BrainWaves Workspaces/Dano Test/Data/Dano/EEG/Dano-1-raw.csv']
replace_ch_names = None
raw = utils.load_data(files, replace_ch_names)
In [5]:
## Filtering Data
# Input
low_cutoff = 1
high_cutoff = 30
# Computation
raw.filter(low_cutoff, high_cutoff, method='iir');
In [7]:
## Epoch Data
# Input
event_id = {'House': 1, 'Face': 2}
tmin=-0.1
tmax=0.8
baseline = (tmin, tmax)
picks = None
reject = None
# Computation
events = find_events(raw)
# TODO: Figure out how to normalize and auto-reject Emotiv EEG data
epochs = Epochs(raw, events=events, event_id=event_id,
tmin=tmin, tmax=tmax, baseline=baseline, reject=reject, preload=True,
verbose=False, picks=picks)
# Output
{"totalEpochs": len(epochs.events), "dropPercentage": (1 - len(epochs.events)/len(events)) * 100, **{x: len(epochs[x]) for x in event_id}}
Out[7]:
In [18]:
## Plot ERPs
# Input
ch_ind = 3
# Computation
conditions = OrderedDict({key: [value] for (key, value) in event_id.items()})
# Output
X, y = utils.plot_conditions(epochs, ch_ind=ch_ind, conditions=conditions,
ci=97.5, n_boot=1000, title='',)