# soribido/bmd_prediction architecture

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

- Interactive diagram: https://gitdiagram.com/soribido/bmd_prediction
- Repository: https://github.com/soribido/bmd_prediction

## Overview

##### Project Type and Purpose
- This is a research/experimental project centered on medical imaging analysis. It leverages deep learning for segmentation and regression (BMD estimation), alongside an XAI component for model interpretability.
- The README provides a paper reference, experimental cases (cropped images, entire vertebrae-masked images, vertebral-body-masked images), and details on various workflows including segmentation and prediction, which indicate a clinical/medical image processing research purpose.

##### File Structure
- Top-Level Files: Standard files such as .gitignore, LICENSE, and README indicate proper project documentation and versioning.
- Directories and their Purposes:
- XAI: Contains a notebook (XAI.ipynb) likely showing the implementation/demonstration of the modified Grad-CAM (Grad-RAM and Grad-RAMP) methods for model interpretability.
- bmd_estimation: Houses notebooks (bmd_CA_case1.ipynb, bmd_pred_case1.ipynb) that likely demonstrate the process and experiments involving BMD prediction.
- bone-segmentation: Contains the segmentation notebook (seg_body_model.ipynb), which uses a U-Net based model to segment the L1 region.
- preprocessing: Includes Python scripts (check_ptinfo.py, ctdicom_check.py, preprocessing_image.py) responsible for preprocessing CT images and ensuring data quality/preparation.

- Clear labels for each primary component:
- "Preprocessing Module" (with sub-tasks like DICOM checks and image formatting)
- "Segmentation Module" (U-Net based segmentation of L1 region)
- "BMD Prediction Module" (Deep residual CNN for BMD estimation)
- "XAI Interpretation Module" (Modified Grad-CAM techniques - Grad-RAM/Grad-RAMP)
Raw CT Images → Preprocessing → Segmentation → Prediction → XAI.

## Diagram (Mermaid)

```mermaid
flowchart TD
    RawCT["Raw CT Images"]:::inputStyle
    Preproc["Preprocessing Module\n(DICOM checks and image formatting)"]:::preprocessingStyle
    Segmentation["Segmentation Module\n(U-Net based segmentation of L1 region)"]:::segmentationStyle
    BMDEstimation["BMD Prediction Module\n(Deep residual CNN for BMD estimation)"]:::predictionStyle
    XAI["XAI Interpretation Module\n(Modified Grad-CAM techniques)"]:::xaiStyle

    RawCT -->|"ingests"| Preproc
    Preproc -->|"processed images"| Segmentation
    Segmentation -->|"segmented outputs"| BMDEstimation
    BMDEstimation -->|"predictions"| XAI

    click Preproc "https://github.com/soribido/bmd_prediction/tree/main/preprocessing/"
    click Segmentation "https://github.com/soribido/bmd_prediction/blob/main/bone-segmentation/seg_body_model.ipynb"
    click BMDEstimation "https://github.com/soribido/bmd_prediction/tree/main/bmd_estimation/"
    click XAI "https://github.com/soribido/bmd_prediction/blob/main/XAI/XAI.ipynb"

    classDef inputStyle fill:#fffbbd,stroke:#333,stroke-width:2px,font-size:12px;
    classDef preprocessingStyle fill:#a2d5ab,stroke:#333,stroke-width:2px,font-size:12px;
    classDef segmentationStyle fill:#a2b5d5,stroke:#333,stroke-width:2px,font-size:12px;
    classDef predictionStyle fill:#d59c85,stroke:#333,stroke-width:2px,font-size:12px;
    classDef xaiStyle fill:#d5a2d8,stroke:#333,stroke-width:2px,font-size:12px;
```
