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)

  1. Unzip the distribution and choose File > Open on the Examples/MinimalGUI folder.

  2. Confirm the SDK artifacts are present in app/libs/ (already populated in the ZIP).

  3. 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), type EEG, double64 at the device sample rate;

  • columns in order: EEG electrodes (microvolts, kOhm in impedance mode), contact_<label> (CONTACT), Accel_x/y/z (ACCEL, m/s2) and Gyro_x/y/z (GYRO, deg/s) when the hardware has them, Digital (TRIG) with digitalInput = 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 (brainaccess node), built from DeviceSession.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.