arXiv:2610.06241cs.LGOct 2026

Manuscript Offprint

arXiv:2610.06241

Few-Shot Prototype Head Adaptation for On-Device ECG Personalization on PSoC~6

Guilherme Silva, Pedro Silva, Gladston Moreira, Eduardo Luz

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Wearable and bedside electrocardiogram (ECG) monitors must adapt to patient-specific morphology to maintain arrhythmia detection accuracy across users, yet personalization is typically performed offline and cannot account for individual physiology, electrode placement, or recording drift. On-device adaptation by backpropagation is expensive for microcontroller-class medical devices because it requires an optimizer state, repeated backward passes through convolutional layers, and labeled arrhythmic beats that may not be available at deployment time. This letter proposes prototype-only head adaptation as a compact personalization primitive for TinyML ECG systems. A one-dimensional convolutional neural network (1-D CNN; 1,314 parameters and 72.6k multiply-accumulate operations per beat) is trained offline on the MIT-BIH Arrhythmia Database under an inter-patient protocol, frozen as a feature extractor, and exported to a PSoC 6 microcontroller. Patient-specific adaptation then reduces to computing closed-form class means in a 32-dimensional embedding space, requiring no convolutional backward pass, no iterative optimization, and only one forward pass per support beat. Prototype adaptation improves inter-patient macro-F1 from 0.635/0.639/0.646 to 0.731/0.771/0.797 at 1/5/10-shot, outperforming linear stochastic-gradient-descent (SGD) head fine-tuning at every shot count for the target tiny backbone. On-device replay over 18 one-shot episodes on a PSoC 6 Cortex-M4F matches the host macro-F1 for the prototype head (0.798), with 11.39 ms per beat, 5.2 KB flash, and 22.2 KB SRAM. A restricted variant that updates only the normal-class prototype from passively buffered sinus beats yields a consistent +0.05 macro-F1 gain, reducing the annotation burden during initial deployment.

Keywords EEG Classification · Arrhythmia · PSoC · Embedded Systems.

1 Introduction

Patient-specific ECG morphology varies with physiology, electrode placement, and recording conditions, causing models trained on one population to degrade on unseen individuals under inter-patient evaluation protocols [1]. Wearable and bedside arrhythmia monitors, therefore, need a mechanism to personalize a deployed classifier for each new user without re-running a full training pipeline in the cloud. Tiny machine learning (TinyML) has made neural-network inference feasible on microcontroller-class IoT devices [2, 3], bringing the classifier physically close to the sensor, but the question of how to adapt that classifier on the same constrained device remains open.

Two barriers make on-device ECG personalization hard. The first is computational. Backpropagation through convolutional layers requires optimizer state, repeated backward passes, and working memory that exceeds the budget of sub-milliwatt medical microcontrollers. Prior work has shown that on-device training is possible under 256 KB SRAM [4] and that 1-D CNN personalization for human activity recognition is feasible on STM32 hardware [5], yet

*The authors would also like to thank the Fundação de Amparo à Pesquisa do Estado de Minas Gerais (FAPEMIG, grants APQ-01768-24), Coordenação de Aperfeiçoamento de Pessoal de Nível Superior - Brazil (CAPES) - Finance Code 001, Conselho Nacional de Desenvolvimento Científico e Tecnológico and Universidade Federal de Ouro Preto (PROPPI/UFOP) for supporting the development of this study.

both approaches rely on gradient-based updates that are costly relative to a medical device's strict power and latency envelope. The second barrier is annotation. Since arrhythmic events are rare, the newly deployed monitor accumulates hundreds of normal sinus beats before a single labeled abnormal beat is available. Gradient-based head fine-tuning cannot begin calibration from normal-only data because it requires labeled examples from every class to update the weight matrix meaningfully. Self-supervised and human-in-the-loop methods have highlighted this gap but remain constrained by limited medical equipment resources [6].

This letter addresses both barriers with a prototype-only head adaptation mechanism. A compact 1-D CNN (1,314 parameters, 72.6k multiply-accumulate operations – MACs – per beat) is trained offline on the MIT-BIH Arrhythmia Database [7] under the inter-patient protocol [1], and its convolutional backbone is then frozen and exported to a PSoC 6 microcontroller. Patient-specific adaptation reduces to computing closed-form class means in a 32-dimensional embedding space, one forward pass per support beat, no backward pass, no optimizer state. A restricted variant further reduces the annotation burden by updating only the normal-class prototype from passively buffered sinus beats, inheriting the abnormal prototype from offline training.

We verify the proposal through three complementary evaluations. (i) Accuracy: prototype adaptation improves inter-patient macro-F1 from 0.635/0.639/0.646 to 0.731/0.771/0.797 at 1/5/10-shot on eligible DS2 patients (vs. 0.664 pre-adaptation on all 22 DS2 records), outperforming a linear-SGD head baseline on a tiny backbone neural network. The restricted normal-only variant yields a consistent +0.05 macro-F1 gain without any arrhythmia annotations. (ii) On-device fidelity: aggregate replay over one-shot DS2 episodes on the target Cortex-M4F matches host macro-F1 (0.798 macro-F1, absolute deviation 0.000), confirming that the closed-form update is numerically faithful on fp32 hardware. (iii) Embedded cost: Data Watchpoint and Trace (DWT) cycle counter profiling reports 11.39 ms per beat (2.8% of the 400 ms RR interval at 150 BPM), with a model-centric footprint of 5.2 KB flash and 22.2 KB SRAM on a device with 1 MB flash and 288 KB SRAM.