sensormotion


Namesensormotion JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/sho-87/sensormotion
SummaryPython package for analyzing sensor-collected human motion data (e.g. physical activity levels, gait dynamics)
upload_time2024-10-18 06:18:47
maintainerNone
docs_urlNone
authorSimon Ho
requires_python>=3
licenseMIT
keywords gait accelerometer signal-processing walking actigraph physical-activity
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            `Installation`_ | `Requirements`_ | `Usage`_ | `Contribution`_ | `Getting Help`_

Sensor Motion
=============

.. image:: https://img.shields.io/pypi/pyversions/sensormotion.svg
   :alt: PyPI - Python Version
   :target: https://pypi.org/project/sensormotion/

.. image:: https://img.shields.io/pypi/v/sensormotion.svg
   :alt: PyPI
   :target: https://pypi.org/project/sensormotion/

.. image:: https://img.shields.io/github/issues/sho-87/sensormotion.svg
   :alt: GitHub issues
   :target: https://github.com/sho-87/sensormotion/issues

.. image:: https://readthedocs.org/projects/sensormotion/badge/?version=latest
   :target: http://sensormotion.readthedocs.io

.. image:: https://badges.gitter.im/gitterHQ/gitter.png
   :target: https://gitter.im/sensormotion/lobby

.. inclusion-marker-main-readme

Python package for analyzing sensor-collected human motion data (e.g.
physical activity levels, gait dynamics).

Dedicated accelerometer devices, such as those made by Actigraph,
usually bundle software for the analysis of the sensor data. In my work
I often collect sensor data from smartphones and have not been able to
find any comparable analysis software.

This Python package allows the user to extract human motion data, such
as gait/walking dynamics, directly from accelerometer signals.
Additionally, the package allows for the calculation of physical
activity (PA) or moderate-to-vigorous physical activity (MVPA) counts,
similar to activity count data offered by companies like Actigraph.

Installation
------------

You can install this package using ``pip``:

::

    pip install sensormotion

Requirements
------------

This package has the following dependencies, most of which are just
Python packages:

- **Python 3.x**

  - The easiest way to install Python is using the
    `Anaconda <https://www.continuum.io/downloads>`__ distribution, as it
    also includes the other dependencies listed below

  - Python 2.x has not been tested, so backwards compatibility is not
    guaranteed

- **numpy**

  - Included with Anaconda. Otherwise, install using pip (``pip install numpy``)

- **scipy**

  - Included with Anaconda. Otherwise, install using pip (``pip install scipy``)

- **matplotlib**

  - Included with Anaconda. Otherwise, install using pip (``pip install matplotlib``)

Usage
-----

Here is brief example of extracting step-based metrics from raw
vertical acceleration data:

Import the package:

.. code:: python

    import sensormotion as sm

If you have a vertical acceleration signal ``x``, and its corresponding
time signal ``t``, we can begin by filtering the signal using a low-pass
filter:

.. code:: python

    b, a = sm.signal.build_filter(frequency=10,
                                  sample_rate=100,
                                  filter_type='low',
                                  filter_order=4)

    x_filtered = sm.signal.filter_signal(b, a, signal=x)

.. image:: images/filter.png

Next, we can detect the peaks (or valleys) in the filtered signal, which
gives us the time and value of each detection. Optionally, we can
include a plot of the signal and detected peaks/valleys:

.. code:: python

    peak_times, peak_values = sm.peak.find_peaks(time=t, signal=x_filtered,
                                                 peak_type='valley',
                                                 min_val=0.6, min_dist=30,
                                                 plot=True)

.. image:: images/peak_detection.png

From the detected peaks, we can then calculate step metrics like cadence
and step time:

.. code:: python

    cadence = sm.gait.cadence(time=t, peak_times=peak_times, time_units='ms')
    step_mean, step_sd, step_cov = sm.gait.step_time(peak_times=peak_times)

Physical activity counts and intensities can also be calculated from the acceleration data:

.. code:: python

    x_counts = sm.pa.convert_counts(x, time, integrate='simpson')
    y_counts = sm.pa.convert_counts(y, time, integrate='simpson')
    z_counts = sm.pa.convert_counts(z, time, integrate='simpson')
    vm = sm.signal.vector_magnitude(x_counts, y_counts, z_counts)
    categories, time_spent = sm.pa.cut_points(vm, set_name='butte_preschoolers', n_axis=3)

.. image:: images/pa_counts.png 

For a more in-depth tutorial, and more workflow examples, please take a look
at the `tutorial <https://github.com/sho-87/sensormotion/blob/master/tutorial.ipynb>`__.

