Skip to content

Commit

Permalink
refactor: adjust cadence calc to use weekdaily
Browse files Browse the repository at this point in the history
Use representative week to calculate peak cadence using weekdaily.
  • Loading branch information
chanshing committed Dec 6, 2023
1 parent fe9512a commit 39a78d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/stepcount/stepcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,16 @@ def _max(x, n=1):

# cadence https://jamanetwork.com/journals/jama/fullarticle/2763292
cadence = Y.resample('min').sum()
cadence_peak1 = cadence.resample('D').agg(_max, n=1).mean()
cadence_peak30 = cadence.resample('D').agg(_max, n=30).mean()
daily_cadence_peak1 = cadence.resample('D').agg(_max, n=1)
daily_cadence_peak30 = cadence.resample('D').agg(_max, n=30)
if not adjust_estimates:
cadence_peak1 = np.round(daily_cadence_peak1.mean())
cadence_peak30 = np.round(daily_cadence_peak30.mean())
else:
weekdaily_cadence_peak1 = daily_cadence_peak1.groupby(daily_cadence_peak1.index.weekday).mean()
weekdaily_cadence_peak30 = daily_cadence_peak30.groupby(daily_cadence_peak30.index.weekday).mean()
cadence_peak1 = np.round(weekdaily_cadence_peak1.mean())
cadence_peak30 = np.round(weekdaily_cadence_peak30.mean())

# distributional features - quantiles
def _QAt(x):
Expand Down

0 comments on commit 39a78d4

Please sign in to comment.