Skip to content

feat: add --minWearPerDay option to filter days with insufficient wear time#274

Merged
chanshing merged 1 commit intomasterfrom
feat/min-wear-per-day
Oct 31, 2025
Merged

feat: add --minWearPerDay option to filter days with insufficient wear time#274
chanshing merged 1 commit intomasterfrom
feat/min-wear-per-day

Conversation

@chanshing
Copy link
Copy Markdown
Member

Summary

Adds 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

  • Flexible time formats: Supports '20h' (hours), '1200m' (minutes), '0.5d' (days), or '20' (default hours)
  • Per-day filtering: Calculates daily wear time and excludes days below threshold
  • Transparency: Excluded days remain in time-series output and are flagged in summary
  • 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)

Example Usage

# Exclude days with < 20 hours of wear time
accProcess data.cwa.gz --minWearPerDay '20h'

# Using minutes
accProcess data.cwa.gz --minWearPerDay '1200m'

# Using days
accProcess data.cwa.gz --minWearPerDay '0.83d'

Testing

Validated with sample.cwa.gz data:

  • ✅ Days with <20h wear time correctly excluded from statistics
  • ✅ Overall metrics adjusted appropriately (avg acceleration decreased 9.15% when excluding partial days)
  • ✅ Time parser handles all supported formats correctly
  • ✅ Backward compatible (all days included when option not specified)

Files Changed

  • src/accelerometer/utils.py: Added parseTimeString() utility
  • src/accelerometer/summarisation.py: Implemented filtering logic
  • src/accelerometer/accProcess.py: Added CLI argument

…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)
@chanshing chanshing merged commit 8886240 into master Oct 31, 2025
25 checks passed
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.

1 participant