()
| 5 | |
| 6 | |
| 7 | def main(): |
| 8 | BoardShim.enable_dev_board_logger() |
| 9 | |
| 10 | # use synthetic board for demo |
| 11 | params = BrainFlowInputParams() |
| 12 | board_id = BoardIds.SYNTHETIC_BOARD.value |
| 13 | board_descr = BoardShim.get_board_descr(board_id) |
| 14 | sampling_rate = int(board_descr['sampling_rate']) |
| 15 | board = BoardShim(board_id, params) |
| 16 | board.prepare_session() |
| 17 | board.start_stream() |
| 18 | BoardShim.log_message(LogLevels.LEVEL_INFO.value, 'start sleeping in the main thread') |
| 19 | time.sleep(10) |
| 20 | nfft = DataFilter.get_nearest_power_of_two(sampling_rate) |
| 21 | data = board.get_board_data() |
| 22 | board.stop_stream() |
| 23 | board.release_session() |
| 24 | |
| 25 | eeg_channels = board_descr['eeg_channels'] |
| 26 | # second eeg channel of synthetic board is a sine wave at 10Hz, should see huge alpha |
| 27 | eeg_channel = eeg_channels[1] |
| 28 | # optional detrend |
| 29 | DataFilter.detrend(data[eeg_channel], DetrendOperations.LINEAR.value) |
| 30 | psd = DataFilter.get_psd_welch(data[eeg_channel], nfft, nfft // 2, sampling_rate, |
| 31 | WindowOperations.BLACKMAN_HARRIS.value) |
| 32 | |
| 33 | band_power_alpha = DataFilter.get_band_power(psd, 7.0, 13.0) |
| 34 | band_power_beta = DataFilter.get_band_power(psd, 14.0, 30.0) |
| 35 | print("alpha/beta:%f", band_power_alpha / band_power_beta) |
| 36 | |
| 37 | |
| 38 | if __name__ == "__main__": |
no test coverage detected