Examples#
This section describes the sample application bundled with the BrainAccessKit SDK.
MinimalGUI Sample App#
The MinimalGUI sample application is a complete, standalone Android project that shows how
to use the BrainAccessKit SDK to:
Scan for nearby BrainAccess devices.
Connect to a selected device and run the handshake.
Stream typed
EegChunks and display the live sample count.Show per-channel electrode contact, cumulative missed (gap-filled) samples, and battery.
Reflect the phone’s Bluetooth state.
It uses plain Android Views (no UI framework) and is the best place to start for a practical implementation of the SDK’s core features.
Running the Sample App#
Android Studio (recommended)
Unzip the distribution and choose
File > Openon theExamples/MinimalGUIfolder.Confirm the SDK artifacts are present in
app/libs/(already populated in the ZIP).Let Gradle sync, connect an Android device (USB/Wi-Fi), and Run.
Command line
cd Examples/MinimalGUI
./gradlew installDebug # Windows: gradlew.bat installDebug
adb shell am start -n com.neurotec.minimalgui/.MainActivity
Optional: Lab Streaming Layer (LSL)#
To forward the stream to an LSL outlet, add lsl-release.aar and liblsl-Java-release.aar
to app/libs/ (plus the JNA dependency, see Installation) and push each chunk to a
BrainAccessLslOutlet — the DeviceSession extension streamToLsl does this for you:
val pump: Job = session.streamToLsl(
scope,
outputMode = OutputMode.NORMAL, // TEST_SIGNAL is published in the header
software = mapOf("myapp" to BuildConfig.VERSION_NAME), // added to the header's versions
digitalInput = false, // true adds the Digital column (fw 3.8.1+)
)
pump.cancel() // stops the stream and closes the outlet
The stream follows the BrainAccess Board LSL contract v1, so BrainAccess Board, LabRecorder, pyxdf and MNE read it without SDK code:
stream name
<BLE name>_<MODEL>_BrainAccess(BrainAccessLslOutlet.contractStreamName),source_id= the advertised BLE name (DeviceSession.name, e.g.BA MAXI 1234), typeEEG,double64at the device sample rate;columns in order: EEG electrodes (
microvolts,kOhmin impedance mode),contact_<label>(CONTACT),Accel_x/y/z(ACCEL,m/s2) andGyro_x/y/z(GYRO,deg/s) when the hardware has them,Digital(TRIG) withdigitalInput = true,Sample(device sample number, exact for any recording length),Streaming(0 on a gap-filled sample),Battery(pct, -1 unknown);the header carries the serial number, firmware and hardware versions, standard 10-05 electrode positions and electrode hardware, reference/ground, cap, versions and the montage (
brainaccessnode), built fromDeviceSession.streamMetadata(...);each sample’s LSL timestamp is the moment the headset took it, from the headset’s clock (firmware 3.8.0+, within about 1 ms). The first seconds of a stream are held until that clock is fitted; without it (older firmware, impedance mode) chunks are stamped on arrival after a 5 s hold.
StreamMetadata.toJson() produces the same metadata as Board’s StreamMetadata schema v1 JSON,
e.g. for a recording sidecar.
Location#
The source code for the sample application is in the Examples/MinimalGUI directory of the
distribution ZIP.