Skip to content

Default value of daysleep_offset missing for single-midnight files. #398

Closed
@l-k-

Description

Hello!

I ran g.shell.GGIR with all the default parameters on a sample 123A_testaccfile.csv file generated by create_test_acc_csvz(), and I got an error during part 3 processing:

Part 3

Busy processing ... see /Users/lk/acc_results/output_acc_data/ms3 for progress

Errors and warnings for 123A_testaccfile.csv.RData$message
[1] "object 'daysleep_offset' not found"

$call
g.sib.det(M, IMP, I, twd = c(-12, 12), timethreshold = timethreshold,
anglethreshold = anglethreshold, acc.metric = acc.metric,
desiredtz = desiredtz, constrain2range = constrain2range,
dayborder = dayborder, myfun = myfun)

The problem is that in g.sib.det.R, daysleep_offset variable isn't assigned a default value for single-midnight files. This was addressed for multi-midnight files in #325 , but the single-midnight scenario was missed.

I'm sending a quick one-line pull request to address this.

But I'm also wondering if you'd want g.sib.det.R rewritten to to combine the two nearly identical "Estimate Sleep Period Time window" blocks into one (I would give it a shot, but don't want to step on anyone's toes!)

I'm concerned that with time people will be inconsistently editing these two blocks and they will start diverging, creating issues. For instance I'm wondering if it's indeed correct that daysleep_offset is accounted for in

GGIR/R/g.sib.det.R

Lines 336 to 337 in d0af9d0

sptwindow_HDCZA_end[j] = (inbedout$sptwindow_HDCZA_end/(3600/ws3)) + startTimeRecord + daysleep_offset
sptwindow_HDCZA_start[j] = (inbedout$sptwindow_HDCZA_start/(3600/ws3)) + startTimeRecord + daysleep_offset

but not in its single-midnight equivalent:

GGIR/R/g.sib.det.R

Lines 245 to 246 in d0af9d0

sptwindow_HDCZA_end[1] = inbedout$sptwindow_HDCZA_end/(3600/ws3) + startTimeRecord
sptwindow_HDCZA_start[1] = inbedout$sptwindow_HDCZA_start/(3600/ws3) + startTimeRecord

I might be overthinking this a bit, but please let me know what your thoughts on this code duplication are.

thank you!

-Lena

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions