# angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures architecture

> Architecture diagram of the GitHub repository angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures
- Repository: https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures

## Overview

The Brain-Image-Segmentation project is centered around developing and testing convolutional neural network (CNN) based segmentation models for brain MRI images using U-Net and related architectures. The project is experimental in nature and primarily implemented in Jupyter notebooks, with separate directories for 2D and 3D experiments, evaluation scripts, model definitions, and predictions.

##### Main Components
- Data Handling & Preprocessing:
– This includes the dataset ingestion (see the README and image references for the brain tumor dataset) and preprocessing steps such as histogram-based enhancement.
- Model Development:
– Within the “2d” directory, you have multiple notebooks (e.g., U_Net.ipynb, M_Net.ipynb, ResNet+_Unet.ipynb) that define different model variants.
– The “3d” directory indicates experiments or implementations with a 3D approach.
- Training & Evaluation:
– The “evaluation” folder (under 2d) holds notebooks that are used to evaluate the model performance (e.g., Evaluation_M_Net.ipynb, Evaluation_Res+Uet.ipynb, etc.).
– The README also mentions evaluation metrics (Dice Coefficient).
- Prediction & Deployment:
– The “predictions” directory contains notebooks that use trained models to generate segmentation predictions.
- Documentation & Reporting:
– There are README files (both at the root and in subdirectories) and even a project report PDF that document the model architecture, dataset, performance, and suggestions for improvements.
- Infrastructure/Dependencies:
– Although not marked as a microservices stack or deployed backend, dependencies are clearly defined in the README. They include Keras, TensorFlow, and supporting libraries (h5py, scipy, scikit-learn).

##### Relationships and Data Flow
- Input Data: MRI images are the starting point. A preprocessing step (histogram correction) is applied before feeding the images into the model.
- Model Training: The training notebooks process the images through the CNN architecture. For 2D, the U-Net (and its variations) is at the core.
- Evaluation: Once training is complete, evaluation notebooks calculate performance metrics (Dice Coefficient) comparing predictions against ground truth.
- Prediction: Separate prediction notebooks generate output segmentation maps for new data.
- Reporting & Visualization: Visualization is achieved via external images (as referenced in the README) and the lab notebook outputs which report performance and demonstrate examples.

##### Architectural Patterns and Design Principles
- Modularity:
– The project is modularized into 2D and 3D experiments, with clear separation of model definitions, data exploration, evaluations, and prediction scripts.
- Experimentation Focus:
– Each notebook is self-contained for a specific task (data exploration, model training, prediction, and evaluation) which reflects an experimental pipeline.
- Separation of Concerns:
– Directories are organized by functionality rather than strictly by production components (e.g., “models” vs. “predictions” vs. “evaluation”).

##### Technologies, Frameworks, and Libraries
- Keras and TensorFlow as core deep learning frameworks.
- Supporting libraries such as h5py, scipy, and scikit-learn.
- Jupyter notebooks are used as the primary development environment, emphasizing an interactive, exploratory approach.

##### Rendering for a Full Understanding
– Ensure that all components are visually distinct, with the data flow clearly indicated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input Node
    Input["MRI Images Input"]:::data

    %% Data Handling & Preprocessing Subgraph
    subgraph "Data Handling & Preprocessing"
        D2["2D Data Exploration"]:::data
        D3["3D Data Exploration"]:::data
    end

    %% Flow from Input to Data Handling
    Input -->|"ingest"| D2
    Input -->|"ingest"| D3

    %% Model Development Subgraph
    subgraph "Model Development"
        subgraph "2D Pipeline"
            U["U-Net Model (2D)"]:::model
            M["M-Net Model (2D)"]:::model
            R["ResNet+U-Net Model (2D)"]:::model
        end
        subgraph "3D Pipeline"
            M3["3D Model Implementation"]:::model
        end
        Dep["Dependencies: Keras,TensorFlow,h5py,scipy,scikit-learn"]:::note
    end

    %% Data Exploration to Model Development connections
    D2 --> U
    D2 --> M
    D2 --> R
    D3 --> M3

    %% Link Models to Dependencies
    U --> Dep
    M --> Dep
    R --> Dep
    M3 --> Dep

    %% Training & Evaluation Subgraph
    subgraph "Training & Evaluation"
        E1["Evaluate U-Net Model"]:::evaluation
        E2["Evaluate M-Net Model"]:::evaluation
        E3["Evaluate ResNet+U-Net Model"]:::evaluation
    end

    %% Model to Evaluation connections
    U --> E1
    M --> E2
    R --> E3
    M3 --> E1

    %% Prediction Generation Subgraph
    subgraph "Prediction Generation"
        P1["2D Prediction - U-Net"]:::prediction
        P2["2D Prediction - M-Net"]:::prediction
        P3["2D Prediction - ResNet+U-Net"]:::prediction
    end

    %% Evaluation to Prediction connections
    E1 --> P1
    E2 --> P2
    E3 --> P3

    %% Documentation & Reporting Subgraph
    subgraph "Documentation & Reporting"
        Doc1["Project README"]:::doc
        Doc2["2D README"]:::doc
        Doc3["3D README"]:::doc
        Doc4["Project Report"]:::doc
        Doc5["Visual References"]:::doc
    end

    %% Prediction to Documentation connections
    P1 --> Doc1
    P2 --> Doc2
    P3 --> Doc3
    Doc1 --> Doc4
    Doc1 --> Doc5

    %% Click Events for Data Handling & Preprocessing
    click D2 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/Data_exploration.ipynb"
    click D3 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/3d/Data_exploration.ipynb"

    %% Click Events for Model Development (2D & 3D)
    click U "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/U_Net.ipynb"
    click M "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/M_Net.ipynb"
    click R "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/ResNet+_Unet.ipynb"
    click M3 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/3d/Model.ipynb"

    %% Click Events for Training & Evaluation
    click E1 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/evaluation/Evaluation_U_Net.ipynb"
    click E2 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/evaluation/Evaluation_M_Net.ipynb"
    click E3 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/evaluation/Evaluation_Res+Uet.ipynb"

    %% Click Events for Prediction Generation
    click P1 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/predictions/Prediction_UNet.ipynb"
    click P2 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/predictions/Predictions_M_Net.ipynb"
    click P3 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/predictions/Predictions_Res+Unet.ipynb"

    %% Click Events for Documentation & Reporting
    click Doc1 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/README.md"
    click Doc2 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/2d/README.MD"
    click Doc3 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/3d/README.md"
    click Doc4 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/blob/master/Brain Image Segmentation Project Report.pdf"
    click Doc5 "https://github.com/angadbajwa23/segmentation-of-2d-brain-mr-images-using-deep-neural-architectures/tree/master/images/pics"

    %% Class Definitions for styling
    classDef data fill:#b3e5fc,stroke:#0277bd,stroke-width:2px,color:#000;
    classDef model fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px,color:#000;
    classDef evaluation fill:#fff9c4,stroke:#f9a825,stroke-width:2px,color:#000;
    classDef prediction fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px,color:#000;
    classDef doc fill:#d1c4e9,stroke:#5e35b1,stroke-width:2px,color:#000;
    classDef note fill:#f0f4c3,stroke:#c0ca33,stroke-width:2px,color:#000;
```
