Skip to content

New guider algorithm specifically for ActivPAL data - #1534

Merged
vincentvanhees merged 32 commits into
mainfrom
issue1287_explore_thigh_based_guider
Sep 10, 2026
Merged

vincentvanhees merged 32 commits into
mainfrom
issue1287_explore_thigh_based_guider

Conversation

@vincentvanhees

@vincentvanhees vincentvanhees commented Aug 12, 2026

Copy link
Copy Markdown
Member

Add new guider specifically designed for ActivPAL data.
The ActivPALs used in my clients dataset tend to fall asleep when the person is sleeping, by which timegaps can be used to inference sleep.

Skip movisens tests on CRAN and GitHub Actions, because they depend on downloading test data which is no longer facilitated.

Fixes #1287

Checklist before merging:

  • Existing tests still work (check by running the test suite, e.g. from RStudio).
  • Added tests (if you added functionality) or fixed existing test (if you fixed a bug).
  • Clean code has been attempted, e.g. intuitive object names and no code redundancy.
  • Documentation updated:
    • Function documentation
    • Chapter vignettes for GitHub IO
    • Vignettes for CRAN
  • Corresponding issue tagged in PR message. If no issue exist, please create an issue and tag it.
  • Updated release notes in inst/NEWS.Rd with a user-readable summary. Please, include references to relevant issues or PR discussions.
  • If you think you made a significant contribution, add your name to the contributors lists in the DESCRIPTION, zenodo.json, and inst/CITATION files.
  • GGIR parameters were added/removed. If yes, please also complete checklist below.

If NEW GGIR parameter(s) were added then these NEW parameter(s) are:

  • documented in man/GGIR.Rd
  • included with a default in R/load_params.R
  • included with value class check in R/check_params.R
  • included in table of vignettes/GGIRParameters.Rmd with references to the GGIR parts the parameter is used in.
  • mentioned in NEWS.Rd as NEW parameter

If GGIR parameter(s) were deprecated these parameter(s) are:

  • documented as deprecated in man/GGIR.Rd
  • removed from R/load_params.R
  • removed from R/check_params.R
  • removed from table in vignettes/GGIRParameters.Rmd
  • mentioned as deprecated parameter in NEWS.Rd
  • added to the list in R/extract_params.R with deprecated parameters such that these do not produce warnings when found in old config.csv files.

@vincentvanhees vincentvanhees changed the title Issue1287 explore thigh based guider New guider algorithm specifically for ActivPAL data Aug 12, 2026
@vincentvanhees
vincentvanhees marked this pull request as ready for review August 12, 2026 17:13

@jhmigueles jhmigueles left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an ActivPAL dataset available to test this functionality myself, so it would be useful to have a test for this new guider to ensure consistency and test the functioning of the guider over real or simulated data. Other than this, I only have some minor comments, mainly related to documentation.

This algorithm was developed for ActivPAL data where night/sleep behaviour is represented by an accelerometer that falls asleep. As a result, the sleep periods are characterised by the zero acceleration as imputed whereas the acceleration during waking hours is represented by sensor noise.

The guider detects this by first deriving a 5 minute rolling average of the acceleration values and then detecting when the resulting acceleration is less than a threshold as specified with parameter \code{LowAcc_threshold}.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the documentation motivate the default value of LowAcc? Since this is based on acceleration and not on angle variability, I assume the threshold would depend heavily on the metric chosen. Is this 0.014 supported for ENMO and should this be changed if a different metric is being used?

Also here, it would be convenient commenting that this threshold is applied over the metric selected with parameter acc.metric.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it needs to be clear that the expected metric is MAD, and the threshold was empirically chosen based on example data from ActivPAL.

ENMO is not informative when working with ActivPAL's that fall asleep during the night, because the autocalibration does not work well in such recordings. This is why I would recommend MAD as acceleration metric.


### Guider: LowAcc (EXPERIMENTAL)

This algorithm was developed for ActivPAL data where night/sleep behaviour is represented by an accelerometer that falls asleep. As a result, the sleep periods are characterised by the zero acceleration as imputed whereas the acceleration during waking hours is represented by sensor noise.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reading at the rationale for this guider, if the ActivPAL falls aslee during night, I would expect that this period is captured as non-wear and then, the NotWorn algorithm would do a good job at identifying the guider window. Should it be motivated why the NotWorn algorithm is not useful in this case and there is a need of this new guider algorithm?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this to be discussed in a paper and not in the documentation, because that is the most logical place to justify added value. This is also the reason why we have EXPERIMENTAL in the header of each guider that has not been described in the literature yet.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, it may help to already provide a little bit of motivation: I have now added "The reason we consider LowAcc instead of NonWorn for thigh-worn ActivPAL data is that non-wear is more difficult to detect in this setting: The high moves less while being awake compare with the wrist and ActivPAL sensors we found to come with a higher level of noise, complicating an accurate distinction between non-wear and inactivity."

| guider_cor_meme_min_hrs | 3 | params_sleep |
| guider_cor_do | 3 | params_sleep |
| guider_cor_meme_min_dys | 3 | params_sleep |
| HDCZA_roll_windowsize | 3 | params_sleep |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for making this parameter configurable? I don't have anything against it, just thinking if the motivation for this change should be documented anywhere.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually not, I added it as part of exploring possible ways to optimise the algorithm, but in the end did not use it.
I agree that it may be good to keep it anyway. It was already documented as a parameter and I have now also updated the changelog to highlight this as a new parameter.

@vincentvanhees

vincentvanhees commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

I don't have an ActivPAL dataset available to test this functionality myself, so it would be useful to have a test for this new guider to ensure consistency and test the functioning of the guider over real or simulated data. Other than this, I only have some minor comments, mainly related to documentation.

The ActivPAL files I have been working with are just csv, read with read.myacc.csv. I have now added a simple test inside test_HASPT.R. The rest of the pipeline is already covered by tests for read.myacc.csv.

@vincentvanhees
vincentvanhees merged commit 0497616 into main Sep 10, 2026
7 checks passed
@vincentvanhees
vincentvanhees deleted the issue1287_explore_thigh_based_guider branch September 12, 2026 08:03
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

Successfully merging this pull request may close these issues.

improve facilitation of ActivPAL csv data

2 participants