Skip to main content

actipy

Github all releases DOI

A Python package to process accelerometer data.

Axivity3 and Axivity6 (.cwa), Actigraph (.gt3x), GENEActiv (.bin), and Matrix (.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             : 50
 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 Glossary for a comprehensive list of outputs.

⚙️ Optional parameters

You can also specify time ranges and additional options:

data, info = actipy.read_device(
    "sample.cwa.gz",
    lowpass_hz=20,
    calibrate_gravity=True,
    detect_nonwear=True,
    resample_hz=50,
    start_time="2014-05-07 18:00:00",  # Start time (ISO format)
    end_time="2014-05-09 18:00:00",    # End time (ISO format)
    skipdays=1,                         # Skip first day
    cutdays=2,                          # Cut last 2 days
    start_first_complete_minute=True,  # Align to minute boundaries
    calibrate_gravity_kwargs={'stdtol_min': 0.01},  # Custom calibration params
    flag_nonwear_kwargs={'patience': '60m'}         # Custom nonwear params
)

📊 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.flag_nonwear(data)
data, info_resample = P.resample(data, 50)

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.

Release files for actipy 3.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for actipy 3.8.2
File Size Uploaded
actipy-3.8.2.tar.gz 93.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for actipy 3.8.2
File Interpreter ABI Platform
actipy-3.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 167.0 kB

Release files / actipy-3.8.2.tar.gz

Download URL actipy-3.8.2.tar.gz
Size 93.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e038de8fba7ace3f30cf3063dc61e95344fd0c79493ee492b48ac3cd8c449129
BLAKE2b-256 checksum
How to use checksums
ad90b2158ff7b0e849acc05e3810e0eaa97a4d3fed9fdd22da86ef696d567ef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / actipy-3.8.2-py3-none-any.whl

Download URL actipy-3.8.2-py3-none-any.whl
Size 73.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d97011423b5384dbc706d6ef5f8166b852a60e85b19e3190f5e62a7aa1862a3
BLAKE2b-256 checksum
How to use checksums
5bfc0dd8e51be6493a71d073b77b080daee2f73ac6d85c01a8d89f45c6a86bc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

3.8.2 This release

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.8

2 release files

3.0.7

2 release files

3.0.6

2 release files

3.0.5

2 release files

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page