How almadani92/w-netr-for-fecg-extraction works
Project Type and Purpose
• The project is a deep-learning pipeline built upon MONAI (a PyTorch-based framework for healthcare signals). Its aim is to extract fetal ECG (FECG) signals using a one-dimensional W-NETR architecture. There are two domains of interest: simulation (synthetic signals) and real data.
• The README explicitly explains that there are separate dataset generation scripts and network definitions for synthetic and real data.
File Structure for Architectural Components
• Data Organization & Generation:
• Directories such as “fetal-ecg-synthetic-database-1.0.0”, “ADFECGDB”, and “PCDB” hold raw data files and scripts that organize these datasets.
• Files like “generate_dataset.py”, “generate_dataset_real.py”, “Dataset_gen2.py”, “Dataset_gen_real.py”, “Dataset_gen_pcdb.py” indicate preprocessing/organizing steps.
• Within these directories you also see sub-components like “fecg_ground”, “mixture”, “mecg_ground” which represent specific channels or aspects of the ECG data.
• Network Architecture:
• The “networks.py” and “networks_real.py” files define the W-NETR architectures tailored for simulation and real data tests.
• The “models” directory holds detailed building blocks (e.g. unetr, PatchEmbeddingBlock, vit etc.) that are used to construct the network layers.
• “init.py” provides configuration options for training.
• Testing & Evaluation:
• Test scripts “test_simulation.py”, “test_real.py”, and “test_pcdb.py” indicate the layers where testing or evaluation is performed.
• The results images in the README (synthetic_results.png and real_results.png in the “images” folder) reflect the output of these tests.
• Utility Support:
• The “util” directory and files like “utils.py” support dataset handling, pre/post processing, and other helper functions.
• Configuration files like “requirements.txt” and “installation_commands_.txt” indicate dependencies and installation instructions.
• External Dependencies:
Defining the Main Components and Their Relationships
A. Data Ingestion and Preprocessing:
• Components: Raw Dataset directories (fetal-ecg-synthetic-database-1.0.0, ADFECGDB, PCDB)
• Process: Dataset generation scripts (e.g., generate_dataset.py, Dataset_gen2.py, Dataset_gen_real.py)
• Data Flow: Raw Data Files → Preprocessing Scripts → Structured Dataloader Files
B. Network Architecture & Training / Testing Modules:
• Components: Network definitions (networks.py, networks_real.py) and associated building blocks in the “models” folder.
• Process: The deep-learning models (W-NETR) are constructed using the components provided in the “models” directory, configured via “init.py”.
• Data Flow: Processed data from the preprocessing stage is fed into the network; model architecture flows through input layers, through the embedding blocks and dynamic blocks (like in unetr and vit) to output prediction signals.
C. Evaluation and Results:
• Components: Testing scripts (test_simulation.py, test_real.py, test_pcdb.py)
• Process: Evaluating model outputs; generating visualization and result plots (as shown in the “images” folder).
• Data Flow: Inference results → Testing scripts → Result visualizations
D. Utility and Helper Modules:
• Components: “util” and “utils.py”
• Process: Support dataset management, logging, and configurations across the data processing and model execution pipelines.
Architectural Patterns and Design Principles
• Separation of Concerns: The architecture distinguishes between data processing and model execution phases. There is a clear split between synthetic (simulation) and real datasets.
• Modularity: Different directories and scripts handle dataset creation, network definition, and testing. This modularity is crucial for extending or debugging different parts.
• Dependency Injection: Configuration settings from “init.py” and clear definitions in “requirements.txt” mean that the runtime environment is controlled and reproducible.