()
| 7 | |
| 8 | |
| 9 | def 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 | |
| 37 | if __name__ == "__main__": |
no test coverage detected