Card

MRI Segmentation Tool

An MRI segmentation tool for lung and heart segmentation using PlatyPy library.

Environment

  • Ubuntu 20.04
  • Python 3.8.10

Installation

  1. Clone this repository:
git clone https://github.com/XiaoKChenEdu/MRI-Segmentation
cd MRI-Segmentation
  1. Install dependencies:
pip install -r requirements.txt
  1. Install the custom lung segmentation module:
chmod +x install_lung.sh
./install_lung.sh

Dependencies

The following Python packages are required:

  • platipy==0.5.1
  • platipy[cardiac]
  • SimpleITK==2.2.1
  • matplotlib==3.7.1
  • numpy==1.24.3

Project Structure

MRI-Segmentation/
├── requirements.txt
├── lung_segmentation.py
├── lung_segmentation_gui.py
├── heart_segmentation.py
├── heart_segmentation_gui.py
├── input/
│   └── volumes/
└── output/

Usage

GUI Tools

  1. For lung segmentation:
python lung_segmentation_gui.py
  1. For heart segmentation:
python heart_segmentation_gui.py

Command Line Tools

  1. For lung segmentation:
python lung_segmentation.py
  1. For heart segmentation:
python heart_segmentation.py

Input Format

The tool accepts NIFTI files (*.nii.gz) as input. Place your input files in the input/volumes/ directory.

Output

The segmentation results will be saved in the output/ directory, organized in subdirectories named after the input file. Each output directory contains:
- Segmentation masks in NIFTI format (*.nii.gz)
- Visualization of the segmentation (PNG format)