dado93 / pywearable

Python package for extraction, visualization, and analysis of physiological data collected through wearable sensors.
https://pywearable.readthedocs.io/en/latest/
MIT License
5 stars 1 forks source link

Integrate bedtime and wakeup time statistics in get_sleep_statistics #65

Open Vaeliss opened 8 months ago

Vaeliss commented 8 months ago

At the moment bedtime and wake-up time are not returned in the general pywearable.sleep.get_sleep_statistics. They should be added.

In order to do so a sleep._compute_sleep_timestamp must be added, which will require a sleep_summary parameter as other compute functions. The main difference to take into account for the calculation of statistics is that the parameter kind can't be applied directly as it is the case for other sleep statistics but must be mapped to functions in the utils module such as utils.get_earliest_bedtime etc..

This mapping could be done by creating a dictionary (kind_mapping) for the mapping which includes only the sleep metrics which have a different behavior w.r.t. the kind parameter. When kind needs to be applied for the calculation of sleep_statistics it should be simply proceeded by something like kind = kind_mapping.get(sleep_metric, kind) so that for metrics which require a different treatment, such as bedtime and wake-up time, the proper function is used.

Vaeliss commented 8 months ago

Clearly, in such case the function sleep.get_sleep_timestamps should be uniformed to the other to call simply sleep.get_sleep_statistic and delegate the actual computation to the new function sleep._compute_sleep_timestamps

dado93 commented 1 month ago

@Vaeliss at the moment we have:

Do you think that the function get_sleep_timestamps, which is the only one that is different from all the others, should still be left in the module? As it does not offer any of the new features (kind, return_df, and so on), I see two options here:

Vaeliss commented 4 weeks ago

I'd probably remove it, as you said now that we have get_bedtime and get_wakeup_time, it's redundant.

However, it's used in several other modules for now (cardiac for hrv stats, stress module, and the labfront loader), so we need to remove it and at the same time substitute it with the two funcs above in those cases.