wadpac / GGIR

Code corresponding to R package GGIR
https://wadpac.github.io/GGIR/
Apache License 2.0
94 stars 60 forks source link

Issue1134 relyonguider #1135

Closed jhmigueles closed 3 months ago

jhmigueles commented 3 months ago

Fixes #1134

This includes a revision of the SPT definition when relyonguider is set to TRUE.

In the original approach, SIB start and end time for the first and last SIB being part of the SPT was modified so that it matched the guider definition. It did not work well at finding the first and last SIB of the SPT. Additionally, this has the challenge that SIB times are modified without keeping track of that, I thought it would be good to leave SIB as they are detected to facilitate methodological research on SPT and SIBs.

In this proposal, when relyonguider = TRUE, it does only affect the SPT definition without modifying the times of the SIBs.

vincentvanhees commented 3 months ago

Thanks Jairo, I am now also investigating and remember again how I intended relyonguider to work. I think the code is in line with how I intended it. The main problem is that the documentation is not very clear.

If:

then my intention was and is that the final estimate of sleep onset is 11pm and that the sib to be shortened to start at 11pm because only then it correctly contributes to the total sleep duration. We are not only interest in sleep onset and wakeup time, all sleep variables need to align with the definition of sleep onset and wake up time.

If:

then my intention was and is that the final estimate of sleep onset is 2am, because we still trust the accelerometer more than the guider to tell us the exact timing of sleep onset.

So, the relyonguider parameter is specific to handle sib windows that overlap with the edges of the guider window.

I think it is best not to suddenly change this functionality, but to first improve the documentation. I will open a new PR for this shortly. In that PR I will then also revise the many object names that refer to SPT such as SptWake and SptOnset in g.part4, which should be guider.

jhmigueles commented 3 months ago

Hi Vincent, thanks, so this was a misunderstanding on the functionality of relyonguider. Then, I think the functionality I'm looking for is not facilitated at the moment, correct me if I'm wrong. I got some accelerometer files in which participants wore parallely two accelerometers (wrist + hip). I planned to use the SPT estimates from wrist and apply those exact times to the hip data. As the SIBs are probably less meaningful in hip, I was planning to build a sleeplog with the wrist estimates and apply those to the hip data ignoring completely the SIBs. Can you think of any way for doing this?

vincentvanhees commented 3 months ago

Can you think of any way for doing this?

You can still do what you plannend but then choose a SIB detection that is too sensitive for hip, e.g. hip HASIB.algo = "vanHees2015" possibly with higher anglethreshold and timethreshold settings, and combine this with relyonguider = TRUE.