Skip to main content

dicomhandler is a package for wrapping many pydicom objects of the same patient, performing transformations in structures and comparing them with the originals.

Project description

dicomhandler

Dicomhandler is a Python tool for integrating DICOM information and processing DICOM radiotherapy structures. It allows to modify the structures (expand, contract, rotate, translate) and to obtain statistics from these modifications without the need to use CT or MRI images and to create new objects with this information, which are compatible with the commercial systems of treatment planning such as Eclipse and Brainlab Elements. It is possible to extract the information from the structures in an easy csv-able form.

Dicomhandler uses DICOM files that belongs to different stages of treatment planning (structures, dose, and plan), by grouping the files of a patient in a single object. DICOM objects have to be created with Pydicom. Also, it allows for the extraction of related information, such as the Cartesian coordinates of structures and multileaf collimator (MLC) positions for each control point in the treatment plan. This is achieved by using the DicomInfo class. It receives as input the DICOM radiotherapy structures (RS), dose (RD), and plan (RP) files (or a subset of these) and constructs a single object that contains all the information for a patient.

Dicomhandler is built on NumPy. NumPy provides an efficient implementation of numerical computations in a high-level language like Python but completely compiled in C, resulting in a significant improvement in speed and code that is clear and easy to maintain.

Table of Contents

Features

The functionalities provided by the package could be divided into three main categories.

  • File transformation: To modify the files’ information in some meaningful way.

  • Format conversion: DICOM files are neither optimized for data analysis, nor straightforward review by clinical staff, but for hardware. For that reason, the package provides means for both scientific manipulation of data and effortless conversion to clinical-friendly formats.

  • Report data: To summarize different DICOM files, or even about the comparison between files.

Examples

Register DICOM files

It is required to operate on a DICOM object by Pydicom. You can use the DICOM files examples by default in the repository).

You can construct an object with different DICOM files from the same patient as:

di = DicomInfo(dicom_structure, dicom_plan)

Anonymize the information

You can choose the information that it has to be anonymized:

di.anonymize(name=True, birth=True, operator=False, creation=False)

Expand or contract margins

You can expand or subtract margins for a single structure. If you want to expand, the input parameter must be positive. Otherwise, negative.

expanded = di.add_margin('5 GTV', 1.5)
contracted = di.add_margin('5 GTV', -1.5)

Rotate or translate

You can rotate or translate a structure (organ or lesion) in an specific direction with respect to an arbitary point or to the isocentre. The keys are: roll, pitch, and yaw (for rotations) and x, y, and z (for translations).

For the isocenter:

di_rotated = di.move('5 GTV', 0.5, 'pitch')
di_translated = di.move('5 GTV', 1.0, 'x')

Or for an arbritary point:

di_rotated = di.move('5 GTV', 0.5, 'pitch', [4.0, -50.0, 20.0])
di_translated = di.move('5 GTV', 1.0, 'x', [4.0, -50.0, 20.0])

Summary in dataframe

A dataframe is generated with the main information of the plan, relevant for clinical statistics. Also, you can obtain the calculated areas of multileaf collimator (MLC) modulation.

To obtain general plan information:

di.summarize_to_dataframe(area=False)

To obtain the MLC areas:

di.summarize_to_dataframe(area=True)

CSV files

A csv file is generated with some information.

Structures

The output file provides the information on the coordinates (x, y, z) of all or some structures of a patient. By default the report is generated for all structures.

For all structures this process takes several minutes.

di.struct_to_csv(path_or_buff='output.csv')

Or you can select some structures to obtain the csv file in a particular path:

di.struct_to_csv(path_or_buff='output.csv', names=['Structure1', 'Structure2'])

Or in buffer:

di.struct_to_csv(path_or_buff=StringIO(), names=['Structure1', 'Structure2'])

Also, the output file can provide the information of gantry angle, gantry direction, table angles, and MLC positions for each checkpoint.

di.mlc_to_csv(path_or_buff="output.csv")

Or in buffer:

di.mlc_to_csv(path_or_buff=StringIO())

Access

We encourage the practice of using virtual environments to avoid dependency incompatibilities. The most convenient way to do this, is by using virtualenv, virtualenvwrapper, and pip.

Install with pip

After setting up and activating the virtualenv, run the following command:

pip install dicomhandler

Install the development version

In case you’d like to be able to update the package code occasionally with the latest bug fixes and improvements, see the source code, or even make your own changes, you can always clone the code directly from the repository:

git clone https://github.com/alxrojas/dicomhandler
cd dicomhandler
pip install -e .

Open and run the project

Run the project as:

from dicomhandler.dicom_info import DicomInfo
from dicomhandler.report import report

Libraries and pre-requisites

The dependencies of the package, that will be automatically installed with the software, are the following:

  • numpy: Data analysis and calculation.
  • pandas: Report statistics.
  • pydicom: DICOM file reader.

Authors

License

This project is licensed under (MIT) - Look the file LICENSE.md for details.

Project Status

Version 0.0.1a1 is complete

Room for Improvement

For future work and improvement:

  • A method to provide the assignment of variable margin to a lesion.
  • A method to evaluate the dose-volume histogram for the displaced structures.
  • The possibility to deform structures.

Acknowledgements

Many thanks to

  • Daniel Venencia, PhD. and Instituto Zunino to provide the resources and the access to data.
  • Juan Cabral, PhD. to evaluate and review this project.

More information for potential applications

Expressions of gratitude

  • Tell others about this project.
  • Cite our project in your paper.
  • Invite someone from the team a beer or a coffee.
  • Give thanks publicly.

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

dicomhandler-0.0.1.tar.gz (21.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dicomhandler-0.0.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file dicomhandler-0.0.1.tar.gz.

File metadata

  • Download URL: dicomhandler-0.0.1.tar.gz
  • Upload date:
  • Size: 21.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for dicomhandler-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ef89a4abadf22f009931d6c50866a3432b3090ad78fe4097e20f0ba7f2bcf76d
MD5 c858eb218104dc663ac9971eb4464ea6
BLAKE2b-256 fde384e44e8ea0536d7ec90b7222572b189a500db406a7a645fb2738d7a1c6b6

See more details on using hashes here.

File details

Details for the file dicomhandler-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: dicomhandler-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for dicomhandler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fed92b828fcfaa6982f6619ec8af0208a979b13114b10d3bb4886131dba5dba2
MD5 5b6a7f38fa3809e4a23a5bf21c35f9de
BLAKE2b-256 31366fc437bd23dbb184223a57c0a26db3092ec5212108b235334179899eaa95

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