Skip to content
Snippets Groups Projects
README.md 2.78 KiB
Newer Older
# Physical Activity Line Modelling
This project is designed to help classify an individual's physical activity patterns over the course of a study by plotting their activity levels per minute and fitting a piecewise equation to the distribution. This model is represented in the following manners: a csv detailing each of the line's parameters for each

## Dependencies
This project requires Python 3.6 or later on any major operating system. 
All library dependencies for this project can be found in the requirements.txt file, which is also located in this repository.


## Installation
To install this program, using git and python's built-in installer pip on the command line of any Linux or iOS machine is recommended. 

Downloading the repository:
```
git clone https://git.cs.usask.ca/kdp740/pa-line-modelling.git
```

Installing dependencies:
```
cd pa-line-modelling
pip install -r requirements.txt
```


## Demonstration
Included in this repository is a small sample of the NHANES 2013-2014 Physical Activity Monitor - Minute participants, located in the demo_data directory, for the purpose of testing this program.
The full dataset can be downloaded from https://wwwn.cdc.gov/nchs/nhanes/search/datapage.aspx?Component=Examination&CycleBeginYear=2013.

### Generate Line Model
To process the demonstration data into a CSV file with our metrics, run the following command:
```
python pa_line_modeling.py demo_data mims
```
Expected runtime: Less than 1 minute.
Expected output: classified_mims_demo_data.csv, a csv containing one row per participant processed

### Generate Overall Distribution Image
To process the demonstration data into a CSV file with our metrics, run the following command:
```
python hexbin.py demo_data mims
```
Expected runtime: Less than 1 minute.
Expected output: demo_data_hexbin-vis_binsize-0.5_skip-0.png, an image that summarizes the distributions in the input file.

If the breakpoints generated by pa_line_modeling.py are to be displayed, the following command can be run after running pa_line_modeling.py:
```
python hexbin.py demo_data mims --box
```
The only difference is that a set of boxplots will be added to the image to mark the distributions of breakpoints.


## Running the Program

When processing our data, it was first divided into individual CSV files in the same directory with each CSV containing all the physical activity records of a single participant.
Then each study could be processed with the following commands:

```
python pa_line_modeling.py NHANES_DIRECTORY mims
python pa_line_modeling.py INTERACT_DIRECTORY counts
```

To run this software on a metric other than the MIMS unit or Actigraph activity count, a new script must be written that passes the appropriate arguments to the calculate_metrics() method in slople_breakpoint_metrics.py, similar to pa_line_modelling.py.