Skip to content

jananipc/pancreatic-neoplasm-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Scalable Residual Feature Aggregation Framework with Hybrid Metaheuristic Optimization for Robust Early Pancreatic Neoplasm Detection in Multimodal CT Imaging

Overview

This repository contains the implementation code for an advanced deep learning framework designed for early detection of pancreatic neoplasms using CT imaging. The project implements a novel approach combining:

  • MAGRes-UNet: Multi-Attention Gated Residual U-Net for image segmentation
  • DenseNet-121 with Residual Feature Stores (RFS): For robust feature extraction
  • Hybrid Ensemble Classification: Combining Vision Transformer and EfficientNet-B3 with metaheuristic optimization

Key Features

  • πŸ₯ Medical Image Preprocessing: CLAHE enhancement, Gaussian blur, and median filtering
  • 🧠 Advanced Architecture: MAGRes-UNet with attention gates and residual connections
  • πŸ” Feature Extraction: DenseNet-121 with Residual Feature Stores from multiple dense blocks
  • 🎯 Ensemble Learning: Optimized combination of state-of-the-art models
  • πŸ“Š Comprehensive Evaluation: Accuracy, Sensitivity, Specificity, F1-score, and Precision metrics

Dataset

Source: Pancreatic CT Images Dataset

The dataset consists of CT scan images organized into two classes:

  • normal: Healthy pancreas scans
  • pancreatic_tumor: Scans showing pancreatic tumors

Dataset Structure

23 Dataset/
β”œβ”€β”€ train/
β”‚   └── train/
β”‚       β”œβ”€β”€ normal/
β”‚       └── pancreatic_tumor/
└── test/
    └── test/
        β”œβ”€β”€ normal/
        └── pancreatic_tumor/

Requirements

Hardware

  • RAM: Minimum 8GB recommended
  • GPU: Optional (supports MPS for Apple Silicon, CUDA for NVIDIA GPUs)
  • Storage: ~5GB for dataset and models

Software Dependencies

pip install torch torchvision
pip install opencv-python
pip install pillow
pip install numpy
pip install pandas
pip install matplotlib
pip install scikit-learn

Installation

  1. Clone the repository
git clone https://github.com/jananipc/pancreatic-neoplasm-detector.git
cd pancreatic-neoplasm-detector
  1. Install dependencies
pip install -r requirements.txt
  1. Download the dataset
    • Download from Kaggle
    • Extract to a local directory
    • Update the base_dir path in the notebook

Project Structure

pancreatic-neoplasm-detector/
β”œβ”€β”€ Early_Pancreatic_Neoplasm_Detection_implementation_code.ipynb
β”œβ”€β”€ README.md
└── requirements.txt (optional)

Implementation Pipeline

Step 1: Data Loading and Exploration

  • Load pancreatic CT images from train and test directories
  • Count images per class
  • Visualize sample images from each class

Step 2: Image Preprocessing

  1. CLAHE (Contrast Limited Adaptive Histogram Equalization)

    • Enhances local contrast in CT images
    • Parameters: clipLimit=2.0, tileGridSize=(8,8)
  2. Gaussian Blur

    • Reduces noise while preserving edges
    • Kernel size: 5Γ—5
  3. Median Filter

    • Removes salt-and-pepper noise
    • Kernel size: 3Γ—3
  4. Normalization

    • Min-max normalization to [0, 1] range

Step 3: MAGRes-UNet Segmentation

  • Architecture: Multi-Attention Gated Residual U-Net
  • Components:
    • Residual blocks in encoder and decoder
    • Attention gates for skip connections
    • 4-level encoder-decoder structure
    • Base channels: 16

Step 4: Feature Extraction

  • Model: DenseNet-121 with Residual Feature Stores
  • Features: Concatenated pooled features from all dense blocks
  • Growth rate: 32
  • Block configuration: (6, 12, 24, 16) layers

Step 5: Classification and Evaluation

Models evaluated:

  • Vision Transformer (ViT)
  • EfficientNet-B3
  • DenseNet-121
  • Xception
  • ResNet-50
  • MobileNetV3-Large
  • Proposed Ensemble Model (ViT + EfficientNet-B3 with optimized weights)

Usage

Running the Notebook

  1. Open Jupyter Notebook
jupyter notebook Early_Pancreatic_Neoplasm_Detection_implementation_code.ipynb
  1. Update Dataset Path

    • Modify base_dir in the notebook to point to your dataset location
  2. Execute Cells Sequentially

    • Step 1: Data loading and exploration
    • Step 2: Preprocessing pipeline
    • Step 3: MAGRes-UNet segmentation
    • Step 4: Feature extraction with DenseNet-121 RFS
    • Step 5: Classification and evaluation

Key Functions

# Preprocessing function
def apply_preprocessing(pil_img):
    # Returns normalized CT image after CLAHE, Gaussian, Median filtering

# Feature extraction
def extract_rfs_features(dataloader, model, device):
    # Extracts features from all dense blocks

# Metrics computation
def compute_metrics_binary(y_true, y_pred):
    # Returns accuracy, sensitivity, specificity, F1, precision

Results

The proposed ensemble model achieves superior performance across all metrics:

Model Accuracy (%) Sensitivity (%) F1-Score (%) Precision (%) Specificity (%)
Vision Transformer 80-89 ~80-89 ~80-89 ~80-89 ~80-89
EfficientNet-B3 80-89 ~80-89 ~80-89 ~80-89 ~80-89
DenseNet-121 70-79 ~70-79 ~70-79 ~70-79 ~70-79
Xception 70-79 ~70-79 ~70-79 ~70-79 ~70-79
ResNet-50 70-79 ~70-79 ~70-79 ~70-79 ~70-79
MobileNetV3-Large 70-79 ~70-79 ~70-79 ~70-79 ~70-79
Proposed Model 93-98 ~93-98 ~93-98 ~93-98 ~93-98

Model Architecture Details

MAGRes-UNet

  • Encoder: 4 residual blocks with max pooling
  • Bottleneck: Deep residual block
  • Decoder: 4 transposed convolution layers with attention-gated skip connections
  • Attention Gates: Multi-level feature refinement
  • Output: Sigmoid-activated segmentation mask

DenseNet-121 RFS

  • Dense Blocks: 4 blocks with (6, 12, 24, 16) layers
  • Growth Rate: 32 channels per layer
  • Transition Layers: Compression and downsampling
  • RFS: Global average pooling from all blocks
  • Feature Dimension: Concatenated multi-scale features

Citation

If you use this code in your research, please cite:

@article{pancreatic_detection_2024,
  title={Scalable Residual Feature Aggregation Framework with Hybrid Metaheuristic Optimization for Robust Early Pancreatic Neoplasm Detection in Multimodal CT Imaging},
  author={[Your Name]},
  journal={IEEE Conference},
  year={2024}
}

Acknowledgments

  • Dataset: Kaggle Pancreatic CT Images
  • Inspired by state-of-the-art medical image analysis techniques
  • Built with PyTorch and scikit-learn

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For questions or collaborations:

Future Work

  • Implement additional metaheuristic optimization algorithms (PSO, GA)
  • Extend to 3D volumetric CT analysis
  • Deploy as a web application for clinical use
  • Add explainability features (Grad-CAM, attention maps)
  • Evaluate on additional pancreatic disease datasets

Note: This is research code for academic purposes. For clinical applications, please consult with medical professionals and follow appropriate regulatory guidelines.

About

Contains implementation code of IEEE paper "Scalable Residual Feature Aggregation Framework with Hybrid Metaheuristic Optimization for Robust Early Pancreatic Neoplasm Detection in Multimodal CT Imaging"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors