Skip to main content

Python package to process wearable accelerometer data

Project description

actipy

A Python package to process accelerometer data.

Axivity3 and Axivity6 (.cwa), Actigraph (.gt3x), and GENEActiv (.bin) files are supported, as well as custom CSV files.

Axivity3 is the activity tracker watch used in the large-scale UK-Biobank accelerometer study.

Getting started

Prerequisite

  • Python 3.8 or greater

    $ python --version  # or python3 --version
    
  • Java 8 (1.8.0) or greater

    $ java -version
    

Install

$ pip install actipy

Usage

import actipy

data, info = actipy.read_device("sample.cwa.gz",  # or "sample.gt3x.gz" or "sample.bin.gz"
                                 lowpass_hz=20,
                                 calibrate_gravity=True,
                                 detect_nonwear=True,
                                 resample_hz=50)

Output:

data [pandas.DataFrame]
                                 x         y         z  temperature      light
 time
 2014-05-07 13:29:50.430 -0.513990  0.070390  1.671922    20.000000  78.420235
 2014-05-07 13:29:50.440 -0.233940 -0.586568  0.082067    20.000000  78.420235
 2014-05-07 13:29:50.450 -0.080319 -0.950817 -0.810613    20.000000  78.420235
 2014-05-07 13:29:50.460 -0.067236 -0.975886 -0.865132    20.000000  78.420235
 2014-05-07 13:29:50.470 -0.109636 -0.857004 -0.508666    20.000000  78.420235
 ...                           ...       ...       ...          ...        ...

info [dict]
 Filename                 : data/sample.cwa.gz
 Filesize(MB)             : 69.4
 Device                   : Axivity
 DeviceID                 : 13110
 ReadErrors               : 0
 SampleRate               : 100.0
 ReadOK                   : 1
 StartTime                : 2014-05-07 13:29:50
 EndTime                  : 2014-05-13 09:50:33
 NumTicks                 : 51391800
 WearTime(days)           : 5.847725231481482
 NumInterrupts            : 1
 ResampleRate             : 100.0
 NumTicksAfterResample    : 25262174
 LowpassOK                : 1
 LowpassCutoff(Hz)        : 20.0
 CalibErrorBefore(mg)     : 82.95806873592024
 CalibErrorAfter(mg)      : 4.434966371604519
 CalibOK                  : 1
 NonwearTime(days)        : 0.0
 NumNonwearEpisodes       : 0
 ...

Refer to the Data Dictionary for a comprehensive list of outputs.

Processing a custom CSV file

You can also use the routines in actipy.processing to process custom CSV files, or for more fine-grained control:

import actipy.processing as P

data, info_lowpass = P.lowpass(data, 100, 20)
data, info_calib = P.calibrate_gravity(data)
data, info_nonwear = P.detect_nonwear(data)
data, info_resample = P.resample(data, sample_rate)

See the documentation for more.

Processing from the command line

We also provide a command-line tool to process a device file (currently, only AX3 and AX6 are supported) and output to CSV:

$ read_cwa sample.cwa.gz -o outputs --lowpass-hz 20 --resample-hz 50 --calibrate-gravity --detect-nonwear

Outputs:

  • "outputs/sample/sample.csv.gz"
  • "outputs/sample/sample-Info.json"

Contributing

If you would like to contribute to this repository, please check out CONTRIBUTING.md. We welcome contributions in the form of bug reports, feature requests, and pull requests.

License

See LICENSE.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

actipy-3.3.0.tar.gz (76.8 kB view details)

Uploaded Source

Built Distribution

actipy-3.3.0-py3-none-any.whl (59.9 kB view details)

Uploaded Python 3

File details

Details for the file actipy-3.3.0.tar.gz.

File metadata

  • Download URL: actipy-3.3.0.tar.gz
  • Upload date:
  • Size: 76.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for actipy-3.3.0.tar.gz
Algorithm Hash digest
SHA256 ba95c170a0019d783dbca4e5bccc7c313856491b6dc878ab73ff088d8ae2ec41
MD5 9750e74ce32c97fb4f907b01d819e0e8
BLAKE2b-256 df891763f987e7df85ab07fb86f7a1099780660f8031bf3dbde775b07f8f4ff6

See more details on using hashes here.

File details

Details for the file actipy-3.3.0-py3-none-any.whl.

File metadata

  • Download URL: actipy-3.3.0-py3-none-any.whl
  • Upload date:
  • Size: 59.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for actipy-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29c4dc21f2e7563c212f571fb3c4b1a1d219bde70eaeddf0c45723a489ee161d
MD5 e657bf070953179a589a28f14ef2a1d1
BLAKE2b-256 f914dfd119de30d97955ce74d784ec465a2e7386da6d11a17c1662399a174cbd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page