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

Function main

python_package/examples/tests/band_power.py:7–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6
7def 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
38if __name__ == "__main__":

Callers 1

band_power.pyFile · 0.70

Calls 14

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_board_descrMethod · 0.65
detrendMethod · 0.65
get_psd_welchMethod · 0.65
get_band_powerMethod · 0.65

Tested by

no test coverage detected