Git Product home page Git Product logo

Comments (4)

Vaeliss avatar Vaeliss commented on August 24, 2024

For additional context:

the get_time_in_sleep_stage function in the sleep module, breaks when the pd.Series is transformed to a dictionary with the .to_dict() method. In fact, while in the Series two rows can have the same index, in the dictionary only the last row is kept for the key.

3 possible ways to fix:

  • Assume that the first sleep of the day is the important one (i.e. the person is sleeping at night) by: participant_sleep_summary = participant_sleep_summary.groupby("calendarDate").head(1)
  • Filter out rows with sleep score 0 completely, before producing the dictionary
  • Avoid the transformation to dict and return the pd.Series, giving the possibility to appropriately handle each sleep occurrence later on. In this case, note, however that if average=True, the mean can be skewed greatly by 0 sleep score naps.

from pywearable.

dado93 avatar dado93 commented on August 24, 2024

This was temporarily fixed in b07d089 . The new implementation returns only the first sleep of the day, and discards additional sleeps occuring during the day,
I am leaving this issue open for further improvements.

from pywearable.

dado93 avatar dado93 commented on August 24, 2024

I believe that the current implementation has to be improved. The order in which Labfront returns the sleep summaries is not always consistent with improving validation methods. In the example reported below, for example, we have that for the calendarDate 2023-08-04, the first sleep summary has a AUTO_TENTATIVE validation, the second one an ENHANCED_FINAL validation, and the third one a ENHANCED_TENTATIVE validation:

sleepSummaryId calendarDate timezoneOffsetInMs unixTimestampInMs isoDate durationInMs validation
x4dbbd48-64cc2270-5d84 2023-08-04 7200000 1691099760000 2023-08-03T23:56:00.000+02:00 23940000 AUTO_TENTATIVE
x4dbbd48-64cc23d8-567c 2023-08-04 7200000 1691100120000 2023-08-04T00:02:00.000+02:00 22140000 ENHANCED_FINAL
x4dbbd48-64cc2414-55c8 2023-08-04 7200000 1691100180000 2023-08-04T00:03:00.000+02:00 21960000 ENHANCED_TENTATIVE
x4dbbd48-64cd70e4-675c 2023-08-05 7200000 1691185380000 2023-08-04T23:43:00.000+02:00 26460000 AUTO_FINAL
x4dbbd48-64cd7288-6720 2023-08-05 7200000 1691185800000 2023-08-04T23:50:00.000+02:00 26400000 ENHANCED_TENTATIVE
x4dbbd48-64ceb328-7350 2023-08-06 7200000 1691267880000 2023-08-05T22:38:00.000+02:00 29520000 AUTO_TENTATIVE
x4dbbd48-64ceb490-73c8 2023-08-06 7200000 1691268240000 2023-08-05T22:44:00.000+02:00 29640000 ENHANCED_FINAL
x4dbbd48-64d00e44-71e8 2023-08-07 7200000 1691356740000 2023-08-06T23:19:00.000+02:00 29160000 ENHANCED_TENTATIVE
x4dbbd48-64d00ef8-6a2c 2023-08-07 7200000 1691356920000 2023-08-06T23:22:00.000+02:00 27180000 AUTO_TENTATIVE
x4dbbd48-64d00ef8-70f8 2023-08-07 7200000 1691356920000 2023-08-06T23:22:00.000+02:00 28920000 ENHANCED_TENTATIVE

Some functions of the module currently retrieve only the first row for a given calendarDate: in this case, we would have gotten a AUTO_TENTATIVE sleep summary, while the proper one should be the ENHANCED_FINAL. Thus, an improved method would be:

  1. Check if there are multiple sleep summaries for a given calendarDate (being aware of the fact that Garmin also tracks daily naps)
  2. Get the sleep summary with the best validation available

Tagging here also @Vaeliss so that he can have a look at it

from pywearable.

dado93 avatar dado93 commented on August 24, 2024

Labfront suggests to follow these decision scheme based on the documentation reported here:

  • The ENHANCED_FINAL one with the longest sleep period
  • The ENHANCED_TENTATIVE one with the longest sleep period
  • The AUTO_FINAL one with the longest sleep period
  • The AUTO_TENTATIVE one with the longest sleep period

from pywearable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.