An end-to-end wearable IoT and Edge-AI platform for real-time stroke rehabilitation scoring.
This project is a complete hardware-to-software pipeline designed to track, analyze, and gamify physical therapy for stroke patients. By combining custom dual-IMU wearables with a mobile-optimized 1D Convolutional Neural Network (CNN) running locally on iOS via Zetic, the system provides zero-latency movement quality scores and voice feedback.
The system is divided into three core pillars:
- Embedded Hardware: Captures raw 6-DOF human movement data at 80Hz.
- AI Scoring: Processes the time-series data to evaluate movement quality.
- Swift App: Manages the BLE connection, runs the Edge AI, and guides the patient.
The wearable component is built from the ground up for low latency and high data throughput, acting as the foundation for the AI model.
- Microcontroller: ESP32-C3 powered by a 4.8V LiPo battery.
- Dual Sensors: 2x MPU6050 (Bicep and Wrist). Both sensors run on a shared hardware I2C bus utilizing custom addressing (
0x68for Bicep,0x69via AD0 pin for Wrist) to prevent collisions. - Diagnostics: An integrated I2C OLED screen (
0x3C) provides real-time device status and debugging. - Custom BLE Pipeline: * The ESP32 unpacks and filters accelerometer and gyroscope axes before transmission.
- An expanded MTU size blasts a tightly packed 76-byte payload over Bluetooth Low Energy (BLE) at 80Hz.
- Payload includes:
timestamp, rawaccel/gyro, andbicep_PRY,wrist_PRYchannels for both sensors.
The AI pipeline evaluates movement quality by comparing patient data against the JU-IMU dataset (Stroke vs. Healthy subjects). The model is specifically optimized for small-dataset generalization and on-device export.
- Side-Aware Selection: Dynamically swaps sensor channels based on whether the patient has Left or Right hemiparesis, ensuring the affected limb always maps to the same input channels (resulting in a 12-channel input).
-
Global Normalization: Uses a global
$(x - \mu) / \sigma$ over all training time-steps rather than per-sample Z-scores. This is crucial as it preserves the cross-patient magnitude differences that distinguish weak stroke movements from healthy ones. - Interpolation: Variable length movements are linearly interpolated to exactly 128 timesteps.
The model utilizes a "shrink time, grow features" pattern suitable for continuous sensor streams:
- Input:
(Batch, 12, 128) - Conv Blocks: Three stride-2 blocks with progressively decreasing kernel sizes (7 β 5 β 3) to capture wide temporal context early and refine local features later.
- Mobile Optimizations: Uses
BatchNorm(highly stable on mobile vs. GroupNorm) and a fixedAvgPool1d(kernel=16)to avoid compatibility issues with mobile converters. - Output: Generates a 0β100 movement quality score based on softmax confidence probabilities.
The trained PyTorch model is packaged via torch.export into a deterministic .pt2 graph, along with the saved global
The iOS application serves as the command center for the patient, processing the hardware data and surfacing the AI insights.
- Real-Time Monitor: Uses
CoreBluetoothto subscribe to the ESP32's custom characteristic, caching the 80Hz stream into 128-timestep sliding windows. - Local Inference via Zetic: The Swift app holds the trained
.pt2AI model. It passes the cached data window into the Zetic runtime, executing the CNN entirely on-device (no cloud computing delay). - Exercise Guide & Gamification: Translates the AI's 0β100 movement quality score into a visual performance dashboard.
- Audio Feedback: Integrates ElevenLabs TTS to provide encouraging, real-time voice guidance to the patient based on their workout selection and current performance score.
- JU-IMU Dataset & AI Research: Oh, Y., Choi, S.-A., Shin, Y., Jeong, Y., Lim, J., & Kim, S. (2024). Investigating Activity Recognition for Hemiparetic Stroke Patients Using Wearable Sensors: A Deep Learning Approach with Data Augmentation. Sensors, 24(1), 210. DOI: 10.3390/s24010210
- Dataset Repository: youngminoh7/JU-IMU on GitHub
- Hardware Datasheet: MPU-6050 Product Specification (PDF)