This project builds a multimodal dataset for Chronic Kidney Disease detection. It combines:
- Tabular Clinical Data: Blood tests (Creatinine, Hemoglobin, etc.) and patient metadata.
- Medical Imaging: CT Scans of kidneys (Normal, Cyst, Tumor, Stone).
The goal is to create a dataset where every patient record (CSV row) is paired with a corresponding medical image, allowing for multi-input machine learning models (e.g., combining MLP for data and CNN for images).
- Purpose: Downloads the CT Kidney dataset from Kaggle.
- Action: Uses the Kaggle API to fetch the dataset, extracts it, and reorganizes the folders into a clean structure (
kidney_images/Tumor,kidney_images/Normal, etc.).
- Purpose: Generates the clinical CSV file.
- Action:
- Downloads real clinical data from a remote repository.
- Cleans the data (handling missing values, fixing types).
- Augments the dataset to 1500 rows using statistical sampling and noise injection to ensure enough data for training.
- Assigns a theoretical image path to each row based on medical logic (e.g., High Creatinine -> Tumor image).
- Purpose: Connects the CSV to the actual downloaded images.
- Action:
- Scans the
kidney_imagesfolder to find all valid.jpgfiles. - Updates the CSV generated in Step 2.
- Replaces the theoretical paths with actual file paths that exist on your disk, ensuring no "File Not Found" errors during training.
- Scans the
- Purpose: Quality Assurance.
- Action:
- Checks class balance (Sick vs. Healthy).
- Verifies that every image path in the CSV actually exists.
- Runs a baseline Logistic Regression model on the tabular data to estimate the "information power" of the blood test features.
Execute the scripts in this specific order to build the dataset:
- Download Images:
python img_download.py
- Generate Clinical Data:
python ds_generate.py
- Link Images to Data:
python fix_path.py
- Verify Integrity:
python audit_data.py
(Generated from audit_data.py)
✅ CSV Loaded: 1500 rows
📊 CLASS DISTRIBUTION:
- CKD (Sick): 405 (27.0%)
- Normal (Healthy): 1095 (73.0%) Note: A 'dumb' model guessing the majority class would have 73.0% accuracy.
🔍 DATA QUALITY:
- Missing Values: 0
- Duplicate Rows: 0
🖼️ IMAGE INTEGRITY SCAN:
- Images Found: 1500
- Images Missing: 0
- Corrupt Files: 0
======================================== 📈 ESTIMATED CLINICAL METRICS (Based on Blood Work) (Running rapid Logistic Regression on Tabular Data...)
Interpretation: These numbers represent the 'Information Power' of your dataset. If a simple statistical test gets high accuracy, your data is very clean.