New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-native-neurosdk2

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-neurosdk2

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.

Source
npmnpm
Version
1.0.11
Version published
Maintainers
2
Created
Source

Documentation

Overview

Neurosdk is a powerful tool for working with neuro-sensors BrainBit, BrainBitBlack, 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.

Getting Started

Firstly, you need to install package.

ReactNative

Available for iOS and Android platforms

Installation

By npm:

$ npm install react-native-neurosdk2 --save

Mostly automatic installation:

$ react-native link react-native-neurosdk2

After installation

Because sdk uses the bluetooth api you need to set up the project.

For Android you need to request runtime permission:

export async function requestPermissionAndroid() {
  try {
    const granted = await PermissionsAndroid.requestMultiple([
      PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
      PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
    ]);
    if (
      granted[PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] ===
      PermissionsAndroid.RESULTS.GRANTED
    ) {
      ...
    }
    if (
      granted[PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT] ===
      PermissionsAndroid.RESULTS.GRANTED
    ) {
      ...
    }
  } catch (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>

Usage

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.

Description

Package contains tree main modules:

  • Scanner - to search for devices
import { Scanner } from 'react-native-neurosdk2'
  • Sensor - methods of interaction with the device
import { Sensor, BrainBitSensor, CallibriSensor } from 'react-native-neurosdk2'
  • Types - implementation of all types of the library, you can either connect everything or only those necessary for a specific task
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,
   SensorState} from 'react-native-neurosdk2'

Errors

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.

CodeDescription
100Invalid scan parameters are specified
101Invalid sensor types are specified for the search
102Failed to create sensor scanner
103Failed to started sensor scanner
104Failed to stopped sensor scanner
105Failed to get a list of sensors
106Failed to get a list of sensors
107Invalid parameters for creating a sensor
108Failed to create sensor
109Sensor not founded
110Failed to connect the sensor
111Failed to disconnect the sensor
112Failed to get a list of sensor features
113Invalid parameters for get a list features of the sensor
114Invalid parameters for get a list commands of the sensor
115Failed to get a list of sensor commands
116Invalid parameters for get a list parameters of the sensor
117Failed to get a list of sensor parameters
118Failed to execute the sensor command
119Failed read the sensor parameter
120Failed read the sensor parameter
121Failed write the sensor parameter
122Failed write the sensor parameter
123Failed add callback the sensor
124Failed add callback the sensor

Scanner

The scanner works like this:

  • Create scanner. When creating a scanner, you need to specify the type of device to search. It can be either one device or several. Here is example for two type of devices - BrainBit and Callibri.
import {Scanner} from 'react-native-neurosdk2'

...

var scanner = new Scanner()
await scanner.init([SensorFamily.LECallibri, SensorFamily.LEBrainBit])
  • During the search, you can get a list of found devices using a callback. To do this, you need to subscribe to receive the event, and unsubscribe after the search is completed:
scanner.AddSensorListChanged(sensors => {
	console.log(sensors)
});
...
scanner.RemoveSensorListChanged();
  • Start search
scanner.start()
  • Stop search
scanner.stop()
  • Additionally, a list of found devices can be obtained using a separate method.
var sensors = await scanner.sensors()

SensorInfo contains information about device:

  • Name - the name of device
  • Address - MAC address of device (UUID for iOS/MacOS)
  • Serial number - device's serial number
  • Sensor family - type of device
  • Sensor model - numerical value of the device model
  • Pairing requared - whether the device needs to be paired or not
  • After you finish working with the scanner, you need to clean up the resources used.
scanner.close();

Important! When restarting the search, the callback will only be called when a new device is found. If you need to get all devices found by the current scanner instance, call the appropriate method.

Sensor

Creating

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, Sensor,  } from "react-native-neurosdk2";

// BrainBit
var sensor: BrainBitSensor = await scanner.createSensor(sensorInfo) as BrainBitSensor;

// Callibri
var sensor: CallibriSensor = await scanner.createSensor(deviceInfo) as CallibriSensor

Device creation is a blocking method, so it must be called from separate thread.

For all types of devices, you can use the same methods to control the device's connection status, invoke commands, and check for functionality.

Manage connection state

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()

Method Connect is blocking too, so it need to be call from separate thread.

Manage device parameters

Battery

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()
Parameters

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:

  • the name of the parameter, represented by an enumeration
  • parameter availability for manipulation. Can be one of three values:
    • read - read-only
    • read and write - parameter can be changed
    • read and notify - parameter is updated over time

You can also check if the parameter is supported, for example Gain:

