diff --git a/NAMESPACE b/NAMESPACE index 0a310ba..bbd7ca6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ export(readGenea, readAxivity, readGENEActiv, GENEActivReader, resample, readWav, - readActiGraphCount, readActiwatchCount) + readActiGraphCount, readActiwatchCount, + readActicalCount) useDynLib(GGIRread, .registration = TRUE) importFrom(Rcpp, sourceCpp) importFrom(data.table, fread) diff --git a/NEWS.md b/NEWS.md index 891fe2d..4564353 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,7 +3,7 @@ - Added a `NEWS.md` file to track changes to the package. - Stops interactive calling of `chooseCRANmirror` on `.onAttach` if interactive and CRAN mirror not set GGIR #1141. - Migrate read function for ActiGraph (csv) and Actiwatch (csv/awd) count data to GGIRread #68. - +- Add read function for Actical (csv) count data #68. # Changes in version 1.0.1 (release date:03-06-2024) diff --git a/R/readActicalCount.R b/R/readActicalCount.R new file mode 100644 index 0000000..011d13d --- /dev/null +++ b/R/readActicalCount.R @@ -0,0 +1,90 @@ +readActicalCount = function(filename = file, desiredEpochSize = NULL, + timeformat = "%m/%d/%Y %H:%M:%S", tz = "", timeformatName = "timeformat") { + # In GGIR set timeformatName to extEpochData_timeformat + + + # ! Assumptions that timeseries start before line 1000 + index = 300 + while (index > 0) { + quote = detectQuote(fn = filename, index = index) + testraw = data.table::fread(input = filename, + header = FALSE, sep = ",", skip = index, + nrows = 2, data.table = FALSE, quote = quote) + if (length(testraw) > 0) { + if (nrow(testraw) == 2) { + if (testraw$V1[2] == testraw$V1[1] + 1) { + break + } + } + } + index = index - 100 + } + # ! Assumption that first column are the epoch numbers + delta = 1 - testraw$V1[1] + index = index + delta + startFound = FALSE + while (startFound == FALSE) { + Dtest = data.table::fread(input = filename, sep = ",", skip = index, quote = quote, nrows = 1) + if (Dtest$V1[1] == 1) { + startFound = TRUE + } else { + # This happens when file is has an empty row between each measurement point is stored + index = index - 1 + if (index < 1) stop("Could not find start of recording", call. = FALSE) + } + } + D = data.table::fread(input = filename, sep = ",", skip = index, quote = quote, data.table = FALSE) + # ! Assumption that column names are present 2 lines prior to timeseries + dashedlineFound = FALSE + dashedLineIndex = index + while (dashedlineFound == FALSE) { + linedata = data.table::fread(input = filename, data.table = FALSE, + header = FALSE, sep = ",", + skip = dashedLineIndex, nrows = 1, quote = quote) + if (length(grep(pattern = "------", x = linedata[1])) == 1) { + dashedlineFound = TRUE + } else { + dashedLineIndex = dashedLineIndex - 1 + } + } + colnames = data.table::fread(input = filename, data.table = FALSE, + header = FALSE, sep = ",", + skip = dashedLineIndex + 1, nrows = (index - dashedLineIndex) - 2, quote = quote) + + collapse = function(x) { + return(paste0(x, collapse = "_")) + } + colnames = tolower(as.character(apply(colnames, MARGIN = 2, FUN = collapse))) + colnames(D) = colnames + # ! Assumptions about columns names + colnames(D)[grep(pattern = "time", x = colnames(D))] = "time" + colnames(D)[grep(pattern = "date", x = colnames(D))] = "date" + colnames(D)[grep(pattern = "activity_counts", x = colnames(D))] = "counts" + colnames(D)[grep(pattern = "steps", x = colnames(D))] = "steps" + D = D[, grep(pattern = "time|date|counts|steps", x = colnames(D))] + timestamp_POSIX = as.POSIXct(x = paste(D$date[1:4], D$time[1:4], sep = " "), + format = timeformat, + tz = tz) + checkTimeFormat(timestamp_POSIX[1], + rawValue = paste(D$date[1], D$time[1], sep = " "), + timeformat = timeformat, + timeformatName = timeformatName) + epSizeShort = mean(diff(as.numeric(timestamp_POSIX))) + timestamp_POSIX = timestamp_POSIX[1] + D = D[, -which(colnames(D) %in% c("date", "time"))] + D = as.matrix(D, drop = FALSE) + + # If requested, aggregate data to lower resolution to match desired + # epoch size in argument windowsizes + if (!is.null(desiredEpochSize)) { + if (desiredEpochSize > epSizeShort) { + step = desiredEpochSize %/% epSizeShort + D = sumAggregate(D, step) + epSizeShort = epSizeShort * step + } + checkEpochMatch(desiredEpochSize, epSizeShort) + } + if (quote == "") D = apply(D, 2, as.numeric) + invisible(list(data = D, epochSize = epSizeShort, + startTime = timestamp_POSIX)) +} \ No newline at end of file diff --git a/README.md b/README.md index 1e5944e..915fd8c 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,11 @@ Functions for reading accelerometer data from the following file formats: -Brand | Device name | File extension | GGIRread function ------- | ------- | ------- | ---------------- -Axivity Ltd https://axivity.com/ | AX3 and AX6 | .cwa | readAxivity -ActivInsights Ltd https://activinsights.com/ | GENEActiv Original and Sleep | .bin | readGENEActiv -Unilever Discover Ltd | Genea (no longer manufactured) | .bin | readGenea \ No newline at end of file +Brand | Device name | File extension | Data type | GGIRread function +------ | ------- | ------- | ---------------- | --------------------- +Axivity Ltd https://axivity.com/ | AX3 and AX6 | .cwa | raw gravitational units |readAxivity +ActivInsights Ltd https://activinsights.com/ | GENEActiv Original and Sleep | .bin | raw gravitational units | readGENEActiv +Unilever Discover Ltd | Genea (no longer manufactured) | .bin | raw gravitational units | readGenea +ActiGraph | ??? | .csv | count data | readActigraph +Actiwatch | ??? | .csv and .awd | count data | readActiwatch +Actical | ??? | .csv | count data | readActical \ No newline at end of file diff --git a/inst/testfiles/Actical.csv b/inst/testfiles/Actical.csv new file mode 100644 index 0000000..3633ede --- /dev/null +++ b/inst/testfiles/Actical.csv @@ -0,0 +1,532 @@ +Actical List Export File (Version 03.00),,,,,,,,, +Filename:,,,,,,,,, +,,,,,,,,, +--------------- Subject and Device Settings ----------------,,,,,,,,, +Identity:,AM2105031920,,,,,,,, +Age:,,years,,,,,,, +Gender:,Unknown,,,,,,,, +Height:,0,cm,,,,,,, +,0,inches,,,,,,, +Weight:,0,kg,,,,,,, +,0,lbs,,,,,,, +Start Date:,13-May-21,(Thu),,,,,,, +Start Time:,00:00,,,,,,,, +Device Serial Number:,B11FFFF,,,,,,,, +,,,,,,,,, +-------------------- Analysis Settings ---------------------,,,,,,,,, +Light/Moderate Cutpoint:,0,kcals/min/kg,,,,,,, +Moderate/Vigorous Cutpoint:,0,kcals/min/kg,,,,,,, +Energy Expenditure Output Type (unit):,AEE,(Activity Energy Expenditure),,,,,,, +Subject Type (age level):,UNKNOWN,,,,,,,, +Device Location:,WRIST,,,,,,,, +Model Type:,SINGLE REGRESSION,,,,,,,, +Smoothing Filter:,1,minute,,,,,,, +,,,,,,,,, +------------------- Epoch-by-Epoch Data --------------------,,,,,,,,, +Epoch#,Day#,Elapsed,Date,Time,Activity,Steps,Energy,Activity,Event Marker +,,Seconds,,,Counts,,Expenditure,Intensity,Button Presses +,,,,,,,kcals/min/kg,(1=sedentary),(1=pressed) +,,,,,,,,(2=light),(0=not pressed) +,,,,,,,,(3=moderate), +,,,,,,,,(4=vigorous), +0,1,60,13-May-21,00:00,250,12,NaN,NaN,0 +1,1,120,13-May-21,00:01,361,50,NaN,NaN,0 +2,1,180,13-May-21,00:02,567,15,0,1,0 +3,1,240,13-May-21,00:03,151,0,0,1,0 +4,1,300,13-May-21,00:04,0,0,0,1,0 +5,1,360,13-May-21,00:05,0,0,0,1,0 +6,1,420,13-May-21,00:06,0,0,0,1,0 +7,1,480,13-May-21,00:07,0,0,0,1,0 +8,1,540,13-May-21,00:08,0,0,0,1,0 +9,1,600,13-May-21,00:09,250,12,0,1,0 +10,1,660,13-May-21,00:10,361,50,0,1,0 +11,1,720,13-May-21,00:11,567,15,0,1,0 +12,1,780,13-May-21,00:12,151,0,0,1,0 +13,1,840,13-May-21,00:13,0,0,0,1,0 +14,1,900,13-May-21,00:14,0,0,0,1,0 +15,1,960,13-May-21,00:15,0,0,0,1,0 +16,1,1020,13-May-21,00:16,0,0,0,1,0 +17,1,1080,13-May-21,00:17,0,0,0,1,0 +18,1,1140,13-May-21,00:18,250,12,0,1,0 +19,1,1200,13-May-21,00:19,361,50,0,1,0 +20,1,1260,13-May-21,00:20,567,15,0,1,0 +21,1,1320,13-May-21,00:21,151,0,0,1,0 +22,1,1380,13-May-21,00:22,0,0,0,1,0 +23,1,1440,13-May-21,00:23,0,0,0,1,0 +24,1,1500,13-May-21,00:24,0,0,0,1,0 +25,1,1560,13-May-21,00:25,0,0,0,1,0 +26,1,1620,13-May-21,00:26,0,0,0,1,0 +27,1,1680,13-May-21,00:27,250,12,0,1,0 +28,1,1740,13-May-21,00:28,361,50,0,1,0 +29,1,1800,13-May-21,00:29,567,15,0,1,0 +30,1,1860,13-May-21,00:30,151,0,0,1,0 +31,1,1920,13-May-21,00:31,0,0,0,1,0 +32,1,1980,13-May-21,00:32,0,0,0,1,0 +33,1,2040,13-May-21,00:33,0,0,0,1,0 +34,1,2100,13-May-21,00:34,0,0,0,1,0 +35,1,2160,13-May-21,00:35,0,0,0,1,0 +36,1,2220,13-May-21,00:36,250,12,0,1,0 +37,1,2280,13-May-21,00:37,361,50,0,1,0 +38,1,2340,13-May-21,00:38,567,15,0,1,0 +39,1,2400,13-May-21,00:39,151,0,0,1,0 +40,1,2460,13-May-21,00:40,0,0,0,1,0 +41,1,2520,13-May-21,00:41,0,0,0,1,0 +42,1,2580,13-May-21,00:42,0,0,0,1,0 +43,1,2640,13-May-21,00:43,0,0,0,1,0 +44,1,2700,13-May-21,00:44,0,0,0,1,0 +45,1,2760,13-May-21,00:45,250,12,0,1,0 +46,1,2820,13-May-21,00:46,361,50,0,1,0 +47,1,2880,13-May-21,00:47,567,15,0,1,0 +48,1,2940,13-May-21,00:48,151,0,0,1,0 +49,1,3000,13-May-21,00:49,0,0,0,1,0 +50,1,3060,13-May-21,00:50,0,0,0,1,0 +51,1,3120,13-May-21,00:51,0,0,0,1,0 +52,1,3180,13-May-21,00:52,0,0,0,1,0 +53,1,3240,13-May-21,00:53,0,0,0,1,0 +54,1,3300,13-May-21,00:54,0,0,0,1,0 +55,1,3360,13-May-21,00:55,0,0,0,1,0 +56,1,3420,13-May-21,00:56,0,0,0,1,0 +57,1,3480,13-May-21,00:57,0,0,0,1,0 +58,1,3540,13-May-21,00:58,0,0,0,1,0 +59,1,3600,13-May-21,00:59,0,0,0,1,0 +60,1,3660,13-May-21,01:00,0,0,0,1,0 +61,1,3720,13-May-21,01:01,0,0,0,1,0 +62,1,3780,13-May-21,01:02,0,0,0,1,0 +63,1,3840,13-May-21,01:03,0,0,0,1,0 +64,1,3900,13-May-21,01:04,0,0,0,1,0 +65,1,3960,13-May-21,01:05,0,0,0,1,0 +66,1,4020,13-May-21,01:06,0,0,0,1,0 +67,1,4080,13-May-21,01:07,0,0,0,1,0 +68,1,4140,13-May-21,01:08,0,0,0,1,0 +69,1,4200,13-May-21,01:09,0,0,0,1,0 +70,1,4260,13-May-21,01:10,0,0,0,1,0 +71,1,4320,13-May-21,01:11,0,0,0,1,0 +72,1,4380,13-May-21,01:12,0,0,0,1,0 +73,1,4440,13-May-21,01:13,0,0,0,1,0 +74,1,4500,13-May-21,01:14,0,0,0,1,0 +75,1,4560,13-May-21,01:15,0,0,0,1,0 +76,1,4620,13-May-21,01:16,0,0,0,1,0 +77,1,4680,13-May-21,01:17,0,0,0,1,0 +78,1,4740,13-May-21,01:18,0,0,0,1,0 +79,1,4800,13-May-21,01:19,0,0,0,1,0 +80,1,4860,13-May-21,01:20,0,0,0,1,0 +81,1,4920,13-May-21,01:21,0,0,0,1,0 +82,1,4980,13-May-21,01:22,0,0,0,1,0 +83,1,5040,13-May-21,01:23,0,0,0,1,0 +84,1,5100,13-May-21,01:24,0,0,0,1,0 +85,1,5160,13-May-21,01:25,0,0,0,1,0 +86,1,5220,13-May-21,01:26,0,0,0,1,0 +87,1,5280,13-May-21,01:27,0,0,0,1,0 +88,1,5340,13-May-21,01:28,0,0,0,1,0 +89,1,5400,13-May-21,01:29,0,0,0,1,0 +90,1,5460,13-May-21,01:30,0,0,0,1,0 +91,1,5520,13-May-21,01:31,0,0,0,1,0 +92,1,5580,13-May-21,01:32,0,0,0,1,0 +93,1,5640,13-May-21,01:33,0,0,0,1,0 +94,1,5700,13-May-21,01:34,0,0,0,1,0 +95,1,5760,13-May-21,01:35,0,0,0,1,0 +96,1,5820,13-May-21,01:36,0,0,0,1,0 +97,1,5880,13-May-21,01:37,0,0,0,1,0 +98,1,5940,13-May-21,01:38,0,0,0,1,0 +99,1,6000,13-May-21,01:39,0,0,0,1,0 +100,1,6060,13-May-21,01:40,0,0,0,1,0 +101,1,6120,13-May-21,01:41,0,0,0,1,0 +102,1,6180,13-May-21,01:42,0,0,0,1,0 +103,1,6240,13-May-21,01:43,0,0,0,1,0 +104,1,6300,13-May-21,01:44,0,0,0,1,0 +105,1,6360,13-May-21,01:45,0,0,0,1,0 +106,1,6420,13-May-21,01:46,0,0,0,1,0 +107,1,6480,13-May-21,01:47,0,0,0,1,0 +108,1,6540,13-May-21,01:48,0,0,0,1,0 +109,1,6600,13-May-21,01:49,0,0,0,1,0 +110,1,6660,13-May-21,01:50,0,0,0,1,0 +111,1,6720,13-May-21,01:51,0,0,0,1,0 +112,1,6780,13-May-21,01:52,0,0,0,1,0 +113,1,6840,13-May-21,01:53,0,0,0,1,0 +114,1,6900,13-May-21,01:54,0,0,0,1,0 +115,1,6960,13-May-21,01:55,0,0,0,1,0 +116,1,7020,13-May-21,01:56,0,0,0,1,0 +117,1,7080,13-May-21,01:57,0,0,0,1,0 +118,1,7140,13-May-21,01:58,0,0,0,1,0 +119,1,7200,13-May-21,01:59,0,0,0,1,0 +120,1,7260,13-May-21,02:00,0,0,0,1,0 +121,1,7320,13-May-21,02:01,0,0,0,1,0 +122,1,7380,13-May-21,02:02,0,0,0,1,0 +123,1,7440,13-May-21,02:03,0,0,0,1,0 +124,1,7500,13-May-21,02:04,0,0,0,1,0 +125,1,7560,13-May-21,02:05,0,0,0,1,0 +126,1,7620,13-May-21,02:06,0,0,0,1,0 +127,1,7680,13-May-21,02:07,0,0,0,1,0 +128,1,7740,13-May-21,02:08,0,0,0,1,0 +129,1,7800,13-May-21,02:09,0,0,0,1,0 +130,1,7860,13-May-21,02:10,0,0,0,1,0 +131,1,7920,13-May-21,02:11,0,0,0,1,0 +132,1,7980,13-May-21,02:12,0,0,0,1,0 +133,1,8040,13-May-21,02:13,0,0,0,1,0 +134,1,8100,13-May-21,02:14,0,0,0,1,0 +135,1,8160,13-May-21,02:15,0,0,0,1,0 +136,1,8220,13-May-21,02:16,0,0,0,1,0 +137,1,8280,13-May-21,02:17,0,0,0,1,0 +138,1,8340,13-May-21,02:18,0,0,0,1,0 +139,1,8400,13-May-21,02:19,0,0,0,1,0 +140,1,8460,13-May-21,02:20,0,0,0,1,0 +141,1,8520,13-May-21,02:21,0,0,0,1,0 +142,1,8580,13-May-21,02:22,0,0,0,1,0 +143,1,8640,13-May-21,02:23,0,0,0,1,0 +144,1,8700,13-May-21,02:24,0,0,0,1,0 +145,1,8760,13-May-21,02:25,0,0,0,1,0 +146,1,8820,13-May-21,02:26,0,0,0,1,0 +147,1,8880,13-May-21,02:27,0,0,0,1,0 +148,1,8940,13-May-21,02:28,0,0,0,1,0 +149,1,9000,13-May-21,02:29,0,0,0,1,0 +150,1,9060,13-May-21,02:30,0,0,0,1,0 +151,1,9120,13-May-21,02:31,0,0,0,1,0 +152,1,9180,13-May-21,02:32,0,0,0,1,0 +153,1,9240,13-May-21,02:33,0,0,0,1,0 +154,1,9300,13-May-21,02:34,0,0,0,1,0 +155,1,9360,13-May-21,02:35,0,0,0,1,0 +156,1,9420,13-May-21,02:36,0,0,0,1,0 +157,1,9480,13-May-21,02:37,0,0,0,1,0 +158,1,9540,13-May-21,02:38,0,0,0,1,0 +159,1,9600,13-May-21,02:39,0,0,0,1,0 +160,1,9660,13-May-21,02:40,0,0,0,1,0 +161,1,9720,13-May-21,02:41,0,0,0,1,0 +162,1,9780,13-May-21,02:42,0,0,0,1,0 +163,1,9840,13-May-21,02:43,0,0,0,1,0 +164,1,9900,13-May-21,02:44,0,0,0,1,0 +165,1,9960,13-May-21,02:45,0,0,0,1,0 +166,1,10020,13-May-21,02:46,0,0,0,1,0 +167,1,10080,13-May-21,02:47,0,0,0,1,0 +168,1,10140,13-May-21,02:48,0,0,0,1,0 +169,1,10200,13-May-21,02:49,0,0,0,1,0 +170,1,10260,13-May-21,02:50,0,0,0,1,0 +171,1,10320,13-May-21,02:51,0,0,0,1,0 +172,1,10380,13-May-21,02:52,0,0,0,1,0 +173,1,10440,13-May-21,02:53,0,0,0,1,0 +174,1,10500,13-May-21,02:54,0,0,0,1,0 +175,1,10560,13-May-21,02:55,0,0,0,1,0 +176,1,10620,13-May-21,02:56,0,0,0,1,0 +177,1,10680,13-May-21,02:57,0,0,0,1,0 +178,1,10740,13-May-21,02:58,0,0,0,1,0 +179,1,10800,13-May-21,02:59,0,0,0,1,0 +180,1,10860,13-May-21,03:00,0,0,0,1,0 +181,1,10920,13-May-21,03:01,0,0,0,1,0 +182,1,10980,13-May-21,03:02,0,0,0,1,0 +183,1,11040,13-May-21,03:03,0,0,0,1,0 +184,1,11100,13-May-21,03:04,0,0,0,1,0 +185,1,11160,13-May-21,03:05,0,0,0,1,0 +186,1,11220,13-May-21,03:06,0,0,0,1,0 +187,1,11280,13-May-21,03:07,0,0,0,1,0 +188,1,11340,13-May-21,03:08,0,0,0,1,0 +189,1,11400,13-May-21,03:09,0,0,0,1,0 +190,1,11460,13-May-21,03:10,0,0,0,1,0 +191,1,11520,13-May-21,03:11,0,0,0,1,0 +192,1,11580,13-May-21,03:12,0,0,0,1,0 +193,1,11640,13-May-21,03:13,0,0,0,1,0 +194,1,11700,13-May-21,03:14,0,0,0,1,0 +195,1,11760,13-May-21,03:15,0,0,0,1,0 +196,1,11820,13-May-21,03:16,0,0,0,1,0 +197,1,11880,13-May-21,03:17,0,0,0,1,0 +198,1,11940,13-May-21,03:18,0,0,0,1,0 +199,1,12000,13-May-21,03:19,0,0,0,1,0 +200,1,12060,13-May-21,03:20,0,0,0,1,0 +201,1,12120,13-May-21,03:21,0,0,0,1,0 +202,1,12180,13-May-21,03:22,0,0,0,1,0 +203,1,12240,13-May-21,03:23,0,0,0,1,0 +204,1,12300,13-May-21,03:24,0,0,0,1,0 +205,1,12360,13-May-21,03:25,0,0,0,1,0 +206,1,12420,13-May-21,03:26,0,0,0,1,0 +207,1,12480,13-May-21,03:27,0,0,0,1,0 +208,1,12540,13-May-21,03:28,0,0,0,1,0 +209,1,12600,13-May-21,03:29,0,0,0,1,0 +210,1,12660,13-May-21,03:30,0,0,0,1,0 +211,1,12720,13-May-21,03:31,0,0,0,1,0 +212,1,12780,13-May-21,03:32,0,0,0,1,0 +213,1,12840,13-May-21,03:33,0,0,0,1,0 +214,1,12900,13-May-21,03:34,0,0,0,1,0 +215,1,12960,13-May-21,03:35,0,0,0,1,0 +216,1,13020,13-May-21,03:36,0,0,0,1,0 +217,1,13080,13-May-21,03:37,0,0,0,1,0 +218,1,13140,13-May-21,03:38,0,0,0,1,0 +219,1,13200,13-May-21,03:39,0,0,0,1,0 +220,1,13260,13-May-21,03:40,0,0,0,1,0 +221,1,13320,13-May-21,03:41,0,0,0,1,0 +222,1,13380,13-May-21,03:42,0,0,0,1,0 +223,1,13440,13-May-21,03:43,0,0,0,1,0 +224,1,13500,13-May-21,03:44,0,0,0,1,0 +225,1,13560,13-May-21,03:45,0,0,0,1,0 +226,1,13620,13-May-21,03:46,0,0,0,1,0 +227,1,13680,13-May-21,03:47,0,0,0,1,0 +228,1,13740,13-May-21,03:48,0,0,0,1,0 +229,1,13800,13-May-21,03:49,0,0,0,1,0 +230,1,13860,13-May-21,03:50,0,0,0,1,0 +231,1,13920,13-May-21,03:51,0,0,0,1,0 +232,1,13980,13-May-21,03:52,0,0,0,1,0 +233,1,14040,13-May-21,03:53,0,0,0,1,0 +234,1,14100,13-May-21,03:54,0,0,0,1,0 +235,1,14160,13-May-21,03:55,0,0,0,1,0 +236,1,14220,13-May-21,03:56,0,0,0,1,0 +237,1,14280,13-May-21,03:57,0,0,0,1,0 +238,1,14340,13-May-21,03:58,0,0,0,1,0 +239,1,14400,13-May-21,03:59,0,0,0,1,0 +240,1,14460,13-May-21,04:00,0,0,0,1,0 +241,1,14520,13-May-21,04:01,0,0,0,1,0 +242,1,14580,13-May-21,04:02,0,0,0,1,0 +243,1,14640,13-May-21,04:03,0,0,0,1,0 +244,1,14700,13-May-21,04:04,0,0,0,1,0 +245,1,14760,13-May-21,04:05,0,0,0,1,0 +246,1,14820,13-May-21,04:06,0,0,0,1,0 +247,1,14880,13-May-21,04:07,0,0,0,1,0 +248,1,14940,13-May-21,04:08,0,0,0,1,0 +249,1,15000,13-May-21,04:09,0,0,0,1,0 +250,1,15060,13-May-21,04:10,0,0,0,1,0 +251,1,15120,13-May-21,04:11,0,0,0,1,0 +252,1,15180,13-May-21,04:12,0,0,0,1,0 +253,1,15240,13-May-21,04:13,0,0,0,1,0 +254,1,15300,13-May-21,04:14,0,0,0,1,0 +255,1,15360,13-May-21,04:15,0,0,0,1,0 +256,1,15420,13-May-21,04:16,0,0,0,1,0 +257,1,15480,13-May-21,04:17,0,0,0,1,0 +258,1,15540,13-May-21,04:18,0,0,0,1,0 +259,1,15600,13-May-21,04:19,0,0,0,1,0 +260,1,15660,13-May-21,04:20,0,0,0,1,0 +261,1,15720,13-May-21,04:21,0,0,0,1,0 +262,1,15780,13-May-21,04:22,0,0,0,1,0 +263,1,15840,13-May-21,04:23,0,0,0,1,0 +264,1,15900,13-May-21,04:24,0,0,0,1,0 +265,1,15960,13-May-21,04:25,0,0,0,1,0 +266,1,16020,13-May-21,04:26,0,0,0,1,0 +267,1,16080,13-May-21,04:27,0,0,0,1,0 +268,1,16140,13-May-21,04:28,0,0,0,1,0 +269,1,16200,13-May-21,04:29,0,0,0,1,0 +270,1,16260,13-May-21,04:30,0,0,0,1,0 +271,1,16320,13-May-21,04:31,0,0,0,1,0 +272,1,16380,13-May-21,04:32,0,0,0,1,0 +273,1,16440,13-May-21,04:33,0,0,0,1,0 +274,1,16500,13-May-21,04:34,0,0,0,1,0 +275,1,16560,13-May-21,04:35,0,0,0,1,0 +276,1,16620,13-May-21,04:36,0,0,0,1,0 +277,1,16680,13-May-21,04:37,0,0,0,1,0 +278,1,16740,13-May-21,04:38,0,0,0,1,0 +279,1,16800,13-May-21,04:39,0,0,0,1,0 +280,1,16860,13-May-21,04:40,0,0,0,1,0 +281,1,16920,13-May-21,04:41,0,0,0,1,0 +282,1,16980,13-May-21,04:42,0,0,0,1,0 +283,1,17040,13-May-21,04:43,0,0,0,1,0 +284,1,17100,13-May-21,04:44,0,0,0,1,0 +285,1,17160,13-May-21,04:45,0,0,0,1,0 +286,1,17220,13-May-21,04:46,0,0,0,1,0 +287,1,17280,13-May-21,04:47,0,0,0,1,0 +288,1,17340,13-May-21,04:48,0,0,0,1,0 +289,1,17400,13-May-21,04:49,0,0,0,1,0 +290,1,17460,13-May-21,04:50,0,0,0,1,0 +291,1,17520,13-May-21,04:51,0,0,0,1,0 +292,1,17580,13-May-21,04:52,0,0,0,1,0 +293,1,17640,13-May-21,04:53,0,0,0,1,0 +294,1,17700,13-May-21,04:54,0,0,0,1,0 +295,1,17760,13-May-21,04:55,0,0,0,1,0 +296,1,17820,13-May-21,04:56,0,0,0,1,0 +297,1,17880,13-May-21,04:57,0,0,0,1,0 +298,1,17940,13-May-21,04:58,0,0,0,1,0 +299,1,18000,13-May-21,04:59,0,0,0,1,0 +300,1,18060,13-May-21,05:00,0,0,0,1,0 +301,1,18120,13-May-21,05:01,0,0,0,1,0 +302,1,18180,13-May-21,05:02,0,0,0,1,0 +303,1,18240,13-May-21,05:03,0,0,0,1,0 +304,1,18300,13-May-21,05:04,0,0,0,1,0 +305,1,18360,13-May-21,05:05,0,0,0,1,0 +306,1,18420,13-May-21,05:06,0,0,0,1,0 +307,1,18480,13-May-21,05:07,0,0,0,1,0 +308,1,18540,13-May-21,05:08,0,0,0,1,0 +309,1,18600,13-May-21,05:09,0,0,0,1,0 +310,1,18660,13-May-21,05:10,0,0,0,1,0 +311,1,18720,13-May-21,05:11,0,0,0,1,0 +312,1,18780,13-May-21,05:12,0,0,0,1,0 +313,1,18840,13-May-21,05:13,0,0,0,1,0 +314,1,18900,13-May-21,05:14,0,0,0,1,0 +315,1,18960,13-May-21,05:15,0,0,0,1,0 +316,1,19020,13-May-21,05:16,0,0,0,1,0 +317,1,19080,13-May-21,05:17,0,0,0,1,0 +318,1,19140,13-May-21,05:18,0,0,0,1,0 +319,1,19200,13-May-21,05:19,0,0,0,1,0 +320,1,19260,13-May-21,05:20,0,0,0,1,0 +321,1,19320,13-May-21,05:21,0,0,0,1,0 +322,1,19380,13-May-21,05:22,0,0,0,1,0 +323,1,19440,13-May-21,05:23,0,0,0,1,0 +324,1,19500,13-May-21,05:24,0,0,0,1,0 +325,1,19560,13-May-21,05:25,0,0,0,1,0 +326,1,19620,13-May-21,05:26,0,0,0,1,0 +327,1,19680,13-May-21,05:27,0,0,0,1,0 +328,1,19740,13-May-21,05:28,0,0,0,1,0 +329,1,19800,13-May-21,05:29,0,0,0,1,0 +330,1,19860,13-May-21,05:30,0,0,0,1,0 +331,1,19920,13-May-21,05:31,0,0,0,1,0 +332,1,19980,13-May-21,05:32,0,0,0,1,0 +333,1,20040,13-May-21,05:33,0,0,0,1,0 +334,1,20100,13-May-21,05:34,0,0,0,1,0 +335,1,20160,13-May-21,05:35,0,0,0,1,0 +336,1,20220,13-May-21,05:36,0,0,0,1,0 +337,1,20280,13-May-21,05:37,0,0,0,1,0 +338,1,20340,13-May-21,05:38,0,0,0,1,0 +339,1,20400,13-May-21,05:39,0,0,0,1,0 +340,1,20460,13-May-21,05:40,0,0,0,1,0 +341,1,20520,13-May-21,05:41,0,0,0,1,0 +342,1,20580,13-May-21,05:42,0,0,0,1,0 +343,1,20640,13-May-21,05:43,0,0,0,1,0 +344,1,20700,13-May-21,05:44,0,0,0,1,0 +345,1,20760,13-May-21,05:45,0,0,0,1,0 +346,1,20820,13-May-21,05:46,0,0,0,1,0 +347,1,20880,13-May-21,05:47,0,0,0,1,0 +348,1,20940,13-May-21,05:48,0,0,0,1,0 +349,1,21000,13-May-21,05:49,0,0,0,1,0 +350,1,21060,13-May-21,05:50,0,0,0,1,0 +351,1,21120,13-May-21,05:51,0,0,0,1,0 +352,1,21180,13-May-21,05:52,0,0,0,1,0 +353,1,21240,13-May-21,05:53,0,0,0,1,0 +354,1,21300,13-May-21,05:54,0,0,0,1,0 +355,1,21360,13-May-21,05:55,0,0,0,1,0 +356,1,21420,13-May-21,05:56,0,0,0,1,0 +357,1,21480,13-May-21,05:57,0,0,0,1,0 +358,1,21540,13-May-21,05:58,0,0,0,1,0 +359,1,21600,13-May-21,05:59,0,0,0,1,0 +360,1,21660,13-May-21,06:00,0,0,0,1,0 +361,1,21720,13-May-21,06:01,0,0,0,1,0 +362,1,21780,13-May-21,06:02,0,0,0,1,0 +363,1,21840,13-May-21,06:03,0,0,0,1,0 +364,1,21900,13-May-21,06:04,0,0,0,1,0 +365,1,21960,13-May-21,06:05,0,0,0,1,0 +366,1,22020,13-May-21,06:06,0,0,0,1,0 +367,1,22080,13-May-21,06:07,0,0,0,1,0 +368,1,22140,13-May-21,06:08,0,0,0,1,0 +369,1,22200,13-May-21,06:09,0,0,0,1,0 +370,1,22260,13-May-21,06:10,0,0,0,1,0 +371,1,22320,13-May-21,06:11,0,0,0,1,0 +372,1,22380,13-May-21,06:12,0,0,0,1,0 +373,1,22440,13-May-21,06:13,0,0,0,1,0 +374,1,22500,13-May-21,06:14,0,0,0,1,0 +375,1,22560,13-May-21,06:15,0,0,0,1,0 +376,1,22620,13-May-21,06:16,0,0,0,1,0 +377,1,22680,13-May-21,06:17,0,0,0,1,0 +378,1,22740,13-May-21,06:18,0,0,0,1,0 +379,1,22800,13-May-21,06:19,0,0,0,1,0 +380,1,22860,13-May-21,06:20,0,0,0,1,0 +381,1,22920,13-May-21,06:21,0,0,0,1,0 +382,1,22980,13-May-21,06:22,0,0,0,1,0 +383,1,23040,13-May-21,06:23,0,0,0,1,0 +384,1,23100,13-May-21,06:24,0,0,0,1,0 +385,1,23160,13-May-21,06:25,0,0,0,1,0 +386,1,23220,13-May-21,06:26,0,0,0,1,0 +387,1,23280,13-May-21,06:27,0,0,0,1,0 +388,1,23340,13-May-21,06:28,0,0,0,1,0 +389,1,23400,13-May-21,06:29,0,0,0,1,0 +390,1,23460,13-May-21,06:30,0,0,0,1,0 +391,1,23520,13-May-21,06:31,0,0,0,1,0 +392,1,23580,13-May-21,06:32,0,0,0,1,0 +393,1,23640,13-May-21,06:33,0,0,0,1,0 +394,1,23700,13-May-21,06:34,0,0,0,1,0 +395,1,23760,13-May-21,06:35,0,0,0,1,0 +396,1,23820,13-May-21,06:36,0,0,0,1,0 +397,1,23880,13-May-21,06:37,0,0,0,1,0 +398,1,23940,13-May-21,06:38,0,0,0,1,0 +399,1,24000,13-May-21,06:39,0,0,0,1,0 +400,1,24060,13-May-21,06:40,0,0,0,1,0 +401,1,24120,13-May-21,06:41,0,0,0,1,0 +402,1,24180,13-May-21,06:42,0,0,0,1,0 +403,1,24240,13-May-21,06:43,0,0,0,1,0 +404,1,24300,13-May-21,06:44,0,0,0,1,0 +405,1,24360,13-May-21,06:45,0,0,0,1,0 +406,1,24420,13-May-21,06:46,0,0,0,1,0 +407,1,24480,13-May-21,06:47,0,0,0,1,0 +408,1,24540,13-May-21,06:48,0,0,0,1,0 +409,1,24600,13-May-21,06:49,0,0,0,1,0 +410,1,24660,13-May-21,06:50,0,0,0,1,0 +411,1,24720,13-May-21,06:51,0,0,0,1,0 +412,1,24780,13-May-21,06:52,0,0,0,1,0 +413,1,24840,13-May-21,06:53,0,0,0,1,0 +414,1,24900,13-May-21,06:54,0,0,0,1,0 +415,1,24960,13-May-21,06:55,0,0,0,1,0 +416,1,25020,13-May-21,06:56,0,0,0,1,0 +417,1,25080,13-May-21,06:57,0,0,0,1,0 +418,1,25140,13-May-21,06:58,0,0,0,1,0 +419,1,25200,13-May-21,06:59,0,0,0,1,0 +420,1,25260,13-May-21,07:00,0,0,0,1,0 +421,1,25320,13-May-21,07:01,0,0,0,1,0 +422,1,25380,13-May-21,07:02,0,0,0,1,0 +423,1,25440,13-May-21,07:03,0,0,0,1,0 +424,1,25500,13-May-21,07:04,0,0,0,1,0 +425,1,25560,13-May-21,07:05,0,0,0,1,0 +426,1,25620,13-May-21,07:06,0,0,0,1,0 +427,1,25680,13-May-21,07:07,0,0,0,1,0 +428,1,25740,13-May-21,07:08,0,0,0,1,0 +429,1,25800,13-May-21,07:09,0,0,0,1,0 +430,1,25860,13-May-21,07:10,0,0,0,1,0 +431,1,25920,13-May-21,07:11,0,0,0,1,0 +432,1,25980,13-May-21,07:12,0,0,0,1,0 +433,1,26040,13-May-21,07:13,0,0,0,1,0 +434,1,26100,13-May-21,07:14,0,0,0,1,0 +435,1,26160,13-May-21,07:15,0,0,0,1,0 +436,1,26220,13-May-21,07:16,0,0,0,1,0 +437,1,26280,13-May-21,07:17,0,0,0,1,0 +438,1,26340,13-May-21,07:18,0,0,0,1,0 +439,1,26400,13-May-21,07:19,0,0,0,1,0 +440,1,26460,13-May-21,07:20,0,0,0,1,0 +441,1,26520,13-May-21,07:21,0,0,0,1,0 +442,1,26580,13-May-21,07:22,0,0,0,1,0 +443,1,26640,13-May-21,07:23,0,0,0,1,0 +444,1,26700,13-May-21,07:24,0,0,0,1,0 +445,1,26760,13-May-21,07:25,0,0,0,1,0 +446,1,26820,13-May-21,07:26,0,0,0,1,0 +447,1,26880,13-May-21,07:27,0,0,0,1,0 +448,1,26940,13-May-21,07:28,0,0,0,1,0 +449,1,27000,13-May-21,07:29,0,0,0,1,0 +450,1,27060,13-May-21,07:30,0,0,0,1,0 +451,1,27120,13-May-21,07:31,0,0,0,1,0 +452,1,27180,13-May-21,07:32,0,0,0,1,0 +453,1,27240,13-May-21,07:33,0,0,0,1,0 +454,1,27300,13-May-21,07:34,0,0,0,1,0 +455,1,27360,13-May-21,07:35,0,0,0,1,0 +456,1,27420,13-May-21,07:36,0,0,0,1,0 +457,1,27480,13-May-21,07:37,0,0,0,1,0 +458,1,27540,13-May-21,07:38,0,0,0,1,0 +459,1,27600,13-May-21,07:39,0,0,0,1,0 +460,1,27660,13-May-21,07:40,0,0,0,1,0 +461,1,27720,13-May-21,07:41,0,0,0,1,0 +462,1,27780,13-May-21,07:42,0,0,0,1,0 +463,1,27840,13-May-21,07:43,0,0,0,1,0 +464,1,27900,13-May-21,07:44,0,0,0,1,0 +465,1,27960,13-May-21,07:45,0,0,0,1,0 +466,1,28020,13-May-21,07:46,0,0,0,1,0 +467,1,28080,13-May-21,07:47,0,0,0,1,0 +468,1,28140,13-May-21,07:48,0,0,0,1,0 +469,1,28200,13-May-21,07:49,0,0,0,1,0 +470,1,28260,13-May-21,07:50,0,0,0,1,0 +471,1,28320,13-May-21,07:51,0,0,0,1,0 +472,1,28380,13-May-21,07:52,0,0,0,1,0 +473,1,28440,13-May-21,07:53,0,0,0,1,0 +474,1,28500,13-May-21,07:54,0,0,0,1,0 +475,1,28560,13-May-21,07:55,0,0,0,1,0 +476,1,28620,13-May-21,07:56,0,0,0,1,0 +477,1,28680,13-May-21,07:57,0,0,0,1,0 +478,1,28740,13-May-21,07:58,0,0,0,1,0 +479,1,28800,13-May-21,07:59,0,0,0,1,0 +480,1,28860,13-May-21,08:00,0,0,0,1,0 +481,1,28920,13-May-21,08:01,0,0,0,1,0 +482,1,28980,13-May-21,08:02,0,0,0,1,0 +483,1,29040,13-May-21,08:03,0,0,0,1,0 +484,1,29100,13-May-21,08:04,0,0,0,1,0 +485,1,29160,13-May-21,08:05,0,0,0,1,0 +486,1,29220,13-May-21,08:06,0,0,0,1,0 +487,1,29280,13-May-21,08:07,0,0,0,1,0 +488,1,29340,13-May-21,08:08,0,0,0,1,0 +489,1,29400,13-May-21,08:09,0,0,0,1,0 +490,1,29460,13-May-21,08:10,0,0,0,1,0 +491,1,29520,13-May-21,08:11,0,0,0,1,0 +492,1,29580,13-May-21,08:12,0,0,0,1,0 +493,1,29640,13-May-21,08:13,0,0,0,1,0 +494,1,29700,13-May-21,08:14,0,0,0,1,0 +495,1,29760,13-May-21,08:15,0,0,0,1,0 +496,1,29820,13-May-21,08:16,0,0,0,1,0 +497,1,29880,13-May-21,08:17,0,0,0,1,0 +498,1,29940,13-May-21,08:18,0,0,0,1,0 +499,1,30000,13-May-21,08:19,0,0,0,1,0 +500,1,30060,13-May-21,08:20,0,0,0,1,0 diff --git a/man/readActicalCount.Rd b/man/readActicalCount.Rd new file mode 100644 index 0000000..f220b5f --- /dev/null +++ b/man/readActicalCount.Rd @@ -0,0 +1,40 @@ +\name{readActicalCount} +\alias{readActicalCount} +\title{ + Read Actical Count data files (csv) +} +\description{ + Reads Actical Count data file. +} +\usage{ + readActicalCount(filename = file, desiredEpochSize = NULL, + timeformat = "\%m/\%d/\%Y \%H:\%M:\%S", tz = "", + timeformatName = "timeformat") +} +\arguments{ + \item{filename}{ + filename (required) + } + \item{desiredEpochSize}{ + Numeric, desired epoch size in seconds. If set aggregate data by summation to + this epochsize. + } + \item{timeformat}{ + Character, timestemp format. + } + \item{tz}{ + Character, timezone name from the timezone database names. + } + \item{timeformatName}{ + Character, name of timeformat variable to print in error message when + timeformat is incorrect, of use to GGIR where argument names can differ. + } +} +\value{ + \item{data}{Matrix with one or multiple columns} + \item{epochSize}{epoch size in seconds of data} + \item{startTime}{POSIXlt format timestamp on which recording starts } +} +\author{ + Vincent T van Hees +} \ No newline at end of file diff --git a/man/readActiwatchCount.Rd b/man/readActiwatchCount.Rd index 7419267..ace96b9 100644 --- a/man/readActiwatchCount.Rd +++ b/man/readActiwatchCount.Rd @@ -34,8 +34,6 @@ \item{data}{Matrix with one or multiple columns} \item{epochSize}{epoch size in seconds of data} \item{startTime}{POSIXlt format timestamp on which recording starts } - \item{deviceSerialNumber}{Device serial number if it could be extracted - from the file header} } \author{ Vincent T van Hees diff --git a/tests/testthat/test_readActicalCount.R b/tests/testthat/test_readActicalCount.R new file mode 100644 index 0000000..f8dbd2d --- /dev/null +++ b/tests/testthat/test_readActicalCount.R @@ -0,0 +1,31 @@ +library(GGIRread) +context("read Actical files") +test_that("Actical csv is correctly read", { + file = system.file("testfiles/Actical.csv", package = "GGIRread") + D = readActicalCount(filename = file, desiredEpochSize = 60, timeformat = "%d-%b-%y %H:%M", tz = "") + expect_equal(D$epochSize, 60) + expect_equal(format(D$startTime), "2021-05-13 00:01:00") + expect_equal(nrow(D$data), 500) + expect_equal(ncol(D$data), 2) + expect_equal(sum(D$data, na.rm = TRUE), 8174) + + D = readActicalCount(filename = file, desiredEpochSize = 120, timeformat = "%d-%b-%y %H:%M", tz = "") + expect_equal(D$epochSize, 120) + expect_equal(format(D$startTime), "2021-05-13 00:01:00") + expect_equal(nrow(D$data), 250) + expect_equal(ncol(D$data), 2) + expect_equal(sum(D$data, na.rm = TRUE), 8174) +}) + +test_that("Actical csv error correctly", { + file = system.file("testfiles/Actical.csv", package = "GGIRread") + expect_error(readActicalCount(filename = file, + desiredEpochSize = 60, + timeformat = "%d/%m/%Y %H:%M", tz = ""), + regexp = "Time format*") + + expect_error(readActicalCount(filename = file, + desiredEpochSize = 5, + timeformat = "%d-%b-%y %H:%M", tz = ""), + regexp = "The short*") +}) \ No newline at end of file