pydicom

Read, modify and write DICOM files with python code

https://github.com/pydicom/pydicom

Science Score: 59.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    2 of 98 committers (2.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.1%) to scientific vocabulary

Keywords

dicom pydicom python

Keywords from Contributors

medical-imaging closember neuroimaging qt neuroscience distribution notebook meg image-analysis tensors
Last synced: 6 months ago · JSON representation

Repository

Read, modify and write DICOM files with python code

Basic Info
Statistics
  • Stars: 2,052
  • Watchers: 63
  • Forks: 506
  • Open Issues: 12
  • Releases: 31
Topics
dicom pydicom python
Created over 12 years ago · Last pushed 6 months ago
Metadata Files
Readme Contributing Funding License

README.md

unit-tests type-hints doc-build test-coverage Python version PyPI version DOI

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.

Note that pydicom is a general-purpose DICOM framework concerned with reading and writing DICOM datasets. In order to keep the project manageable, it does not handle the specifics of individual SOP classes or other aspects of DICOM. Other libraries both inside and outside the pydicom organization are based on pydicom and provide support for other aspects of DICOM, and for more specific applications.

Examples are pynetdicom, which is a Python library for DICOM networking, and deid, which supports the anonymization of DICOM files.

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: ```python

from pydicom import dcmread from pydicom.data import gettestdatafile path = gettestdatafile("CT_small.dcm") ds = dcmread(path) type(ds.PixelData) 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:

```python

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) ```

Decompressing Pixel Data

JPEG, JPEG-LS and JPEG 2000

Converting JPEG, JPEG-LS or JPEG 2000 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.

RLE

Decompressing RLE Pixel Data only requires NumPy, however it can be quite slow. You may want to consider installing one or more additional Python libraries to speed up the process.

Compressing Pixel Data

Information on compressing Pixel Data using one of the below formats can be found in the corresponding encoding guides. These guides cover the specific requirements for each encoding method and we recommend you be familiar with them when performing image compression.

JPEG-LS, JPEG 2000

Compressing image data from an ndarray or bytes object to JPEG-LS or JPEG 2000 requires installing the following:

RLE

Compressing using RLE requires no additional packages but can be quite slow. It can be sped up by installing pylibjpeg with the pylibjpeg-rle plugin, or gdcm.

Examples

More examples are available in the documentation.

Change a patient's ID ```python from pydicom import dcmread

ds = dcmread("/path/to/file.dcm")

Edit the (0010,0020) 'Patient ID' element

ds.PatientID = "12345678" ds.saveas("/path/to/fileupdated.dcm") ```

Display the Pixel Data

With NumPy and matplotlib ```python import matplotlib.pyplot as plt from pydicom import dcmread, examples

The path to the example "ct" dataset included with pydicom

path: "pathlib.Path" = examples.get_path("ct") ds = dcmread(path)

arr is a numpy.ndarray

arr = ds.pixel_array

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

Contributing

We are all volunteers working on pydicom in our free time. As our resources are limited, we very much value your contributions, be it bug fixes, new core features, or documentation improvements. For more information, please read our contribution guide.

Owner

  • Name: DICOM in Python
  • Login: pydicom
  • Kind: organization

development for software, modules, and containers for dicom applications that use Python

GitHub Events

Total
  • Issues event: 56
  • Watch event: 140
  • Delete event: 21
  • Issue comment event: 248
  • Push event: 132
  • Pull request event: 106
  • Pull request review event: 271
  • Pull request review comment event: 217
  • Fork event: 32
  • Create event: 21
Last Year
  • Issues event: 56
  • Watch event: 140
  • Delete event: 21
  • Issue comment event: 248
  • Push event: 132
  • Pull request event: 106
  • Pull request review event: 271
  • Pull request review comment event: 217
  • Fork event: 32
  • Create event: 21

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 1,589
  • Total Committers: 98
  • Avg Commits per committer: 16.214
  • Development Distribution Score (DDS): 0.739
Past Year
  • Commits: 95
  • Committers: 12
  • Avg Commits per committer: 7.917
  • Development Distribution Score (DDS): 0.526
