Read RTPLAN DICOM and list informationΒΆ

Given an RTPLAN DICOM file, list basic info for the beams in it.

Beam name    Number   Gantry   SSD (cm)
 Field 1           1      0.0     89.8

# authors : Guillaume Lemaitre <>
# license : MIT

import pydicom
from import get_testdata_file


def list_beams(plan_dataset):
    """Summarizes the RTPLAN beam information in the dataset."""
    lines = ["{name:^13s} {num:^8s} {gantry:^8s} {ssd:^11s}".format(
        name="Beam name", num="Number", gantry="Gantry", ssd="SSD (cm)")]
    for beam in plan_dataset.BeamSequence:
        cp0 = beam.ControlPointSequence[0]
        SSD = float(cp0.SourceToSurfaceDistance / 10)
        lines.append("{b.BeamName:^13s} {b.BeamNumber:8d} "
                     "{gantry:8.1f} {ssd:8.1f}".format(b=beam,
    return "\n".join(lines)

filename = get_testdata_file('rtplan.dcm')
dataset = pydicom.dcmread(filename)

Total running time of the script: ( 0 minutes 0.003 seconds)

Gallery generated by Sphinx-Gallery