Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-neurosdk2
Advanced tools
ReactNative NeuroSDK2 is a set of libraries for iOS and Android operating systems providing tools needed for configuring and receiving raw data from neuro sensors.
Neurosdk is a powerful tool for working with neuro-sensors BrainBit, BrainBitBlack, NeuroEEG-M, Callibri and Kolibri. All these devices work with BLE 4.0+ technology. SDK allows you to connect, read the parameters of devices, as well as receive signals of various types from the selected device.
Firstly, you need to install package.
Available for iOS and Android platforms
$ npm install react-native-neurosdk2 --save
$ react-native link react-native-neurosdk2
Because sdk uses the bluetooth api you need to set up the project.
For Android you need to request runtime permission:
async function requestPermissionAndroid() {
try {
let permissions: Array<Permission> = [];
let androidApi31 = Platform.constants['Release'] >= 31;
if (androidApi31) { // for android 12 (api 31+)
permissions.push(PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN);
permissions.push(PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT);
} else {
permissions.push(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
permissions.push(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION);
}
if (permissions.length == 0) { return; }
const result = await PermissionsAndroid.requestMultiple(permissions);
for (let i = 0; i < permissions.length; i++) {
const perm = permissions[i];
if (perm !== undefined && result[perm] != PermissionsAndroid.RESULTS.GRANTED) {
requestPermissionAndroid();
}
}
} catch (err) {
console.warn(err);
}
}
For iOS you need to add a key to Info.plist
because it uses bluetooth too:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Explanation to using bluetooth</string>
SDK can be conditionally divided into two parts: device search (Scanner object) and the device itself (Sensor object).
The scanner allows you to find devices nearby, it is also responsible for the first creation of the device. When created, the device is automatically connected. In the future, the connection state can be controlled through the sensor object. Whatever type of device you work with, the use of the scanner will be the same.
The sensor allows you to monitor the status of the device, set parameters, receive a signal of various types.
It is recommended to work with both parts in a separate thread. During the connection, the SDK also reads the main characteristics of the device, which significantly increases the time of the connection method, which will cause the application to freeze.
If an error occurs while working with the library, you will receive an exception for any of the methods.
Package contains tree main modules:
import { Scanner } from 'react-native-neurosdk2'
import { Sensor, BrainBitSensor, BrainBit2Sensor, BrainBitBlackSensor, CallibriSensor, NeuroEEGSensor } from 'react-native-neurosdk2'
import {SensorSamplingFrequency,
SensorGain,
SensorDataOffset,
SensorExternalSwitchInput,
SensorADCInput,
SensorAccelerometerSensitivity,
SensorGyroscopeSensitivity,
SensorFirmwareMode,
IrAmplitude,
RedAmplitude,
FPGData,
SensorAmpMode,
SensorCommand,
SensorParamAccess,
SensorParameter,
SensorFeature,
SensorFilter,
SensorFamily,
SensorInfo,
SensorVersion,
MEMSData,
Point3D,
BrainBitSignalData,
BrainBitResistData,
CallibriSignalData,
CallibriEnvelopeData,
CallibriRespirationData,
CallibriColorType,
CallibriSignalType,
CallibriStimulatorMAState,
CallibriStimulationParams,
CallibriMotionAssistantParams,
CallibriMotionCounterParam,
QuaternionData,
CallibriElectrodeState,
CallibriMotionAssistantLimb,
CallibriStimulatorState,
SignalChannelsData,
ResistChannelsData,
EEGChannelInfo,
EEGChannelId,
EEGChannelType,
NeuroEEGAmplifierParam,
EEGRefMode,
EEGChannelMode,
GenCurrent,
BrainBit2AmplifierParam,
BrainBit2ChannelMode,
ResistRefChannelsData,
SensorState} from 'react-native-neurosdk2'
Here is a list of exceptions that occur when working with SDK. You need to be guided by this list in order to understand what happened in the process of executing a particular method.
Code | Description |
---|---|
100 | Invalid scan parameters are specified |
101 | Invalid sensor types are specified for the search |
102 | Failed to create sensor scanner |
103 | Failed to started sensor scanner |
104 | Failed to stopped sensor scanner |
105 | Failed to get a list of sensors |
106 | Failed to get a list of sensors |
107 | Invalid parameters for creating a sensor |
108 | Failed to create sensor |
109 | Sensor not founded |
110 | Failed to connect the sensor |
111 | Failed to disconnect the sensor |
112 | Failed to get a list of sensor features |
113 | Invalid parameters for get a list features of the sensor |
114 | Invalid parameters for get a list commands of the sensor |
115 | Failed to get a list of sensor commands |
116 | Invalid parameters for get a list parameters of the sensor |
117 | Failed to get a list of sensor parameters |
118 | Failed to execute the sensor command |
119 | Failed read the sensor parameter |
120 | Failed read the sensor parameter |
121 | Failed write the sensor parameter |
122 | Failed write the sensor parameter |
123 | Failed add callback the sensor |
124 | Failed add callback the sensor |
The scanner works like this:
import {Scanner} from 'react-native-neurosdk2'
...
var scanner = new Scanner()
await scanner.init([SensorFamily.LECallibri,
SensorFamily.LEBrainBit,
SensorFamily.LEBrainBit2,
SensorFamily.LEBrainBitFlex,
SensorFamily.LEBrainBitPro,
SensorFamily.LEBrainBitBlack,
SensorFamily.LEBrainBit2,
SensorFamily.LENeuroEEG])
scanner.AddSensorListChanged(sensors => {
console.log(sensors)
});
...
scanner.RemoveSensorListChanged();
scanner.start()
scanner.stop()
var sensors = await scanner.sensors()
SensorInfo
contains information about device:
scanner.close();
When a found device is disconnected or loses signal, it will not immediately disappear in the scanner.
You need to create a device using a scanner. All manipulations with the device will be performed without errors only if the device is connected.
import { CallibriSensor, BrainBitSensor, NeuroEEGSensor, Sensor } from "react-native-neurosdk2";
// BrainBit
var sensor: BrainBitSensor = await scanner.createSensor(sensorInfo) as BrainBitSensor;
// BrainBit
var sensor: BrainBitBlackSensor = await scanner.createSensor(sensorInfo) as BrainBitBlackSensor;
// BrainBit 2/Flex/Pro
var sensor: BrainBit2Sensor = await scanner.createSensor(sensorInfo) as BrainBit2Sensor;
// Callibri
var sensor: CallibriSensor = await scanner.createSensor(deviceInfo) as CallibriSensor
// NeuroEEG
var sensor: NeuroEEGSensor = await scanner.createSensor(deviceInfo) as NeuroEEGSensor
For all types of devices, you can use the same methods to control the device's connection status, invoke commands, and check for functionality.
Connection status can be obtained in two ways. The first one is using the sensor property State
.
The second way is in real time using a callback:
sensor.AddConnectionChanged((state)=>{
console.log(SensorState[state])
})
...
sensor.RemoveConnectionChanged()
A connection can be in two states: connected (InRange) and disconnected (OutOfRange).
Important! The state change callback will not come after the device is created, only after disconnecting (device lost from the scope or using a method) and then connected. The device does not automatically reconnect.
You can connect and disconnect from device manually by methods Connect()
and Disconnect()
. To receive connection state in real time you need to subscribe to stateChanged
event. Also you can get connection state by sensor's property.
await sensor.disconnect()
...
await sensor.connect()
Also, you can get power value from each device by sensor property BattPower
or by callback in real time:
sensor.AddBatteryChanged((power)=>{
console.log(power)
})
...
sensor.RemoveBatteryChanged()
Each device has its own settings, and some of them can be configured as you need. Not all settings can be changed and not every device supports all settings.
First you need to find out what parameters the device supports and whether they can be changed:
console.log(sensor.getParameters().map(parameter => SensorParameter[parameter.Param] + ": " + SensorParamAccess[parameter.ParamAccess]))
// Output:
//
// ["Name: Read",
// "FirmwareMode: Read",
// "FirmwareVersion: Read",
// "State: ReadNotify", ... ]
Info about parameter includes two fields:
You can also check if the parameter is supported, for example Gain
:
if(sensor.isSupportedParameter(SensorParameter.Gain)){
...
}
Name of device. String value.
var name: string = sensor.getName()
...
sensor.setName('new_name') // <- this is throw an exeption, you cannot set device name
Information about the connection status of a device. Can take two values:
var state: SensorState = sensor.getState()
MAC-address of device. For iOS/MacOS represents by UUID. String value.
var address: string = sensor.getAddress()
Serial number of device. String value.
For callibri device families, this field is empty in SensorInfo
when searching, and you can get it immediately after connecting using this property.
var sn: string = sensor.getSerialNumber()
Count of channels of device. Number value.
var chCount: number = sensor.getChannelsCount()()
Only to Callibri MF sensor!
Device signal filter activity states. If the parameter is supported by the device, it becomes possible to set the desired filters to the device. The next filters are available:
If sensor does not support filter in input list the method throw an exception
NOTE: Setting a hardware filter list that contains LPFBwhLvl2CutoffFreq400Hz will not occur in a callibri sensor at a frequency other than 1000Hz
var filters: Array<SensorFilter> = sensor.getHardwareFilters()
...
sensor.setHardwareFilters([SensorFilter.FilterBSFBwhLvl2CutoffFreq55_65Hz, SensorFilter.FilterHPFBwhLvl2CutoffFreq10Hz])
You can also check if the filter is supported, for example HPFBwhLvl1CutoffFreq1Hz
:
if(sensor.isSupportedFilter(SensorFilter.FilterHPFBwhLvl1CutoffFreq1Hz)){
...
}
Or you can check all supported filters:
var filters: Array<SensorFilter> = sensor.getSupportedFilters();
Information about the current mode of operation of the device firmware. It can be in two states:
var mode: SensorFirmwareMode = sensor.getFirmwareMode()
...
// Setter supports only with Callibri MF
sensor.setFirmwareMode(SensorFirmwareMode.ModeApplication)
An property that is used to set or get the sample rate of a physiological signal. The higher the value, the more data flow from the device to the application, which means the higher the power consumption, but also the higher the range of measured frequencies. And there are also limitations on the physical communication channel (BLE) in terms of bandwidth.
Recommendations for choosing a value:
It is unchanged for BrainBit and BrainBitBlack and is 250 Hz. Can be changed for Signal Callibri/Kolibri and can take on the following values:
Not available for Callibi EMS. Dont use for NeuroEEG-M device, you need to use a 'setAmplifierParam()' method for it. If you try to set an unsupported value to the device, an exception will be thrown.
var sf: SensorSamplingFrequency = sensor.getSamplingFrequency()
...
// Setter supports only with Callibri MF
sensor.setSamplingFrequency(SensorSamplingFrequency.FrequencyHz1000)
Gain of an ADC signal. The higher the gain of the input signal, the less noise in the signal, but also the lower the maximum amplitude of the input signal. For Callibi/Kolibri MF you can set the desired value. Not available for Callibi/Kolibri EMS. Dont use for NeuroEEG device, you need to use a 'setAmplifierParam()' method for it
Gain parameter is unsupported by BrainBit 2 sensor
var gain: SensorGain = sensor.getGain()
...
// Setter supports only with Callibri MF or BrainBit
sensor.setGain(SensorGain.Gain3)
Available values for BrainBit: 1, 2, 3, 4, 6, 8, 12
If you try to set an unsupported value to the device, an exception will be thrown.
Signal offset. It is unchanged for BrainBit and BrainBitBlack and is 0. For Callibi/Kolibri MF you can set the desired value. Not available for Callibi/Kolibri EMS and NeuroEEG-M.
var offset: SensorDataOffset = sensor.getDataOffset()
...
sensor.setDataOffset(SensorDataOffset.DataOffset0)
If you try to set an unsupported value to the device, an exception will be thrown.
Switched signal source. This parameter is available only to Callibi/Kolibri. It is can take on the following values:
var extSwInp: SensorExternalSwitchInput = sensor.getExtSwInput()
...
sensor.setExtSwInput(SensorExternalSwitchInput.ExtSwInElectrodes)
If you try to set an unsupported value to the device, an exception will be thrown.
State value of an ADC (Analog to Digital Converter) input of a device. This property is available only to Callibi/Kolibri. It is can take on the following values:
var input: SensorADCInput = sensor.getADCInput()
...
sensor.setADCInput(SensorADCInput.Electrodes)
If you try to set an unsupported value to the device, an exception will be thrown.
The sensitivity value of the accelerometer, if the device supports it. This property is available only to Callibi/Kolibri. It is recommended to check the presence of the MEMS module before use. It is can take on the following values:
var accSens: SensorAccelerometerSensitivity = sensor.getAccSens()
...
sensor.setAccSens(SensorAccelerometerSensitivity.AccSens2g)
If you try to set an unsupported value to the device, an exception will be thrown.
The gyroscope gain value, if the device supports it. This property is available only to Callibi/Kolibri. It is recommended to check the presence of the MEMS module before use. It is can take on the following values:
var gyreSens: SensorGyroscopeSensitivity = sensor.getGyroSens()
...
sensor.setGyroSens(SensorGyroscopeSensitivity.GyroSens250Grad)
If you try to set an unsupported value to the device, an exception will be thrown.
Parameter for obtaining information about the state of the stimulation mode and the motion assistant mode. This parameter is available only to Callibi/Kolibri EMS. Contains:
Each of the fields can be in three states:
var maState: CallibriStimulatorMAState = sensor.getStimulatorMAState()
If you try to set an unsupported value to the device, an exception will be thrown.
Stimulation parameters. This property is available only to Callibi/Kolibri EMS. Contains:
var param: CallibriStimulationParams = sensor.getStimulatorParam()
...
sensor.setStimulatorParam(CallibriStimulationParams.Frequency)
If you try to set an unsupported value to the device, an exception will be thrown.
Parameter for describing a stimulation mode, if the device supports this mode. This structure describes the parameters for starting the stimulation mode depending on the place of application of the device, the position of the limb in space and the pause between the starts of this mode while the specified conditions are met. Parameter available only for Callibi/Kolibri stimulator. Contain a structure named CallibriMotionAssistantParams
with fields:
var param: CallibriMotionAssistantParams = sensor.getMotionAssistantParam()
...
sensor.setMotionAssistantParam(CallibriMotionAssistantParams.GyroStart)
If you try to set an unsupported value to the device, an exception will be thrown.
Information about the device firmware version. Contain a structure named SensorVersion
with fields:
var version: SensorVersion = sensor.getVersion()
This parameter is available only to Callibi/Kolibri. Contain a structure named MotionCounterParamCallibri
with fields:
var param: CallibriMotionCounterParam = sensor.getMotionCounterParam()
...
sensor.setMotionCounterParam(CallibriMotionCounterParam.InsenseThresholdMG)
If you try to set an unsupported value to the device, an exception will be thrown.
Contains the number of motions. This parameter is available only to Callibi/Kolibri. A numeric value that cannot be changed.
var counter: string = sensor.getMotionCounter()
Battery power value. Integer value.
var power = sensor.getBattPower()
Type of device. Enumeration.
var family: SensorFamily = sensor.getSensFamily()
Operating mode of the physiological amplifier. Parameter is available for BraibBitBlack and for NeuroEEG-M.
var mode: SensorAmpMode = sensor.getAmpMode()
Frequency of updating resistance values. Immutable value. Not available for Callibri/Kolibri. Don't has a fixed value for BrainBit/BrainBitBlack. To get this frequency in NeuroEEG-M, it is required to use getAmplifierParam.
var freq: SensorSamplingFrequency = sensor.getSamplingFrequencyResist();
Frequency of updating MEMS values. Immutable value. Available for Callibri/Kolibri supporting MEMS.
var freq: SensorSamplingFrequency = sensor.getSamplingFrequencyMEMS();
Frequency of updating breath values. Immutable value. Available for Callibri/Kolibri supporting breath.
var freq: SensorSamplingFrequency = sensor.getSamplingFrequencyResp();
Frequency of updating envelope values. Immutable value. Available for Callibri/Kolibri supporting envelope.
var freq: SensorSamplingFrequency = sensor.getSamplingFrequencyEnvelope();
Each device has a specific set of modules. You can find out which modules the device has using the property Feature
:
console.log(sensor.getFeatures().map(feature => SensorFeature[feature]))
// Output:
//
// ["Signal", "Resist"]
You can also check if the feature is supported, for example Signal
:
if(sensor.isSupportedFeature(SensorFeature.Signal)){
...
}
The device can execute certain commands. The list of supported commands can be obtained as follows:
console.log(sensor.getCommands().map(command => SensorCommand[command]))
// Output:
//
// ["StartSignal", "StopSignal", ...]
And also check if the device can execute the desired command:
if(sensor.isSupportedCommand(SensorCommand.StartSignal)){
...
}
The BrainBit and BrainBitBlack is a headband with 4 electrodes and 4 data channels - O1, O2, T3, T4. The device has a frequency of 250 Hz, which means that data on each of the channels will come at a frequency of 250 samples per second. The parameters of this device, such as gain, data offset and the other, cannot be changed, if you try to do this, an exception will appear.
sensor.setName("newname") // <- This throw an exeption!
You can distinguish BrainBit device from Flex by the firmware version number: if the
SensorVersion.FwMajor
is more than 100 - it's Flex, if it's less than BrainBit.
BrainBitBlack, unlike BrainBit, requires pairing with a PC/mobile device. So, before connecting to the BBB, you must put it into pairing mode. SDK starts the pairing process automatically.
To receive signal data, you need to subscribe to the corresponding callback. The values will be received as a packet from four channels at once, which will avoid desynchronization between them. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute
command. This method is also recommended to be run in an separate thread.
sensor.AddSignalReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalReceived();
sensor.ExecuteCommand(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
NOTE: For BrainBit PackNum may be duplicated, although the data (O1-T4) are different. In this case we get 2 counts from BrainBit with the same packet number
Some devices support signal quality check functions using signal ping. You can send a specific value (marker) to the device and it will return that marker with the next signal data packet. Marker is small value one byte in size.
Available only to BrainBitBlack
sensor.pingNeuroSmart(5)
BrainBit and BrainBitBlack also allow you to get resistance values. With their help, you can determine the quality of the electrodes to the skin. Initial resistance values are infinity. The values change when the BB is on the head.
For BrainBit the upper limit of resistance is 2.5 ohms.
sensor.AddResistanceReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartResist)
...
sensor.RemoveResistanceReceived();
sensor.execute(SensorCommand.StopResist)
You get resistance values structure of samples for each channel:
The Callibri family of devices has a wide range of built-in modules. For each of these modules, the SDK contains its own processing area. It is recommended before using any of the modules to check if the module is supported by the device using one of the methods isSupportedFeature
, isSupportedCommand
or isSupportedParameter
To receive signal data, you need to subscribe to the corresponding callback. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute
command.
The sampling rate can be controlled using the SamplingFrequency
property. For example, at a frequency of 1000 Hz, the device will send 1000 samples per second. Supports frequencies 125/250/500/1000/2000 Hz. You can also adjust the signal offset (DataOffset
) and signal power (Gain
).
sensor.AddSignalReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalReceived();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
By default, the Callibri/Kolibri gives a signal without filters. In order to receive a certain type of signal, for example, EEG or ECG, you need to configure the device in a certain way. For this there is a property SignalTypeCallibri
. Preset signal types include:
ExtSwInput
property.Hardware filters disabled by default for all signal types. You can enable filters by HardwareFilters
property, for example LP filter.
Important! When using an LP filter in the sensor, you will not see the constant component of the signal.
var signalType = sensor.getSignalType()
...
sensor.setSignalType(CallibriSignalType.ECG)
To get the values of the envelope, you need to subscribe to a specific event and start pickup. The channel must be configured in the same way as for a normal signal, and all parameters work the same way. Then the signal is filtered and decimated at 20 Hz.
sensor.AddEnvelopeDataChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartEnvelope)
...
sensor.RemoveEnvelopeDataChanged();
sensor.execute(SensorCommand.StopEnvelope)
You get signal values as a list of samples, each containing:
Allows you to determine the presence of electrical contact of the device electrodes with human skin. It can be in three states:
To receive data, you need to subscribe to the corresponding callback and start signal pickup.
sensor.AddElectrodeStateChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveElectrodeStateChanged();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
The breathing microcircuit is optional on request. Its presence can be checked using the IsSupportedFeature
method. To receive data, you need to connect to the device, subscribe to the notification of data receipt and start picking up.
if(sensor.isSupportedFeature(SensorFeature.Respiration))
{
sensor.AddRespirationChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartRespiration)
...
sensor.RemoveRespirationChanged();
sensor.execute(SensorCommand.StopRespiration)
}
You get signal values as a list of samples, each containing:
The MEMS microcircuit is optional on request. Its presence can be checked using the IsSupportedFeature
method. This means that the device contains an accelerometer and a gyroscope. Contains information about the position of the device in space. Channel sampling frequency is 100 Hz.
MEMS data is a structure:
Quaternion data is a structure:
It is recommended to perform calibration on a flat, horizontal non-vibrating surface before starting work using the CalibrateMEMS
command. Calibration state can be checked using the MEMSCalibrateState
property, it can take only two values: calibrated (true), not calibrated (false).
MEMS and quaternion available only to Callibri/Kolibri MF!
// For receiving MEMS
sensor.AddMMEMSDataReceived((data)=>{
console.log(data)
})
sensor.execute(SensorCommand.StartMEMS)
...
sensor.RemoveMEMSDataReceived()
sensor.execute(SensorCommand.StopMEMS)
// For quarternion
sensor.AddQuaternionDataReceived((data)=>{
console.log(data)
})
sensor.execute(SensorCommand.StartAngle)
...
sensor.RemoveQuaternionDataReceived()
sensor.execute(SensorCommand.StopAngle)
Parameters for motion counter. You can configure it with the CallibriMotionCounterParam
property, in it:
You can find out the current number of movements using the MotionCounter
property. You can reset the counter with the ResetMotionCounter
command. No additional commands are needed to start the counter, it will be incremented all the time until the reset command is executed.
if(sensor.isSupportedParameter(SensorParameter.MotionCounter)
{
sensor.setMotionCounterParam({
InsenseThresholdMG: 250, InsenseThresholdSample:250
})
var motionCount = sensor.getMotionCounter()
sensor.execute(SensorCommand.ResetMotionCounter)
}
Callibri is a EMS if it supports the stimulation module:
var isStimulator = sensor.isSupportedFeature(SensorFeature.CurrentStimulator)
Before starting the session, you need to correctly configure the device, otherwise the current strength may be too strong or the duration of stimulation too long. The setting is done using the StimulatorParamCallibri
property. You can set the following options:
You can start and stop stimulation with the following commands:
sensor.execute(SensorCommand.StartCurrentStimulation)
...
sensor.execute(SensorCommand.StopCurrentStimulation)
Stimulation does not stop after the
StimulusDuration
time has elapsed.
You can check the state of stimulation using the StimulatorMAState
property. Contains two parameters:
Each of the parameters can be in 4 states:
The Callibri EMS, which contains the MEMS module, can act as a motion corrector. You can set the initial and final angle of the device and the limb on which the Callibri/Kolibri is installed, as well as a pause between stimulations and turn on the motion assistant. All the time while the device is tilted in the set range, stimulation will met. Stimulation will take place according to the settings of StimulatorParam
.
The motion corrector works in the background. After turning on the motion assistant mode, it will work regardless of the connection to a mobile device/PC. You can turn on the motion corrector mode using a special command. When the device is rebooted, it is also reset.
Motion corrector parameters are a structure with fields:
sensor.setMotionAssistantParam({
GyroStart: 45,
GyroStop:10,
Limb: CallibriMotionAssistantLimb.RightLeg,
MinPauseMs: 10
})
sensor.execute(SensorCommand.EnableMotionAssistant)
...
sensor.execute(SensorCommand.StopCurrentStimulation)
NeuroEEG-M requires pairing with a PC/mobile device. So, before connecting to device, you must put it into pairing mode. SDK starts the pairing process automatically.
Allows for long-term monitoring of brain biopotentials through 21 channels, with parallel registration of three polygraphic channels: ECG, EMG and EOG.
NeuroEEG-M device supports the next signal frequencies:
And gain values:
NeuroEEG device has 24 channels. You can get channels count by getChannelsCount()
method or check constant value NeuroEEGSensor.getMaxChCount()
. Get channels count:
let maxChCount: number = NeuroEEGSensor.getMaxChCount()
let chCount: number = sensor.getChannelsCount()
Receive supportes channels info:
let channels: Array<EEGChannelInfo> = getSupportedChannels()
EEGChannelInfo
contains some info:
EEGChannelId
type - physical location of the channel. Possible values:EEGChannelType
type - type of channel, possible values A1, A2, differential or referentString
type - channel namenumber
type - channel number. By this number the channel will be located in the array of signal or resistance valuesThis device can show it's current amplifier mode. It can be in the following states:
You can check amp. mode by two ways:
sensor.AddAmpModeChanged((ampMode)=>
{
console.info("ampMode: " + ampMode)
});
var mode: SensorAmpMode = sensor.getAmpMode()
It is very important parameter for NeuroEEG-M device because you can set amplifier parameters only if device into PowerDown
or Idle
mode.
You can configure each channel and whole device settings by setting amplifier parameters.
let maxChCount = NeuroEEGSensor.getMaxChCount();
let ampParam: NeuroEEGAmplifierParam = {
ReferentResistMesureAllow: false,
Frequency: SensorSamplingFrequency.FrequencyHz500,
ReferentMode: EEGRefMode.A1A2,
ChannelMode: Array(maxChCount).fill(EEGChannelMode.EEGChannelModeSignalResist),
ChannelGain: Array(maxChCount).fill(SensorGain.Gain6)
};
sensor.setAmplifierParam(ampParam)
let result: NeuroEEGAmplifierParam = sensor.getAmplifierParam();
Channel modes:
Referent modes:
ReferentResistMesureAllow - flag, allows resistance measurement by references (if true, the signal is not valid)
To receive signal data, you need to subscribe to the corresponding callback. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute
command. This method is also recommended to be run in an separate thread.
The sampling rate can be controlled using the Frequency
value of amplifier parameters. For example, at a frequency of 1000 Hz, the device will send about 1000 samples per second. Supports frequencies 250/500/1000 Hz. You can also adjust signal power (Gain
) value for each channel.
sensor.AddSignalDataReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalDataReceived();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
Num
value of EEGChannelInfo
from getSupportedChannels()
method.NeuroEEG-M also allow you to get resistance values. With their help, you can determine the quality of the electrodes to the skin. Initial resistance values are infinity. The values change when the device is on the head.
sensor.AddResistDataReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartResist)
...
sensor.RemoveResistDataReceived();
sensor.execute(SensorCommand.StopResist)
You get resistance values structure of samples for each channel:
Num
value of EEGChannelInfo
from getSupportedChannels()
method.This device supports capturing signal and resistance at the same time.
NOTE: In this mode resistData may not arrive every update of the SignalResistReceived callback.
sensor.AddSignalResistReceived((signalData, resistData)=>{
});
sensor.execute(SensorCommand.StartSignalAndResist)
...
sensor.RemoveSignalResistReceived();
sensor.execute(SensorCommand.StopSignalAndResist)
The BrainBit2 class is designed to work with several device families: BrainBit 2, BrainBit Pro, BrainBit Flex, BrainBit Flex Pro. All devices have a sampling frequency of 250Hz. All devices can work in two modes - signal and resistance separately. These devices have different number of channels - BrainBit2, BrainBit Flex have 4 channels each and BrainBitPro, BrainBit FlexPro have 8 channels each. The main difference from BraibBit of the first version is that they do not support gain property, but have the ability to set gain for each channel separately using BrainBit2AmplifierParam
structure.
The device can have 4 or 8 channels. To determine how many and which channels they are, you need to use the getSupportedChannels()
method:
let channels: Array<EEGChannelInfo> = getSupportedChannels()
EEGChannelInfo
contains some info:
EEGChannelId
type - physical location of the channel. Possible values:IIn most cases, you will receive the values
O1
,O2
,T3
,T4
orUnknown
.Unknown
means that the position of a specific electrode is free.
EEGChannelType
type - type of channel, possible values A1
, A2
, Differential
or Referent
String
type - channel namenumber
type - channel number. By this number the channel will be located in the array of signal or resistance valuesAlso you can check only channels count without info:
let maxChCount: number = BrainBit2Sensor.getMaxChCount()
let chCount: number = sensor.getChannelsCount()
This device can show it's current amplifier mode. It can be in the following states:
You can check amp. mode by two ways:
sensor.AddAMPModeChanged((ampMode)=>
{
console.info("ampMode: " + ampMode)
});
var mode: SensorAmpMode = sensor.getAmpMode()
It is very important parameter for BrainBit2 device because you can set amplifier parameters only if device into PowerDown
or Idle
mode.
You can configure each channel and whole device settings by setting amplifier parameters.
let chCount = sensor.getChannelsCount();
let ampParam: BrainBit2AmplifierParam = {
Current: GenCurrent.GenCurr6nA,
ChSignalMode: Array(chCount).fill(BrainBit2ChannelMode.ChModeNormal),
ChResistUse: Array(chCount).fill(true),
ChGain: Array(chCount).fill(SensorGain.Gain6),
};
sensor.setAmplifierParam(ampParam)
Current - setting parameters of the probe current generator
Signal modes:
Gain - gain of an ADC signal for each channel.
If you do not want to set all parameters, but change only one, for example Gain, it is recommended to read the current parameters of the device and change the desired parameter:
let chCount = sensor.getChannelsCount();
var ampParamp = sensor.getAmplifierParam();
ampParam.ChGain = Array(chCount).fill(SensorGain.Gain3);
sensor.setAmplifierParam(ampParam);
To receive signal data, you need to subscribe to the corresponding callback. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute
command. This method is also recommended to be run in an separate thread.
sensor.AddSignalReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalReceived();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
Num
value of EEGChannelInfo
from getSupportedChannels()
method.BrainBit2 also allow you to get resistance values. With their help, you can determine the quality of the electrodes to the skin. Initial resistance values are infinity. The values change when the device is on the head.
sensor.AddResistanceReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartResist)
...
sensor.RemoveResistanceReceived();
sensor.execute(SensorCommand.StopResist)
You get resistance values structure of samples (ResistRefChannelsData
) for each channel:
Num
value of EEGChannelInfo
from getSupportedChannels()
method.FAQs
ReactNative NeuroSDK2 is a set of libraries for iOS and Android operating systems providing tools needed for configuring and receiving raw data from neuro sensors.
We found that react-native-neurosdk2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.