Skip to content
Snippets Groups Projects
Commit af6957a2 authored by William G. Tresselt's avatar William G. Tresselt
Browse files

Added failsafe for speller, will only take as much data as duration says

parent 50ac8cfd
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,8 @@ channels = ['Fp1', 'Fz', 'F3', 'F7', 'F9', 'FC5', 'FC1', 'C3', 'T7', 'CP5', 'CP1 ...@@ -12,6 +12,8 @@ channels = ['Fp1', 'Fz', 'F3', 'F7', 'F9', 'FC5', 'FC1', 'C3', 'T7', 'CP5', 'CP1
removed_channels = ['Fp1', 'F8', 'F7', 'Fp2', 'F3', 'F4'] removed_channels = ['Fp1', 'F8', 'F7', 'Fp2', 'F3', 'F4']
#frequencies_main = [4,5,6,7,9,11] #frequencies_main = [4,5,6,7,9,11]
frequencies_main = [4,5,5.5,6,7,7.4] frequencies_main = [4,5,5.5,6,7,7.4]
#frequencies_main = [8.18,9,10,11.25,12.86,15]
frequencies = ['8.18_sin_h1','8.18_cos_h1','8.18_sin_h2','8.18_cos_h2','8.18_sin_h3','8.18_cos_h3', frequencies = ['8.18_sin_h1','8.18_cos_h1','8.18_sin_h2','8.18_cos_h2','8.18_sin_h3','8.18_cos_h3',
'9_sin_h1', '9_cos_h1','9_sin_h2', '9_cos_h2','9_sin_h3', '9_cos_h3', '9_sin_h1', '9_cos_h1','9_sin_h2', '9_cos_h2','9_sin_h3', '9_cos_h3',
'10_sin_h1','10_cos_h1','10_sin_h2','10_cos_h2','10_sin_h3','10_cos_h3', '10_sin_h1','10_cos_h1','10_sin_h2','10_cos_h2','10_sin_h3','10_cos_h3',
...@@ -141,8 +143,11 @@ while True: ...@@ -141,8 +143,11 @@ while True:
# If buffer is filled with data ready to be compared in CCA, and the start of the buffer is the start of # If buffer is filled with data ready to be compared in CCA, and the start of the buffer is the start of
# the Eye Tracking data (Eye Tracking trigger) # the Eye Tracking data (Eye Tracking trigger)
if (len(buffer) == fragment_samples) and buffer[0][0] == 1 and buffer[0][fragment_samples-round(delay*fs)] != 0: if (len(buffer) == fragment_samples) and buffer[0][0] == 1:
print(len(buffer)) if (buffer[fragment_samples - round(delay * fs) - 1][0] != (fragment_samples - round(delay * fs))):
print("Found invalid stare")
continue
fragment = np.array(buffer[:fragment_samples]) fragment = np.array(buffer[:fragment_samples])
fragment_eeg = np.array(buffer_eeg[:fragment_samples]) fragment_eeg = np.array(buffer_eeg[:fragment_samples])
...@@ -151,7 +156,7 @@ while True: ...@@ -151,7 +156,7 @@ while True:
# Makes both streams to a single dataframe # Makes both streams to a single dataframe
df = pd.concat([pd.DataFrame(np.array(fragment)), pd.DataFrame(np.array(fragment_eeg))], axis=1, join='inner') df = pd.concat([pd.DataFrame(np.array(fragment)), pd.DataFrame(np.array(fragment_eeg))], axis=1, join='inner')
df.columns = ['N'] + channels
# If any delay added, shift signal accordingly # If any delay added, shift signal accordingly
df['N'] = df['N'].shift(round(delay * fs)) df['N'] = df['N'].shift(round(delay * fs))
df = df.iloc[round(delay * fs):] df = df.iloc[round(delay * fs):]
......
...@@ -17,6 +17,7 @@ removed_channels = ['Fp1', 'F8', 'F7', 'Fp2', 'F3', 'F4'] ...@@ -17,6 +17,7 @@ removed_channels = ['Fp1', 'F8', 'F7', 'Fp2', 'F3', 'F4']
#The frequencies used for the SSVEP speller #The frequencies used for the SSVEP speller
#frequencies_main = [4,5,6,7,9,11] #frequencies_main = [4,5,6,7,9,11]
frequencies_main = [4,5,5.5,6,7,7.4] frequencies_main = [4,5,5.5,6,7,7.4]
#frequencies_main = [8.18,9,10,11.25,12.86,15]
#The channels used for the BCI Speller combined with CCA #The channels used for the BCI Speller combined with CCA
occ_channels = ['O1', 'O2', 'Oz', 'P3', 'P4', 'Pz', 'P7', 'P8'] occ_channels = ['O1', 'O2', 'Oz', 'P3', 'P4', 'Pz', 'P7', 'P8']
...@@ -216,8 +217,12 @@ while True: ...@@ -216,8 +217,12 @@ while True:
# If buffer is filled with data ready to be compared in CCA, and the start of the buffer is the start of # If buffer is filled with data ready to be compared in CCA, and the start of the buffer is the start of
# the Eye Tracking data (Eye Tracking trigger) # the Eye Tracking data (Eye Tracking trigger)
if (len(buffer) == fragment_samples) and buffer[0][0] == 1 and buffer[0][fragment_samples-round(delay*fs)] != 0:
print(len(buffer)) if (len(buffer) == fragment_samples) and (buffer[0][0] == 1):
if(buffer[fragment_samples - round(delay * fs)-1][0] != (fragment_samples-round(delay * fs))):
print("Found invalid stare")
continue
fragment = np.array(buffer[:fragment_samples]) fragment = np.array(buffer[:fragment_samples])
fragment_eeg = np.array(buffer_eeg[:fragment_samples]) fragment_eeg = np.array(buffer_eeg[:fragment_samples])
triggered = True triggered = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment