Skip to content

Commit d4ed309

Browse files
committed
updates
1 parent c14d92c commit d4ed309

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

NFB_tools.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
Created on Sat Mar 23 14:15:36 2019
66
77
@author: ssshe
8+
9+
10+
Adapted from https://github.com/NeuroTechX/bci-workshop
11+
812
"""
913

1014
# Most code comes from bci_workshop_tools
@@ -62,19 +66,33 @@ def GrattonEmcpRaw(ch_names, n_chEEG, data_epoch):
6266
data_epoch (numpy.ndarray): feature matrix of shape [number of feature points,
6367
number of different features]
6468
"""
69+
70+
# VEOG (eyeblink) correction
6571
raw_eeg = data_epoch[:,:n_chEEG] #get EEG data only
6672
raw_eeg = raw_eeg.T
6773
# eog_idx = [int(ch_names.index('HEOG')),int(ch_names.index('VEOG'))]
6874
eog_idx = int(ch_names.index('VEOG')) #for eyeblink correction
6975
raw_eog = np.zeros((data_epoch.shape[0],1)) #pre-allocate
7076
raw_eog[:,0] = data_epoch[:,eog_idx]
7177
raw_eog = raw_eog.T
72-
78+
# Calculate beta values
7379
beta = np.linalg.solve(np.dot(raw_eog,raw_eog.T), np.dot(raw_eog,raw_eeg.T))
7480
eeg_corrected = (raw_eeg.T - np.dot(raw_eog.T,beta)).T
75-
7681
data_epoch[:,:n_chEEG] = eeg_corrected.T #replace w/corrected data
82+
83+
# HEOG (eye movemrny) correction
84+
raw_eegH = data_epoch[:,:n_chEEG] #get EEG data only
85+
raw_eegH = raw_eegH.T
86+
eog_idxH = int(ch_names.index('HEOG')) #for eyeblink correction
87+
raw_eogH = np.zeros((data_epoch.shape[0],1)) #pre-allocate
88+
raw_eogH[:,0] = data_epoch[:,eog_idxH]
89+
raw_eogH = raw_eogH.T
90+
# Calculate beta values
91+
betaH = np.linalg.solve(np.dot(raw_eogH,raw_eogH.T), np.dot(raw_eogH,raw_eegH.T))
92+
eeg_correctedH = (raw_eegH.T - np.dot(raw_eogH.T,betaH)).T
93+
data_epoch[:,:n_chEEG] = eeg_correctedH.T #replace w/corrected data
7794

95+
7896
return data_epoch
7997

8098

NFB_try1.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
@author: S3
44
Created on Tue Mar 5 11:09:36 2019
55
6+
7+
Adapted from https://github.com/NeuroTechX/bci-workshop
8+
69
"""
710
# Most code comes from bci_workshop
811

@@ -23,7 +26,7 @@
2326
#------------------------------------------------------------------------------
2427
#==============================================================================
2528

26-
29+
2730

2831
# first resolve an EEG stream on the lab network
2932
print("looking for an EEG stream...")

0 commit comments

Comments
 (0)