Skip to main content

Conversion of medical images to MHA and TIFF.

Project description

panimg

CI PyPI PyPI - Python Version Code style: black

NOT FOR CLINICAL USE

Conversion of medical images to MHA and TIFF. Requires Python 3.7, 3.8 or 3.9. libvips-dev and libopenslide-dev must be installed on your system. For compressed DICOM support ensure that gdcm is installed.

Under the hood we use:

  • SimpleITK
  • pydicom
  • Pillow
  • openslide-python
  • pyvips

Usage

panimg takes a folder full of files and tries to covert them to MHA or TIFF. For each subdirectory of files it will try several strategies for loading the contained files, and if an image is found it will output it to the output folder. It will return a structure containing information about what images were produced, what images were used to form the new images, image metadata, and any errors from any of the strategies.

NOTE: Alpha software, do not run this on folders you do not have a backup of.

from pathlib import Path
from panimg import convert

result = convert(
    input_directory=Path("/path/to/files/"),
    output_directory=Path("/where/files/will/go/"),
)

Supported Formats

Input Output Strategy Notes
.mha .mha metaio
.mhd with .raw or .zraw .mha metaio
.dcm .mha dicom 1
.nii .mha nifty
.nii.gz .mha nifty
.png .mha fallback 2
.jpeg .mha fallback 2
.tiff .tiff & .dzi tiff 3
.svs (Aperio) .tiff & .dzi tiff 3
.vms, .vmu, .ndpi (Hamamatsu) .tiff & .dzi tiff 3
.scn (Leica) .tiff & .dzi tiff 3
.mrxs (MIRAX) .tiff & .dzi tiff 3
.biff (Ventana) .tiff & .dzi tiff 3

1: Compressed DICOM requires gdcm

2: 2D only, unitary dimensions

3: DZI only created if possible

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panimg-0.1.0.tar.gz (20.5 kB view hashes)

Uploaded Source

Built Distribution

panimg-0.1.0-py3-none-any.whl (24.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page