A helper for the SensorPositionDateset (recorded 2019, published 2021)
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sensor_position_dataset_helper-1.2.0.tar.gz
.
File metadata
- Download URL: sensor_position_dataset_helper-1.2.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1700fd11b494be21d24971e5368e35e8ef3c0972a7d9fb72d5e3c9ade820742 |
|
MD5 | 18ea6b0383e86c0b327c868de2288b04 |
|
BLAKE2b-256 | 52a778772bfe7ad2b5d25e18c3a5f514af16887ea8ba14ed5052ff557d359af7 |
File details
Details for the file sensor_position_dataset_helper-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: sensor_position_dataset_helper-1.2.0-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.10.5 Linux/5.13.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1c9f36005a0531262b52b74ad667300822da03e74f4eed6f6c764b442372474 |
|
MD5 | 83b343148642976d020cff693c871664 |
|
BLAKE2b-256 | d88d1048602e7310a8b57bbf675a26fc9cc39d39ab1edc2f1d2f722450efa262 |