{"id":31004287,"url":"https://github.com/aonurakman/stroke-detection-n-segmentation","last_synced_at":"2026-04-13T08:31:33.791Z","repository":{"id":179689357,"uuid":"663975485","full_name":"aonurakman/Stroke-Detection-n-Segmentation","owner":"aonurakman","description":"Detection, classification and segmentation of stroke regions from brain tomography images. - Bachelor's Thesis - 2021 - Yildiz Technical University","archived":false,"fork":false,"pushed_at":"2026-01-28T23:46:02.000Z","size":11977,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-29T14:34:32.241Z","etag":null,"topics":["computer-vision","densenet","inception","mask-rcnn","medical","mobilenet","python","stroke","tomography","transfer-learning","u-net","vgg16","yolov3"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aonurakman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-07-08T15:27:08.000Z","updated_at":"2026-01-28T23:45:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"3cb1da62-fc8e-4287-81cf-8ff079a6a7e5","html_url":"https://github.com/aonurakman/Stroke-Detection-n-Segmentation","commit_stats":null,"previous_names":["aonurakman/stroke-detection-n-segmentation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aonurakman/Stroke-Detection-n-Segmentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aonurakman%2FStroke-Detection-n-Segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aonurakman%2FStroke-Detection-n-Segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aonurakman%2FStroke-Detection-n-Segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aonurakman%2FStroke-Detection-n-Segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aonurakman","download_url":"https://codeload.github.com/aonurakman/Stroke-Detection-n-Segmentation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aonurakman%2FStroke-Detection-n-Segmentation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31746101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T06:26:45.479Z","status":"ssl_error","status_checked_at":"2026-04-13T06:26:44.645Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","densenet","inception","mask-rcnn","medical","mobilenet","python","stroke","tomography","transfer-learning","u-net","vgg16","yolov3"],"created_at":"2025-09-13T01:54:12.935Z","updated_at":"2026-04-13T08:31:33.784Z","avatar_url":"https://github.com/aonurakman.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Detection, Classification and Segmentation of Stroke Regions in Brain CT Images\n\nBachelor's Thesis - 2021 - Yildiz Technical University\n\n**Team members:** AKMAN, Onur; AYDIN, Ahmet; SINAR, Emine Betul\n\n**Full report:** [View PDF](https://github.com/aonurakman/Stroke-Detection-n-Segmentation/blob/d046383654f4e6b97ad4dbb893ce0f26149a3cd9/Doc/Report.pdf)\n\n## Overview\n\nThis project presents a comprehensive deep learning pipeline for automated stroke analysis in non-contrast computed tomography (CT) images. The system performs three primary tasks:\n\n1. **Detection:** Binary classification to determine the presence or absence of stroke\n2. **Classification:** Multi-class classification to identify stroke type (hemorrhagic or ischemic)\n3. **Segmentation:** Pixel-wise localization of stroke regions within CT images\n\nThe pipeline employs a two-phase approach combining multiple state-of-the-art deep learning architectures to achieve robust performance across all tasks.\n\n## Methodology\n\n### Phase 1: Stroke Detection\n\nThe detection phase employs an ensemble approach using transfer learning with the following architectures:\n- VGG16\n- Inception\n- MobileNet\n- ResNet\n- EfficientNet\n- DenseNet\n\nThe final prediction is obtained through soft-voting across all models, improving overall robustness and accuracy.\n\n![Fusion of models in Phase 1](https://i.hizliresim.com/59zgai2.PNG)\n\n### Phase 2: Classification and Segmentation\n\nThe classification and segmentation phase utilizes instance segmentation models to simultaneously identify stroke type and generate pixel-wise masks:\n\n**Primary Approach:** Mask R-CNN with transfer learning provides both stroke classification (hemorrhagic/ischemic) and precise segmentation masks.\n\n**Alternative Approaches:** U-Net and YOLOv3 were also trained and evaluated for comparison. While these models demonstrated competitive performance in classification, they produce bounding boxes rather than pixel-wise segmentation masks.\n\n![Segmentation in Phase 2](https://i.hizliresim.com/derossa.PNG)\n\n## Dataset\n\nThe dataset consists of 6,650 CT images in various formats (PNG, DICOM, MASK, and OVERLAY):\n- **Hemorrhagic stroke:** 1,093 images\n- **Ischemic stroke:** 1,130 images\n- **No stroke:** 4,427 images\n\n*Note: The dataset cannot be publicly shared due to privacy regulations.*\n\n## Prerequisites\n\n- Python 3.x\n- Google Colab (for Jupyter notebook execution) or local Jupyter environment\n- Google Drive account (for cloud-based training)\n- Required Python packages (varies by model, see individual sections below)\n- For Mask R-CNN: [Matterport Mask R-CNN implementation](https://github.com/matterport/Mask_RCNN)\n\n## General Setup Instructions\n\n1. **Environment Setup:**\n   - Clone or download this repository\n   - Prepare your Python environment with necessary dependencies\n   - Ensure sufficient storage space (~250 MB per epoch for model checkpoints)\n\n2. **Data Preparation:**\n   - Organize CT images and corresponding mask files according to model-specific requirements\n   - Ensure all images are in PNG format\n   - Maintain consistent naming conventions between images and their masks\n\n3. **Path Configuration:**\n   - Update file path variables in scripts to match your directory structure\n   - Configure ROOT_DIR or equivalent path variables as specified in each section\n\n\n\n## Model Training and Testing\n\n### Mask R-CNN\n\n#### Training\n\n1. **Setup Dependencies:**\n   - Download the Mask R-CNN implementation from [Matterport's repository](https://github.com/matterport/Mask_RCNN)\n   - Copy the `mrcnn` folder, `setup.py`, and `requirements.txt` to your working directory\n   - Download pre-trained COCO weights `mask_rcnn_coco.h5` from the [releases page](https://github.com/matterport/Mask_RCNN/releases)\n\n2. **Directory Structure:**\n   ```\n   ROOT_DIR/\n   ├── mrcnn/\n   ├── setup.py\n   ├── requirements.txt\n   ├── mask_rcnn_coco.h5\n   └── Dataset/\n       ├── train/\n       │   ├── *.png (CT images)\n       │   └── annotations.json\n       └── val/\n           ├── *.png (CT images)\n           └── annotations.json\n   ```\n\n3. **Configuration:**\n   - Set the `ROOT_DIR` variable in the training script to your working directory path\n   - Update all file path variables to match your directory structure\n   - Ensure at least 250 MB of free storage per training epoch for model checkpoints\n\n4. **Data Format:**\n   - All CT images must be in PNG format\n   - Annotation files should be in JSON format containing mask information\n   - Place training images and annotations in `Dataset/train/`\n   - Place validation images and annotations in `Dataset/val/`\n\n5. **Execution:**\n   - Run the training script from `Code/Phase 2/Mask R-CNN/MaskRCNN_training.py`\n   - Model weights are automatically saved after each epoch\n\n#### Testing\n\n1. **Setup:**\n   - Use the same Mask R-CNN dependencies as training\n   - Create two directories: `test_imgs/` and `test_masks/`\n\n2. **Directory Structure:**\n   ```\n   ROOT_DIR/\n   ├── mrcnn/\n   ├── setup.py\n   ├── requirements.txt\n   ├── model_weights.h5\n   ├── test_imgs/\n   └── test_masks/\n   ```\n\n3. **Data Preparation:**\n   - Place test CT images in `test_imgs/`\n   - Place corresponding ground truth masks in `test_masks/` with matching filenames\n   - For mask images: non-zero pixel values indicate stroke regions, zero values indicate background\n\n4. **Configuration:**\n   - Set `ROOT_DIR` to your working directory\n   - Specify the path to your trained model weights\n   - Update file path variables in the testing script\n\n5. **Execution:**\n   - Run the testing script to perform inference on test images\n\n#### IoU (Intersection over Union) Measurement\n\n1. **Setup:**\n   - Follow the same dependency setup as training/testing\n   - Create `img/` and `mask/` directories\n\n2. **Directory Structure:**\n   ```\n   ROOT_DIR/\n   ├── mrcnn/\n   ├── setup.py\n   ├── requirements.txt\n   ├── model_weights.h5\n   ├── img/\n   └── mask/\n   ```\n\n3. **Data Preparation:**\n   - Place original CT images in `img/`\n   - Place corresponding ground truth masks in `mask/` with matching filenames\n\n4. **Execution:**\n   - Run the IoU measurement script to evaluate segmentation accuracy\n\n\n### U-Net\n\n#### Training\n\n1. **Environment:**\n   - Open the U-Net training Jupyter notebook in Google Colab or local Jupyter environment\n   - Mount Google Drive if using Colab\n\n2. **Data Preparation:**\n   - Organize dataset with images and masks in the same directory\n   - Ensure each image and its corresponding mask have identical filenames\n   - Split data into training and validation sets\n   - Upload to Google Drive or local directory\n\n3. **Execution:**\n   - Mount your Drive (if using Colab)\n   - Execute notebook cells sequentially\n   - Model checkpoints and training logs will be saved automatically\n\n#### IoU Measurement\n\n1. **Environment Setup:**\n   - Open `Unet_mask_test.py` in an IDE (e.g., Spyder, PyCharm, or VS Code)\n   - Place the trained model file `model.h5` in the same directory as the script\n\n2. **Configuration:**\n   - Set the stroke type for testing in the script:\n     - `1` for hemorrhagic stroke\n     - `0` for ischemic stroke\n   - Specify input image path\n   - All images must be in PNG format\n\n3. **Execution:**\n   - Run the script to generate segmentation predictions\n   - Output images will be saved in the script directory\n\n\n### YOLOv3\n\n#### Training\n\n1. **Environment:**\n   - Open the YOLOv3 training Jupyter notebook in Google Colab or local Jupyter environment\n   - Mount Google Drive if using Colab\n\n2. **Data Preparation:**\n   - Prepare bounding box annotations for each training image\n   - Annotations must be in YOLO format with one line per object: `class_id x_center y_center width height` (all coordinates normalized relative to image dimensions)\n   - Generate YOLO-format annotation files (`.txt`) using one of these methods:\n     - Use [LabelImg](https://github.com/tzutalin/labelImg) annotation tool\n     - Use provided scripts to convert existing annotations to YOLO format\n\n3. **Configuration Files:**\n   - Adapt configuration files from YOLOv3 sample files:\n     - `train.cfg`: Training configuration\n     - `test.cfg`: Testing configuration  \n     - `train.names`: Class names file\n   - Upload configuration files along with dataset to Google Drive or local directory\n\n4. **Execution:**\n   - Mount your Drive (if using Colab)\n   - Execute notebook cells sequentially\n   - Training progress and model weights will be saved automatically\n\n## Repository Structure\n\n```\n├── Code/\n│   ├── Phase 1/              # Stroke detection models\n│   └── Phase 2/              # Classification and segmentation models\n│       ├── Mask R-CNN/\n│       ├── U-NET/\n│       └── YoloV3/\n├── Database/                 # Dataset information\n├── Doc/                      # Project documentation and report\n├── Run/                      # Detailed run instructions\n└── README.md\n```\n\n## Citation\n\nIf you use this work in your research, please cite:\n\n```\nAKMAN, O., AYDIN, A., \u0026 SINAR, E. B. (2021). Detection, Classification and Segmentation of \nStroke Regions in Brain CT Images. Bachelor's Thesis, Yildiz Technical University.\n```\n\n## License\n\nThis project is part of a Bachelor's Thesis submitted to Yildiz Technical University in 2021.\n\n## Contact\n\nFor questions or collaboration inquiries, please contact the team members or open an issue in this repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faonurakman%2Fstroke-detection-n-segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faonurakman%2Fstroke-detection-n-segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faonurakman%2Fstroke-detection-n-segmentation/lists"}