Skip to main content

PyPI PyPI - Downloads Code style: black

SensorPositionComparison Helper

This is a helper module to extract and handle the data of the SensorPositionComparison Dataset.

If you use the dataset or this package, please cite:

Küderle, Arne, Nils Roth, Jovana Zlatanovic, Markus Zrenner, Bjoern Eskofier, and Felix Kluge.
“The Placement of Foot-Mounted IMU Sensors Does Affect the Accuracy of Spatial Parameters during Regular Walking.”
PLOS ONE 17, no. 6 (June 9, 2022): e0269567. https://doi.org/10.1371/journal.pone.0269567.

Installation and Usage

Install the project via pip or poetry:

pip install sensor_position_dataset_helper
poetry add sensor_position_dataset_helper

Dataset Handling

You also need to download the actual Dataset from here. If you are member of the MaD Lab, you can also get a git-lfs version from our internal server.

Then you need to tell this library about the position of the dataset. Note that the path should point to the top-level repo folder of the dataset. This can either be done globally:

from sensor_position_dataset_helper import set_data_folder

set_data_folder("PATH/TO/THE_DATASET")

Or on a-per function basis

from sensor_position_dataset_helper import get_all_subjects

get_all_subjects(data_folder="PATH/TO/THE_DATASET")

If you are using the tpcp-dataset objects, you need to provide the path in the init.

from sensor_position_dataset_helper.tpcp_dataset import SensorPositionDatasetSegmentation

dataset = SensorPositionDatasetSegmentation(dataset_path="PATH/TO/THE_DATASET")

Code Examples

For simple operations we suggest to use the provided functions. For a list of functions see the sensor_position_dataset_helper/helper.py file.

In this example we load the gait test data of a 4x10 slow gait test of one participant:

from sensor_position_dataset_helper import get_all_subjects, get_metadata_subject, get_imu_test, get_mocap_test

DATA_FOLDER = "PATH/TO/THE_DATASET"
print(list(get_all_subjects(data_folder=DATA_FOLDER)))
# ['4d91', '5047', '5237', '54a9', '6dbe_2', '6e2e', '80b8', '8873', '8d60', '9b4b', 'c9bb', 'cb3d', 'cdfc', 'e54d']

print(list(get_metadata_subject("54a9", data_folder=DATA_FOLDER)["imu_tests"].keys()))
# ['fast_10', 'fast_20', 'long', 'normal_10', 'normal_20', 'slow_10', 'slow_20']

# Finally get the data.
# Note, this thorws a couple of warnings during the data loading, do to the use of custom sensor firmware.
# These warnings can be ignored.
imu_data = get_imu_test("54a9", "slow_10", data_folder=DATA_FOLDER)

mocap_traj = get_mocap_test("54a9", "slow_10", data_folder=DATA_FOLDER)

For advanced usage we recommend the use of the tpcp datasets. They provide an object oriented way to access the data and abstract a lot of the complexity that comes with loading the data. For general information about object oriented datasets and why they are cool, check out our tpcp library.

Here we load the same data as above, but using the dataset object:

from sensor_position_dataset_helper.tpcp_dataset import SensorPositionDatasetMocap

DATA_FOLDER = "PATH/TO/THE_DATASET"
ds = SensorPositionDatasetMocap(data_folder=DATA_FOLDER)
print(ds)
# SensorPositionDatasetMocap [98 groups/rows]
#
#      participant       test
#   0         4d91    fast_10
#   1         4d91    fast_20
#   2         4d91       long
#   3         4d91  normal_10
#   4         4d91  normal_20
#   ..         ...        ...
#   93        e54d       long
#   94        e54d  normal_10
#   95        e54d  normal_20
#   96        e54d    slow_10
#   97        e54d    slow_20
#   
#   [98 rows x 2 columns]
#

print(ds.get_subset(participant="54a9"))
# SensorPositionDatasetMocap [7 groups/rows]
#
#     participant       test
#   0        54a9    fast_10
#   1        54a9    fast_20
#   2        54a9       long
#   3        54a9  normal_10
#   4        54a9  normal_20
#   5        54a9    slow_10
#   6        54a9    slow_20
#

data_point = ds.get_subset(participant="54a9", test="slow_10")

# The data is not loaded until here.
# Only when accessing the `.data` or the `marker_position_` attribute the data is loaded.
imu_data = data_point.data
mocap_traj = data_point.marker_position_

Managing Dataset Revisions

To ensure reproducibility, you should save the version of the dataset that was used for a certain analysis. If you are part of the MaD-Lab and using the internal git-versioned version of the dataset we provide some helpers.

If you are using the version from Zenodo, we unfortunally have no easy way to verify the version and integrity of the extracted data on disk. Therefore, make sure to document the version of the Zenodo dataset and verify the md5 hasshum of the zip-file you downloaded from Zenodo.

For the git version you can use the helper as follows:

from sensor_position_dataset_helper import ensure_git_revision

ensure_git_revision(data_folder="PATH/TO/THE_DATASET", version="EXPECTED GIT HASH")

This will produce an error, if the dataset version you are using is not the one you expect, or if the dataset repo has uncommitted changes. This will prevent bugs, because you accidentally use the wrong dataset version and will directly document the correct version.

Metadata

Release files for sensor-position-dataset-helper 1.2.0

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

Source distribution (sdist)

Source distribution for sensor-position-dataset-helper 1.2.0
File Size Uploaded Provenance Actions
sensor_position_dataset_helper-1.2.0.tar.gz 18.4 kB Without provenance Details for sensor_position_dataset_helper-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sensor-position-dataset-helper 1.2.0
File Interpreter ABI Platform Actions
sensor_position_dataset_helper-1.2.0-py3-none-any.whl Python 3 none any Details for sensor_position_dataset_helper-1.2.0-py3-none-any.whl

Total release size: 36.9 kB

Release files / sensor_position_dataset_helper-1.2.0.tar.gz

Download URL sensor_position_dataset_helper-1.2.0.tar.gz
Size 18.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b1700fd11b494be21d24971e5368e35e8ef3c0972a7d9fb72d5e3c9ade820742
BLAKE2b-256 checksum
How to use checksums
52a778772bfe7ad2b5d25e18c3a5f514af16887ea8ba14ed5052ff557d359af7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1031-azure

Release files / sensor_position_dataset_helper-1.2.0-py3-none-any.whl

Download URL sensor_position_dataset_helper-1.2.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1c9f36005a0531262b52b74ad667300822da03e74f4eed6f6c764b442372474
BLAKE2b-256 checksum
How to use checksums
d88d1048602e7310a8b57bbf675a26fc9cc39d39ab1edc2f1d2f722450efa262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1031-azure

Security for sensor-position-dataset-helper 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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