Closed vincentvanhees closed 4 years ago
Current thoughts on S3 class object for the input data:
rawacc <- list(acc = data.frame(accx=x, accy=y, accz=z),
original_sample_rate = 100,
current_sample_rate = 50,
unit="g")
class(rawacc) <- "rawacc"
An alternative approach could be to define a class around the external function, rather than around the data.
mytool = list(FUN, model_coefficients = c(), expected_sample_rate=50, expected_unit="g", minlength = 5, outputres = 5) class(mytool) = "externalTool"
Which makes it clear for the external function developer what to provide.
Object components:
Hi Vincent, thanks for all the work and documentation on this. I'm a bit stuck in the 'applyExtFunction.R' script, as there is a call to a 'resample' function. Does this function come from library, or should it be included in the .R files with GGIR? IT doesn't seem to be in the _issue241ExtrnlFuncEmbedding branch?
IT is inside the resampleAcc function, which is defined inside applyExtFunction.R:
'Resample' seems to be getting called somehow, as this is the error that I am stuck at:
Hi Matt, resample is a c++ function from the src directory, which needs to be compiled with (only if you are working with the code in development mode):
library("Rcpp")
pathR = "/home/GGIR"
sourceCpp(paste0(pathR,"/src/numUnpack.cpp"))
sourceCpp(paste0(pathR,"/src/resample.cpp"))
I am currently trying to fix some issues in this part of the code. so please hold on. I am hopeful that I can commit my changes in the upcoming hour or so. This relates robustness to incorret use of myfun$timestamp value.
sounds good, thanks!
I am done for the day, the above commit was what I wanted to do. To check I did not break anything I run the counts example and the dominant frequency example from the vignette and they still seem to work.
Thanks for those updates Vincent, it seems to be working well now. For, the step count algorithm, the user will want to have the number of steps taken each day as well as the total number of steps taken over the entire recording? Do you think you will set this up to auto generate in the output, or will there be some sort of myfun setting to indicate how the final output should be shown?
Great work on this tool, it is a very powerful way to quickly apply different algorithms to long term activity recordings!
Thanks Matt for letting me know. Yes, I think some input will be needed to make it generically useful.
Possible types of features:
Possible types of aggregating per day and per recording:
Possible desired ways of reporting:
Next, the myfun object may then need to carry a choice for each of these three categories. For example, to be named: outputtype = "eventcount", how2aggregate4report = "sum", and GGIRreport = 2. Can you think of any additional types or decisions that need to be accounted for to be future proof?
I think that is a pretty thorough list of how algorithm creators will want to categorize outputs.
There might be a need to only include results from either day or night or else to separate day results and night results. Maybe this would take more time to implement, so could be something to do down the road. For the steps algorithm I don't need it.
Can you send me an example milestone file with the step count in it? I could use that to develop the automated incorporation of total steps per day in the csv report.
Closing this issue as it seems to be working for a variety of use cases.
Most recent addition is the use of an external function for sleep detection and embedding in all sleep and part 5 reports. I have added a pdf copy of the tutorial to the repo https://github.com/wadpac/GGIR/tree/GGIR2.0/pdf_vignettes_for_github_only
Inclusion in new release: I merged all progress with branch GGIR2.0, which I aim to merge with the master branch in the upcoming weeks and that will be release 2.0-0 (GitHub only). Next, I will encourage the GGIR e-mail list (google group) to start testing it, followed by 2.1-0 a couple of weeks later on GitHUb and on CRAN.
New ideas for improvement can be collected in a new issue, for now I think it is good enough.
The plan is to allow for specification of an external function to be applied to the raw accelerometer data, and to integrate the output of that function in the GGIR output. For example, an external algorithm for sleep detection, step detection, cycling detection, etc. The advantages include:
Plan for now:
Embed sleep/nonwear classification output LRAP project in part 2 and 4 reports: