bhelsel / agcounts

R package for extracting actigraphy counts from accelerometer data.
Other
9 stars 5 forks source link

Faster agcalibrate #33

Closed muschellij2 closed 5 months ago

muschellij2 commented 5 months ago

It's unclear to me why you need to create timestamps, or anything of the like from the raw data when you do the calibration. It would seem as though you should be able to just get the calibration coefficients from the function similar to what you do in GGIR, and simply apply them.

bhelsel commented 5 months ago

Hi John @muschellij2 , thanks for the suggestion. I need to look at this a little closer so I'm going to hold off on merging the pull request for now. I agree that recreating the time stamps slows down agcalibrate but my goal was to try and get something close to the output you get from GGIR. I still need to test it more, but if you run GGIR::g.calibrate it applies the calibration coefficients but also imputes the time gaps into the data frame. The number of rows would also be different from all the agread parsers since all methods read in the zeros before converting to ActiGraph counts to get us closer to the *.agd files. I'll look into other ways to speed it up as I never thought merge was the best option. I'm open to your ideas here.

bhelsel commented 5 months ago

It looks like the conversion to a data.table speeds up the merge function. Users may want to impute the time gaps similar to GGIR, but I created an imputeTimeGaps argument set to FALSE as default in case someone wants the zero data. Both methods are relatively fast now and your suggestion is set to default since it is more memory friendly to R's global environment.