I would also recommend looking over the
`documentation <http://sensormotion.readthedocs.io>`__ to see other
functionalities of the package.

Contribution
------------

I work on this package in my spare time, on an "as needed" basis for my
research projects. However, pull requests for bug fixes and new features
are always welcome!

Please see the `develop
branch <https://github.com/sho-87/sensormotion/tree/develop>`__ for the
development version of the package, and check out the `issues
page <https://github.com/sho-87/sensormotion/issues>`__ for bug reports
and feature requests.

Getting Help
------------

You can find the full documentation for the package
`here <http://sensormotion.readthedocs.io>`__

Python's built-in help function will show documentation for any module
or function: ``help(sm.gait.step_time)``

You're encouraged to post questions, bug reports, or feature requests as
an `issue <https://github.com/sho-87/sensormotion/issues>`__

Alternatively, ask questions on
`Gitter <https://gitter.im/sensormotion/lobby>`__

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sho-87/sensormotion",
    "name": "sensormotion",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "gait accelerometer signal-processing walking actigraph physical-activity",
    "author": "Simon Ho",
    "author_email": "simonho.ubc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5e/be/94bf7e6e6e8cd12611d4d52f63a22c3da21f517b7d1d9c971aae477ee2d8/sensormotion-1.1.5.tar.gz",
    "platform": null,
    "description": "`Installation`_ | `Requirements`_ | `Usage`_ | `Contribution`_ | `Getting Help`_\n\nSensor Motion\n=============\n\n.. image:: https://img.shields.io/pypi/pyversions/sensormotion.svg\n   :alt: PyPI - Python Version\n   :target: https://pypi.org/project/sensormotion/\n\n.. image:: https://img.shields.io/pypi/v/sensormotion.svg\n   :alt: PyPI\n   :target: https://pypi.org/project/sensormotion/\n\n.. image:: https://img.shields.io/github/issues/sho-87/sensormotion.svg\n   :alt: GitHub issues\n   :target: https://github.com/sho-87/sensormotion/issues\n\n.. image:: https://readthedocs.org/projects/sensormotion/badge/?version=latest\n   :target: http://sensormotion.readthedocs.io\n\n.. image:: https://badges.gitter.im/gitterHQ/gitter.png\n   :target: https://gitter.im/sensormotion/lobby\n\n.. inclusion-marker-main-readme\n\nPython package for analyzing sensor-collected human motion data (e.g.\nphysical activity levels, gait dynamics).\n\nDedicated accelerometer devices, such as those made by Actigraph,\nusually bundle software for the analysis of the sensor data. In my work\nI often collect sensor data from smartphones and have not been able to\nfind any comparable analysis software.\n\nThis Python package allows the user to extract human motion data, such\nas gait/walking dynamics, directly from accelerometer signals.\nAdditionally, the package allows for the calculation of physical\nactivity (PA) or moderate-to-vigorous physical activity (MVPA) counts,\nsimilar to activity count data offered by companies like Actigraph.\n\nInstallation\n------------\n\nYou can install this package using ``pip``:\n\n::\n\n    pip install sensormotion\n\nRequirements\n------------\n\nThis package has the following dependencies, most of which are just\nPython packages:\n\n- **Python 3.x**\n\n  - The easiest way to install Python is using the\n    `Anaconda <https://www.continuum.io/downloads>`__ distribution, as it\n    also includes the other dependencies listed below\n\n  - Python 2.x has not been tested, so backwards compatibility is not\n    guaranteed\n\n- **numpy**\n\n  - Included with Anaconda. Otherwise, install using pip (``pip install numpy``)\n\n- **scipy**\n\n  - Included with Anaconda. Otherwise, install using pip (``pip install scipy``)\n\n- **matplotlib**\n\n  - Included with Anaconda. Otherwise, install using pip (``pip install matplotlib``)\n\nUsage\n-----\n\nHere is brief example of extracting step-based metrics from raw\nvertical acceleration data:\n\nImport the package:\n\n.. code:: python\n\n    import sensormotion as sm\n\nIf you have a vertical acceleration signal ``x``, and its corresponding\ntime signal ``t``, we can begin by filtering the signal using a low-pass\nfilter:\n\n.. code:: python\n\n    b, a = sm.signal.build_filter(frequency=10,\n                                  sample_rate=100,\n                                  filter_type='low',\n                                  filter_order=4)\n\n    x_filtered = sm.signal.filter_signal(b, a, signal=x)\n\n.. image:: images/filter.png\n\nNext, we can detect the peaks (or valleys) in the filtered signal, which\ngives us the time and value of each detection. Optionally, we can\ninclude a plot of the signal and detected peaks/valleys:\n\n.. code:: python\n\n    peak_times, peak_values = sm.peak.find_peaks(time=t, signal=x_filtered,\n                                                 peak_type='valley',\n                                                 min_val=0.6, min_dist=30,\n                                                 plot=True)\n\n.. image:: images/peak_detection.png\n\nFrom the detected peaks, we can then calculate step metrics like cadence\nand step time:\n\n.. code:: python\n\n    cadence = sm.gait.cadence(time=t, peak_times=peak_times, time_units='ms')\n    step_mean, step_sd, step_cov = sm.gait.step_time(peak_times=peak_times)\n\nPhysical activity counts and intensities can also be calculated from the acceleration data:\n\n.. code:: python\n\n    x_counts = sm.pa.convert_counts(x, time, integrate='simpson')\n    y_counts = sm.pa.convert_counts(y, time, integrate='simpson')\n    z_counts = sm.pa.convert_counts(z, time, integrate='simpson')\n    vm = sm.signal.vector_magnitude(x_counts, y_counts, z_counts)\n    categories, time_spent = sm.pa.cut_points(vm, set_name='butte_preschoolers', n_axis=3)\n\n.. image:: images/pa_counts.png \n\nFor a more in-depth tutorial, and more workflow examples, please take a look\nat the `tutorial <https://github.com/sho-87/sensormotion/blob/master/tutorial.ipynb>`__.\n\nI would also recommend looking over the\n`documentation <http://sensormotion.readthedocs.io>`__ to see other\nfunctionalities of the package.\n\nContribution\n------------\n\nI work on this package in my spare time, on an \"as needed\" basis for my\nresearch projects. However, pull requests for bug fixes and new features\nare always welcome!\n\nPlease see the `develop\nbranch <https://github.com/sho-87/sensormotion/tree/develop>`__ for the\ndevelopment version of the package, and check out the `issues\npage <https://github.com/sho-87/sensormotion/issues>`__ for bug reports\nand feature requests.\n\nGetting Help\n------------\n\nYou can find the full documentation for the package\n`here <http://sensormotion.readthedocs.io>`__\n\nPython's built-in help function will show documentation for any module\nor function: ``help(sm.gait.step_time)``\n\nYou're encouraged to post questions, bug reports, or feature requests as\nan `issue <https://github.com/sho-87/sensormotion/issues>`__\n\nAlternatively, ask questions on\n`Gitter <https://gitter.im/sensormotion/lobby>`__\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python package for analyzing sensor-collected human motion data (e.g. physical activity levels, gait dynamics)",
    "version": "1.1.5",
    "project_urls": {
        "Documentation": "http://sensormotion.readthedocs.io",
        "Homepage": "https://github.com/sho-87/sensormotion",
        "Source": "https://github.com/sho-87/sensormotion",
        "Tracker": "https://github.com/sho-87/sensormotion/issues"
    },
    "split_keywords": [
        "gait",
        "accelerometer",
        "signal-processing",
        "walking",
        "actigraph",
        "physical-activity"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "841c63aa3876e952b4d6931880d332182b79eac1f22e215cae0ead5172647482",
                "md5": "d21bfb7534c1092c25fdf3dfc8802358",
                "sha256": "c205c9226a20d692b1fa60a6bb1f91d08e4075d1227f2ed9f48acd984d4f314f"
            },
            "downloads": -1,
            "filename": "sensormotion-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d21bfb7534c1092c25fdf3dfc8802358",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 20576,
            "upload_time": "2024-10-18T06:18:46",
            "upload_time_iso_8601": "2024-10-18T06:18:46.247080Z",
            "url": "https://files.pythonhosted.org/packages/84/1c/63aa3876e952b4d6931880d332182b79eac1f22e215cae0ead5172647482/sensormotion-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ebe94bf7e6e6e8cd12611d4d52f63a22c3da21f517b7d1d9c971aae477ee2d8",
                "md5": "e289ffac5699aa9110c38cab1d202063",
                "sha256": "411104318fe1721fb10046884d28cf8233611cc392272a0a646282ee3a650a5f"
            },
            "downloads": -1,
            "filename": "sensormotion-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e289ffac5699aa9110c38cab1d202063",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 19067,
            "upload_time": "2024-10-18T06:18:47",
            "upload_time_iso_8601": "2024-10-18T06:18:47.263191Z",
            "url": "https://files.pythonhosted.org/packages/5e/be/94bf7e6e6e8cd12611d4d52f63a22c3da21f517b7d1d9c971aae477ee2d8/sensormotion-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-18 06:18:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sho-87",
    "github_project": "sensormotion",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sensormotion"
}
        
Elapsed time: 3.60405s