Data reprocessing and time window settings

269 views
Skip to first unread message

R package GGIR

unread,
Sep 19, 2023, 1:56:37 AM9/19/23
to R package GGIR
Hi All,

I have used GGIR to extract the sleep and PA variables from .bin files, but didn't attain the raw time series files because the argument was not included in the codes. Now I want to export the time series to .csv files, do I need to do everything again from scratch? Or is there a way to get the time series with less steps?

Another questions is about the time window settings. If I need to analyze a full sleep period for every night, is it better to choose the result file with the time window "WW" instead of "MM"? In that case, is the "WW" time window contradictory to the parameter qwindow (0,24) because they divide a day differently? Also the guiders (HDCZA) by default segment the time from noon to noon to look for SIBs, which seems to be another different way to define a "day". How can these parameters be coordinated? Thank you!

R package GGIR

unread,
Sep 19, 2023, 4:43:18 AM9/19/23
to R package GGIR
Hello GGIR user,

I'm assuming by "raw data" you mean the epoch-level data relating to the first value in windowsizes argument e.g. 5s epochs.
If you ensure you have overwrite = F, and epochvalues2csv = TRUE, you will be able to just run the same code again. As all the other files and meta-data exists, there will be no overwriting and GGIR will just generate the csv files in the meta folder, which will be a quick process.

The second question I will leave for someone else to respond to, but encourage you to check this isn't already answered in Vincent et al.'s in-depth vignette.

Regards,
Ben

Vincent van Hees

unread,
Sep 25, 2023, 11:34:12 AM9/25/23
to zzy...@gmail.com, R package GGIR
I have used GGIR to extract the sleep and PA variables from .bin files, but didn't attain the raw time series files because the argument was not included in the codes. Now I want to export the time series to .csv files, do I need to do everything again from scratch? Or is there a way to get the time series with less steps?

In addition to Ben's response, please clarify what you are trying to export and whether you are trying to use GGIR options to export time series or are doing it in another way?

Another questions is about the time window settings. If I need to analyze a full sleep period for every night, is it better to choose the result file with the time window "WW" instead of "MM"? In that case, is the "WW" time window contradictory to the parameter qwindow (0,24) because they divide a day differently? Also the guiders (HDCZA) by default segment the time from noon to noon to look for SIBs, which seems to be another different way to define a "day". How can these parameters be coordinated? Thank you!

This is why part 4 and 5 generate separate reports:

Part 4 focusses on sleep detection between noon-noon or between 6pm-6pm if person wakes up after noon. The objective is to quantify nighttime sleep only, this is what you would use for sleep research.

Part 5 focuses on full day time-use. If sleep is a critical component of this and/or if you expect participants to fall asleep after midnight occasionally then I would use WW because that ensures that the full sleep period is preserved and neither the night nor the waking hours are split in two. Resulting 'days' will not be of equal length, the trick then is to normalise time values by dividing it by the window size, which GGIR does not do but is something you would have to do yourself as GGIR provides all the relevant columns. However, some may argue differently which is why GGIR also facilitate MM analyses.

Vincent

------- Original Message -------
--
You received this message because you are subscribed to the Google Groups "R package GGIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to RpackageGGIR...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/RpackageGGIR/b3d3190e-97e0-47f3-811b-c353b90e1f7fn%40googlegroups.com.

Evelyn C.

unread,
Sep 28, 2023, 5:30:31 AM9/28/23
to R package GGIR
Hi Ben and Vincent,

Thank you very much for your replies!

I am trying to export the aggregated raw acceleration with an epoch of 5s or 10s. Is it also possible to export accelerations along the x, y, and z axes with the same timestamp using GGIR?

Another small question: what does T5A5 mean in the Part 4 output files? Unfortunately I couldn't find the relevant explanations from the GGIR vignette. 

Thanks,

Evelyn

Ben Maylor

unread,
Sep 28, 2023, 6:52:18 AM9/28/23
to Evelyn C., R package GGIR
Hi Evelyn,

You're most welcome. To get corresponding x,y,z angles for each 5 second epoch you just need to include this in your GGIR function call:
do.anglez=TRUE,
do.anglex=TRUE,
do.angley=TRUE,

This will generate them in the csv output along with the acceleration metric used e.g.
timestamp anglex angley anglez ENMO
yyyy-mm-ddT10:15:00+0100 -41.8298 -11.4056 32.8486 0.0558
yyyy-mm-ddT10:15:05+0100 -31.6534 -26.2329 35.4357 0.0255
yyyy-mm-ddT10:15:10+0100 -35.436 -23.2156 29.9964 0.0255


T5A5 refers to the Time and Angle thresholds in the script parameters:
timethreshold= c(5),
anglethreshold=5,

What these mean in terms of the detection of sleep is described in vincents paper here: https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0142533

Thanks,
Ben


