# deeppsp/cinc2022 architecture

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

- Interactive diagram: https://gitdiagram.com/deeppsp/cinc2022
- Repository: https://github.com/deeppsp/cinc2022

## Overview

##### Main Components Identification

The system should be divided into these major components:

a) Data Processing Layer
- Data Reader (data_reader.py)
- Dataset Handler (dataset.py)
- Augmentation & Transforms (utils/transforms.py, utils/augmentations.py)

b) Model Layer
- Core Models
- CRNN (models/crnn.py)
- Wav2Vec2 (models/wav2vec2.py)
- MLP (models/mlp.py)
- Model Heads (models/heads.py)
- Multi-task Learning Components (models/model_ml.py)

c) Training Infrastructure
- Trainer (trainer.py)
- Configuration (cfg.py, cfg_models.py)
- Evaluation (evaluate_model.py)

d) Feature Engineering
- Signal Processing Utils
- Springer DWT (utils/springer_dwt.py)
- Heart Rate Detection (utils/schmidt_heart_rate.py)
- Spike Removal (utils/schmidt_spike_removal.py)

**[Input Data] → [Data Processing Layer] → [Feature Engineering] → [Model Layer] → [Training Infrastructure] → [Evaluation & Output]**

##### Specific Elements

a) Data Flow Path:
**Raw PCG Data → Preprocessing → Feature Extraction → Model Training → Predictions**

b) Model Architecture Details:
- Parallel paths for different model types (CRNN, Wav2Vec2)
- Multi-task learning branches
- Model head connections

c) Training Pipeline:
- Configuration injection points
- Evaluation feedback loop
- Metrics collection points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        RawData["Raw PCG Data"]
    end

    subgraph DataProcessing["Data Processing Layer"]
        DR["Data Reader"]:::code
        DH["Dataset Handler"]:::code
        DT["Data Transforms"]:::code
        DA["Data Augmentations"]:::code
    end

    subgraph FeatureEng["Feature Engineering"]
        SP["Signal Processing"]
        subgraph Utils["Signal Processing Utils"]
            SDWT["Springer DWT"]:::code
            HRD["Heart Rate Detection"]:::code
            SR["Spike Removal"]:::code
        end
    end

    subgraph ModelLayer["Model Layer"]
        subgraph CoreModels["Core Models"]
            CRNN["CRNN"]:::code
            W2V["Wav2Vec2"]:::code
            MLP["MLP"]:::code
        end
        MH["Model Heads"]:::code
        MTL["Multi-task Learning"]:::code
    end

    subgraph Training["Training Infrastructure"]
        TR["Trainer"]:::code
        CFG["Configuration"]:::code
        EV["Evaluation"]:::code
    end

    subgraph Output
        Predictions["Model Predictions"]
        Metrics["Performance Metrics"]
    end

    %% Connections
    RawData --> DR
    DR --> DH
    DH --> DT
    DH --> DA
    DT --> SP
    DA --> SP
    
    SP --> SDWT
    SP --> HRD
    SP --> SR
    
    SDWT --> CoreModels
    HRD --> CoreModels
    SR --> CoreModels
    
    CRNN --> MH
    W2V --> MH
    MLP --> MH
    
    MH --> MTL
    MTL --> TR
    
    CFG --> TR
    TR --> EV
    
    EV --> Predictions
    EV --> Metrics

    %% Click Events
    click DR "https://github.com/DeepPSP/cinc2022/blob/master/data_reader.py"
    click DH "https://github.com/DeepPSP/cinc2022/blob/master/dataset.py"
    click DT "https://github.com/DeepPSP/cinc2022/blob/master/utils/transforms.py"
    click DA "https://github.com/DeepPSP/cinc2022/blob/master/utils/augmentations.py"
    click CRNN "https://github.com/DeepPSP/cinc2022/blob/master/models/crnn.py"
    click W2V "https://github.com/DeepPSP/cinc2022/blob/master/models/wav2vec2.py"
    click MLP "https://github.com/DeepPSP/cinc2022/blob/master/models/mlp.py"
    click MH "https://github.com/DeepPSP/cinc2022/blob/master/models/heads.py"
    click MTL "https://github.com/DeepPSP/cinc2022/blob/master/models/model_ml.py"
    click TR "https://github.com/DeepPSP/cinc2022/blob/master/trainer.py"
    click CFG "https://github.com/DeepPSP/cinc2022/blob/master/cfg.py"
    click EV "https://github.com/DeepPSP/cinc2022/blob/master/evaluate_model.py"
    click SDWT "https://github.com/DeepPSP/cinc2022/blob/master/utils/springer_dwt.py"
    click HRD "https://github.com/DeepPSP/cinc2022/blob/master/utils/schmidt_heart_rate.py"
    click SR "https://github.com/DeepPSP/cinc2022/blob/master/utils/schmidt_spike_removal.py"

    %% Styles
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef code fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    classDef flow fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
    classDef process fill:#fff3e0,stroke:#ef6c00,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Component"]:::default
        L2["Code File"]:::code
        L3["Data Flow"]:::flow
        L4["Process"]:::process
    end
```
