feat: add --minWearPerDay option to filter days with insufficient wear time#274
Merged
feat: add --minWearPerDay option to filter days with insufficient wear time#274
Conversation
…r time
Add a new --minWearPerDay CLI option that allows excluding days with less
than a user-specified amount of wear time from summary statistics. This
addresses a common requirement in accelerometer research to avoid bias
from partial recording days.
Features:
- New --minWearPerDay argument supporting flexible time formats:
* Hours: '20h' or '20H' or '20' (default unit)
* Minutes: '1200m' or '1200M'
* Days: '0.83d' or '0.83D'
- Per-day wear time calculation and filtering
- Excluded days are set to NaN for imputation but remain in time-series output
- New summary fields:
* wearTime-numDaysExcluded: count of excluded days
* wearTime-numDaysIncluded: count of included days
* wearTime-minWearPerDayThreshold(hrs): applied threshold
* day{N}-includedInSummary: per-day inclusion flag (0 or 1)
Changes:
- src/accelerometer/utils.py: Added parseTimeString() utility function
- src/accelerometer/summarisation.py: Implemented filtering logic in
writeMovementSummaries() and updated getActivitySummary()
- src/accelerometer/accProcess.py: Added CLI argument and time parsing
Testing:
Validated with sample.cwa.gz data showing expected behavior:
- Days with <20h wear time correctly excluded from statistics
- Overall metrics adjusted appropriately (e.g., avg acceleration
decreased 9.15% when excluding partial days)
- Maintains backward compatibility (all days included when not specified)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
--minWearPerDayCLI option that allows excluding days with less than a user-specified amount of wear time from summary statistics. This addresses a common requirement in accelerometer research to avoid bias from partial recording days.Features
'20h'(hours),'1200m'(minutes),'0.5d'(days), or'20'(default hours)wearTime-numDaysExcluded: count of excluded dayswearTime-numDaysIncluded: count of included dayswearTime-minWearPerDayThreshold(hrs): applied thresholdday{N}-includedInSummary: per-day inclusion flag (0 or 1)Example Usage
Testing
Validated with sample.cwa.gz data:
Files Changed
src/accelerometer/utils.py: AddedparseTimeString()utilitysrc/accelerometer/summarisation.py: Implemented filtering logicsrc/accelerometer/accProcess.py: Added CLI argument