Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

OxWearables/sedentary-detection

Open more actions menu

Repository files navigation

Sedentary Detection

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.

Getting started

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/

Raw data

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.

Installing the environments and packages

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:

  1. Create a virtual environment:

    conda create -n sedentary python pip

    This creates a virtual environment called sedentary with Python and Pip.

  2. Activate the environment:

    conda activate sedentary

    You should now see (sedentary) written in front of your prompt.

  3. Install required packages:

    pip install -r sedentary_detection/requirements.txt

Running the scripts

Extracting the list of raw wrist accelerometer files

In command line/terminal, activate a conda environment:

conda activate actinet

Run 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/

Deploying the models

Deploy the models on the wrist accelerometer data

python models:

sbatch sedentary_detection/scripts/batch_run_py.sh

R models:

sbatch sedentary_detection/scripts/batch_run_r.sh

Cleaning and preparing the time-series data

Cleaning the data:

sbatch sedentary_detection/scripts/batch_run_clean.sh

Merging the time-series data:

sbatch sedentary_detection/scripts/batch_run_merge.sh

Produce analysis outputs

Run through the Jupyter notebooks in order:

  1. 0_StudyPopulation.ipynb
  2. 1_MainAnalysis.ipynb
  3. 2_SubgroupAnalysis.ipynb
  4. 3_SensitivityAnalysis.ipynb

About

Evaluation of the detection of sedentary behaviour on the Smart Work & Life dataset

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.