Top Committers
Name Email Commits
scaramallion s****n 415
Darcy Mason d****n@g****m 405
mrbean-bremen m****n 188
rhaxton r****n@g****m 119
Suever s****r@g****m 71
dependabot[bot] 4****] 46
Dimitri Papadopoulos Orfanos 3****s 43
vsoch v****t@s****u 36
pre-commit-ci[bot] 6****] 29
Guillaume Lemaitre g****8@g****m 24
lamy d****l@l****t 12
Chris Bridge c****4@g****m 10
Markus D. Herrmann h****d 10
Alex Rothberg a****g@g****m 10
Joan Massich m****k@g****m 9
James Kerns j****0@g****m 9
Korijn van Golen k****n@c****m 9
Aditya Panchal a****l@b****g 8
Simon Biggs me@s****t 7
Thomas Robitaille t****e@g****m 7
Brendan Moloney m****n@g****m 6
Matthew Shun-Shin m@s****m 6
Blair Conrad b****r@b****m 5
p.l.zajdel p****l@g****m 5
youngkiu y****u@g****m 4
Markus Mattes m****7@g****m 4
Zvi Baratz z****z@g****m 3
Félix C. Morency f****y@g****m 3
Tim t****n@g****m 3
ferdymercury f****y 2
and 68 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 226
  • Total pull requests: 447
  • Average time to close issues: 10 months
  • Average time to close pull requests: about 1 month
  • Total issue authors: 150
  • Total pull request authors: 40
  • Average comments per issue: 4.53
  • Average comments per pull request: 2.1
  • Merged pull requests: 378
  • Bot issues: 0
  • Bot pull requests: 103
Past Year
  • Issues: 49
  • Pull requests: 117
  • Average time to close issues: 15 days
  • Average time to close pull requests: 2 days
  • Issue authors: 36
  • Pull request authors: 16
  • Average comments per issue: 2.27
  • Average comments per pull request: 1.17
  • Merged pull requests: 90
  • Bot issues: 0
  • Bot pull requests: 31
Top Authors
Issue Authors
  • scaramallion (23)
  • darcymason (18)
  • CPBridge (5)
  • naterichman (4)
  • hackermd (4)
  • ZviBaratz (3)
  • erikogabrielsson (3)
  • BJladika (3)
  • Kri-Ol (3)
  • kwijk (3)
  • rconnaughton (3)
  • mrbean-bremen (3)
  • bersbersbers (2)
  • yehudahkay (2)
  • joon612 (2)
Pull Request Authors
  • scaramallion (187)
  • dependabot[bot] (74)
  • darcymason (45)
  • pre-commit-ci[bot] (29)
  • DimitriPapadopoulos (27)
  • mrbean-bremen (19)
  • CPBridge (9)
  • hackermd (3)
  • ZviBaratz (3)
  • emmanuel-ferdman (2)
  • bocchris-aws (2)
  • jstark-tpx (2)
  • katia-sentry (2)
  • naterichman (2)
  • yarikoptic (2)
Top Labels
Issue Labels
enhancement (60) pixel-data (56) bug (39) question (21) housekeeping (11) Documentation (10) typing (4) Difficulty-Medium (3) Difficulty-Hard (2) imported (2) needs details (2) duplicate (2) RFC (1) performance (1) invalid (1) release (1) Difficulty-Easy (1) Performance (1)
Pull Request Labels
dependencies (74) python (9) github_actions (4) enhancement (2) RFC (2) housekeeping (1) invalid (1)

Packages

  • Total packages: 18
  • Total downloads:
    • pypi 1,168,781 last-month
  • Total docker downloads: 180,338
  • Total dependent packages: 334
    (may contain duplicates)
  • Total dependent repositories: 1,562
    (may contain duplicates)
  • Total versions: 144
  • Total maintainers: 8
pypi.org: pydicom

A pure Python package for reading and writing DICOM data

  • Versions: 41
  • Dependent Packages: 300
  • Dependent Repositories: 1,519
  • Downloads: 1,130,766 Last month
  • Docker Downloads: 180,338
