brainaccess_board package#
Submodules#
brainaccess_board.database module#
- class brainaccess_board.database.ReadDB(filename='current')[source]#
Bases:
object
Get current database file to read from it
- Parameters:
filename (str)
- get_mne(device=None, duration=None, time_range=None, only_lsl=True, marker_devices_include=None)[source]#
Get data from the database as mne objects
If no parameters are given, dictionary with all devices full data are returned.
- Parameters:
device (str, optional) – The device identifier. Usually the LSL uid. If empty all devices are returned.
duration (int, Optional) – The duration in seconds from the end.
time_range (tuple, Optional) – The time range to get data from. If duration is set time_range is ignored.
only_lsl (bool, Optional) – If True, only LSL devices are included. With default templates non LSL devices are not recorded.
marker_devices_include (list, Optional) – List of marker devices to include. If left empty all marker devices are included.
- Returns:
Dictionary with mne objects.
- Return type:
dict
brainaccess_board.message_queue module#
- class brainaccess_board.message_queue.BoardControl(logger=None, request_timeout=5000)[source]#
Bases:
SocketClient
Control BrainAccess Board via messages
- Parameters:
logger (Logger | None)
request_timeout (int)
- class brainaccess_board.message_queue.SocketClient(port, commands, mode='json', request_timeout=5000, logger=None)[source]#
Bases:
object
Client to send messages to server
- Parameters:
port (int)
commands (dict)
mode (str)
request_timeout (int)
logger (Logger | None)
brainaccess_board.sq module#
- brainaccess_board.sq.adapt_array(arr)[source]#
Converts a NumPy array to a binary format for storing in SQLite.
- Parameters:
arr (ndarray)
- Return type:
memoryview
- brainaccess_board.sq.convert_array(text)[source]#
Converts a binary format back to a NumPy array.
- Parameters:
text (bytes)
- Return type:
ndarray
- brainaccess_board.sq.get_data(handle, device=None, direction='last', count=10)[source]#
Retrieves data from a table based on the direction and count of records.
Parameters: handle (Dict): The database handle. device (Optional[str]): The device identifier. direction (str): Direction of retrieval (‘all’, ‘last’, ‘first’). count (int): Number of records to retrieve.
Returns: List: Data records.
- Parameters:
handle (Dict)
device (str | None)
direction (str)
count (int)
- Return type:
list
- brainaccess_board.sq.get_data_after(handle, start, column, device)[source]#
Retrieves data records that have a timestamp greater than the specified start time.
Parameters: handle (Dict): The database handle. start (float): The start time. column (str): The column to compare the time. device (str): The device identifier.
Returns: List: Data records.
- Parameters:
handle (Dict)
start (float)
column (str)
device (str)
- Return type:
List
- brainaccess_board.sq.get_devices(handle)[source]#
Lists all devices based on the tables available in the database.
Parameters: handle (Dict): The database handle.
Returns: List[str]: A list of device identifiers.
- Parameters:
handle (Dict)
- Return type:
List[str]
- brainaccess_board.sq.get_first_timestamp(handle, device)[source]#
Gets the earliest timestamp from a data table for a specific device.
Parameters: handle (Dict): The database handle. device (str): The device identifier.
Returns: Optional[float]: The earliest timestamp if found, else None.
- Parameters:
handle (Dict)
device (str)
- Return type:
float | None
- brainaccess_board.sq.get_handle(name, uri=False)[source]#
Establishes a connection to an SQLite database and sets up the cursor.
Parameters: name (Union[pathlib.Path, str]): Path to the SQLite database file. uri (bool): Whether to treat the name as a URI.
Returns: Dict: A dictionary containing the cursor and connection objects.
- Parameters:
name (Path | str)
uri (bool)
- Return type:
Dict
- brainaccess_board.sq.get_last_seconds_data(handle, device, duration)[source]#
Retrieves data from the last given number of seconds.
Parameters: handle (Dict): The database handle. device (str): The device identifier. duration (int): The duration in seconds.
Returns: List: Data records.
- Parameters:
handle (Dict)
device (str)
duration (int)
- Return type:
List
- brainaccess_board.sq.get_metadata(handle, device)[source]#
Fetches metadata for a given device from the database.
Parameters: handle (Dict): The database handle. device (str): The device identifier.
Returns: List: Metadata records.
- Parameters:
handle (Dict)
device (str)
- Return type:
List
- brainaccess_board.sq.get_range_data(handle, device, time_range)[source]#
Retrieves data within a given time range.
- Parameters:
(Dict) (handle)
(str) (device)
(tuple) (time_range)
handle (Dict)
device (str)
time_range (tuple)
- Returns:
List
- Return type:
Data records.
- brainaccess_board.sq.get_table(handle, name, name2=None)[source]#
Finds a specific table based on given name patterns.
Parameters: handle (Dict): The database handle. name (str): Primary name pattern. name2 (Optional[str]): Secondary name pattern.
Returns: Optional[str]: The table name if found, else None.
- Parameters:
handle (Dict)
name (str)
name2 (str | None)
- Return type:
str | None
- brainaccess_board.sq.get_tables(handle)[source]#
Retrieves the list of all tables in the database.
Parameters: handle (Dict): The database handle.
Returns: List[str]: A list of table names.
- Parameters:
handle (Dict)
- Return type:
List[str]
- brainaccess_board.sq.query(handle, sql_query)[source]#
Executes a given SQL query and fetches all results.
Parameters: handle (Dict): The database handle containing cursor and connection. sql_query (str): The SQL query to execute.
Returns: List: Query results.
- Parameters:
handle (Dict)
sql_query (str)
- Return type:
List
brainaccess_board.stream module#
- class brainaccess_board.stream.Stimulation(name='BrainAccessMarkers', source_id='BrainAccessMarkers')[source]#
Bases:
object
Initialize LSL marker device.
- Parameters:
name (str, optional) – Name of the LSL stream, by default “BrainAccessMarkers”
source_id (str, optional) – Source ID of the LSL stream, by default “BrainAccessMarkers”
brainaccess_board.utils module#
Module contents#
- brainaccess_board.db_connect(filename='current')[source]#
Connect to the database.
- Parameters:
filename (str) – Name of the database file.
- Returns:
tuple – ReadDB object and connection status.
- Return type:
(ReadDB, bool)
- brainaccess_board.msg_connect()[source]#
Create connection to BrainAccess Board for communication.
- Returns:
tuple – BoardControl object, commands dictionary and connection status.
- Return type:
(BoardControl, dict, bool)