All Projects → pydicom → Pydicom

pydicom / Pydicom

Licence: other
Read, modify and write DICOM files with python code

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Pydicom

Pynetdicom
A Python implementation of the DICOM networking protocol
Stars: ✭ 289 (-73.8%)
Mutual labels:  dicom
Dicomparser
JavaScript parser for DICOM Part 10 data
Stars: ✭ 515 (-53.31%)
Mutual labels:  dicom
Dvh Analytics Bokeh
A DVH Database for Clinicians and Researchers (Deprecated)
Stars: ✭ 32 (-97.1%)
Mutual labels:  dicom
Medpy
Medical image processing in Python
Stars: ✭ 321 (-70.9%)
Mutual labels:  dicom
Cornerstonetools
A framework for tools built on top of Cornerstone.
Stars: ✭ 411 (-62.74%)
Mutual labels:  dicom
Dicom
⚡High Performance DICOM Medical Image Parser in Go.
Stars: ✭ 643 (-41.7%)
Mutual labels:  dicom
fmjpeg2koj
JPEG2000 codec for DCMTK using openjpeg
Stars: ✭ 32 (-97.1%)
Mutual labels:  dicom
Dvh Analytics
A DICOM Database Application for Radiation Oncology
Stars: ✭ 49 (-95.56%)
Mutual labels:  dicom
Ctk
A set of common support code for medical imaging, surgical navigation, and related purposes.
Stars: ✭ 498 (-54.85%)
Mutual labels:  dicom
Highdicom
High-level DICOM abstractions for the Python programming language
Stars: ✭ 32 (-97.1%)
Mutual labels:  dicom
Dcmtk
Official DCMTK Github Mirror
Stars: ✭ 361 (-67.27%)
Mutual labels:  dicom
Dcm2niix
dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC
Stars: ✭ 364 (-67%)
Mutual labels:  dicom
Fo Dicom
Fellow Oak DICOM for .NET, .NET Core, Universal Windows, Android, iOS, Mono and Unity
Stars: ✭ 674 (-38.89%)
Mutual labels:  dicom
Weasis
Weasis is a DICOM viewer available as a desktop application or as a web-based application.
Stars: ✭ 311 (-71.8%)
Mutual labels:  dicom
Pytorch Dicom Classification
Code for analyzing medical images saved as .dicom files
Stars: ✭ 33 (-97.01%)
Mutual labels:  dicom
Osirix
OsiriX DICOM Viewer
Stars: ✭ 284 (-74.25%)
Mutual labels:  dicom
Ami
AMI Medical Imaging (AMI) JS ToolKit
Stars: ✭ 569 (-48.41%)
Mutual labels:  dicom
Mricrogl
DEPRECATED development has moved to https://github.com/rordenlab/MRIcroGL12
Stars: ✭ 49 (-95.56%)
Mutual labels:  dicom
Mricron
Simple medical imaging visualization tool designed for NIfTI images. Includes dcm2nii for conversion of DICOM, Philips, and other proprietary formats.
Stars: ✭ 37 (-96.65%)
Mutual labels:  dicom
Imageio
Python library for reading and writing image data
Stars: ✭ 846 (-23.3%)
Mutual labels:  dicom

CircleCI codecov Python version PyPI version DOI Gitter

pydicom

pydicom is a pure Python package for working with DICOM files. It lets you read, modify and write DICOM data in an easy "pythonic" way.

As a pure Python package, pydicom can run anywhere Python runs without any other requirements, although if you're working with Pixel Data then we recommend you also install NumPy.

If you're looking for a Python library for DICOM networking then you might be interested in another of our projects: pynetdicom.

Installation

Using pip:

pip install pydicom

Using conda:

conda install -c conda-forge pydicom

For more information, including installation instructions for the development version, see the installation guide.

Documentation

The pydicom user guide, tutorials, examples and API reference documentation is available for both the current release and the development version on GitHub Pages.

Pixel Data

Compressed and uncompressed Pixel Data is always available to be read, changed and written as bytes:

>>> from pydicom import dcmread
>>> from pydicom.data import get_testdata_file
>>> path = get_testdata_file("CT_small.dcm")
>>> ds = dcmread(path)
>>> type(ds.PixelData)
<class 'bytes'>
>>> len(ds.PixelData)
32768
>>> ds.PixelData[:2]
b'\xaf\x00'

If NumPy is installed, Pixel Data can be converted to an ndarray using the Dataset.pixel_array property:

>>> arr = ds.pixel_array
>>> arr.shape
(128, 128)
>>> arr
array([[175, 180, 166, ..., 203, 207, 216],
       [186, 183, 157, ..., 181, 190, 239],
       [184, 180, 171, ..., 152, 164, 235],
       ...,
       [906, 910, 923, ..., 922, 929, 927],
       [914, 954, 938, ..., 942, 925, 905],
       [959, 955, 916, ..., 911, 904, 909]], dtype=int16)

Compressed Pixel Data

JPEG, JPEG-LS and JPEG 2000

Converting JPEG compressed Pixel Data to an ndarray requires installing one or more additional Python libraries. For information on which libraries are required, see the pixel data handler documentation.

Compressing data into one of the JPEG formats is not currently supported.

RLE

RLE encoded Pixel Data only requires NumPy, and compression and decompression are both supported.

Examples

More examples are available in the documentation.

Change a patient's ID

from pydicom import dcmread

ds = dcmread("/path/to/file.dcm")
# Edit the (0010,0020) 'Patient ID' element
ds.PatientID = "12345678"
ds.save_as("/path/to/file_updated.dcm")

Display the Pixel Data

With NumPy and matplotlib

import matplotlib.pyplot as plt
from pydicom import dcmread
from pydicom.data import get_testdata_file

# The path to a pydicom test dataset
path = get_testdata_file("CT_small.dcm")
ds = dcmread(path)
# `arr` is a numpy.ndarray
arr = ds.pixel_array

plt.imshow(arr, cmap="gray")
plt.show()

Contributing

To contribute to pydicom, read our contribution guide.

To contribute an example or extension of pydicom that doesn't belong with the core software, see our contribution repository: contrib-pydicom.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].