# yudhik11/heart-rate-monitoring_ppg architecture

> Architecture diagram of the GitHub repository yudhik11/heart-rate-monitoring_ppg, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yudhik11/heart-rate-monitoring_ppg
- Repository: https://github.com/yudhik11/heart-rate-monitoring_ppg

## Overview

##### Core Components
- Data Input/Acquisition:
– Represent the raw input signals, which include PPG signals (from two pulse oximeters), ECG signals, and accelerometer data captured via the wristband.
– Mark that the data comes originally from .mat files (as seen under Problem_Statement/Data and Ouput directories).
- Preprocessing & Signal Conditioning:
– Include modules for filtering and conditioning the raw biosignals. Files like H_filter.m, BP.m (Bandpass Filter), and perhaps LMS_sig.m indicate filtering stages.
- Feature Extraction & Peak Detection:
– Show that after conditioning, the system detects key features. Scripts such as discoverPeak.m, findClosestPeak.m, and findPksInRange.m hint at algorithms for peak detection.
- Heart Rate Estimation Algorithms:
– Identify the core estimation methods (e.g., FOCUSS.m, MPinverse.m, Periodogram.m, SMART.m, SSR.m, SSR_JOSS.m, and SPT_JOSS.m). These modules likely implement different algorithmic approaches for estimating heart rate.
- Control/Integration Script:
– The script.m (and team_42.sh for batch execution) serve as the central controller that sequences the processing steps.
- Data Output & Reporting:
– The Ouput folder and report_team_42.pdf indicate reviewed and saved results. Show that results are written out (including BPM trace files) and possibly compared to ground truth.

##### Relationships and Data Flow
- From acquisition, route the signals to a “Preprocessing” block (filtering using BP.m, H_filter.m, LMS_sig.m, etc.) that cleans the signal.
- The filtered signal then flows into the “Feature Extraction” block, illustrated with peak detection routines (discoverPeak, findClosestPeak, findPksInRange).
- Results from these algorithms then aggregate—via the main control script—to produce heart rate estimations.
- Finally, direct the output to a “Results / Reporting” block, showing generation of BPM trace mat files and other documented outputs.

##### Architectural Patterns and Technologies
- That the design is modular: each MATLAB function (.m file) encapsulates a specific algorithmic step with a clear input/output pattern.
- That the architecture follows a pipeline (or layered) pattern—data moves from acquisition to preprocessing, then feature extraction and estimation, and finally to reporting.
- Denote that the implementation is in MATLAB with research-focused algorithms, often benchmarking multiple methods against each other.
- External documentation references (like the IEEE papers in the README and additional PDFs in resources) which provide context and are supportive of choosing different modules.

##### Implementation Details
- Then branch out to “Feature Extraction” (peak detectors) leading into multiple algorithmic blocks (FOCUSS, SMART, SSR, etc.).
- A central orchestration module (script.m and associated shell script) that ties these components together.
- Finally, the “Output” block should capture how the results (heart rate estimates; BPM trace files) are stored and reported.
- A section referencing “Documentation & Resources” (pointing to PDFs in Problem_Statement and resources) that validate the design choices.

##### Final Touches
- Every component has a clear label.
- Data handling (input/output operations),
- Configuration/Control scripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input/Acquisition
    subgraph "Data Input/Acquisition"
        DI["Raw Data (.mat files)"]:::input
    end

    %% Preprocessing & Signal Conditioning
    subgraph "Preprocessing & Signal Conditioning"
        BP["BP.m"]:::preproc
        HF["H_filter.m"]:::preproc
        LMS["LMS_sig.m"]:::preproc
    end

    %% Feature Extraction & Peak Detection
    subgraph "Feature Extraction & Peak Detection"
        DP["discoverPeak.m"]:::feature
        FCP["findClosestPeak.m"]:::feature
        FPR["findPksInRange.m"]:::feature
    end

    %% Heart Rate Estimation Algorithms
    subgraph "Heart Rate Estimation Algorithms"
        FOCUSS["FOCUSS.m"]:::algorithm
        MPInv["MPinverse.m"]:::algorithm
        Periodo["Periodogram.m"]:::algorithm
        SMART["SMART.m"]:::algorithm
        SSR["SSR.m"]:::algorithm
        SSRJ["SSR_JOSS.m"]:::algorithm
        SPTJ["SPT_JOSS.m"]:::algorithm
    end

    %% Control/Integration Script
    subgraph "Control/Integration Script"
        SCRIPT["script.m"]:::control
        TEAM["team_42.sh"]:::control
    end

    %% Data Output & Reporting
    subgraph "Data Output & Reporting"
        OUTPUT["Output Folder"]:::output
        REPORT["report_team_42.pdf"]:::output
    end

    %% Data Flow Connections (vertical pipeline)
    DI -->|"loads"| BP
    DI -->|"loads"| HF
    DI -->|"loads"| LMS

    BP -->|"filtered"| DP
    HF -->|"filtered"| DP
    LMS -->|"filtered"| DP

    DP -->|"features"| FOCUSS
    FCP -->|"features"| SMART
    FPR -->|"features"| SSR

    FOCUSS -->|"estimates"| SCRIPT
    MPInv -->|"estimates"| SCRIPT
    Periodo -->|"estimates"| SCRIPT
    SMART -->|"estimates"| SCRIPT
    SSR -->|"estimates"| SCRIPT
    SSRJ -->|"estimates"| SCRIPT
    SPTJ -->|"estimates"| SCRIPT

    SCRIPT -->|"controls"| OUTPUT
    TEAM -->|"controls"| OUTPUT
    OUTPUT -->|"reports"| REPORT

    %% Click Events for Data Input
    click DI "https://github.com/yudhik11/heart-rate-monitoring_ppg/tree/master/Problem_Statement/Data"

    %% Click Events for Preprocessing files
    click BP "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/BP.m"
    click HF "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/H_filter.m"
    click LMS "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/LMS_sig.m"

    %% Click Events for Feature Extraction files
    click DP "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/discoverPeak.m"
    click FCP "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/findClosestPeak.m"
    click FPR "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/findPksInRange.m"

    %% Click Events for Heart Rate Estimation Algorithms
    click FOCUSS "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/FOCUSS.m"
    click MPInv "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/MPinverse.m"
    click Periodo "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/Periodogram.m"
    click SMART "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/SMART.m"
    click SSR "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/SSR.m"
    click SSRJ "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/SSR_JOSS.m"
    click SPTJ "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/SPT_JOSS.m"

    %% Click Events for Control/Integration Script
    click SCRIPT "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/script.m"
    click TEAM "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/team_42.sh"

    %% Click Events for Data Output & Reporting
    click OUTPUT "https://github.com/yudhik11/heart-rate-monitoring_ppg/tree/master/Ouptut"
    click REPORT "https://github.com/yudhik11/heart-rate-monitoring_ppg/blob/master/20161094_20161093/report_team_42.pdf"

    %% Style definitions
    classDef input fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef preproc fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef feature fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef algorithm fill:#F5B7B1,stroke:#CD6155,stroke-width:2px;
    classDef control fill:#D7BDE2,stroke:#8E44AD,stroke-width:2px;
    classDef output fill:#FAD7A0,stroke:#F39C12,stroke-width:2px;
```
