AI ECG analysis from wearable device in mobile app

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
AI ECG analysis from wearable device in mobile app
Complex
from 2 weeks to 3 months
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

AI-Powered ECG Analysis from Wearables

ECG from Apple Watch Series 4+ or AliveCor KardiaMobile—single-channel recording, 30 seconds, 512 Hz. Sufficient for detecting atrial fibrillation and other rhythm disorders. Developer task—accept signal, process correctly, apply model without false negatives or regulatory violations.

Getting ECG Data

Apple Watch + HealthKit

Apple Watch Series 4+ records ECG via HKElectrocardiogram. Access through HealthKit:

import HealthKit

func fetchLatestECG() async throws -> (HKElectrocardiogram, [Double]) {
    let ecgType = HKObjectType.electrocardiogramType()
    let query = HKSampleQuery(
        sampleType: ecgType,
        predicate: nil,
        limit: 1,
        sortDescriptors: [NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false)]
    ) { _, samples, error in
        // handle
    }

    // Separate subquery for voltage data
    let voltageQuery = HKElectrocardiogramQuery(ecg) { _, result in
        switch result {
        case .measurement(let measurement):
            if let voltage = measurement.quantity(for: .appleWatchSimilarToLeadI) {
                let microvolts = voltage.doubleValue(for: .volt()) * 1_000_000
                voltageData.append(microvolts)
            }
        case .done: break
        case .error(let error): print(error)
        }
    }
    healthStore.execute(voltageQuery)
}

Apple returns raw signal in volts, selected Lead I (wrist). Sampling frequency—512 Hz, length—~15360 samples per 30 seconds.

Third-Party Devices: BLE + Protocol

AliveCor KardiaMobile, Withings Move ECG and similar transmit ECG via BLE with proprietary protocols. Most provide SDKs: KardiaMobile SDK for iOS/Android, Withings SDK. Without SDK—analyze BLE packets via CBCentralManager and reverse-engineer protocol (time-consuming, unreliable).

Signal Preprocessing: Without It, Model Fails

Raw ECG signal contains noise: baseline wander (isoline drift from breathing), muscle artifacts, electrical interference 50/60 Hz. Pre-processing before model input mandatory.

Bandpass filter 0.5–40 Hz removes baseline wander and high-frequency noise:

from scipy.signal import butter, filtfilt

def bandpass_filter(signal, fs=512, lowcut=0.5, highcut=40):
    nyq = fs / 2
    low = lowcut / nyq
    high = highcut / nyq
    b, a = butter(4, [low, high], btype='band')
    return filtfilt(b, a, signal)

R-peak detection (Pan-Tompkins algorithm) needed for RR-interval calculation—basis for arrhythmia detection. Library neurokit2 implements Pan-Tompkins, BioSPPy. On mobile, implement natively: Swift via Accelerate framework (vDSP), Kotlin via KotlinDL or port scipy code via TFLite custom ops.

Models for Arrhythmia Detection

CNN for Rhythm Classification

Standard approach—1D CNN on 2.5–10 second signal window. Input tensor: [batch, time_steps, 1]. Architecture: several Conv1D → MaxPool → Dense → Softmax.

Public datasets: PhysioNet MIT-BIH Arrhythmia Database (48 dual-channel recordings), PTB-XL (21,799 clinical ECGs with 71 diagnoses). MIT-BIH available via wfdb library.

After training, convert to CoreML:

import coremltools as ct

spec = ct.convert(
    torch_model,
    inputs=[ct.TensorType(shape=(1, 2560, 1), dtype=np.float32)],
    compute_precision=ct.precision.FLOAT16,
    compute_units=ct.ComputeUnit.CPU_AND_NE
)
spec.save("ECGClassifier.mlpackage")

FLOAT16 quantization halves model size without significant accuracy loss for ECG classification. Neural Engine (NE) accelerates inference on A12+ devices.

Limitations of On-Device Analysis

Single-channel wrist ECG—not clinical 12-channel. Apple's sensitivity per their research: AF—99.3%, but specific rhythm. Other disorders (blocks, WPW) require 12-channel recording.

Regulatory Requirements — Most Important

If app claims disease diagnosis—it's a medical device (CE Class IIa in EU, FDA 510(k)/De Novo in USA). Development takes multiples longer due to clinical trial requirements, design control, software validation.

If app positioned as information only ("shows rhythm patterns, not diagnostic tool")—regulatory burden lower. All disclaimers must be on result screens, not just ToS.

Apple does this: each ECG result in Apple Health accompanied by "consult your doctor".

Development Process

Clarify regulatory strategy before development. Integrate with HealthKit or third-party SDK. Implement signal processing (filters, R-peak detection). Develop and validate ML model on public datasets. Convert to CoreML/TFLite. UI: ECG visualization, analysis result, mandatory disclaimers.

Timeframe Estimates

Basic AF detector with CoreML and HealthKit integration—3–5 weeks. Extended system with multiple arrhythmia types, clinical data validation—2–3 months. Full medical device with regulatory documentation—separate multi-month project.