Unity Bandpower Interface is a seamless Unity plugin designed for developers working with Unicorn BCI Core devices. It enables real-time bandpower calculation, allowing effortless integration of bandpower-based BCI games and applications. With an intuitive setup and optimized performance, this interface empowers developers to create immersive, brain-driven experiences with ease.
Prerequisites
Hardware Requirements
Development
Deployment
Prefabs
Device
Connection Dialog
Logger
SQ Bar
Bandpower Bars
Quickstart Guide
Deploy to Windows
Deploy to macOS
Deploy to Android
Troubleshooting
Android: No activity in the Android manifest
macOs: libgtecble.dylib is blocked
- Development: Windows or Mac computer
- Deployment: Windows, Mac or Android device
- Unicorn BCI Core
- Bluetooth adapter supporting Bluetooth 5
- Windows 11
- Unity
2022.3.56f1 - NET Framework
.NET Framework 4.8 - Visual Studio
Microsoft Visual Studio 2022
- macOS 14.5+
- Unity
2022.3.56f1 - Xcode
15.4 - Command Line Tools for Xcode
15.3 - Visual Studio Code
- Windows 11
- NET Framework
.NET Framework 4.8
- macOS 14.5+
- SDK Version 31+
- Unicorn BCI Core - Adds Unicorn BCI Core devices to the available devices list
- Simulator - Adds simulator devices to the available devices list
- All Devices - Adds simulator and Unicorn BCI Core devices to the available devices list
It is possible to simulate good, floating or grounded EEG using the simulator devices. It is also possible to simulate alpha activity using the simulator devices.
It is possible to modify the buffersize and buffer overlap used for bandpower calculation. The output rate of calculated bandpower is affected by changing buffersize and buffer overlap.
The Unity Bandpower interface is estimating bandpower for various frequency bands. It is possible to modify the cutoff frequencies of each calculated frequency band in the advanced settings.
The Unity Bandpower interface calculates different bandpower ratios from the defined frequency bands. Available ratios are:
It is possible to set the output data rate of EEG in the EEG Data Settings. Data is buffered and output as [samples, channels] array to match the defined output data rate.
The device prefab provides an event system as an interface to unity.
The event called when devices are discovered. Available devices are provided as list of strings.
Event data: List<string>
The event called when device state changed. Th current device state is provided as 'State' enum.
Event data: List<State>
The event called when a signal rocessing pipeline state changed. The current state is provided as string.
Event data: string
The event called when a runtime exception occured. The Exception is provided as 'Exception' object.
Event data: Exception
The event called when bandpower values for each channel individually are available. The frequency of the event is affected by the buffer settings and bandpower ranges set in the Advanced Settings. Data is provided as Dictionary with the frequency band name as Key (delta, theta, alpha, beta-low, beta-mid, beta-hig, gamma) and the bandpower values as double array as value.
Event data: Dictionary<string, double[]>
The event called when averaged bandpower values over all channels are available. The frequency of the event is affected by the buffer settings and bandpower ranges set in the Advanced Settings. Data is provided as Dictionary with the frequency band name as Key (delta, theta, alpha, beta-low, beta-mid, beta-hig, gamma) and the bandpower value as double value.
Event data: Dictionary<string, double>
The event called when bandpower ratios for each channel individually are available. The frequency of the event is affected by the buffer settings and bandpower ranges set in the Advanced Settings. Data is provided as Dictionary with the bandpower ratio name as Key (PowerRatioIndex, DeltaAlphaRatio, ThetaAlphaRatio, ThetaBetaRatio, ThetaBetaAlphaRatio, EngagementIndex) and the bandpower ratios as double array as value.
Event data: Dictionary<string, double[]>
The event called when averaged bandpower ratios over all channels are available. The frequency of the event is affected by the buffer settings and bandpower ranges set in the Advanced Settings. Data is provided as Dictionary with the bandpower ratio name as Key (PowerRatioIndex, DeltaAlphaRatio, ThetaAlphaRatio, ThetaBetaRatio, ThetaBetaAlphaRatio, EngagementIndex) and the bandpower ratio as double value.
Event data: Dictionary<string, double>
The event called when new signal quality values are available.
Event data: List<ChannelStates>
The event called when battery level data is available.
Event data: float
The event called when data is lost.
Event data: None
The event called when raw data is available
Event data: Dictionary<Rawdata>
The connection dialog prefab is a very simple pre defined connection dialog featuring a dropdown menu to select devices and a button to connect to a device or disconnect from a device. Drag this object into your scene ans a child object of the device object to automatically connect events or connect via the unity event system.
The logger prefab is a logging module writing messages provided by the device. Drag this object into your scene ans a child object of the device object to automatically connect events or connect via the unity event system.
The sq bar prefab is a simple module visualizing the eeg signal quality. Drag this object into your scene ans a child object of the device object to automatically connect events or connect via the unity event system.
The sq bar prefab is a simple module visualizing the averaged bandpower values. Drag this object into your scene ans a child object of the device object to automatically connect events or connect via the unity event system.
-
Open Unity Hub on your Windows or Mac
-
Create a new Unity Project
- Import the Unity Bandpower Interface unity package.
Click Assets -> Import Package -> Custom Package... -> load .unitypackage
Ensure that all items are selected and click 'Import'.
-
Open Assets -> Plugins -> gtec -> Bandpower -> Prefabs.
-
Drag the device prefab into your scene.
-
Drag the connection dialog prefab into your scene.
-
Drag the logger prefab into your scene.
-
Drag the sq bar prefab into your scene.
-
Drag the bandpower bars prefab into your scene.
-
Set the 'Type' setting is set to 'Unicorn BCI Core' or 'All Devices'
-
Turn your Unicorn BCI Core device on
-
Click the Play Button in the Unity Editor
-
Wait until the device is discovered and click 'Connect'
-
The bandpower bars should start moving and the signal quality bar should start changing colors
- Select 'Windows' as Target Platform.
- Select target architecture
- Click 'Build'
Note:
An Windows device is required to build for Windows
- Select 'macOS' as Target Platform.
- Select target architecture
- Click 'Build'
Note:
A mac device is required to build for macOS
- Select 'Android' as Target Platform.
- Select target architecture
- Click 'Build'
Note:
An Android device is required to build for Android
The Android manifest might look different for different Unity versions. It's recommended to use Unity 2022.3.56f1. If you want to go with your Unity version you can try to create a new Android manifest.
- Delete the installed Android manifest
Assets/Plugins/Android/AndroidManifest.xml - Create a new manifest by clicking
Edit -> Project Settings -> Player -> Publishing Settings -> Custom Main Manifest - A new Android manifest should have been created at
Assets/Plugins/Android/AndroidManifest.xml.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="@style/UnityThemeSelector"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
</manifest>
- Do not modify the
<application>section. Add the required permissions to the Adnroid manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />s
<uses-feature android:name="android.hardware.bluetooth" android:required="true"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<application>
<activity android:name="com.unity3d.player.UnityPlayerActivity"
android:theme="@style/UnityThemeSelector"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
</application>
</manifest>
The library interacting with the device might be blocked on macOs, even if the library is signed.
To allow the library being used click Settings -> Privacy & Security -> Allow Anyway. It should be possible to load libgtecble.dylib in uUnity now.