From: rpacka...@googlegroups.com <rpacka...@googlegroups.com> on behalf of Evelyn C. <zzy...@gmail.com>
Sent: 28 September 2023 10:30
To: R package GGIR <Rpacka...@googlegroups.com>
Subject: Re: [GGIR] Re: Data reprocessing and time window settings
 
--
You received this message because you are subscribed to the Google Groups "R package GGIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to RpackageGGIR...@googlegroups.com.

Evelyn C.

unread,
Oct 2, 2023, 6:31:13 AM10/2/23
to R package GGIR
Hi Ben,

Thank you for your very clear answers.
As you said, I added the function calls, but still only got the ACC data using ENMO metric, with no corresponding x, y, and z angles for 5s epoch. Could you help check if there are some problems with the following codes? Thanks again!

library(GGIR) g.shell.GGIR(#=======================================              # General parameters              mode= c(1,2,3,4,5),              datadir="C:/Raw data",              outputdir="C:/Users/Desktop/Data analysis",              studyname= "studyname",              f0 = c(),              f1 = c(),              overwrite = FALSE,              do.report=c(4,5),              idloc=1,              print.filename=TRUE,              storefolderstructure = TRUE,              do.parallel = FALSE,              chunksize=0.5,              windowsizes = c(5,900,3600),
             # Part 1 parameters:              # backup.cal.coef = "redo",              # chunksize=1,              # printsummary=TRUE,              do.enmo= TRUE, acc.metric="ENMO",              do.anglez=TRUE,              do.anglex=TRUE,              do.angley=TRUE,                # Part 2 parameters:              strategy = 1,              # ndayswindow=7,              hrs.del.start = 0,              hrs.del.end = 0,              maxdur = 7,              includedaycrit = 16,              winhr = c(5,10),              qlevels = c(c(1380/1440),c(1410/1440)),              qwindow=c(0,24),              ilevels = c(seq(0,400,by=50),8000),              mvpathreshold =c(191.6), #MVPA (moderate and vigorous physical activity threshold              bout.metric = 4,              # iglevels=TRUE,
             # Part 3 parameters:              timethreshold= 5,              anglethreshold=5,              ignorenonwear = TRUE, # if TRUE non-wear is not detected as sleep (if FALSE then it will work with imputed data)              constrain2range = TRUE,              do.part3.pdf = FALSE
             # Part 4 parameters:              excludefirstlast = FALSE,              includenightcrit = 16, # number of minimum valid hours in a day to attempt sleep analysis              def.noc.sleep = 1,              # If sleep log is available:              loglocation = c(),              #loglocation= loglocation,              outliers.only = FALSE,              criterror = 4,              relyonsleeplog = FALSE,              sleeplogidnum = FALSE,              colid=1,              coln1=2,              do.visual = TRUE,                         # Part 5 parameters:              excludefirstlast.part5=TRUE,              threshold.lig = c(53.6), #threshold(s) for inactivity              threshold.mod = c(191.6), #threshold(s) for moderate activity              threshold.vig = c(695.8), #threshold(s) for vigorous activity              boutcriter = 0.8,              boutcriter.in = 0.8, #fraction of an inactivity bout that needs to be below the threshold              boutcriter.lig = 0.8, #fraction of a light activity bout that needs to be between the thresholds              boutcriter.mvpa = 0.8, #fraction of a light activity bout that needs to be above the threshold              boutdur.in = c(5,10,30),              boutdur.lig = c(5,10),              boutdur.mvpa = c(5,10),              timewindow = c("WW", "MM"),
             # # Report generation              # # Key functions: Generating reports based on meta-data              save_ms5rawlevels =TRUE,              visualreport=FALSE,              dofirstpage = TRUE,              viewingwindow=1)


Best regards,

Evelyn

Ben Maylor

unread,
Oct 2, 2023, 7:22:39 AM10/2/23
to Evelyn C., R package GGIR
Hi Evelyn, you do not have epochvalues2csv=TRUE inside your function from what I can see. Please add that line, delete the meta/csv folder contents and then re-run the script. as you have overwrite set to false, the script will skip over all the parts it's already done and just generate the csv files for you.

Let me know if any problems.
Thanks,
Ben

Sent: 02 October 2023 11:31

Evelyn C.

unread,
Oct 2, 2023, 2:19:56 PM10/2/23
to R package GGIR
Hi Ben, I did what you said and got the csv folder but it's empty. Do you know why is that? Sorry for so many questions :(

Best regard,
Evelyn

Vincent van Hees

unread,
Oct 11, 2023, 9:24:32 AM10/11/23
to Evelyn C., R package GGIR
Dear Evelyn,

Are you sure you did not get an error or warning message?

Does the part 2 report indicate that there is data in the file?

Can you share again your updated GGIR call to ensure there is no misunderstanding about what you tried to do in your last attempt? Always try to make your issue as reproducible as possible to make it easy for others to help you.

Vincent
------- Original Message -------
Reply all
Reply to author
Forward
0 new messages