MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / main

Function main

python_package/examples/tests/serialization.py:9–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8
9def main():
10 BoardShim.enable_dev_board_logger()
11
12 # use synthetic board for demo
13 params = BrainFlowInputParams()
14 board = BoardShim(BoardIds.SYNTHETIC_BOARD.value, params)
15 board.prepare_session()
16 board.start_stream()
17 BoardShim.log_message(LogLevels.LEVEL_INFO.value, 'start sleeping in the main thread')
18 time.sleep(10)
19 data = board.get_board_data()
20 board.stop_stream()
21 board.release_session()
22
23 # demo how to convert it to pandas DF and plot data
24 eeg_channels = BoardShim.get_eeg_channels(BoardIds.SYNTHETIC_BOARD.value)
25 df = pd.DataFrame(np.transpose(data))
26 print('Data From the Board')
27 print(df.head(10))
28
29 # demo for data serialization using brainflow API, we recommend to use it instead pandas.to_csv()
30 DataFilter.write_file(data, 'test.csv', 'w') # use 'a' for append mode
31 restored_data = DataFilter.read_file('test.csv')
32 restored_df = pd.DataFrame(np.transpose(restored_data))
33 print('Data From the File')
34 print(restored_df.head(10))
35
36
37if __name__ == "__main__":

Callers 1

serialization.pyFile · 0.70

Calls 12

prepare_sessionMethod · 0.95
start_streamMethod · 0.95
get_board_dataMethod · 0.95
stop_streamMethod · 0.95
release_sessionMethod · 0.95
BoardShimClass · 0.90
get_eeg_channelsMethod · 0.65
write_fileMethod · 0.65
read_fileMethod · 0.65
log_messageMethod · 0.45

Tested by

no test coverage detected