# rajas/ecgtk architecture

> Architecture diagram of the GitHub repository rajas/ecgtk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajas/ecgtk
- Repository: https://github.com/rajas/ecgtk

## Overview

Primary Flow:
- Input Files (.dat, .hea, .atr, .qrs)
- → WFDB File Handler
- → Data Processing Modules
- → Visualization/Output

##### Component Relationships

a. Data Input Layer:
- Io_utils.py interfacing with raw ECG files
- To wfdbtools.py as the primary parser

b. Processing Layer:
- Wfdbtools.py to rdetect.py for R-wave detection
- Link markedit.py for annotation handling

c. Output Layer:
- Plotter.py to both processing modules
- Visualization output

##### Key Features to Highlight

- File format support (212 and 16)
- Key functions: rdsamp(), rdann(), plot_data()
- Data transformation pipeline
- Annotation handling capabilities

##### Technical Details

- Supported file extensions (.dat, .hea, .atr, .qrs)
- Data formats (212, 16)
- Key Python dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        InputFiles["Input Files (.dat, .hea, .atr, .qrs)"]
        F212["Format 212"]:::format
        F16["Format 16"]:::format
        InputFiles --> F212
        InputFiles --> F16
    end

    subgraph Core["Core Processing Layer"]
        WFDB["WFDB File Handler"]:::core
        IO["I/O Utilities"]:::io
        RWave["R-wave Detection"]:::core
        Marker["Marker Editor"]:::core
    end

    subgraph Output
        Plot["Plotting System"]:::viz
        Visual["Visualization Output"]:::viz
    end

    subgraph Testing
        Test["Testing Component"]:::test
    end

    %% Connections
    F212 --> IO
    F16 --> IO
    IO --> WFDB
    WFDB --> RWave
    WFDB --> Marker
    RWave --> Plot
    Marker --> Plot
    Plot --> Visual
    WFDB --> Test

    %% Click Events
    click WFDB "https://github.com/RajaS/ecgtk/blob/master/ecgtk/wfdbtools.py"
    click Plot "https://github.com/RajaS/ecgtk/blob/master/ecgtk/plotter.py"
    click RWave "https://github.com/RajaS/ecgtk/blob/master/ecgtk/rdetect.py"
    click Marker "https://github.com/RajaS/ecgtk/blob/master/ecgtk/markedit.py"
    click IO "https://github.com/RajaS/ecgtk/blob/master/ecgtk/io_utils.py"
    click F212 "https://github.com/RajaS/ecgtk/tree/master/samples/format212/"
    click F16 "https://github.com/RajaS/ecgtk/tree/master/samples/format16/"
    click Test "https://github.com/RajaS/ecgtk/blob/master/ecgtk/wfdbtools_test.py"

    %% Styling
    classDef core fill:#2374ab,stroke:#2374ab,color:white
    classDef io fill:#47a025,stroke:#47a025,color:white
    classDef viz fill:#ff7f50,stroke:#ff7f50,color:white
    classDef format fill:#808080,stroke:#808080,color:white
    classDef test fill:#purple,stroke:#purple,color:white

    %% Legend
    subgraph Legend
        L1["Core Processing"]:::core
        L2["I/O Operations"]:::io
        L3["Visualization"]:::viz
        L4["Data Formats"]:::format
        L5["Testing"]:::test
    end
```
