-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #975 from OpenBCI/development
GUI 5.0.5
- Loading branch information
Showing
17 changed files
with
997 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import argparse | ||
import time | ||
import numpy as np | ||
import brainflow | ||
from brainflow.board_shim import BoardShim, BrainFlowInputParams, LogLevels, BoardIds | ||
from brainflow.data_filter import DataFilter, FilterTypes, AggOperations | ||
from pylsl import StreamInfo, StreamOutlet | ||
|
||
#from queue import Queue | ||
BoardShim.enable_dev_board_logger() | ||
params = BrainFlowInputParams() | ||
params.serial_port = '/dev/cu.usbserial-DM00D7TW' | ||
board = BoardShim(BoardIds.CYTON_BOARD.value, params) # added cyton board id here | ||
srate = board.get_sampling_rate(BoardIds.CYTON_BOARD.value) | ||
board.prepare_session() | ||
board.start_stream() | ||
eeg_chan = BoardShim.get_eeg_channels(BoardIds.CYTON_BOARD.value) | ||
aux_chan = BoardShim.get_accel_channels(BoardIds.CYTON_BOARD.value) | ||
|
||
print('EEG channels:') | ||
print(eeg_chan) | ||
print('Accelerometer channels') | ||
print(aux_chan) | ||
|
||
# define lsl streams | ||
|
||
# Defining stream info: | ||
name = 'OpenBCIEEG' | ||
ID = 'OpenBCIEEG' | ||
channels = 8 | ||
sample_rate = 250 | ||
datatype = 'float32' | ||
streamType = 'EEG' | ||
|
||
print(f"Creating LSL stream for EEG. \nName: {name}\nID: {ID}\n") | ||
info_eeg = StreamInfo(name, streamType, channels, sample_rate, datatype, ID) | ||
chns = info_eeg.desc().append_child("channels") | ||
for label in ["AFp1", "AFp2", "C3", "C4", "P7", "P8", "O1", "O2"]: | ||
ch = chns.append_child("channel") | ||
ch.append_child_value("label", label) | ||
info_aux = StreamInfo('OpenBCIAUX', 'AUX', 3, 250, 'float32', 'OpenBCItestAUX') | ||
chns = info_aux.desc().append_child("channels") | ||
for label in ["X", "Y", "Z"]: | ||
ch = chns.append_child("channel") | ||
ch.append_child_value("label", label) | ||
outlet_aux = StreamOutlet(info_aux) | ||
outlet_eeg = StreamOutlet(info_eeg) | ||
|
||
# construct a numpy array that contains only eeg channels and aux channels with correct scaling | ||
# this streams to lsl | ||
while True: | ||
data = board.get_board_data() # this gets data continiously | ||
# don't send empty data | ||
if len(data[0]) < 1 : continue | ||
eeg_data = data[eeg_chan] | ||
aux_data = data[aux_chan] | ||
#print(scaled_eeg_data) | ||
#print(scaled_aux_data) | ||
#print('------------------------------------------------------------------------------------------') | ||
eegchunk = [] | ||
for i in range(len(eeg_data[0])): | ||
eegchunk.append((eeg_data[:,i]).tolist()) #scale data here | ||
outlet_eeg.push_chunk(eegchunk) | ||
auxchunk = [] | ||
for i in range(len(aux_data[0])): | ||
auxchunk.append((aux_data[:,i]).tolist()) #scale data here | ||
outlet_aux.push_chunk(auxchunk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import os | ||
import csv | ||
|
||
|
||
def split(filehandler, delimiter=',', row_limit=4000000, | ||
output_name_template='output_%s.csv', output_path='.', keep_headers=True): | ||
|
||
reader = csv.reader(filehandler, delimiter=delimiter) | ||
current_piece = 1 | ||
current_out_path = os.path.join( | ||
output_path, | ||
output_name_template % current_piece | ||
) | ||
current_out_writer = csv.writer(open(current_out_path, 'w', newline=''), delimiter=delimiter) | ||
current_limit = row_limit | ||
headers = [] | ||
if keep_headers: | ||
for i in range (5): | ||
headerRow = next(reader); | ||
headers.append(headerRow) | ||
current_out_writer.writerow(headerRow) | ||
|
||
for i, row in enumerate(reader): | ||
if i + 1 > current_limit: | ||
current_piece += 1 | ||
current_limit = row_limit * current_piece | ||
current_out_path = os.path.join( | ||
output_path, | ||
output_name_template % current_piece | ||
) | ||
current_out_writer = csv.writer(open(current_out_path, 'w', newline=''), delimiter=delimiter) | ||
if keep_headers: | ||
for headerRowI in headers: | ||
current_out_writer.writerow(headerRowI) | ||
print (headerRowI) | ||
print (i) | ||
current_out_writer.writerow(row) | ||
|
||
split(open('OpenBCI-RAW-2021-04-05_21-49-12.txt', 'r')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.