CoolFace
Apppublic

benedictpepper/Brain-Tumor-Segmentation

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

Brain Tumor Segmentation using Fuzzy C-Means (FCM)

Python OpenCV scikit-fuzzy Graphviz

An automated medical image analysis tool that applies the Fuzzy C-Means (FCM) soft clustering algorithm to segment brain MRI scans and highlight potential tumor regions.

๐Ÿ“Œ Project Overview

Diagnosing brain tumors accurately from Magnetic Resonance Imaging (MRI) is critical but often subjective and time-consuming. This project provides an automated segmentation pipeline using Fuzzy Logic. By clustering pixel data into distinct tissue groups (background, healthy tissue, fluids, and potential tumors), this tool serves as a reliable aid for medical image analysis.

๐Ÿ› ๏ธ Tech Stack & Tools

  • โ€”Language: Python
  • โ€”Computer Vision: OpenCV
  • โ€”Machine Learning / Fuzzy Logic: scikit-fuzzy, NumPy
  • โ€”Visualization: Matplotlib, Graphviz (for automated process mapping)
  • โ€”GUI / Interactions: Tkinter

๐Ÿš€ Key Features

  • โ€”Fuzzy C-Means Implementation: Configured to dynamically group MRI pixels into 4 distinct clusters with a fuzziness parameter of 2.0, ideal for handling the blurred boundaries of medical tissues.
  • โ€”Automated Workflow Mapping: Dynamically generates and displays Graphviz flowcharts mapping both the overall system process and the internal FCM algorithmic loops.
  • โ€”Interactive File Selection: Built-in Tkinter GUI for seamless, user-friendly local image selection and processing.
  • โ€”Quantitative Evaluation: Automatically calculates and outputs the Fuzzy Partition Coefficient (FPC) and objective function convergence to validate clustering quality.

๐Ÿ“‚ Repository Structure

text
fcm-brain-tumor-segmentation/
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ sample_mri.jpg        # Example MRI scans for testing
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ segment_fcm.py        # Main execution script
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ””โ”€โ”€ README.md

๐Ÿ’ป How to Run Locally

  1. 1.Clone the repository:
bash
   git clone https://github.com/bennypepper/Brain-Tumor-Segmentation.git
   cd brain-tumor-segmentation
  1. 1.Install the required dependencies:
bash
   pip install -r requirements.txt

Note for Windows Users: Graphviz requires a system-level installation. If the executable is missing from your PATH, the script will open an interactive prompt to help you locate the `bin` folder automatically.

  1. 1.Execute the segmentation script:
bash
   python src/segment_fcm.py

๐Ÿ“Š Results & Performance

The algorithm efficiently reached optimal convergence in 34 iterations with a minimized objective function of 10,852,001.55.

  • โ€”Fuzzy Partition Coefficient (FPC): 0.9156 (A score highly close to 1.0, indicating exceptionally well-defined and compact clusters).
  • โ€”Visual Output: The system outputs a side-by-side comparison of the original MRI, the isolated cluster labels, and a color-mapped segmentation where potential tumor mass is isolated.

๐Ÿ”ฎ Future Development

  • โ€”Ground Truth Validation: Compare algorithmic outputs against expert-annotated masks to calculate exact Accuracy, Specificity, and Dice Coefficients.
  • โ€”Skull Stripping Pipeline: Introduce a pre-processing step to isolate brain tissue from the skull for improved clustering focus.
  • โ€”Texture Analysis Integration: Expand feature extraction beyond pixel intensity to include tissue texture matrices.