Skip to main content

Utils for gathering, aggregation and handling metadata from DICOM files.

Project description

Utils for gathering, aggregation and handling metadata from DICOM files.

Installation

From pip

pip install dicom-csv

or from GitHub

git clone https://github.com/neuro-ml/dicom-csv
cd dicom-csv
pip install -e .

Example join_tree

>>> from dicom_csv import join_tree
>>> folder = '/path/to/folder/'
>>> meta = join_tree(folder, verbose=2)
>>> meta.head(3)
AccessionNumber AcquisitionDate ... WindowCenter WindowWidth
000002621237 20200922 ... -500.0 1500.0
000002621237 20200922 ... -40.0 400.0
000002621237 20200922 ... -500.0 1500.0
3 rows x 155 columns

Example load 3D image

from a series of dicom files (each containing 2D image)

from dicom_csv import join_tree, order_series, stack_images
from pydicom import dcmread
from pathlib import Path

# 1. Collect metadata from all dicom files
folder = Path('/path/to/folder/')
meta = join_tree(folder, verbose=2)

# 2. Select series to load
uid = '...' # unique identifier of a series you want to load,
            # you could list them by `meta.SeriesInstanceUID.unique()`
series = meta.query("SeriesInstanceUID==@uid")

# 3. Read files & combine them into a single volume
images2d = [dcmread(folder / row[1].PathToFolder / row[1].FileName) for row in series.iterrows()] 
image3d = stack_images(order_series(images2d))

Documentation

You can find the documentation here.

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

dicom_csv-0.5.0.tar.gz (20.4 kB view details)

Uploaded Source

File details

Details for the file dicom_csv-0.5.0.tar.gz.

File metadata

  • Download URL: dicom_csv-0.5.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for dicom_csv-0.5.0.tar.gz
Algorithm Hash digest
SHA256 36296d8f6314838e8607abfc0edb339406bf3bfb665faba0a7b561fab2694a2d
MD5 c18727af943e1d991d02af9025545a3e
BLAKE2b-256 dafbebacfcaa3a8503a7cda372706b38664ebe6c986c0ed71c28702142b3afb5

See more details on using hashes here.

Supported by

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