- React 19.2.0 - Modern UI framework for building interactive user interfaces
- Vite 7.2.2 - Fast build tool and development server
- Bootstrap - CSS framework for responsive design
- JavaScript (ES6+) - Modern JavaScript features
- Flask 3.1.2 - Lightweight Python web framework
- Flask-CORS 6.0.1 - Cross-Origin Resource Sharing support
- Python 3.x - Backend programming language
- PyTorch ≥2.0.0 - Deep learning framework
- Torchvision ≥0.15.0 - Computer vision utilities and pre-trained models
- ResNet18 - Pre-trained CNN architecture for image classification
- Custom Autoencoder - Neural network for future MRI generation
- GradCAM - Gradient-weighted Class Activation Mapping for visualization
- NumPy ≥1.24.0 - Numerical computing library
- OpenCV-Python ≥4.8.0 - Computer vision and image processing
- Pillow ≥10.0.0 - Image processing library
- scikit-learn ≥1.3.0 - Machine learning utilities
- Google Generative AI (Gemini 2.0 Flash) - Large Language Model for clinical care plan generation
- google-generativeai 0.8.5 - Official Python SDK for Google Gemini API
- SQLite3 - Lightweight relational database for storing:
- Uploaded MRI images
- Patient information
- Analysis results
- Generated care plans
- ReportLab 4.0.9 - Python library for generating professional PDF reports
- tqdm ≥4.66.0 - Progress bars for long-running operations
- ESLint - JavaScript code linting
- Node.js & npm - Package management for frontend
- Virtual Environment (venv) - Python environment isolation
- RESTful API - Standard API architecture
- Base64 Encoding - Image data encoding for transmission
- User navigates to the Patient Information Form
- Fills in patient details (name, age, MRN, DOB, etc.)
- Fills in radiologist information (name, specialty, license)
- Option to use Autofill button for quick testing
- Clicks "Continue to Upload" button
- User uploads brain MRI scan image(s) via drag-and-drop or file browser
- Images are:
- Validated (format, size)
- Stored in SQLite database (base64 encoded)
- Saved to disk as backup
- Upload progress is displayed with real-time feedback
- On successful upload, proceeds to analysis
-
Image Preprocessing
- Convert to grayscale
- Resize to 128×128 pixels
- Normalize pixel values
- Convert to RGB format for ResNet18
-
Classification (ResNet18)
- Load pre-trained ResNet18 model
- Classify into 4 categories:
- No Impairment
- Very Mild Impairment
- Mild Impairment
- Moderate Impairment
- Calculate current risk score:
1 - P(No Impairment)
-
GradCAM Visualization
- Generate Class Activation Map (CAM) for current MRI
- Highlight brain regions important for classification
- Create heatmap overlay on original image
- Save as current_heatmap.png
-
Brain Region Detection
- Divide CAM into 3×3 spatial zones
- Map zones to anatomical brain regions:
- Frontal Lobe, Temporal Lobe, Parietal Lobe
- Hippocampus, Amygdala, Precuneus
- Posterior Cingulate Cortex, Thalamus, Basal Ganglia
- Extract top 2 most activated regions
-
Autoencoder Processing
- Load trained autoencoder model
- Encode current MRI to 64-dimensional latent space
- Apply progression vector (learned direction from "No Impairment" → "Moderate Impairment")
- Shift latent representation:
z_future = z_current + α × progression_vector - Decode to generate predicted future MRI
-
Future Classification
- Classify predicted future MRI using same ResNet18 model
- Calculate future risk score
- Generate future prediction classification
-
Future GradCAM
- Generate CAM for predicted future MRI
- Create future_heatmap.png
- Extract future brain regions
-
Data Preparation
- Format analysis results:
- Current & future risk scores
- Current & future classifications
- Current & future brain regions
- Structure data as JSON
- Format analysis results:
-
Google Gemini API Call
- Load clinical prompt template (acts as neuroradiologist)
- Send formatted data to Gemini 2.0 Flash model
- Generate comprehensive clinical care plan
-
Care Plan Sections Generated:
- IMPRESSION - Diagnosis-style summary
- DETAILED NEUROANATOMICAL INTERPRETATION - Region-by-region analysis
- RISK TRAJECTORY SUMMARY - Current vs future comparison
- PREDICTED FUNCTIONAL IMPACT - Expected symptoms by region
- PERSONALIZED 5-YEAR CARE PLAN:
- Immediate (0-3 months)
- Short Term (3-12 months)
- Long Term (1-3 years)
- Future Projection (3-5 years)
- PRESENT-TO-FUTURE DIFFERENCE SUMMARY - What worsens, stays stable, red flags
- Store complete analysis in SQLite database:
- Image ID (foreign key)
- Patient information (JSON)
- Current risk score & prediction
- Future risk score & prediction
- Current & future brain regions (JSON arrays)
- Generated care plan (text)
- Timestamp
- Doctor Report Page shows:
- 4 Brain Scan Images:
- Original Current MRI
- Current Heatmap (GradCAM)
- Predicted Future MRI
- Future Heatmap (GradCAM)
- Analysis Findings:
- Current classification & risk score
- Future prediction & risk score
- Brain Regions:
- Current affected regions
- Future affected regions
- Personalized Care Plan:
- Full clinical report from Gemini
- All 6 sections formatted
- 4 Brain Scan Images:
- User clicks "Download PDF" button
- ReportLab generates professional PDF containing:
- Patient information
- Scan information
- All 4 brain scan images (2×2 grid)
- Analysis findings
- Overall assessment
- Clinical recommendations
- Full care plan (separate page)
- Radiologist information
- PDF is downloaded to user's device
User Input
↓
[Patient Info Form] → SQLite DB
↓
[Image Upload] → SQLite DB (ImageData table)
↓
[ML Analysis Pipeline]
├─→ ResNet18 Classifier → Current Risk Score & Prediction
├─→ GradCAM → Current Heatmap
├─→ Region Detector → Current Brain Regions
├─→ Autoencoder → Future MRI Generation
├─→ ResNet18 Classifier → Future Risk Score & Prediction
├─→ GradCAM → Future Heatmap
└─→ Region Detector → Future Brain Regions
↓
[Google Gemini API] → Care Plan Generation
↓
[SQLite DB] → AnalysisResults table (stores everything)
↓
[Frontend Display] → Doctor Report Page
↓
[PDF Generation] → ReportLab → Download
- Automated Analysis - Complete ML pipeline from image to insights
- Future Prediction - AI-generated progression modeling
- Visual Explanations - GradCAM heatmaps show model reasoning
- Anatomical Mapping - Identifies specific brain regions affected
- AI-Generated Care Plans - Professional clinical reports via Gemini
- Data Persistence - All results stored in database
- Professional PDFs - Medical-grade report generation
- Responsive UI - Modern, user-friendly interface
- Input: 128×128 RGB images
- Architecture: Pre-trained ResNet18 (ImageNet weights)
- Output: 4-class classification (Alzheimer's severity levels)
- Purpose: Risk assessment and classification
- Encoder: 4-layer CNN (1→32→64→128→256 channels)
- Latent Space: 64 dimensions
- Decoder: 4-layer transposed CNN (256→128→64→32→1 channels)
- Purpose: Future MRI generation via latent space manipulation
- Method: Mean difference in latent space
- Calculation:
z_moderate - z_no_impairment - Usage: Applied with alpha factor (0.5) to predict progression
- Purpose: Disease progression modeling
POST /upload- Upload MRI imagesGET /images- Retrieve all uploaded imagesGET /image/<id>- Get specific imagePOST /analyze- Run complete ML analysis + care plan generationPOST /generate-report- Generate PDF reportPOST /generate-care-plan- Generate care plan only (standalone)GET /stats- Database statistics
- End-to-End Pipeline - From image upload to clinical report
- Progressive Disease Modeling - Predicts future brain state
- Explainable AI - GradCAM visualizations show model focus
- Clinical Integration - LLM generates professional medical reports
- Complete Data Management - Persistent storage of all analyses
- Production-Ready - Error handling, validation, professional UI
Built for HACKRPI 2025