-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention rounding #24
Comments
@muschellij2 Thanks for mentioning this difference in the |
I think the results should be rounded to 3 decimals to replicate the output
from actilife.
…On Tue, Oct 3, 2023 at 5:51 PM Brian C. Helsel ***@***.***> wrote:
@muschellij2 <https://github.com/muschellij2> Thanks for mentioning this
difference in the read.gt3x and pygt3x packages. It seems like this might
be something that needs to be fixed with the read.gt3x R package since it
is returning rounded decimal points. Any thoughts as to what part of the
code is doing the rounding or any potential solutions?
—
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIGPLQ25SSZJOUQHCKAFYLX5SCH5AVCNFSM6AAAAAA4LXTPVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBVG44DGNBUG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
From what I've found, the library(agcounts)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
path <- system.file("extdata/example.gt3x", package = "agcounts")
agd_path <- system.file("extdata/example5sec.agd", package = "agcounts")
agd <- agcounts:::.read_agd(agd_path)$data
pygt3x <-
agcounts::agread(path, parser = "pygt3x") %>%
agcounts::calculate_counts(epoch = 5)
pygt3x_round <-
agcounts::agread(path, parser = "pygt3x") %>%
dplyr::mutate_at(.vars = 2:4, .funs = round, 3) %>%
agcounts::calculate_counts(epoch = 5)
pygt3x_ncar_round <-
agcounts::agread(path, parser = "pygt3x") %>%
dplyr::mutate_at(.vars = 2:4, .funs = ncar::Round, 3) %>%
agcounts::calculate_counts(epoch = 5)
colSums(abs(pygt3x[, 2:5] - agd[, 2:5]))
#> Axis1 Axis2 Axis3 Vector.Magnitude
#> 0 0 0 0
colSums(abs(pygt3x_round[, 2:5] - agd[, 2:5]))
#> Axis1 Axis2 Axis3 Vector.Magnitude
#> 7 4 13 9
colSums(abs(pygt3x_ncar_round[, 2:5] - agd[, 2:5]))
#> Axis1 Axis2 Axis3 Vector.Magnitude
#> 7 4 16 11
read.gt3x <-
agcounts::agread(path, parser = "read.gt3x") %>%
agcounts::calculate_counts(epoch = 5)
colSums(abs(pygt3x_ncar_round[, 2:5] - read.gt3x[, 2:5]))
#> Axis1 Axis2 Axis3 Vector.Magnitude
#> 0 0 0 0 Created on 2023-10-04 with reprex v2.0.2 |
Actigraph specification of GT3X format specifically says to round ACTIVITY packets: https://github.com/actigraph/GT3X-File-Format/blob/main/LogRecords/Activity2.md#scaling-activity-values and https://github.com/actigraph/GT3X-File-Format/blob/main/LogRecords/Activity.md#scaling-activity-values |
The documentation doesn't change the fact that the |
That’s fair, but many will likely use base::round and get slightly wrong
results. Either way, is this noted in the docs?
…On Wed, Oct 4, 2023 at 9:50 AM Brian C. Helsel ***@***.***> wrote:
The documentation doesn't change the fact that the pygt3x parser is
getting a more consistent output compared to Actilife and is the method
that ActiGraph recommended to read in the .gt3x raw files when their
agcounts Python package was released. If users want a value rounded to 3
decimal points then it seems like the read.gt3x parser would be the best
option since it rounds similar to Ncar::Round. Users could also round the
values after reading them into R and before calculating the activity counts
which yields the same output as the read.gt3x parser.
—
Reply to this email directly, view it on GitHub
<#24 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIGPLSM27NGGNLRXPGS4KDX5VSSPAVCNFSM6AAAAAA4LXTPVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWHEZDCMRUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
We list the preferred method as |
As per the GT3X documentation, rounding half away from zero is the norm for rounding GT3X data as the last step (https://github.com/actigraph/GT3X-File-Format/blob/d4aa795a3d06cc8b22b4e3df645b597cdeee6d92/LogRecords/Activity.md?plain=1#L226). It should be noted somewhere that the normal
round
in R does not do this, but thencar::Round
function will (as well as many others).This is important because you can get some slight differences from the readers:
Created on 2023-09-05 with reprex v2.0.2
Session info
The text was updated successfully, but these errors were encountered: