Skip to content

anishvkalbhor/PCOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🩺 PCOS Detect - Multimodal AI Risk Assessment System

PCOS Detect is an end-to-end AI-powered clinical decision support system designed to assess Polycystic Ovary Syndrome (PCOS) risk using a combination of:

  • Structured clinical (tabular) data
  • Pelvic ultrasound imaging
  • Automatic medical report (PDF) parsing

The system integrates machine learning, deep learning, document intelligence, and full-stack engineering into a single modular pipeline focused on robustness, explainability, and real-world usability.

⚠️ This system is intended for screening and decision-support purposes only and must not be used as a medical diagnostic tool.


✨ Key Features

  • Multimodal PCOS risk prediction (Tabular + Ultrasound)
  • Domain-specific expert ensemble for clinical features
  • Adaptive meta-learning–based fusion
  • Explainable AI with Grad-CAM for ultrasound interpretation
  • Automatic medical report (PDF) parsing
  • Secure FastAPI backend with Next.js frontend
  • ROC-AUC–driven evaluation metrics

🧠 System Architecture

Medical PDF ──┐
β”œβ”€β”€β–Ά Document Parser ──▢ Auto-filled Form (Editable)
Manual Input β”€β”˜

Tabular Data ─────────▢ Clinical Experts (3 Models)
β”‚
Ultrasound Image ─▢ CNN + Texture Features ─▢ Ultrasound Model
β”‚
Meta Learner (Stacking)
β”‚
Adaptive Multimodal Fusion
β”‚
Final PCOS Risk (Low / Moderate / High)

🧩 Core Components

Backend

  • FastAPI-based REST services
  • Secure, modular inference pipeline
  • Models loaded once at application startup
  • Stateless, auditable prediction endpoints

Frontend

  • Next.js (App Router) with TypeScript
  • Guided clinical data entry workflow
  • PDF upload with editable auto-filled fields
  • Ultrasound image upload
  • Explainable results dashboard

Models

  • CatBoost classifiers for tabular and ultrasound data
  • EfficientNet-B0 for ultrasound feature extraction (transfer learning)
  • ResNet50 for Grad-CAM explainability
  • Meta learner for expert fusion

πŸ“ Project Structure

PCOS/
β”œβ”€β”€ app/                  # FastAPI backend
β”‚   β”œβ”€β”€ api/              # Route handlers
β”‚   β”œβ”€β”€ core/             # Configuration
β”‚   β”œβ”€β”€ models/           # Pydantic schemas
β”‚   └── main.py           # App entry point
β”‚
β”œβ”€β”€ data/
β”‚   β”œβ”€β”€ tabular/           # Clinical datasets
β”‚   β”œβ”€β”€ features/          # Ultrasound texture features
β”‚   └── ultrasound/        # Raw & processed images
β”‚
β”œβ”€β”€ frontend/              # Next.js frontend
β”‚   β”œβ”€β”€ app/               # App Router pages
β”‚   β”œβ”€β”€ lib/               # API utilities
β”‚   └── public/            # Static assets
β”‚
β”œβ”€β”€ models/                # Trained ML models
β”‚   β”œβ”€β”€ expert_hormonal.cbm
β”‚   β”œβ”€β”€ expert_metabolic.cbm
β”‚   β”œβ”€β”€ expert_symptom.cbm
β”‚   β”œβ”€β”€ ultrasound_catboost.cbm
β”‚   └── resnet50_gradcam.pth
β”‚
β”œβ”€β”€ scripts/               # Data preprocessing & training scripts
β”œβ”€β”€ notebooks/             # Experiments & evaluation
β”œβ”€β”€ requirements.txt
└── README.md

πŸ§ͺ Datasets

Tabular Clinical Data

Includes:

  • Demographics (Age, Height, Weight, BMI)
  • Hormonal markers (FSH, LH, AMH, TSH, PRL, Progesterone)
  • Metabolic indicators (RBS, Weight Gain)
  • Symptoms and lifestyle factors

Target Variable: PCOS (0 / 1)


Ultrasound Imaging Data

  • Ovarian ultrasound scans

  • Feature extraction using:

    • EfficientNet-B0 embeddings
    • Local Binary Pattern (LBP) texture descriptors

Medical Report PDFs

  • Blood test reports
  • Ultrasound summaries

Used only for automatic data extraction, not for model training.


🧠 Modeling Strategy

Tabular Expert Models

Instead of one monolithic model, clinical features are split into domain-specific experts:

Expert Feature Focus
Hormonal FSH, LH, AMH, TSH, PRL
Metabolic BMI, RBS, Weight Gain
Symptom Acne, Hair Growth, Exercise
  • Model: CatBoostClassifier
  • Metric: ROC-AUC
  • Native handling of missing and categorical values

Meta Learner (Stacking)

Outputs of all experts are combined using a meta learner.

Meta Features

  • Expert probabilities
  • Mean and maximum confidence
  • Standard deviation
  • Pairwise disagreement

Goal

  • Improve calibration
  • Reduce individual expert bias
  • Increase robustness

Ultrasound Modeling

  • Backbone: EfficientNet-B0 (ImageNet pretrained)
  • Texture features: LBP
  • Final classifier: CatBoost

Adaptive Multimodal Fusion

Final PCOS risk is computed dynamically:

  • High tabular confidence β†’ tabular weighted more
  • High ultrasound confidence β†’ ultrasound weighted more
  • Otherwise β†’ balanced fusion

πŸ” Explainable AI (Grad-CAM)

  • Dedicated ResNet50 CNN trained for visualization
  • Grad-CAM heatmaps highlight ovarian regions
  • Exposed via backend API
  • Displayed in frontend alongside predictions

Validation Accuracy: ~81%


πŸ“„ Medical Document Parsing

Supported Inputs

  • PDF lab reports
  • Tables and free text

Parsing Stack

  • Camelot (table extraction)
  • pdfplumber (text extraction)
  • Regex-based numeric parsing
  • Unit normalization and validation
  • Confidence scoring per extracted field

Sample Output

{
  "FSH": { "value": 5.8, "confidence": 0.95 },
  "AMH": { "value": 8.4, "confidence": 0.93 }
}

πŸ“Š Model Performance (Summary)

Component Metric Score
Hormonal Expert ROC-AUC ~0.71
Metabolic Expert ROC-AUC ~0.63
Symptom Expert ROC-AUC ~0.75
Meta Learner ROC-AUC ~0.80
Ultrasound (Grad-CAM CNN) Accuracy ~81%

🌐 API Endpoints

Predict PCOS

POST /api/pcos/predict

FormData

tabular_data β†’ JSON
ultrasound   β†’ Image (optional)

Parse Medical Report

POST /api/pcos/parse-document

FormData

document β†’ PDF

βš™οΈ Installation & Setup

Backend

conda create -n pcos python=3.10
conda activate pcos
pip install -r requirements.txt
uvicorn app.main:app --reload

Frontend

cd frontend
npm install
npm run dev

⚠️ Disclaimer

This system is not a medical diagnostic tool.

It is intended for educational, research, and decision-support purposes only. Final diagnosis must always be made by a licensed healthcare professional.

About

PCOS Detect is an end-to-end AI-powered clinical decision support system designed to assess Polycystic Ovary Syndrome (PCOS)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors