Unisens / pyunisens

Python library to handle Unisens data
MIT License
4 stars 3 forks source link

undersnading the value coming out of the Unisens object #5

Open koriawas opened 2 years ago

koriawas commented 2 years ago

Hi @skjerns ,

I am using the pyunisens library for reading the files coming out of Movisens Device which follows the Unisens format.

I wanted to ask whether the 'signal value' coming out of object

signal = u.signal_bin signal = u['signal.bin'] signal = u.entries['signal.bin'] signal = u[0]

are already the Real world values or do I need to convert it like this ? value = (ADCout - baseline) * lsbValue

my unisens.XML look like below

`'

'`
jottenbacher commented 2 years ago

Example to get real world values:

import numpy as np
import unisens

u = unisens.Unisens('C:/temp/ttt')  # folder containing the unisens.xml
signal = u.entries['ecg.bin']
data = signal.get_data()
print(data[0:10])

If want the unscaled values:

data = signal.get_data(scaled=False)
koriawas commented 2 years ago

Hi @jottenbacher,

Thank you for the quick response. I already have the values BUT I am confused about scale. What scale is used?

is it same as the below formula? value = (ADCout - baseline) * lsbValue

Also while inserting the value into a new unisens file does it again scaled down? if Yes, what's the scale?

In my usecase I am reading a big unisens file and then trimming it into small files/records. I just want to ensure I do not end-up putting different ECG values in the trimmed file than the big unisens ECG file.

Thanks.

Saskia-K commented 1 year ago

This issue might be solved with my current pull request:

Up to now, the scaling with baseline and lsbValue is done when reading the data (as scaled defaults to True) but not when writing the data (there is no option like scaled).

With my changes from the pull request, scaling always happens for reading and writing when values for baseline and / or lsbValue are set. Due to not having the scaled option when writing, I removed the option for reading to achieve consistent behaviour.