This repository is used for the evaluation of the detection of sedentary behaviour on the Smart Work and Life (SWAL) dataset. This dataset consist of wrist and thigh accelerometer data concurrently worn by over 700 participants across the UK. Thigh data can form a silver standard for the identification of sitting/lying, and therefore sedentary behaviour, based on the orientation of the device, extract using the open-source PALBatch algorithm.
Classifying sedentary, otherly labelled as non-sleep inactive behaviour, using wrist-devices is more complicated, relying on either falling below thresholds of overall acceleration, or advanced machine learning technique. This repository seeks to discover how well the classified sedentary behaviour from models applied to the wrist-worn data, aligns with the silver-standard reporting of sedentary behaviour, from the thigh worn device.
Note that in all cases throughout this repository, the path sedentary_detection/ should be replaced with the full path to this repository, such as: C:/Users/{your_name}/Projects/sedentary-detection/
This repository depends on access to the raw, SWAL dataset, consisting of .cwa files from the wrist monitor, and prepared 1-second epoch .csv file outputs of the thigh monitor, produced by PALBatch.
The wrist data should be appropriately copied to/linked to the folder: sedentary_detection/data/raw/wrist/, with this folder containing each of the .cwa files, with no subfolders.
The thigh data should also be appropriately copied to/linked to the folder: sedentary_detection/data/raw/thigh/, with this folder containing each of the .csv files (with semi-colon separators), and no subfolders.
This repository depends on the deployment of a variety of models between R and Python. To do so, necessary packages must be installed, either with R, or Anaconda. Links are provided below for instructions for the installation of all the necessary packages. The batch scripts in scripts/ are written for SLURM and can be submitted with sbatch.
| Tool / Package | Documentation / Repository |
|---|---|
| Accelerometer | https://biobankaccanalysis.readthedocs.io/en/latest |
| ActiNet | https://actinet.readthedocs.io/en/latest/ |
| GGIR | https://wadpac.github.io/GGIR/ |
| Actimetric | https://github.com/PhysicalActivityOpenTools/actimetric |
To install the necessary packages to run the evaluation notebooks:
-
Create a virtual environment:
conda create -n sedentary python pipThis creates a virtual environment called
sedentarywith Python and Pip. -
Activate the environment:
conda activate sedentaryYou should now see
(sedentary)written in front of your prompt. -
Install required packages:
pip install -r sedentary_detection/requirements.txt
In command line/terminal, activate a conda environment:
conda activate actinetRun the python script to extract the list of files, and save it in an appropriate location.
python sedentary_detection/scripts/get_files.py -f sedentary_detection/data/raw/wrist/ -o sedentary_detection/Deploy the models on the wrist accelerometer data
python models:
sbatch sedentary_detection/scripts/batch_run_py.shR models:
sbatch sedentary_detection/scripts/batch_run_r.shCleaning the data:
sbatch sedentary_detection/scripts/batch_run_clean.shMerging the time-series data:
sbatch sedentary_detection/scripts/batch_run_merge.shRun through the Jupyter notebooks in order:
0_StudyPopulation.ipynb1_MainAnalysis.ipynb2_SubgroupAnalysis.ipynb3_SensitivityAnalysis.ipynb