API Reference
BoardShim(board_id, params)
Section titled “BoardShim(board_id, params)”Creates a board handle. Does not open a connection or allocate resources yet.
board = BoardShim(BoardIds.NEUROPAWN_KNIGHT_BOARD, params)prepare_session()
Section titled “prepare_session()”Opens the serial connection to the board and allocates BrainFlow’s internal
resources. Must be called before start_stream(). Raises an exception if the
port cannot be opened or the board is not detected.
board.prepare_session()start_stream(buffer_size)
Section titled “start_stream(buffer_size)”Starts the internal ring buffer and begins reading packets from the board.
buffer_size is the number of samples the buffer can hold before wrapping —
450000 is sufficient for most use cases.
board.start_stream(450000)After calling start_stream(), wait at least 2 seconds before sending
channel commands to let the board stabilise.
config_board(command)
Section titled “config_board(command)”Sends an ASCII command string to the board at runtime. Used to enable channels, set gain, and configure RLD. See the Command Set for all available commands.
board.config_board("chon_1_12") # enable channel 1 at gain 12board.config_board("rldadd_1") # add channel 1 to RLDget_board_data()
Section titled “get_board_data()”Returns all samples currently in the ring buffer as a 2D NumPy array, then clears the buffer. Rows are data channels; columns are samples ordered oldest to newest.
data = board.get_board_data()# shape → (num_rows, num_samples)Use this for one-shot capture, or when you want to process exactly what has accumulated since the last call.
get_current_board_data(num_samples)
Section titled “get_current_board_data(num_samples)”Returns up to num_samples of the most recent data without removing it from
the buffer. Ideal for real-time processing loops where you want a sliding
window of the latest signal.
data = board.get_current_board_data(sampling_rate * 2) # last 2 secondsget_eeg_channels(board_id) / get_exg_channels(board_id)
Section titled “get_eeg_channels(board_id) / get_exg_channels(board_id)”Returns the row indices in the data array that correspond to EEG/ExG channels.
Use these to index into get_board_data() output without hardcoding row numbers.
eeg_channels = BoardShim.get_eeg_channels(BoardIds.NEUROPAWN_KNIGHT_BOARD)eeg_data = data[eeg_channels, :] # shape: (8, num_samples), values in µVget_sampling_rate(board_id)
Section titled “get_sampling_rate(board_id)”Returns the board’s sampling rate in samples per second.
sampling_rate = BoardShim.get_sampling_rate(BoardIds.NEUROPAWN_KNIGHT_BOARD)# → 125stop_stream()
Section titled “stop_stream()”Stops reading from the board and halts the ring buffer. The session stays open —
you can call start_stream() again without re-running prepare_session().
board.stop_stream()release_session()
Section titled “release_session()”Closes the serial connection and frees all resources allocated by
prepare_session(). Always call this when you are finished with the board.
board.release_session()