if(sensor.isSupportedParameter(SensorParameter.Gain)){
    ...
}
Parameter description
Name

Name of device. String value.

var name: string = sensor.getName()
...
sensor.setName('new_name') // <- this is throw an exeption, you cannot set device name
State

Information about the connection status of a device. Может принимать два значения:

  • InRange - Device connected
  • OutOfRange - The device is turned off or out of range
var state: SensorState = sensor.getState()
Address

MAC-address of device. For iOS/MacOS represents by UUID. String value.

var address: string = sensor.getAddress()
SerialNumber

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()
HardwareFilterState

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 using the HardwareFilters property. The next filters are available:

  • HPFBwhLvl1CutoffFreq1Hz
  • HPFBwhLvl1CutoffFreq5Hz
  • BSFBwhLvl2CutoffFreq45_55Hz
  • BSFBwhLvl2CutoffFreq55_65Hz
  • HPFBwhLvl2CutoffFreq10Hz
  • LPFBwhLvl2CutoffFreq400Hz

If sensor does not support filter in input list the method throw an exception

var filters: Array<SensorFilter> = sensor.getHardwareFilters()
...
sensor.getHardwareFilters([SensorFilter.FilterBSFBwhLvl2CutoffFreq55_65Hz, SensorFilter.FilterHPFBwhLvl2CutoffFreq10Hz])
FirmwareMode

Information about the current mode of operation of the device firmware. It can be in two states:

  • ModeBootloader - the device is in bootloader mode
  • ModeApplication - normal operation
var mode: SensorFirmwareMode = sensor.getFirmwareMode()
...
// Setter supports only with Callibri MF
sensor.setFirmwareMode(SensorFirmwareMode.ModeApplication)
SamplingFrequency

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:

  • For EEG signals not less than 250 Hz;
  • For ECG signals 125 Hz;
  • For EMG not less than 1000 Hz. When working with several devices at the same time, it is not recommended to increase the frequency above 1000 Hz;
  • The breath channel has a fixed sampling rate of 20 Hertz. MEMS channels have a fixed sampling rate of 100 Hertz.

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:

  • 125 Hz
  • 250 Hz
  • 500 Hz
  • 1000 Hz
  • 2000 Hz

Not available for Callibi EMS. 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

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. It is unchanged for BrainBit and BrainBitBlack and is 6. For Callibi/Kolibri MF you can set the desired value. Not available for Callibi/Kolibri EMS.

  • 1
  • 2
  • 3
  • 4
  • 6
  • 8
  • 12
  • 24
var gain: SensorGain = sensor.getGain()
...
// Setter supports only with Callibri MF
sensor.setGain(SensorGain.Gain3)

If you try to set an unsupported value to the device, an exception will be thrown.

Offset

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.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
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.

ExternalSwitchState

Switched signal source. This parameter is available only to Callibi/Kolibri. It is can take on the following values:

  • ExtSwInElectrodesRespUSB - Respiratory channel data source is USB connector. The source of myographic channel data are terminals.
  • ExtSwInElectrodes - Terminals are the source of myographic channel data. The breathing channel is not used.
  • ExtSwInUSB - The source of myographic channel data is the USB connector. The breathing channel is not used.
  • ExtSwInRespUSB - Respiratory channel data source is USB connector. Myographic channel is not used.
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.

ADCInputState

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:

  • Electrodes - Inputs to electrodes. This mode is designed to receive a physiological signal from the place of application.
  • Short - Inputs are short-circuited. This mode is designed to close the outputs. The output will have noise at the baseline or 0 volt level.
  • Test - Inputs to the ADC test. This mode is intended for checking the correctness of the ADC operation. The output should be a square wave signal with a frequency of 1 Hz and an amplitude of +/- 1 mV.
  • Resistance - Inputs for measuring the interelectrode resistance. This mode is designed to measure the interelectrode resistance, as well as to obtain a physiological signal. This is the recommended default mode.

The value is stored and changed in the ADCInput property.

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.

AccelerometerSens

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:

  • 2g - Normal sensitivity. Minimum value. Sufficient for practical use
  • 4g - Increased sensitivity.
  • 8g - High sensitivity.
  • 16g - Maximum sensitivity.

The value is stored and changed in the AccSens property.

If you try to set an unsupported value to the device, an exception will be thrown.