Rankings
Dependent packages count: 0.1%
Dependent repos count: 0.3%
Average: 0.5%
Downloads: 0.5%
Docker downloads count: 0.9%
Last synced: 6 months ago
spack.io: py-pydicom

Pure python package for DICOM medical file reading and writing 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.

  • Versions: 4
  • Dependent Packages: 5
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 4.3%
Average: 5.0%
Stargazers count: 5.9%
Dependent packages count: 9.7%
Maintainers (1)
Last synced: about 1 year ago
alpine-edge: py3-pydicom-pyc

Precompiled Python bytecode for py3-pydicom

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 4.8%
Average: 6.5%
Stargazers count: 7.8%
Dependent packages count: 13.4%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: pydicom

pydicom is a pure python package for parsing DICOM files. DICOM is a standard (https://dicomstandard.org) for communicating medical images and related information such as reports and radiotherapy objects. pydicom makes it easy to read these complex files into natural pythonic structures for easy manipulation. Modified datasets can be written again to DICOM format files. See the `Getting Started <https://pydicom.github.io/pydicom/stable/>`_ page for installation and basic information, and the `Pydicom User Guide

  • Versions: 18
  • Dependent Packages: 26
  • Dependent Repositories: 41
Rankings
Dependent packages count: 2.6%
Dependent repos count: 5.6%
Average: 6.6%
Forks count: 8.0%
Stargazers count: 10.1%
Last synced: 6 months ago
proxy.golang.org: github.com/pydicom/pydicom
  • Versions: 31
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.4%
Average: 6.6%
Dependent repos count: 6.9%
Last synced: 6 months ago
alpine-edge: py3-pydicom

Read, modify and write DICOM files with python

  • Versions: 10
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Forks count: 4.8%
Average: 6.8%
Stargazers count: 7.8%
Dependent packages count: 14.6%
Maintainers (1)
Last synced: 6 months ago
pypi.org: pyjpegls

JPEG-LS for Python via CharLS C++ Library

  • Versions: 7
  • Dependent Packages: 3
  • Dependent Repositories: 1
  • Downloads: 37,982 Last month
Rankings
Dependent packages count: 10.1%
Downloads: 11.1%
Average: 14.3%
Dependent repos count: 21.6%
Last synced: 6 months ago
pypi.org: ukritlib

Testing Python Package From Ukrit Fongsomboon

  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 33 Last month
Rankings
Dependent packages count: 10.1%
Average: 21.1%
Dependent repos count: 21.6%
Downloads: 31.5%
Maintainers (1)
Last synced: 6 months ago
pypi.org: medcog-dicom-anonymizer

Program to anonymize dicom files with default and custom rules.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 9.8%
Average: 37.1%
Dependent repos count: 64.5%
Maintainers (1)
Last synced: about 1 year ago
anaconda.org: pydicom

pydicom is a pure python package for parsing DICOM files. DICOM is a standard (https://dicomstandard.org) for communicating medical images and related information such as reports and radiotherapy objects. pydicom makes it easy to read these complex files into natural pythonic structures for easy manipulation. Modified datasets can be written again to DICOM format files. See the `Getting Started <https://pydicom.github.io/pydicom/stable/>`_ page for installation and basic information, and the `Pydicom User Guide

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 42.3%
Average: 44.4%
Dependent repos count: 46.5%
Last synced: 6 months ago
alpine-v3.22: py3-pydicom-pyc

Precompiled Python bytecode for py3-pydicom

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.21: py3-pydicom-pyc

Precompiled Python bytecode for py3-pydicom

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.19: py3-pydicom

Read, modify and write DICOM files with python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.19: py3-pydicom-pyc

Precompiled Python bytecode for py3-pydicom

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.22: py3-pydicom

Read, modify and write DICOM files with python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.21: py3-pydicom

Read, modify and write DICOM files with python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.20: py3-pydicom

Read, modify and write DICOM files with python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago
alpine-v3.20: py3-pydicom-pyc

Precompiled Python bytecode for py3-pydicom

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/publish-pypi-deploy.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v2 composite
  • pypa/gh-action-pypi-publish master composite
.github/workflows/PR.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/merge.yml actions
.github/workflows/pr-typing.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/tests_wf.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
pyproject.toml pypi