Database Connection#
The primary purpose of this section is to demonstrate how to retrieve data from the BrainAccess Board database. Below is an example of how to connect to the active database and access MNE-formatted EEG data.
For these examples to work, ensure that the BrainAccess Board is running and the device is properly connected.
Example: Connecting to the Database#
import brainaccess_board as bb
# Connect to the database
db, status = bb.db_connect()
if status:
# Retrieve all data from all connected devices as a dictionary {device_id: MNE structure}
data = db.get_mne()
print(f"Dictionary of connected devices:\n{data}")
if data:
print(f"MNE structure: {data[next(iter(data))]}")
# Retrieve the last 10 seconds of data
data_10sec = db.get_mne(duration=10)
print(data_10sec)
Example Output#
Dictionary of connected devices:
{'747d3630-62d1-4f20-a9d6-65f5a41ed2b9': <RawArray | 8 x 38250 (153.0 s),
~2.3 MB, data loaded>}
MNE structure: <RawArray | 8 x 38250 (153.0 s), ~2.3 MB, data loaded>
{
'747d3630-62d1-4f20-a9d6-65f5a41ed2b9': <RawArray | 8 x 2501 (10.0 s),
~171 kB, data loaded>
}