GyroscopeSens

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:

  • 250Grad - The range of measured values of the angular velocity is from 0 to 2000 degrees per second. Recommended for measuring angles.
  • 500Grad - The range of measured values of the angular velocity is from 0 to 1000 degrees per second.
  • 1000Grad - The range of measured values of the angular velocity is from 0 to 500 degrees per second.
  • 2000Grad - The range of measured values of the angular velocity is from 0 to 250 degrees per second.

The value is stored and changed in the GyroSens property.

If you try to set an unsupported value to the device, an exception will be thrown.

StimulatorAndMAState

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:

  • StimulatorState - Stimulation mode state
  • MAState - Drive assistant mode state

Each of the fields can be in three states:

  • Enabled
  • Disabled
  • NoParams

If you try to set an unsupported value to the device, an exception will be thrown.

StimulatorParamPack

Stimulation parameters. This property is available only to Callibi/Kolibri EMS. Contains:

  • Current - stimulus amplitude in mA. 1..100.
  • PulseWidth - duration of the stimulating pulse by us. 20..460.
  • Frequency - frequency of stimulation impulses by Hz. 1..200.
  • StimulusDuration - maximum stimulation time by ms. 0...65535.

The value is stored and changed in the StimulatorParamCallibri property.

If you try to set an unsupported value to the device, an exception will be thrown.

MotionAssistantParamPack

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. Параметр доступен только для Callibi/Kolibri стимулятора. Contain a structure named CallibriMotionAssistantParams with fields:

  • GyroStart - Angle value in degrees at which the stimulation mode will start, if it is correctly configured.
  • GyroStop - Angle value in degrees above which the stimulation mode will stop, if it is correctly configured.
  • Limb - multiple of 10. This means that the device is using the (MinPauseMs / 10) value. Correct values: 10, 20, 30, 40 ...
  • MinPauseMs - Pause between starts of stimulation mode in milliseconds.

The value is stored and changed in the MotionAssistantParamCallibri property.

If you try to set an unsupported value to the device, an exception will be thrown.

FirmwareVersion

Information about the device firmware version. Contain a structure named SensorVersion with fields:

  • firmware major
  • firmware minor
  • firmware patch
  • hardware major
  • hardware minor
  • hardware patch
  • extension major

The value is stored and changed in the Version property.

var version: SensorVersion = sensor.getVersion()
MotionCounterParamPack

This parameter is available only to Callibi/Kolibri. Contain a structure named MotionCounterParamCallibri with fields:

  • InsenseThresholdMG - Insense threshold mg. 0..500
  • InsenseThresholdSample - Algorithm insense threshold in time (in samples with the MEMS sampling rate) 0..500

The value is stored and changed in the CallibriMotionCounterParam property.

MotionCounter

Contains the number of motions. This parameter is available only to Callibi/Kolibri. A numeric value that cannot be changed. The value is stored and changed in the MotionCounterCallibri property.

BattPower

Battery power value. Integer value.

var power = sensor.getBattPower()
SensorFamily

Type of device. Enumeration.

var family: SensorFamily = sensor.getSensFamily()
SensorMode

Operating mode of the physiological amplifier. Parameter is available only for BraibBitBlack. The value is stored in the SensorAmpMode property.

SamplingFrequencyResist

Frequency of updating resistance values. Immutable value. Not available for Callibri/Kolibri. Don't has a fixed value for BrainBit/BrainBitBlack.

SamplingFrequencyMEMS

Frequency of updating MEMS values. Immutable value. Available for Callibri/Kolibri supporting MEMS.

SamplingFrequencyResp

Frequency of updating breath values. Неизмениемое значение. Available for Callibri/Kolibri supporting breath.

Features

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)){
    ...
}
Commands

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)){
    ...
}

BrainBit, BrainBitBlack

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.

Receiving signal

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:

  • PackNum - number for each packet
  • Marker - marker of sample, if it was sent and this feature is supported by the device
  • O1 - value of O1 channel in V
  • O2 - value of O2 channel in V
  • T3 - value of T3 channel in V
  • T4 - value of T4 channel in V

Ping signal

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)

Recieving resistance

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:

  • O1 - value of O1 channel in Ohm
  • O2 - value of O2 channel in Ohm
  • T3 - value of T3 channel in Ohm
  • T4 - value of T4 channel in Ohm

Callibri MF, Kolibri MF

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

Receiving signal

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 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:

  • PackNum - number for each packet
  • array of samples in V

