Scalable Residual Feature Aggregation Framework with Hybrid Metaheuristic Optimization for Robust Early Pancreatic Neoplasm Detection in Multimodal CT Imaging
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
- π₯ 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
Source: Pancreatic CT Images Dataset
The dataset consists of CT scan images organized into two classes:
normal: Healthy pancreas scanspancreatic_tumor: Scans showing pancreatic tumors
23 Dataset/
βββ train/
β βββ train/
β βββ normal/
β βββ pancreatic_tumor/
βββ test/
βββ test/
βββ normal/
βββ pancreatic_tumor/
- RAM: Minimum 8GB recommended
- GPU: Optional (supports MPS for Apple Silicon, CUDA for NVIDIA GPUs)
- Storage: ~5GB for dataset and models
pip install torch torchvision
pip install opencv-python
pip install pillow
pip install numpy
pip install pandas
pip install matplotlib
pip install scikit-learn- Clone the repository
git clone https://github.com/jananipc/pancreatic-neoplasm-detector.git
cd pancreatic-neoplasm-detector- Install dependencies
pip install -r requirements.txt- Download the dataset
- Download from Kaggle
- Extract to a local directory
- Update the
base_dirpath in the notebook
pancreatic-neoplasm-detector/
βββ Early_Pancreatic_Neoplasm_Detection_implementation_code.ipynb
βββ README.md
βββ requirements.txt (optional)
- Load pancreatic CT images from train and test directories
- Count images per class
- Visualize sample images from each class
-
CLAHE (Contrast Limited Adaptive Histogram Equalization)
- Enhances local contrast in CT images
- Parameters:
clipLimit=2.0,tileGridSize=(8,8)
-
Gaussian Blur
- Reduces noise while preserving edges
- Kernel size: 5Γ5
-
Median Filter
- Removes salt-and-pepper noise
- Kernel size: 3Γ3
-
Normalization
- Min-max normalization to [0, 1] range
- 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
- 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
Models evaluated:
- Vision Transformer (ViT)
- EfficientNet-B3
- DenseNet-121
- Xception
- ResNet-50
- MobileNetV3-Large
- Proposed Ensemble Model (ViT + EfficientNet-B3 with optimized weights)
- Open Jupyter Notebook
jupyter notebook Early_Pancreatic_Neoplasm_Detection_implementation_code.ipynb-
Update Dataset Path
- Modify
base_dirin the notebook to point to your dataset location
- Modify
-
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
# 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, precisionThe 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 |
- 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
- 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
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}
}- Dataset: Kaggle Pancreatic CT Images
- Inspired by state-of-the-art medical image analysis techniques
- Built with PyTorch and scikit-learn
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or collaborations:
- GitHub: @jananipc @knabigaru-crypto @KoviAnusha
- Repository: Pancreatic Neoplasm Detector
- 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.