Using E4 files error only 0's may be mixed with negative subscripts

74 views
Skip to first unread message

Neil Kennedy

unread,
Dec 19, 2022, 4:29:01 AM12/19/22
to R package GGIR
Hello Group,

First, thank you for all the work on this package. I need some help running GGIR on data from the Empatica E4 for a study looking at the effect of sleep on alcohol cravings.

I am using the E4.GGIR.Export function to format my raw E4 output. Is there any sample configuration to run GGIR once I get the formatted file?

When I use rmc.myacc.csv my output looks good, but when I use GGIR I get the following error:

#########
 Part 1

Checking that user has read access permission for all files in data directory: Yes
Checking that user has write access permission for directory specified by argument outputdir: Yes
1
P1 file 1

Investigate calibration of the sensors with function g.calibrate:

Loading chunk: 1Error in xj[i] : only 0's may be mixed with negative subscripts
###########


and when I use traceback:
###########
13: `[.data.frame`(meta_temp, 1:(nrow(meta_temp) - 1), 2:7)
12: meta_temp[1:(nrow(meta_temp) - 1), 2:7]
11: is.data.frame(x)
10: rowSums(meta_temp[1:(nrow(meta_temp) - 1), 2:7] == meta_temp[2:nrow(meta_temp),
        2:7])
9: which(rowSums(meta_temp[1:(nrow(meta_temp) - 1), 2:7] == meta_temp[2:nrow(meta_temp),
       2:7]) == 3)
8: g.calibrate(datafile, params_rawdata = params_rawdata, params_general = params_general,
       params_cleaning = params_cleaning)
7: main_part1(i, params_metrics, params_rawdata, params_cleaning,
       params_general, datadir, fnames, fnamesfull, outputdir, myfun,
       filelist, studyname, ffdone, tmp5, tmp6, use.temp, daylimit,
       path3, outputfolder, is.mv)
6: g.part1(datadir = datadir, outputdir = outputdir, f0 = f0, f1 = f1,
       studyname = studyname, myfun = myfun, params_rawdata = params_rawdata,
       params_metrics = params_metrics, params_cleaning = params_cleaning,
       params_general = params_general)
5: GGIR(datadir = "C:/Users/neil_k/Downloads/GGIR/e4Tools/dataE4Tools",
       outputdir = "C:/Users/neil_k/Downloads/GGIR/e4Tools/resultsE4Tools",
       rmc.file = "1_GGIR_out.csv", rmc.sf = 32, rmc.col.time = 1,
       rmc.unit.time = "UNIXsec", rmc.desiredtz = "America/New_York",
       rmc.firstrow.acc = 20, rmc.col.acc = 2:4, rmc.unit.acc = "bits",
       rmc.bitrate = 32, rmc.dynamic_range = 2, rmc.unsignedbit = FALSE,
       rmc.col.temp = 5, rmc.unit.temp = "C", ) at e4ToolsScript.R#12
4: eval(ei, envir)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("c:\\Users\\neil_k\\Downloads\\GGIR\\e4Tools\\e4ToolsScript.R",
       encoding = "UTF-8")
###########


Here is my code:
#######
GGIR(
  datadir="C:/Users/neil_k/Downloads/GGIR/e4Tools/dataE4Tools",
  outputdir="C:/Users/neil_k/Downloads/GGIR/e4Tools/resultsE4Tools",

  #time
  rmc.sf = 32,
  rmc.col.time=1,
  rmc.unit.time = "UNIXsec",
  rmc.desiredtz = "America/New_York",
  #acc
  rmc.firstrow.acc = 21,
  rmc.col.acc = 2:4,
  rmc.unit.acc = "bits",
  rmc.bitrate = 32,
  rmc.dynamic_range = 2,
  rmc.unsignedbit = FALSE,
  #temp
  rmc.col.temp = 5,
  rmc.unit.temp = "C",
)
##########

And the first few lines of my data:
######
"device_brand" "E4" "" "" ""
"recording_ID" "1" "" "" ""
"device_serial_number" "A02D9B" "" "" ""
"N_subfiles" "A02D9B" "" "" ""
"timestamp_type" "unix_ms" "" "" ""
"timezone_tzdata_format" "America/New_York" "" "" ""
"acc_sample_rate" "32" "" "" ""
"acc_unit" "bits" "" "" ""
"acc_dynrange_plusmin_g" "2" "" "" ""
"acc_bit_resolution" "8" "" "" ""
"temp_sample_rate" "4" "" "" ""
"temp_units" "celsius" "" "" ""
"temp_range_min" "-40" "" "" ""
"temp_range_max" "115" "" "" ""
"temp_resolution" "0.2" "" "" ""
"starttime" "2021-07-14 19:26:21 EDT" "" "" ""
"" "" "" "" ""
"" "" "" "" ""
"" "" "" "" ""
"timestamp" "acc_x_bits" "acc_y_bits" "acc_z_bits" "temp"
"1626305181" "48" "-10" "40" "26.91"
"1626305181" "47" "-9" "37" "26.91"
"1626305181" "50" "-8" "36" "26.91"
"1626305181" "53" "-10" "40" "26.91"
"1626305181" "51" "-8" "36" "26.91"
"1626305181" "49" "-8" "35" "26.91"
...
#######

Any idea what's going wrong here?

Thank you for any help,
Neil

Cathy

unread,
Dec 21, 2022, 7:02:49 AM12/21/22
to R package GGIR
Hi Neil,
Just in case it is any help, I got this message trying to read a csv file when I entered the wrong sample frequency in rmc.sf.
Thanks,
Cathy

Neil Kennedy

unread,
Dec 28, 2022, 6:14:12 AM12/28/22
to R package GGIR
Thanks for the tip Cathy. However I'm sure that 32Hz that I used was the correct sample rate according to E4, and I got the same error when I tried other sample rates

Vincent van Hees

unread,
Feb 15, 2023, 9:00:11 AM2/15/23
to Neil Kennedy, R package GGIR, caw...@gmail.com
Hello Neil and Cathy,

It seems you emailed me around the time I was getting ready for my winter break, and then it kind of got lost in my pile of e-mails.

I do not have recent practical experience with the E4. Would you mind sending me a test case to help me reproduce and investigate the issue.

Ideally I would need:
  • original E4 file
  • script to convert E4 to csv
  • your current attempt to read this csv with GGIR

Once we have it all to work it may be good to put all the code we used in a mini-tutorial somewhere inside the GGIR documentation.

Thanks, Vincent

Dr. Vincent van Hees | Independent consultant | https://accelting.com/
image

------- 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/d72676bd-4d68-4927-b06b-d2f36e156f11n%40googlegroups.com.

Cathy

unread,
Feb 16, 2023, 5:13:38 AM2/16/23
to R package GGIR
Hi Vincent,
Thanks getting back to us.  I am not sure my files will be that helpful because they are Empatica files that have already been processed to csv (I don't have the script used for this).  I am going to try out the suggestions you gave me on another post, and I will let you know if that solves my csv import issues.  I don't have data to import directly to GGIR from Empatica at the moment, but that is something I would like to do in the future.
Thanks so much for your help,
Cathy

Reply all
Reply to author
Forward
0 new messages