### Install PyNeuroSDK2 Source: https://pypi.org/project/pyneurosdk2/1.0.9 Use pip to install the pyneurosdk2 package. Specify the version for exact installation. ```bash pip install pyneurosdk2==1.0.9 ``` -------------------------------- ### Install NeuroSDK2 Library on Linux Source: https://pypi.org/project/pyneurosdk2/1.0.9 For Linux, first download the NeuroSDK2 .deb package from GitHub, then install it using dpkg. ```bash sudo apt install ./libneurosdk2.deb ``` -------------------------------- ### Start Device Search Source: https://pypi.org/project/pyneurosdk2/1.0.9 Initiate the device search process using the scanner.start() method. ```python scanner.start() ``` -------------------------------- ### Register Callback for Resistance Data Reception Source: https://pypi.org/project/pyneurosdk2/1.0.9 Set up a callback to receive resistance measurements from the sensor. This requires starting the resistance measurement command. ```python def on_brain_bit_resist_data_received(sensor, data): print(data) sensor.resistDataReceived = on_brain_bit_resist_data_received sensor.exec_command(SensorCommand.StartResist) sensor.exec_command(SensorCommand.StopResist) ``` -------------------------------- ### Register Callback for Electrode State Changes Source: https://pypi.org/project/pyneurosdk2/1.0.9 Set up a callback to monitor changes in electrode connection states for Callibri and Kolibri devices. This requires starting signal transmission. ```python def onCallibriElectrodeStateChanged(sensor, data): print(data) sensor.electrodeStateChanged = onCallibriElectrodeStateChanged ``` -------------------------------- ### BrainBit 2 Amplifier Parameter Setup Source: https://pypi.org/project/pyneurosdk2 Configure amplifier parameters for BrainBit 2 devices, including gain, signal mode, resistance usage, and current. ```APIDOC ## BrainBit 2 Amplifier Parameter Setup ### Description Configure various amplifier parameters for BrainBit 2 devices to customize channel and device settings. This includes setting the gain for each channel, signal modes, resistance usage, and the probe current generator settings. ### Usage ```python amp_param = sensor.amplifier_param # Get current amplifier parameters ch_count = sensor.channels_count # Get the number of channels # Setup Gain for all channels amp_param.ChGain = [SensorGain.Gain6 for i in range(ch_count)] # Other parameters (examples): # amp_param.ChSignalMode = [BrainBit2ChannelMode.ChModeNormal for i in range(ch_count)] # amp_param.ChResistUse = [True for i in range(ch_count)] # amp_param.Current = GenCurrent.GenCurr6nA sensor.amplifier_param = amp_param # Apply the updated parameters ``` ### Parameter Details: * **Current**: Defines the probe current generator settings: * `GenCurr0nA` * `GenCurr6nA` * `GenCurr12nA` * `GenCurr18nA` * `GenCurr24nA` * `GenCurr6uA` * `GenCurr24uA` * `Unsupported` * **Signal modes**: Defines the input mode for each channel: * `Short` - Shorted input. * `Normal` - Bipolar input mode (used for EEG). * **Resist use**: Indicates whether resistance measurement is used for a channel (doesn't apply to the current device version). * **Gain**: Sets the gain of the ADC signal for each channel. ``` -------------------------------- ### Get Supported Channels Source: https://pypi.org/project/pyneurosdk2/1.0.9 Retrieve the list of supported channels for the sensor. This helps in understanding the physical layout and availability of channels. ```python supported_channels = sensor.supported_channels ``` -------------------------------- ### Execute Sensor Commands Source: https://pypi.org/project/pyneurosdk2/1.0.9 Send commands to the sensor to perform actions like starting or stopping signal or resistance readings. Ensure the command is supported by the sensor. ```python sensor.exec_command(SensorCommand.StartSignal) ``` ```python sensor.exec_command(SensorCommand.StopSignal) ``` ```python sensor.exec_command(SensorCommand.StartResist) ``` ```python sensor.exec_command(SensorCommand.StopResist) ``` -------------------------------- ### Sequential Resistance and Signal Reading Source: https://pypi.org/project/pyneurosdk2/1.0.9 Demonstrates the correct sequence for reading resistance and signal data, highlighting the need to stop one mode before starting the other to avoid conflicts. ```python sensor.exec_command(SensorCommand.StartResist) sleep(10) sensor.exec_command(SensorCommand.StopResist) ... sensor.exec_command(SensorCommand.StartSignal) sleep(10) sensor.exec_command(SensorCommand.StopSignal) ``` -------------------------------- ### Configure Amplifier Parameters Source: https://pypi.org/project/pyneurosdk2 Configure essential amplifier parameters such as resistance measurement, sampling frequency, channel gain, and channel mode. This must be done after connecting the device and before starting data acquisition to ensure valid signal and resistance values. ```python ch_count = sensor.channels_count amp_param = sensor.amplifier_param amp_param.ReferentResistMesureAllow = True amp_param.Frequency = SensorSamplingFrequency.FrequencyHz500 amp_param.ChannelGain = [SensorGain.Gain3 for i in range(ch_count)] amp_param.ChannelMode = [EEGChannelMode.EEGChModeSignalResist for i in range(ch_count)] sensor.amplifier_param = amp_param ``` -------------------------------- ### Receive Resistance Data via Callback Source: https://pypi.org/project/pyneurosdk2/1.0.9 Register a callback to process resistance values transmitted by the sensor. Ensure that signal reception is stopped before starting resistance readings, and vice versa. ```python def on_brain_bit_resist_data_received(sensor, data): print(data) sensor.resistDataReceived = on_brain_bit_resist_data_received sensor.exec_command(SensorCommand.StartResist) sensor.exec_command(SensorCommand.StopResist) ``` ```python sensor.resistDataReceived = None ``` -------------------------------- ### Retrieve Found Sensors Source: https://pypi.org/project/pyneurosdk2/1.0.9 Get a list of all currently found sensors using the scanner.sensors() method. ```python sensors = scanner.sensors() ``` -------------------------------- ### Get Number of Channels Source: https://pypi.org/project/pyneurosdk2 Retrieve the total number of channels available on the NeuroEEG device using the `channels_count` property. ```python ch_count = sensor.channels_count ``` -------------------------------- ### Receive Signal Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to this callback to get signal values. The data is returned as a list of packages, each containing channel values, a packet number, and a marker if supported. ```python def on_signal_data_received(sensor, data: list[HeadbandSignalData]): print(data) sensor.signalDataReceived = on_signal_data_received sensor.exec_command(SensorCommand.StartSignal) ... sensor.exec_command(SensorCommand.StopSignal) sensor.signalDataReceived = None ``` -------------------------------- ### Get Callibri/Kolibri Serial Number Source: https://pypi.org/project/pyneurosdk2/1.0.9 After connecting to a Callibri or Kolibri device, retrieve its serial number using the sensor.serial_number attribute. ```python sn = sensor.serial_number ``` -------------------------------- ### Receive Signal Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to a callback function to receive real-time signal data. The device must be commanded to start transmitting signal data using `StartSignal`. Ensure the sampling rate and gain are configured appropriately via amplifier parameters. To stop receiving data, set the callback to `None` and send the `StopSignal` command. ```python def on_signal_data_received(sensor: Sensor, data: list[SignalChannelsData]): print(data) sensor.signalDataReceived = on_signal_data_received sensor.exec_command(SensorCommand.StartSignal) ... sensor.signalDataReceived = None sensor.exec_command(SensorCommand.StopSignal) ``` -------------------------------- ### Receive Resistance Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to a callback function to receive real-time resistance data, which helps determine electrode-to-skin contact quality. The device must be commanded to start transmitting resistance data using `StartResist`. To stop receiving data, set the callback to `None` and send the `StopResist` command. ```python def on_resist_data_received(sensor: Sensor, data: list[ResistChannelsData]): print(data) sensor.resistDataReceived = on_resist_data_received sensor.exec_command(SensorCommand.StartResist) ... sensor.resistDataReceived = None sensor.exec_command(SensorCommand.StopResist) ``` -------------------------------- ### Start and Stop Receiving BrainBit Signal Data Source: https://pypi.org/project/pyneurosdk2 Initiate and terminate the streaming of signal data from a BrainBit sensor. A callback function is required to process the received data. ```python def on_brain_bit_signal_data_received(sensor, data): print(data) sensor.signalDataReceived = on_brain_bit_signal_data_received sensor.exec_command(SensorCommand.StartSignal) sensor.exec_command(SensorCommand.StopSignal) ``` -------------------------------- ### Get Current Amplifier Mode Source: https://pypi.org/project/pyneurosdk2/1.0.9 Directly query the current amplifier mode of the sensor. This is useful for checking the state at any point in time. ```python mode = sensor.amp_mode ``` -------------------------------- ### Get Sensor Information Source: https://pypi.org/project/pyneurosdk2/1.0.9 Retrieve various properties of the connected sensor, such as its family, features, commands, name, state, address, serial number, battery power, sampling frequency, gain, data offset, and firmware version. ```python print(sensor.sens_family) # SensorFamily.LEBrainBit print(sensor.features) # [, ...] print(sensor.commands) # [,...] print(sensor.parameters) print(sensor.name) # BrainBit print(sensor.state) # SensorState.StateInRange print(sensor.address) # AA:BB:CC:DD:EE:FF print(sensor.serial_number) # 123456 print(sensor.batt_power) # 50 print(sensor.sampling_frequency) # SensorSamplingFrequency.FrequencyHz250 print(sensor.gain) # SensorGain.Gain6 print(sensor.data_offset) # SensorDataOffset.DataOffset0 print(sensor.version) # SensorVersion(FwMajor=50, FwMinor=0, FwPatch=0, HwMajor=1, HwMinor=0, HwPatch=0, ExtMajor=65) ``` -------------------------------- ### Initialize Scanner for Device Search Source: https://pypi.org/project/pyneurosdk2 Initialize the Scanner with a list of sensor families to search for. ```python scanner = Scanner([SensorFamily.LEBrainBit, SensorFamily.LEBrainBit2, SensorFamily.LECallibri, SensorFamily.LEHeadband, SensorFamily.LEHeadPhones2]) ``` -------------------------------- ### Check Feature, Command, and Parameter Support Source: https://pypi.org/project/pyneurosdk2/1.0.9 Verify if the connected sensor supports specific features, commands, or parameters before attempting to use them. This prevents errors and ensures compatibility. ```python sensor.is_supported_feature(sensor_future) sensor.is_supported_command(sensor_command) sensor.is_supported_parameter(sensor_parameter) ``` -------------------------------- ### Create Sensor Instance Source: https://pypi.org/project/pyneurosdk2/1.0.9 Create a sensor instance from a SensorInfo object obtained during the search. This method is blocking and connects automatically. ```python sensor = scanner.create_sensor(sensInfo) ``` -------------------------------- ### Initialize Scanner for Specific Devices Source: https://pypi.org/project/pyneurosdk2/1.0.9 Create a Scanner instance, specifying the types of sensors to search for, such as LEBrainBit and LECallibri. ```python scanner = Scanner([SensorFamily.LEBrainBit, SensorFamily.LECallibri]) ``` -------------------------------- ### Receive Signal Data via Callback Source: https://pypi.org/project/pyneurosdk2/1.0.9 Set up a callback function to receive real-time signal data from the sensor. Remember to unsubscribe by setting the callback to None when finished. ```python def on_brain_bit_signal_data_received(sensor, data): print(data) sensor.signalDataReceived = on_brain_bit_signal_data_received sensor.exec_command(SensorCommand.StartSignal) sensor.exec_command(SensorCommand.StopSignal) ``` ```python sensor.signalDataReceived = None ``` -------------------------------- ### Import Scanner Class Source: https://pypi.org/project/pyneurosdk2/1.0.9 Import the Scanner class from the neurosdk.scanner module to initiate device searching. ```python from neurosdk.scanner import Scanner ``` -------------------------------- ### Receive FPG Data Source: https://pypi.org/project/pyneurosdk2 Set up this callback to receive FPG data. The callback returns a packet of samples containing values for the red and infrared channels. ```python def on_fpg_data_received(sensor, data: list[FPGData]): print(data) sensor.fpgDataReceived = on_fpg_data_received sensor.exec_command(SensorCommand.StartFPG) ... sensor.exec_command(SensorCommand.StopFPG) sensor.fpgDataReceived = None ``` -------------------------------- ### Receiving Resistance Data Source: https://pypi.org/project/pyneurosdk2 Set up a callback to receive resistance data and execute commands to start/stop resistance measurement. ```APIDOC ## Receiving Resistance Data ### Description Configure a callback function to receive resistance values from the sensor. You can start and stop the resistance measurement using specific commands. The callback returns a packet containing resistance values in volts for four channels. ### Callback Setup ```python def on_brain_bit_resist_data_received(sensor, data): print(data) sensor.resistDataReceived = on_brain_bit_resist_data_received ``` ### Starting Resistance Measurement ```python sensor.exec_command(SensorCommand.StartResist) ``` ### Stopping Resistance Measurement ```python sensor.exec_command(SensorCommand.StopResist) ``` ### Unsubscribing from Callback ```python sensor.resistDataReceived = None ``` ### Data Packet Structure Each packet contains resistance values in volts: * `O1`: float * `O2`: float * `T3`: float * `T4`: float ### Important Note BrainBit devices cannot simultaneously measure resistance and signal. Ensure one mode is stopped before starting the other. For example: ```python sensor.exec_command(SensorCommand.StartResist) sleep(10) # Wait for resistance measurement sensor.exec_command(SensorCommand.StopResist) sensor.exec_command(SensorCommand.StartSignal) sleep(10) # Wait for signal measurement sensor.exec_command(SensorCommand.StopSignal) ``` ``` -------------------------------- ### Parameter and Feature Support Check Source: https://pypi.org/project/pyneurosdk2 Check if specific features, commands, or parameters are supported by the device. ```APIDOC ## Parameter and Feature Support Check ### Description Check if the device supports a given feature, command, or parameter. This is useful for ensuring compatibility and proper usage of device capabilities. ### Usage ```python # Check if a feature is supported if sensor.is_supported_feature(sensor_future): print("Feature is supported") # Check if a command is supported if sensor.is_supported_command(sensor_command): print("Command is supported") # Check if a parameter is supported if sensor.is_supported_parameter(sensor_parameter): print("Parameter is supported") ``` ### Example Parameter Info ``` # Example of parameter information, showing parameter and its access level [ParameterInfo(Param=, ParamAccess=), ParameterInfo(Param=, ParamAccess=)] ``` ``` -------------------------------- ### Receiving Signal Data Source: https://pypi.org/project/pyneurosdk2 Set up a callback to receive signal data and execute commands to start/stop signal transmission. ```APIDOC ## Receiving Signal Data ### Description Configure a callback function to receive real-time signal data from the sensor. You can start and stop the signal transmission using specific commands. The callback receives data packets containing values from 4 channels, a packet number, and a marker if the feature is supported. ### Callback Setup ```python def on_brain_bit_signal_data_received(sensor, data): print(data) sensor.signalDataReceived = on_brain_bit_signal_data_received ``` ### Starting Signal Reception ```python sensor.exec_command(SensorCommand.StartSignal) ``` ### Stopping Signal Reception ```python sensor.exec_command(SensorCommand.StopSignal) ``` ### Unsubscribing from Callback ```python sensor.signalDataReceived = None ``` ### Data Packet Structure Each package contains: * `PackNum`: int * `Marker`: int * `O1`: float * `O2`: float * `T3`: float * `T4`: float ``` -------------------------------- ### Connect to Existing Device Source: https://pypi.org/project/pyneurosdk2/1.0.9 Reconnect to a device that was previously created but is not currently connected. This method is blocking. ```python sensor.connect() ``` -------------------------------- ### Import Sensor Classes Source: https://pypi.org/project/pyneurosdk2/1.0.9 Import specific sensor classes from the neurosdk module for different device types. ```python from neurosdk.callibri_sensor import CallibriSensor from neurosdk.brainbit_sensor import BrainBitSensor from neurosdk.brainbit_2_sensor import BrainBit2Sensor from neurosdk.brainbit_black_sensor import BrainBitBlackSensor ``` -------------------------------- ### Register Callback for Amplifier Mode Changes Source: https://pypi.org/project/pyneurosdk2 Set up a callback function to be notified whenever the amplifier mode changes. The callback receives the sensor object and the new amplifier mode. ```python def on_amp_mode_changed(sensor: Sensor, mode: SensorAmpMode): print('Amp mode: {0}'.format(mode)) sensor.sensorAmpModeChanged = on_amp_mode_changed ``` -------------------------------- ### Register Callback for Amplifier Mode Changes Source: https://pypi.org/project/pyneurosdk2/1.0.9 Set up a callback function to be notified whenever the device's amplifier mode changes. This is crucial for performing certain operations that depend on the device's current state. ```python def on_amp_mode_changed(sensor, mode): print('Amp mode: {0}'.format(mode)) sensor.sensorAmpModeChanged = on_amp_mode_changed ``` -------------------------------- ### Configure Headphone Amplifier Parameters Source: https://pypi.org/project/pyneurosdk2 Change device parameters for headphones by setting the amplifier_param attribute. This allows configuration of signal and resistance channels, gain, and current. ```python amplifierParams = sensor.amplifier_param sensor.amplifier_param = Headphones2AmplifierParam(ChSignalUse1=True, ChSignalUse2=True, ChSignalUse3=True, ChSignalUse4=True, ChResistUse1=True, ChResistUse2=True, ChResistUse3=True, ChResistUse4=True, ChGain1=SensorGain.Gain6, ChGain2=SensorGain.Gain6, ChGain3=SensorGain.Gain6, ChGain4=SensorGain.Gain6, Current=GenCurrent.GenCurr6nA) ``` -------------------------------- ### Configure BrainBit 2 Amplifier Parameters Source: https://pypi.org/project/pyneurosdk2/1.0.9 Set amplifier parameters for BrainBit 2, including gain, signal mode, resistance usage, and current generator settings. Ensure to update the amplifier_param object on the sensor. ```python amp_param = sensor.amplifier_param # current amplifier params ch_count = sensor.channels_count # channels count of devices # setup Gain amp_param.ChGain = [SensorGain.Gain6 for i in range(ch_count)] # and other parameters # amp_param.ChSignalMode = [BrainBit2ChannelMode.ChModeNormal for i in range(ch_count)] # amp_param.ChResistUse = [True for i in range(ch_count)] # amp_param.Current = GenCurrent.GenCurr6nA sensor.amplifier_param = amp_param ``` -------------------------------- ### Receive FPG Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to photoplethysmography (FPG) data using a callback. Ensure to stop the FPG stream and unsubscribe the callback when finished. ```python def on_fpg_data_received(sensor, data: list[FPGData]): print(data) sensor.fpgDataReceived = on_fpg_data_received sensor.exec_command(SensorCommand.StartFPG) ... sensor.exec_command(SensorCommand.StopFPG) sensor.fpgDataReceived = None ``` -------------------------------- ### Register Callback for Signal Data Reception Source: https://pypi.org/project/pyneurosdk2/1.0.9 Subscribe to receive real-time signal data from the sensor. The data is provided in volts and requires the device to be in a signal-transmitting state. ```python def on_signal_data_received(sensor, data): print(data) sensor.signalDataReceived = on_signal_data_received ``` -------------------------------- ### Check Parameter Access Levels Source: https://pypi.org/project/pyneurosdk2/1.0.9 Examine the access level for sensor parameters to determine if they are readable, writable, or notify-able. This is crucial before attempting to modify any device property. ```python [ParameterInfo(Param=, ParamAccess=), ParameterInfo(Param=, ParamAccess=) ...] ``` -------------------------------- ### Setting Gain Source: https://pypi.org/project/pyneurosdk2 Set the gain parameter for BrainBit sensors. ```APIDOC ## Setting Gain ### Description Allows setting the gain parameter for BrainBit sensors to adjust signal amplification. ### Method ```python sensor.gain = SensorGain.Gain3 ``` ### Parameters * **gain** (SensorGain) - The desired gain setting for the sensor. Example: `SensorGain.Gain3`. ``` -------------------------------- ### Receive Signal and Resistance Simultaneously (Headband) Source: https://pypi.org/project/pyneurosdk2 Subscribe to both signal and resistance events and execute the related command to receive both data types concurrently from a headband device. ```python def on_resist_data_received(sensor, data: HeadbandResistData): print(data) def on_signal_data_received(sensor, data: list[HeadbandSignalData]): print(data) sensor.resistDataReceived = on_resist_data_received sensor.signalDataReceived = on_signal_data_received sensor.exec_command(SensorCommand.StartSignalAndResist) ... sensor.exec_command(SensorCommand.StopSignalAndResist) sensor.resistDataReceived = None sensor.signalDataReceived = None ``` -------------------------------- ### Set BrainBit Sensor Gain Source: https://pypi.org/project/pyneurosdk2 Configure the gain setting for a BrainBit sensor. Ensure the sensor is compatible before setting this parameter. ```python sensor.gain = SensorGain.Gain3 ``` -------------------------------- ### Import Common Types Source: https://pypi.org/project/pyneurosdk2/1.0.9 Import all common types from the neurosdk.cmn_types module for general use. ```python from neurosdk.cmn_types import * ``` -------------------------------- ### Receive Signal and Resistance Simultaneously Source: https://pypi.org/project/pyneurosdk2 Subscribe to both signal and resistance data streams concurrently. Remember to stop both streams and unsubscribe their respective callbacks. ```python def on_resist_data_received(sensor, data: list[Headphones2ResistData]): print(data) def on_signal_data_received(sensor, data: list[Headphones2SignalData]): print(data) sensor.resistDataReceived = on_resist_data_received sensor.signalDataReceived = on_signal_data_received sensor.exec_command(SensorCommand.StartSignalAndResist) ... sensor.exec_command(SensorCommand.StopSignalAndResist) sensor.resistDataReceived = None sensor.signalDataReceived = None ``` -------------------------------- ### Register Callback for Callibri Signal Data Source: https://pypi.org/project/pyneurosdk2/1.0.9 Subscribe to receive signal data from Callibri devices. The data is provided in volts per packet. ```python def on_callibri_signal_data_received(sensor, data): print(data) sensor.signalDataReceived = on_callibri_signal_data_received ``` -------------------------------- ### Receive Resistance Data Source: https://pypi.org/project/pyneurosdk2 Use this callback to receive resistance values. The callback returns a packet of samples containing resistance values in volts. ```python def on_resist_data_received(sensor, data: HeadbandResistData): print(data) sensor.resistDataReceived = on_resist_data_received sensor.exec_command(SensorCommand.StartResist) ... sensor.exec_command(SensorCommand.StopResist) sensor.resistDataReceived = None ``` -------------------------------- ### Receive MEMS Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to Micro-Electro-Mechanical Systems (MEMS) data, including accelerometer and gyroscope readings, using a callback. Stop the MEMS stream and unsubscribe the callback when complete. ```python def on_mems_data_received(sensor: Sensor, data: list[MEMSData]): print(data) sensor.memsDataReceived = on_mems_data_received sensor.exec_command(SensorCommand.StartMEMS) ... sensor.exec_command(SensorCommand.StopMEMS) sensor.memsDataReceived = None ``` -------------------------------- ### Receive MEMS Data Source: https://pypi.org/project/pyneurosdk2 Use this callback to receive MEMS data, which includes packet number, accelerometer, and gyroscope coordinates. ```python def on_mems_data_received(sensor: Sensor, data: list[MEMSData]): print(data) sensor.memsDataReceived = on_mems_data_received sensor.exec_command(SensorCommand.StartMEMS) ... sensor.exec_command(SensorCommand.StopMEMS) sensor.memsDataReceived = None ``` -------------------------------- ### Device Information Retrieval Source: https://pypi.org/project/pyneurosdk2 Retrieve various properties and information about the connected sensor device. ```APIDOC ## Device Information Retrieval ### Description Retrieve various properties and information about the connected sensor device, such as its family, features, commands, name, state, address, serial number, power status, sampling frequency, gain, data offset, and firmware/hardware versions. ### Usage ```python print(sensor.sens_family) # SensorFamily.LEBrainBit print(sensor.features) # [, ...] print(sensor.commands) # [,...] print(sensor.parameters) print(sensor.name) # BrainBit print(sensor.state) # SensorState.StateInRange print(sensor.address) # AA:BB:CC:DD:EE:FF print(sensor.serial_number) # 123456 print(sensor.batt_power) # 50 print(sensor.sampling_frequency) # SensorSamplingFrequency.FrequencyHz250 print(sensor.gain) # SensorGain.Gain6 print(sensor.data_offset) # SensorDataOffset.DataOffset0 print(sensor.version) # SensorVersion(FwMajor=50, FwMinor=0, FwPatch=0, HwMajor=1, HwMinor=0, HwPatch=0, ExtMajor=65) ``` ``` -------------------------------- ### Receive Signal and Resistance Simultaneously Source: https://pypi.org/project/pyneurosdk2 Use this callback to receive both signal and resistance data. Note that resistData may not arrive with every SignalResistReceived callback update. ```python def on_signal_resist_data_received(sensor: Sensor, signal: list[SignalChannelsData], resist: list[ResistChannelsData]): print('Signal: {0}'.format(signal)) print('Resist: {0}'.format(resist)) sensor.signalResistDataReceived = on_signal_resist_data_received sensor.exec_command(SensorCommand.StartSignalAndResist) ... sensor.signalResistDataReceived = None sensor.exec_command(SensorCommand.StopSignalAndResist) ``` -------------------------------- ### Receive Resistance Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to resistance data using a callback function. Ensure to stop the resistance stream and unsubscribe the callback when done. ```python def on_resist_data_received(sensor, data: list[Headphones2ResistData]): print(data) sensor.resistDataReceived = on_resist_data_received sensor.exec_command(SensorCommand.StartResist) ... sensor.exec_command(SensorCommand.StopResist) sensor.resistDataReceived = None ``` -------------------------------- ### Receive Signal Data Source: https://pypi.org/project/pyneurosdk2 Subscribe to signal data using a callback function. Ensure to stop the signal and unsubscribe the callback when done. ```python def on_signal_data_received(sensor, data: list[Headphones2SignalData]): print(data) sensor.signalDataReceived = on_signal_data_received sensor.exec_command(SensorCommand.StartSignal) ... sensor.exec_command(SensorCommand.StopSignal) sensor.signalDataReceived = None ``` -------------------------------- ### Clean Up Sensor and Scanner Resources Source: https://pypi.org/project/pyneurosdk2/1.0.9 Manually release resources held by the sensor and scanner objects when they are no longer needed. This is typically handled by the garbage collector, but explicit deletion can be necessary. ```python del sensor del scanner ``` -------------------------------- ### Sensor Found Callback Source: https://pypi.org/project/pyneurosdk2/1.0.9 Define and assign a callback function to the sensorsChanged attribute to be notified when sensors are found or lost. ```python def sensorFound(scanner, sensors): for i in range(len(sensors)): print('Sensor %s' % sensors[i]) scanner.sensorsChanged = sensorFound ``` -------------------------------- ### Stop Device Search Source: https://pypi.org/project/pyneurosdk2/1.0.9 Terminate the device search process using the scanner.stop() method. ```python scanner.stop() ``` -------------------------------- ### Unsubscribe from Resistance Data Reception Source: https://pypi.org/project/pyneurosdk2/1.0.9 Disable the callback for resistance data to stop receiving resistance values. Assign None to the resistDataReceived property. ```python sensor.resistDataReceived = None ``` -------------------------------- ### Unsubscribe from Signal Data Reception Source: https://pypi.org/project/pyneurosdk2/1.0.9 Remove the callback for signal data reception to stop receiving updates. Set the corresponding property to None. ```python sensor.signalDataReceived = None ``` -------------------------------- ### Unsubscribe from Electrode State Changes Source: https://pypi.org/project/pyneurosdk2/1.0.9 Disable notifications for electrode state changes by setting the electrodeStateChanged property to None. ```python sensor.electrodeStateChanged = None ``` -------------------------------- ### Disconnect from Device Source: https://pypi.org/project/pyneurosdk2/1.0.9 Terminate the connection to the currently connected device using the sensor.disconnect() method. ```python sensor.disconnect() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.