Signal settings

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:

  • EEG - parameters: Gain6, Offset = 3, ADCInputResistance
  • EMG - parameters: Gain6, Offset = 3, ADCInputResistance
  • ECG - parameters: Gain6, Offset = 3, ADCInputResistance
  • EDA (GSR) - parameters: Gain6, Offset = 8, ADCInputResistance, ExternalSwitchInputMioElectrodes. By default the input to the terminals is set. If you want to change it to USB use the ExtSwInput property.
  • StrainGaugeBreathing - parameters: Gain6, Offset = 4, ADCInputResistance, ExternalSwitchInputMioUSB
  • ImpedanceBreathing - parameters: Gain6, Offset = 4, ADCInputResistance, ExternalSwitchInputRespUSB

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.getSignalTypeCallibri()
...
sensor.setSignalTypeCallibri(CallibriSignalType.ECG)

Receiving envelope

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:

  • PackNum - number for each packet
  • sample in V

Check electrodes state

Allows you to determine the presence of electrical contact of the device electrodes with human skin. It can be in three states:

  • Normal - The electrodes have normal skin contact. Low electrical resistance between electrodes. The expected state when working with physiological signals.
  • Detached - High electrical resistance between electrodes. High probability of interference in the physiological signal.
  • HighResistance - There is no electrical contact between the electrodes of the device.

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:

  • PackNum - number for each packet
  • sample in V

Receiving Respiration

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:

  • PackNum - number for each packet
  • array of samples in V

MEMS

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:

  • PackNum - number for each packet
  • Accelerometer - accelerometer data. Contains:
    • X - Abscissa Acceleration
    • Y - Y-axis acceleration
    • Z - Acceleration along the applicate axis
  • Gyroscope - gyroscope data
    • X - The angle of inclination along the abscissa axis
    • Y - Inclination angle along the ordinate axis
    • Z - Angle of inclination along the axis of the applicate

Quaternion data is a structure:

  • PackNum - number for each packet
  • W - Rotation component
  • X - Vector abscissa coordinate
  • Y - Vector coordinate along the ordinate axis
  • Z - The coordinate of the vector along the axis of the applicate

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 MEMSCalibrateStateCallibri 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)

Motion counter

Представляет собой счетчик движений. Настроить можно с помощью свойства CallibriMotionCounterParam, в нем:

  • InsensThreshmG – Threshold of the algorithm's deadness in amplitude (in mg). The maximum value is 500mg. The minimum value is 0.
  • InsensThreshSamp - Threshold of the algorithm's insensitivity in time (in samples with the MEMS sampling rate). The maximum value is 500 samples. The minimum value is 0.

You can find out the current number of movements using the MotionCounterCallibri 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.setMotionCounterParamCallibri({
        InsenseThresholdMG: 250, InsenseThresholdSample:250
    })
    var motionCount = sensor.getMotionCounterCallibri()
    sensor.execute(SensorCommand.ResetMotionCounter)
}

Callibri/Kolibri EMS

Callibri is a EMS if it supports the stimulation module:

var isStimulator = sensor.isSupportedFeature(SensorFeature.CurrentStimulator)

Stimulation

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:

  • Current - stimulus amplitude in mA. 1..100
  • PulseWidth - duration of the stimulating pulse by us. 20..460
  • Frequency - frequency of stimulation impulses by Hz. 1..200.
  • StimulusDuration - maximum stimulation time by ms. 0...65535. Zero is infinitely.

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 StimulatorMAStateCallibri property. Contains two parameters:

  • StimulatorState - Stimulation mode state
  • MAState - Drive assistant mode state

Each of the parameters can be in 4 states:

  • StimStateNoParams - parameter not set
  • StimStateDisabled - mode disabled
  • StimStateEnabled - mode enabled
  • StimStateUnsupported - sensor unsupported

Motion assistant

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 StimulatorParamCallibri.

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:

  • GyroStart - Angle value in degrees at which the stimulation mode will start, if it is correctly configured.
  • GyroStop - Angle value in degrees above which the stimulation mode will stop, if it is correctly configured.
  • Limb - overlay location in stimulation mode, if supported.
  • MinPauseMs - Pause between starts of stimulation mode in milliseconds. Multiple of 10. This means that the device is using the (MinPauseMs / 10) value. Correct values: 10, 20, 30, 40 ...
sensor.setMotionAssistantParamCallibri({
    GyroStart: 45, 
    GyroStop:10, 
    Limb: CallibriMotionAssistantLimb.RightLeg, 
    MinPauseMs: 10
 })
sensor.execute(SensorCommand.EnableMotionAssistant)
...
sensor.execute(SensorCommand.StopCurrentStimulation)

Keywords

react-native

FAQs

Package last updated on 14 Aug 2023

Did you know?

Socket

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.

Install

Related posts