-
Notifications
You must be signed in to change notification settings - Fork 71
/
analyze_channel.py
75 lines (53 loc) · 1.91 KB
/
analyze_channel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import EEGrunt
# Required settings #
# Data source. Options:
# 'muse' for data from Muse headsets.
# 'muse-lsl' for data from Muse headsets recorded with Lab Streaming Layer.
# 'openbci' for OpenBCI Cyton data recorded with the OpenBCI GUI;
# 'openbci-ganglion' for OpenBCI Ganglion data recorded with the OpenBCI GUI;
# 'openbci-openvibe' for Cyton data recorded with OpenViBE's csv writer
# 'openbci-ganglion-openvibe' for Ganglion data recorded with OpenViBE's csv writer
source = 'openbci'
# Path to EEG data file
path = 'data/'
# EEG data file name
filename = 'eegrunt-obci-raw-test-data.csv'
# Session title (used in some plots and such)
session_title = "EEGrunt OpenBCI Sample Data"
# Channel
channel = 1
# Initialize
EEG = EEGrunt.EEGrunt(path, filename, source, session_title)
# Here we can set some additional properties
# The 'plot' property determines whether plots are displayed or saved.
# Possible values are 'show' and 'save'
EEG.plot = 'show'
# Load the EEG data
EEG.load_data()
EEG.load_channel(channel)
print("Processing channel "+ str(EEG.channel))
# Removes OpenBCI DC offset
EEG.remove_dc_offset()
# Notches 60hz noise (if you're in Europe, switch to 50Hz)
EEG.notch_mains_interference()
# Make signal plot
EEG.signalplot()
# Calculates spectrum data and stores as EEGrunt attribute(s) for reuse
EEG.get_spectrum_data()
# Returns bandpassed data
# (uses scipy.signal butterworth filter)
start_Hz = 1
stop_Hz = 50
EEG.data = EEG.bandpass(start_Hz,stop_Hz)
# Make Spectrogram
EEG.spectrogram()
# Line graph of amplitude over time for a given frequency range.
# Arguments are start frequency, end frequency, and label
EEG.plot_band_power(8,12,"Alpha")
# Power spectrum plot
EEG.plot_spectrum_avg_fft()
# Plot coherence fft (not tested recently...)
# s1 = bandpass(seginfo["data"][:,1-1], config['band'])
# s2 = bandpass(seginfo["data"][:,8-1], config['band'])
# plot_coherence_fft(s1,s2,"1","8")
EEG.showplots()