PAAT - Physical Activity Analysis Toolbox
The physical activity analysis toolbox (PAAT) is a comprehensive toolbox to analyze raw acceleration data. We developed all code mainly for analyzing ActiGraph data (GT3X files) in large sample study settings where manual annotation and analysis is not feasible.
This package has been developed and is maintained by researchers at UiT - the arctic university of Norway and was supported by the High Northern Population Studies, an interdisciplinary initiative to improve the health of future generations. The purpose of this package is to make our research on raw accelerometry easier accessible to other researchers. Most methods implemented in this package have been described in scientific papers which are usually cited in the function’s description. If you are using any of these methods in your research, we would be grateful if you cite the corresponding original paper(s).
Quickstart
Installation
The easiest way is to install paat directly from PyPI using pip:
pip install paat
For reproducible versions, see zenodo.
Usage
PAAT comprises several functions to work with raw data from ActiGraph devices. The following code snippet should give you a brief overview and idea on how to use this package. Further examples and more information on the functions can be found in the documentation.
It is also possible to use other packages such as actipy or SciKit Digital Health (SKDH) to load the data. The only prerequisite is that a pandas DataFrame with a TimeStamp index and the sampling frequency is provided. The pandas DataFrame should have raw acceleration data of the vertical axis (“Y” column), the sagittal axis (“X” column), and the frontal axis (“Z” column).
# Load data from file
data, sample_freq = paat.read_gt3x('path/to/gt3x/file')
# Detect non-wear time
data.loc[:, "Non Wear Time"] = paat.detect_non_wear_time_hees2011(data, sample_freq)
# Detect sleep episodes
data.loc[:, "Time in Bed"] = paat.detect_time_in_bed_weitz2024(data, sample_freq)
# Classify moderate-to-vigorous and sedentary behavior using the cutpoints from Sanders et al. (2019)
# Classify moderate-to-vigorous and sedentary behavior using the cutpoints from Sanders et al. (2019)
data.loc[:, ["MVPA", "SB"]] = paat.calculate_pa_levels(
data,
sample_freq,
mvpa_cutpoint=.069,
sb_cutpoint=.015
)
# Merge the activity columns into one labelled column. columns indicates the
# importance of the columns, later names are more important and will be kept
data.loc[:, "Activity"] = paat.create_activity_column(
data,
columns=["SB", "MVPA", "Time in Bed", "Non Wear Time"]
)
# Remove the other columns after merging
data = data[["X", "Y", "Z", "Activity"]]
Note
Note that these are only examples. There are multiple methods implemented in PAAT and the processing pipeline can easily be adjusted to individual needs. More (and also interactive) examples can be found in the examples section and an overview over the implemented methods including references to the original publications is also provided in the API documentation.