Skip to content

MHI-AI-CoreLab/pydicom-batch

Repository files navigation

PYDICOM Batch Export

Python Version License

This project provides Python-based batch image export scripts for PACS servers compliant with the DICOM protocol. It enables efficient extraction and management of medical images, making it ideal for data science projects and AI research that require large-scale medical imaging datasets.

🚀� Acknowledgment

This project is based on the excellent work of pydicom-batch by @therlaup. The original project provided the foundation and inspiration for this implementation. We've adapted and restructured the codebase while maintaining the core functionality and robustness of the original work.

🚀 Features

  • DICOM C-FIND queries for discovering available images
  • DICOM C-MOVE operations for image retrieval
  • Configurable batch operations via YAML files
  • CSV-based batch request management
  • Support for data anonymization
  • Flexible directory structure for exported files

🛠️ Prerequisites

  • Python 3.12.1
  • Access to a DICOM-compliant PACS server
  • Network connectivity to the PACS server
  • Proper firewall configuration for DICOM communication

⚙️ Installation

  1. Create and activate a Conda environment:
conda create --name pydicom-batch python=3.12.1
conda activate pydicom-batch
  1. Install required packages:
pip install -r requirements.txt

🔧 Configuration

Port Configuration

If not running in a container with port forwarding, configure your firewall to allow communication with the PACS server (example for port 4000).:

# Add TCP port
sudo firewall-cmd --add-port=4000/tcp --permanent

# Add UDP port (if needed)
sudo firewall-cmd --add-port=4000/udp --permanent

# Reload firewall
sudo firewall-cmd --reload

# Verify ports
sudo firewall-cmd --list-ports

DICOM Configuration

  1. Copy the template configuration:
cp config/dicom-template.yml.example config/dicom.yml
  1. Edit config/dicom.yml with your specific PACS server settings:
    • PACS server hostname/IP
    • Port numbers
    • Application Entity Titles (AET)
    • Query parameters

🚀 Usage

Run the main script:

python main.py

📁 Project Structure

  • config/ - Configuration files and templates
  • data/ - Storage for exported DICOM files and databases
  • scu.py - Service Class User implementation
  • scp.py - Service Class Provider implementation
  • main.py - Main execution script
  • common.py - Shared utilities and functions

🔍 Technical Details

The project is built on top of:

📝 Important DICOM Concepts

DICOM communication involves:

  • SCU (Service Class User) - Generates requests
  • SCP (Service Class Provider) - Responds to requests
  • AE (Application Entity) - Unique identifiers for DICOM nodes
  • Operations: C-FIND (query), C-MOVE (transfer), C-STORE (storage)

🤝 Contributing

Contributions are welcome! Please feel free to submit pull requests.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages