Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect sensor type #8

Closed
mesca opened this issue Aug 8, 2021 · 11 comments
Closed

Detect sensor type #8

mesca opened this issue Aug 8, 2021 · 11 comments
Assignees

Comments

@mesca
Copy link

mesca commented Aug 8, 2021

Opensignals is able to detect the sensor type for each channel (EDA, ECG, etc.)
I do not see anything in the API documentation that would allow me to do the same.
Is this possible with the Python API?

@DFNOsorio
Copy link
Contributor

Hey,

To get the sensors connected, you simply have to call the .getSensors() on your instance. For example if you use the sample code provided, your instance should be something like this: device = NewDevice(address), and to get the sensors just call device.getSensors() (P.S. This method only works with devices that have the biosignals 3.7 and up firmware)

Best regards

@DFNOsorio DFNOsorio self-assigned this Aug 9, 2021
@mesca
Copy link
Author

mesca commented Aug 9, 2021

Hi Daniel,
Thanks for the pointer. Unfortunately, .getSensors() segfaults on my machine (macOS 11.5).
I tried with Python 3.7, 3.8, and 3.9. Firmware version: 3.7. Hardware version: 17.0.

@mesca
Copy link
Author

mesca commented Aug 9, 2021

Here is the output of lddb:

Process 10840 launched: '/Users/mesca/opt/miniconda3/envs/timeflux/bin/python' (x86_64)
2021-08-09 16:04:00.898988+0200 python[10840:101182] instantiateOnDevice for regular
Process 10840 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x141)
    frame #0: 0x0000000101e3c66f _datetime.cpython-39-darwin.so`new_date_ex + 95
_datetime.cpython-39-darwin.so`new_date_ex:
->  0x101e3c66f <+95>:  callq  *0x130(%rcx)
    0x101e3c675 <+101>: testq  %rax, %rax
    0x101e3c678 <+104>: je     0x101e3c696               ; <+134>
    0x101e3c67a <+106>: movq   $-0x1, 0x10(%rax)
Target 0: (python) stopped.

@DFNOsorio
Copy link
Contributor

The API in this rep for macOS is for the 3.7 Python, but we tested using the built in (non Anaconda) version (sometimes there are weird behaviors when using it).
What sensors do you have attached to the device?

@mesca
Copy link
Author

mesca commented Aug 9, 2021

The built-in version I have is 3.8.2, and it does not work with it either.
I tried with an EDA sensor, then ECG, then both.

@DFNOsorio
Copy link
Contributor

I've just updated the compiled API for version 3.8 and 3.9, and also performed a quick test.
Screenshot 2021-08-09 at 16 22 35

@mesca
Copy link
Author

mesca commented Aug 9, 2021

Eager to test, but the macOS lib has disappeared from the repo ;)

@DFNOsorio
Copy link
Contributor

Done. I changed the folder structure and forgot to do the add command

@mesca
Copy link
Author

mesca commented Aug 9, 2021

Thanks, it works!
I can see the following properties: ['characteristics', 'clas', 'color', 'hwVersion', 'measurCalib', 'productionTime', 'serialNum', 'type', 'uid']
Can you tell me how to map these to the actual sensor type? The only API documentation I have is here, but it is clearly outdated.

@DFNOsorio
Copy link
Contributor

Glad to hear it works.

The key in the return dictionary is the port to which the sensor is connected.

The properties you listed are as follow:
uid - Sensor 48-bit unique identifier
clas - Sensor class
serialNum - Sensor serial number within its class
hwVersion - Sensor hardware version number
type - Sensor interface type bitmask
productionTime - Sensor production timestamp
color - Sensor sleeve color
characteristics - Sensor characteristics
measurCalib - Sensor measurements or calibration data

The clas is what I think you want. You can implement the following list to convert the number to the sensor type sensorClasses = ['UNKNOWN', 'EMG', 'ECG', 'LUX', 'EDA', 'BVP', 'RESP', 'XYZ', 'SYNC', 'EEG', 'SYNC_ADAP', 'SYNC_LED', 'SYNC_SW', 'USB', 'FORCE', 'TEMP', 'VPROBE', 'BREAKOUT', 'SpO2', 'GONI', 'ACT', 'EOG', 'EGG']

To map the color (the colored sleeve on the sensor), sensorColors = ['unknown', 'black', 'gray', 'white', 'dark_blue', 'light_blue', 'red', 'green', 'yellow', 'orange', 'light_green', 'brown']

The characteristics and measurCalib (measured calibration) are sensor specific.

Some sensors have variants (present in the characteristics dict) and can be mapped using sensorVariants = { 'SpO2': {'H': 'hSpO2', 'F': 'fSpO2', 'L': 'SpO2'}, 'FORCE': {'1': 'FSRI', '2': 'FSRII', '3': 'FSRIII', '4': 'FSRIV', '5': 'LOADCELL', '6': 'FORCEPLATFORM'} }

@mesca
Copy link
Author

mesca commented Aug 9, 2021

Perfect, thanks a lot.
I think I have everything I need. I am closing this issue.
It would be great to update the documentation.

@mesca mesca closed this as completed Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants