{"id":27067979,"url":"https://github.com/sankoktas/bhi360-fall-detection","last_synced_at":"2026-05-07T01:31:28.678Z","repository":{"id":283896057,"uuid":"953222713","full_name":"sankoktas/bhi360-fall-detection","owner":"sankoktas","description":"Fall detection system using Bosch BHI360 sensor data with time-series labeling, feature extraction, and machine learning (LOSO CV + Gradient Boosting).","archived":false,"fork":false,"pushed_at":"2025-05-20T20:57:21.000Z","size":51939,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-25T03:33:02.736Z","etag":null,"topics":["accelerometer","bhi360","bosch-sensors","data-augmentation","fall-detection","feature-extraction","gradient-boosting","gyroscope","human-activity-recognition","label-studio","loso-cross-validation","machine-learning","python","scikit-learn","sensor-data","smote","time-series"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sankoktas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-22T21:10:07.000Z","updated_at":"2025-05-20T20:57:24.000Z","dependencies_parsed_at":"2025-03-22T22:23:12.836Z","dependency_job_id":"e0f73531-ce9a-4ed8-ade9-96967f7726e7","html_url":"https://github.com/sankoktas/bhi360-fall-detection","commit_stats":null,"previous_names":["sankoktas/thesiscode"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sankoktas/bhi360-fall-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankoktas%2Fbhi360-fall-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankoktas%2Fbhi360-fall-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankoktas%2Fbhi360-fall-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankoktas%2Fbhi360-fall-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sankoktas","download_url":"https://codeload.github.com/sankoktas/bhi360-fall-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sankoktas%2Fbhi360-fall-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32719409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T00:29:05.620Z","status":"ssl_error","status_checked_at":"2026-05-07T00:28:57.074Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accelerometer","bhi360","bosch-sensors","data-augmentation","fall-detection","feature-extraction","gradient-boosting","gyroscope","human-activity-recognition","label-studio","loso-cross-validation","machine-learning","python","scikit-learn","sensor-data","smote","time-series"],"created_at":"2025-04-05T20:17:19.857Z","updated_at":"2026-05-07T01:31:28.666Z","avatar_url":"https://github.com/sankoktas.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\r\n  \u003cimg src=\"assets/banner.png\" alt=\"Motion Classification Pipeline Banner\" width=\"100%\"\u003e\r\n\u003c/p\u003e\r\n\r\n# 🧠 Embedded Fall Detection Pipeline with Wrist-Worn IMU Data\r\n\r\nThis project implements a complete, embedded-ready pipeline for **human activity recognition and fall detection** using wrist-mounted **Bosch BHI360** sensor data. Developed as part of a master's thesis, it demonstrates the feasibility of deploying machine learning models entirely **on-device**, on ultra-low-power hardware, without the need for external computation or connectivity.\r\n\r\n---\r\n\r\n## 🔍 Overview\r\n\r\nFalls are a major cause of injury and hospitalization among older adults. Detecting them early using wearables can enable faster intervention, improve safety, and reduce healthcare costs. However, many machine learning solutions are too resource-hungry for deployment on microcontrollers.\r\n\r\nThis project bridges that gap by combining:\r\n\r\n- 🎯 Accurate **fall detection using inertial signals**\r\n- ⚙️ Lightweight, efficient **decision tree models**\r\n- 🔧 Real-time **on-device inference** using embedded firmware\r\n- 📉 Evaluation via **Leave-One-Session-Out Cross-Validation**\r\n- 🧠 Feature-rich yet embedded-compatible model engineering\r\n\r\n---\r\n\r\n## 🧾 Data Collection Info\r\n\r\n- 📦 **Sensor:** Bosch BHI360 Shuttle Board  \r\n- 🧠 **Firmware:** `Bosch_Shuttle3_BHI360_BMM150.fw`  \r\n- 📈 **Sensor Configuration:**\r\n  - Accelerometer (Corrected, Non-Wakeup) at **200 Hz**\r\n  - Gyroscope (Corrected, Non-Wakeup) at **200 Hz**\r\n\r\nData was logged as JSON and then processed using this notebook for machine learning.\r\n\r\n---\r\n\r\n## 📁 Files \u0026 Structure\r\n\r\n- `app.ipynb` – Main Jupyter notebook for preprocessing, training, evaluation\r\n- `training_data.csv` – Final training-ready dataset with session IDs\r\n\r\n---\r\n\r\n## 🛠️ Label Studio Setup\r\n\r\nUse this config when importing time series data into Label Studio:\r\n\r\n```xml\r\n\u003cView\u003e\r\n  \u003cTimeSeriesLabels name=\"tsLabels\" toName=\"ts\"\u003e\r\n    \u003cLabel value=\"FALL\" background=\"red\"/\u003e\r\n    \u003cLabel value=\"MOTION\" background=\"#ffea00\"/\u003e\r\n    \u003cLabel value=\"NO MOTION\" background=\"#05ff16\"/\u003e\r\n  \u003c/TimeSeriesLabels\u003e\r\n\r\n  \u003cTimeSeries name=\"ts\" valueType=\"json\" value=\"$tsData\" timeColumn=\"timestamp_s\" ordered=\"true\"\u003e\r\n    \u003cChannel column=\"accel_x\" legend=\"accel_x\"/\u003e\r\n    \u003cChannel column=\"accel_y\" legend=\"accel_y\"/\u003e\r\n    \u003cChannel column=\"accel_z\" legend=\"accel_z\"/\u003e\r\n    \u003cChannel column=\"gyro_x\" legend=\"gyro_x\"/\u003e\r\n    \u003cChannel column=\"gyro_y\" legend=\"gyro_y\"/\u003e\r\n    \u003cChannel column=\"gyro_z\" legend=\"gyro_z\"/\u003e\r\n  \u003c/TimeSeries\u003e\r\n\u003c/View\u003e\r\n```\r\n\r\n---\r\n\r\n## 📦 Pipeline Components\r\n\r\n### ✅ Label Parsing \u0026 Preprocessing\r\n- Raw IMU (accelerometer + gyroscope) data collected at **200 Hz**\r\n- JSON logs parsed and restructured into consistent time-series frames\r\n- Corrupted or incomplete samples removed\r\n- Labels merged from **Label Studio** annotations using session timestamps\r\n\r\n### 📊 Feature Extraction\r\n- Extracted from **2-second windows** with **0.25-second hops**\r\n- Includes:\r\n  - Time-domain features (mean, variance, skewness, kurtosis, range, percentiles)\r\n  - Frequency-domain features (FFT energy, dominant frequency index)\r\n  - Custom heuristics (impact peak, jerk magnitude, signal magnitude area, time to peak)\r\n\r\n### ⚙️ Data Augmentation + Balancing\r\n- Class imbalance addressed using **SMOTE**\r\n- Optional augmentation for rare event simulation\r\n\r\n### 🤖 Model Training\r\n- Two classifiers compared:\r\n  - `HistGradientBoostingClassifier` – high-performing, but too large for embedded use\r\n  - `DecisionTreeClassifier` – slightly lower accuracy, but fits into embedded memory\r\n- Trained using **Leave-One-Session-Out (LOSO) cross-validation** to test generalization\r\n\r\n### 📈 Evaluation\r\n- Reports:\r\n  - Per-class precision, recall, F1\r\n  - Overall macro scores\r\n- Includes:\r\n  - Confusion matrices\r\n  - Metric plots\r\n\r\n---\r\n\r\n## 🔌 Firmware Deployment\r\n\r\nThe trained `DecisionTreeClassifier` was exported to C using [`m2cgen`](https://github.com/BayesWitnesses/m2cgen) and embedded into the BHI360 firmware.\r\n\r\nKey integration steps:\r\n- `model.c` and `model.h` inserted under `libs/my_classifier/`\r\n- Wrapper function created to expose inference to SDK\r\n- Custom virtual driver `VirtMyClassifier` written to invoke the model\r\n- Registered under:\r\n  - `boards/Bosch_Shuttle3_BHI360_MyModel.cfg`\r\n  - `common/config.7189_di03_rtos_bhi360.cmake`\r\n- Final firmware image:  \r\n  `release/gccfw/Bosch_Shuttle3_BHI360_MyModel.fw`\r\n\r\nFlashing can be done via **Bosch Development Desktop 2.0**.\r\n\r\nMore details about firmware deployment in the README file under the SDK folder. \r\n\r\n---\r\n\r\n## 🧾 Data Collection Info\r\n\r\n- 👤 **Subject:** One healthy adult, 30 sessions\r\n- 📍 **Placement:** Left wrist (taped securely)\r\n- 📈 **Sampling:** 200 Hz (accelerometer + gyroscope)\r\n- 🧠 **Sensor Platform:** Bosch Shuttle Board 3.0 + Application Board 3.1\r\n- 🔌 **Firmware Used for Collection:** `Bosch_Shuttle3_BHI360_BMM150.fw`\r\n\r\nEach session includes:\r\n- Static idle\r\n- General arm motion\r\n- Sit-to-stand and stand-to-sit transitions\r\n- Simulated forward, backward, and lateral falls\r\n\r\n---\r\n\r\n## 🚀 Reproducibility\r\nTo replicate the results:\r\n- Record inertial data with the BHI360 at 200 Hz.\r\n- Annotate using Label Studio and the template above.\r\n- Run app.ipynb to preprocess, extract features, and train models.\r\n- Use m2cgen to export the selected model to C.\r\n- Integrate the C code into the SDK and build the firmware.\r\n- Flash Bosch_Shuttle3_BHI360_MyModel.fw using Bosch Desktop 2.0\r\n\r\n## 📣 Acknowledgements\r\nThis project was built using Bosch Sensortec hardware and SDK, with thanks to the open-source ML community for tools like scikit-learn, m2cgen, and Label Studio.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsankoktas%2Fbhi360-fall-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsankoktas%2Fbhi360-fall-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsankoktas%2Fbhi360-fall-detection/lists"}