paulhibbing / AGread

Read Accelerometer Files from ActiGraph Accelerometers
Other
15 stars 4 forks source link

Identical sleep on #31

Open muschellij2 opened 3 years ago

muschellij2 commented 3 years ago

I've seen identical sleep_ON times, so https://github.com/paulhibbing/AGread/blob/c3e00b9bfa3870d114d03064f270b06a57ecd2bb/R/impute_primary.R#L44 would fail. I'm not sure if this should be a failure rather than a warning, but it makes it so you can't read in the gt3x. Can't share it (IRB), so it's hard give a minimal working example.

paulhibbing commented 3 years ago

Thanks John. Sorry you keep running into these checks I put in... I do think they're worth it, to help me spot places where my underlying assumptions are not correct.

In this case, could it just be changed to the following?

stopifnot(all(
  sign(as.numeric(diff(
    events$idle_sleep_events$sleep_ON
  )))%in%0:1
))

Ideally that's a permanent solution, but in my mind it's tentative for now. It should at least get the file to run, and from there I'd like to understand the behavior a little more before settling on a permanent solution. I don't understand why multiple events would be logged for the same timestamp, and I'm also uncertain if both events will have a corresponding sleep_OFF occurrence. If not, this is going to be trickier to fix.

No worries on not being able to share the file. Could you try the above and let me know how it goes? For internal testing, I usually convert the gt3x to csv in ActiLife, and then make sure I get consistent output from read_gt3x and read_AG_raw(file, return_raw = TRUE). It's probably sufficient to compare using all.equal(gt3x, raw, scale = 1, tolerance = 0.001, check.attributes = FALSE), but I like to also run it through PAutilities::test_errors. The latter takes a little bit of finagling, so I'm fine if you want to skip it.