Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g.part5.definedays warning: "number of items to replace is not a multiple of replacement length" #1039

Closed
2 tasks done
l-k- opened this issue Feb 8, 2024 · 1 comment · Fixed by #1045
Closed
2 tasks done

Comments

@l-k-
Copy link
Collaborator

l-k- commented Feb 8, 2024

(I'm not very familiar with part 5 code, so I was hoping someone might know right away the correct way to fix this. If not, I can give it a shot next week.)

I ran GGIR master branch on the UK biobank sample cwa file, found here: biobank.ctsu.ox.ac.uk/ukb/ukb/examples/accsamp.zip (This is a file use by profileGGIR)

When part 5 is executed, I get the following warning message:

In breaks_i[bi] = fullQqq[grep(breaks[bi], ts$time[fullQqq])] :
  number of items to replace is not a multiple of replacement length

The exact command I used:

GGIR(datadir="/Users/user/cwa", outputdir="/Users/user/res", overwrite=TRUE, do.parallel = FALSE, do.cal=FALSE, printsummary=TRUE, verbose = TRUE, windowsizes = c(10,660,1800))

The warning is triggered in g.part5.definedays, here, for the very first time block.

This very first time block spans the time from 2013-07-13 10:11:00 to 2013-07-20 09:55:50, so its first midnight is 2013-07-14, but this midnight is not recorded in nightsi. So the very first fullQqq window contains the time span from 2013-07-13 10:11:00 all the way to 2013-07-14 23:59:50, which means that it contains not one but two "23:59:50" timestamps.

So fullQqq[grep(breaks[2], ts$time[fullQqq])] matches not one but two timestamps. And then breaks_i[2] = fullQqq[grep(breaks[2], ts$time[fullQqq])] results in the warning "number of items to replace is not a multiple of replacement length"

You can see the details in the screenshot below:
image

There are two ways to solve this --

either

  1. make sure that the first midnight 2013-07-14 is recorded in nightsi,
    or
  2. modify the assignment breaks_i[bi] = fullQqq[grep(breaks[bi], ts$time[fullQqq])] to take the last of the fullQqq[grep(breaks[bi], ts$time[fullQqq])] elements.

I'm not sure which one of these solutions is preferable, since I don't know a lot about part 5.

Additional info

  1. Sensor brand: Axivity
  2. Data format: cwa
  3. Are you using a sleep diary to guide the sleep detection: NO
  4. Copy of R command used: GGIR(datadir="/Users/user/cwa", outputdir="/Users/user/res", overwrite=TRUE, do.parallel = FALSE, do.cal=FALSE, printsummary=TRUE, verbose = TRUE, windowsizes = c(10,660,1800))
  5. Have you tried processing your data based on GGIR's default argument values? Does the issue you report still appear? YES, and I got the same warning message, but I didn't re-do my debugging with default values.

Desktop (please complete the following information):

  • OS: Mac OS
  • GGIR Version: 3.0-5, latest master

Before submitting

  • Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
  • Have you tried this on the latest master branch from GitHub?
@vincentvanhees vincentvanhees self-assigned this Feb 14, 2024
@vincentvanhees
Copy link
Member

Thanks for creating this issue. I see the problem is that the ts$time[fullQqq] spans more than 24 hours, because qqq defaults to going from 1 to the first midnight, while the first 2 midnights are not present. I am now preparing a PR to catch this.

vincentvanhees added a commit that referenced this issue Feb 14, 2024
- simplifies qwindow2timestamp to be just a numeric to timestamp conversion without epoch corrections.
- catches when first midnight is not within 24 hours of the recording start, and then assigns qqq[1] to the first midnight minus 24 hours.
- deals with 24:00:00 not existing outside the function in one place
- rename function name fixTime to be more intuitive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants