Usage
This section describes the practical execution flow of the repository.
The project is intended to be run in two consecutive stages:
build semantic candidate windows from raw wearable data
detect movement and gait over those stored semantic windows
Execution order
The normal order is:
run
find_mscodeidsverify that
activity_legandactivity_allwere created correctlyrun
find_gaitinspect
effective_movementandeffective_gaitoptionally run the ground-truth validation utilities in
tests
Stage 1: semantic construction
Use find_mscodeids to retrieve CodeIDs from InfluxDB and construct the
semantic tables required by the gait stage.
Example:
python -m ms_monitoring.find_mscodeids \
-c config.yaml \
-f "2025-05-11 00:00:00" \
-u "2025-05-12 00:00:00" \
--save 1 \
-v 2
This stage may generate:
rows in
codeidsrows in
activity_legrows in
activity_all
Stage 2: movement and gait detection
Use find_gait to process previously created activity_all windows.
Example using explicit IDs:
python -m ms_monitoring.find_gait \
-c config.yaml \
-i "152" \
--save 1 \
-v 2
Example using a recent time window:
python -m ms_monitoring.find_gait \
-c config.yaml \
--hours-back 25 \
--save 0 \
-v 1
This stage may generate:
rows in
effective_movementrows in
effective_gaitGPS enrichment fields inside
effective_gait:gps_points,gps_distance_m,gps_elapsed_sec,gps_avg_speed_m_s, andgps_validated
Dry-run workflow
Both CLI tools support a dry mode through --save 0.
This is useful when you want to:
inspect intermediate outputs without modifying PostgreSQL
debug a time range
validate that segmentation or gait detection behaves as expected before persistence
Validation workflow
The repository also includes a ground-truth validation utility based on an Excel file with manually labeled windows.
Example:
python -m tests.validate_ground_truth \
-e path/to/ground_truth.xlsx \
-c config.yaml \
-l es
This validation stage compares the algorithm output against manually labeled windows and reports metrics such as:
accuracy
precision
recall / sensitivity
specificity
F1-score
Cohen’s Kappa
confusion matrix
Operational notes
timestamps are normalized before database queries
the gait stage depends on
activity_allalready existinginertial analysis is performed on resampled data
gait rows are GPS-enriched before final storage
repeated executions are designed to avoid uncontrolled duplication in the main semantic output tables