wadpac / GGIR

Code corresponding to R package GGIR
https://wadpac.github.io/GGIR/
Apache License 2.0
99 stars 62 forks source link

Mistake in identifying vm column? #1122

Closed tarensanders closed 5 months ago

tarensanders commented 6 months ago

Hi Vincent,

I'm trying to work with some .agd files. I know that in the past GGIR hasn't supported non-raw formats, but it seems like GGIR now supports it (after converting to CSV, as you suggest in #981).

So I've written a script to convert agd to csv, but I'm running into problems during the imputation. Specifically:

Error in Math.data.frame(list(NeishabouriCount_y = c("0", "44", "113",  : 
  non-numeric-alike variable(s) in data frame: NeishabouriCount_y, NeishabouriCount_x, NeishabouriCount_z, NeishabouriCount_x.1

The fact that there are two NeishabouriCount_xseems odd to me. Inspecting the part1 output confirms that this is how the metalong/metashort is created.

r$> head(M$metashort)
                 timestamp NeishabouriCount_y NeishabouriCount_x NeishabouriCount_z NeishabouriCount_x
1 2017-09-12T15:00:00+1000                  0                  0                  0                  0
2 2017-09-12T15:00:01+1000                 44                  9                  0                 45
3 2017-09-12T15:00:02+1000                113                  9                 29                118
4 2017-09-12T15:00:03+1000                 28                  0                 43                 52
5 2017-09-12T15:00:04+1000                 53                  3                 41                 68
6 2017-09-12T15:00:05+1000                 61                 91                100                149

So I went digging and found this section:

https://github.com/wadpac/GGIR/blob/5185b22364937ba95cefdb2af4430268b363dfea/R/convertEpochData.R#L286-L289

It seems like this is a mistake, and that this should instead be "NeishabouriCount_vm" as is referenced elsewhere.

https://github.com/wadpac/GGIR/blob/5185b22364937ba95cefdb2af4430268b363dfea/R/g.analyse.perday.R#L392

This would only affect agd files where the vm is included in the output of the csv file. I'll open a PR with a fix for this for you to merge if you agree that this is a mistake.

tarensanders commented 6 months ago

It turns out this issue is unrelated to the problem I'm having with the converted data. I'm trying to follow these instructions, but I'm still getting an error about non-numeric-alike variable(s) which seems to occur in g.impute. I'm happy to keep digging my way through this, but if you happen to know what I'm doing wrong that would be great.

I'm running:

GGIR::GGIR(
  mode = 1:2,
  datadir = "/Users/tasanders/Downloads/Testfiles/CSV",
  outputdir = "/Users/tasanders/Downloads/Testfiles/outdir",
  dataFormat = "actigraph_csv",
  windowsizes = c(1, 900, 3600), studyname = "test",
  extEpochData_timeformat = "%m-%d-%Y %H:%M:%S",
  do.neishabouricounts = TRUE, acc.metric = "NeishabouriCount_x",
  HASPT.algo = "NotWorn", HASIB.algo = "NotWorn", overwrite = TRUE
)

Edit: Worked it out - M$metashort has all of the data stored as characters rather than as numerics. Not sure if this is a problem with GGIR or with my conversion script, but at least it is simple to solve.