In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

import dicom

In [2]:
dcm = dicom.read_file("star.dcm", force=True)
dcm


Out[2]:
(0008, 0005) Specific Character Set              CS: 'ISO_IR 100'
(0008, 0012) Instance Creation Date              DA: '20151127'
(0008, 0013) Instance Creation Time              TM: '143229'
(0008, 0014) Instance Creator UID                UI: 2.16.840.1.114337
(0008, 0016) SOP Class UID                       UI: RT Plan Storage
(0008, 0018) SOP Instance UID                    UI: 2.16.840.1.114337.1.1.1448595149.0
(0008, 0020) Study Date                          DA: ''
(0008, 0030) Study Time                          TM: ''
(0008, 0050) Accession Number                    SH: '1'
(0008, 0060) Modality                            CS: 'RTPLAN'
(0008, 0070) Manufacturer                        LO: 'CMS, Inc.'
(0008, 0090) Referring Physician's Name          PN: ''
(0008, 1070) Operators' Name                     PN: ''
(0008, 1090) Manufacturer's Model Name           LO: 'Monaco'
(0010, 0010) Patient's Name                      PN: 'Phantom,Monaco'
(0010, 0020) Patient ID                          LO: 'MrSTAR'
(0010, 0030) Patient's Birth Date                DA: '19691231'
(0010, 0040) Patient's Sex                       CS: 'O'
(0010, 1000) Other Patient IDs                   LO: 'MonacoPhantom'
(0010, 1001) Other Patient Names                 PN: 'Phantom,Monaco'
(0020, 000d) Study Instance UID                  UI: 2.16.840.1.114337.208007652905.23470.1285961861.0
(0020, 000e) Series Instance UID                 UI: 2.16.840.1.114337.1448595149
(0020, 0010) Study ID                            SH: 'MonacoPhantom'
(0020, 0011) Series Number                       IS: '1'
(0020, 0013) Instance Number                     IS: '1'
(300a, 0002) RT Plan Label                       SH: 'AMrSTAR'
(300a, 0003) RT Plan Name                        LO: 'MrSTAR'
(300a, 0004) RT Plan Description                 ST: ''
(300a, 0006) RT Plan Date                        DA: '20151127'
(300a, 0007) RT Plan Time                        TM: '143058.000000'
(300a, 000c) RT Plan Geometry                    CS: 'PATIENT'
(300a, 000e) Prescription Description            ST: 'Plan: RxA'
(300a, 0010)  Dose Reference Sequence   2 item(s) ---- 
   (300a, 0012) Dose Reference Number               IS: '1'
   (300a, 0014) Dose Reference Structure Type       CS: 'SITE'
   (300a, 0020) Dose Reference Type                 CS: 'TARGET'
   (300a, 0026) Target Prescription Dose            DS: '2.00'
   ---------
   (300a, 0012) Dose Reference Number               IS: '2'
   (300a, 0014) Dose Reference Structure Type       CS: 'COORDINATES'
   (300a, 0018) Dose Reference Point Coordinates    DS: ['-0.5', '-121.4', '0.0']
   (300a, 0020) Dose Reference Type                 CS: 'TARGET'
   ---------
(300a, 0070)  Fraction Group Sequence   1 item(s) ---- 
   (300a, 0071) Fraction Group Number               IS: '1'
   (300a, 0078) Number of Fractions Planned         IS: '1'
   (300a, 0080) Number of Beams                     IS: '1'
   (300a, 00a0) Number of Brachy Application Setups IS: '0'
   (300c, 0004)  Referenced Beam Sequence   1 item(s) ---- 
      (300a, 0082) Beam Dose Specification Point       DS: ['-0.5', '-121.4', '0.0']
      (300a, 0084) Beam Dose                           DS: '0.000'
      (300a, 0086) Beam Meterset                       DS: '1000.000000'
      (300c, 0006) Referenced Beam Number              IS: '1'
      ---------
   (300c, 0050)  Referenced Dose Reference Sequence   1 item(s) ---- 
      (300c, 0051) Referenced Dose Reference Number    IS: '1'
      ---------
   ---------
(300a, 00b0)  Beam Sequence   1 item(s) ---- 
   (0008, 1040) Institutional Department Name       LO: '1~QA Clinic'
   (300a, 00b2) Treatment Machine Name              SH: 'Boo'
   (300a, 00b3) Primary Dosimeter Unit              CS: 'MU'
   (300a, 00b4) Source-Axis Distance                DS: '1000.0'
   (300a, 00b6)  Beam Limiting Device Sequence   2 item(s) ---- 
      (300a, 00b8) RT Beam Limiting Device Type        CS: 'ASYMX'
      (300a, 00bc) Number of Leaf/Jaw Pairs            IS: '1'
      ---------
      (300a, 00b8) RT Beam Limiting Device Type        CS: 'ASYMY'
      (300a, 00bc) Number of Leaf/Jaw Pairs            IS: '1'
      ---------
   (300a, 00c0) Beam Number                         IS: '1'
   (300a, 00c2) Beam Name                           LO: 'AP'
   (300a, 00c3) Beam Description                    ST: 'AP'
   (300a, 00c4) Beam Type                           CS: 'STATIC'
   (300a, 00c6) Radiation Type                      CS: 'ELECTRON'
   (300a, 00ce) Treatment Delivery Type             CS: 'TREATMENT'
   (300a, 00d0) Number of Wedges                    IS: '0'
   (300a, 00e0) Number of Compensators              IS: '0'
   (300a, 00ed) Number of Boli                      IS: '0'
   (300a, 00f0) Number of Blocks                    IS: '1'
   (300a, 00f2) Total Block Tray Factor             DS: ''
   (300a, 00f4)  Block Sequence   1 item(s) ---- 
      (300a, 00e1) Material ID                         SH: 'Cerrobend'
      (300a, 00f5) Block Tray ID                       SH: ''
      (300a, 00f6) Source to Block Tray Distance       DS: '947.9'
      (300a, 00f8) Block Type                          CS: 'APERTURE'
      (300a, 00fa) Block Divergence                    CS: 'PRESENT'
      (300a, 00fb) Block Mounting Position             CS: 'SOURCE_SIDE'
      (300a, 00fc) Block Number                        IS: '1'
      (300a, 00fe) Block Name                          LO: 'Block'
      (300a, 0100) Block Thickness                     DS: '15.0'
      (300a, 0104) Block Number of Points              IS: '9'
      (300a, 0106) Block Data                          DS: ['21.7', '45.4', '17.6', '11.1', '39.3', '-26.7', '-2.3', '-10.1', '-39.6', '-24.7', '-29.0', '8.1', '-43.4', '41.6', '-9.3', '30.0', '21.7', '45.4']
      ---------
   (300a, 0107)  Applicator Sequence   1 item(s) ---- 
      (300a, 0108) Applicator ID                       SH: '10X10'
      (300a, 0109) Applicator Type                     CS: 'ELECTRON_SQUARE'
      (300a, 010a) Applicator Description              LO: '10X10'
      ---------
   (300a, 010e) Final Cumulative Meterset Weight    DS: '1.0'
   (300a, 0110) Number of Control Points            IS: '2'
   (300a, 0111)  Control Point Sequence   2 item(s) ---- 
      (300a, 0112) Control Point Index                 IS: '0'
      (300a, 0114) Nominal Beam Energy                 DS: '12.0'
      (300a, 0115) Dose Rate Set                       DS: '0'
      (300a, 011a)  Beam Limiting Device Position Sequence   2 item(s) ---- 
         (300a, 00b8) RT Beam Limiting Device Type        CS: 'ASYMX'
         (300a, 011c) Leaf/Jaw Positions                  DS: ['-96.0', '96.0']
         ---------
         (300a, 00b8) RT Beam Limiting Device Type        CS: 'ASYMY'
         (300a, 011c) Leaf/Jaw Positions                  DS: ['-89.0', '89.0']
         ---------
      (300a, 011e) Gantry Angle                        DS: '0.0'
      (300a, 011f) Gantry Rotation Direction           CS: 'NONE'
      (300a, 0120) Beam Limiting Device Angle          DS: '0.0'
      (300a, 0121) Beam Limiting Device Rotation Direc CS: 'NONE'
      (300a, 0122) Patient Support Angle               DS: '0.0'
      (300a, 0123) Patient Support Rotation Direction  CS: 'NONE'
      (300a, 0125) Table Top Eccentric Angle           DS: '0.0'
      (300a, 0126) Table Top Eccentric Rotation Direct CS: 'NONE'
      (300a, 0128) Table Top Vertical Position         DS: ''
      (300a, 0129) Table Top Longitudinal Position     DS: ''
      (300a, 012a) Table Top Lateral Position          DS: ''
      (300a, 012c) Isocenter Position                  DS: ['-0.5', '-121.4', '0.0']
      (300a, 012e) Surface Entry Point                 DS: ['-0.5', '-120.4', '0.0']
      (300a, 0130) Source to Surface Distance          DS: '1001.0'
      (300a, 0134) Cumulative Meterset Weight          DS: '0'
      (300c, 0050)  Referenced Dose Reference Sequence   2 item(s) ---- 
         (300a, 010c) Cumulative Dose Reference Coefficie DS: ''
         (300c, 0051) Referenced Dose Reference Number    IS: '1'
         ---------
         (300a, 010c) Cumulative Dose Reference Coefficie DS: ''
         (300c, 0051) Referenced Dose Reference Number    IS: '2'
         ---------
      ---------
      (300a, 0112) Control Point Index                 IS: '1'
      (300a, 0115) Dose Rate Set                       DS: '0'
      (300a, 011e) Gantry Angle                        DS: '0.0'
      (300a, 0134) Cumulative Meterset Weight          DS: '1'
      (300c, 0050)  Referenced Dose Reference Sequence   2 item(s) ---- 
         (300a, 010c) Cumulative Dose Reference Coefficie DS: ''
         (300c, 0051) Referenced Dose Reference Number    IS: '1'
         ---------
         (300a, 010c) Cumulative Dose Reference Coefficie DS: ''
         (300c, 0051) Referenced Dose Reference Number    IS: '2'
         ---------
      ---------
   (300c, 006a) Referenced Patient Setup Number     IS: '1'
   ---------
(300a, 0180)  Patient Setup Sequence   1 item(s) ---- 
   (0018, 5100) Patient Position                    CS: 'HFS'
   (300a, 0182) Patient Setup Number                IS: '1'
   (300a, 01b0) Setup Technique                     CS: 'ISOCENTRIC'
   ---------
(300c, 0060)  Referenced Structure Set Sequence   1 item(s) ---- 
   (0008, 1150) Referenced SOP Class UID            UI: RT Structure Set Storage
   (0008, 1155) Referenced SOP Instance UID         UI: 1.2.840.10008.5.1.4.1.1.481.3.1448595145
   ---------
(300e, 0002) Approval Status                     CS: 'UNAPPROVED'

In [3]:
block_data = dcm.BeamSequence[0].BlockSequence[0].BlockData
block_data


Out[3]:
['21.7', '45.4', '17.6', '11.1', '39.3', '-26.7', '-2.3', '-10.1', '-39.6', '-24.7', '-29.0', '8.1', '-43.4', '41.6', '-9.3', '30.0', '21.7', '45.4']

In [9]:
energy = float(dcm.BeamSequence[0].ControlPointSequence[0].NominalBeamEnergy)
energy


Out[9]:
12.0

In [14]:
ssd = float(dcm.BeamSequence[0].ControlPointSequence[0].SourceToSurfaceDistance) / 10
ssd


Out[14]:
100.1

In [17]:
applicator = dcm.BeamSequence[0].ApplicatorSequence[0].ApplicatorID
applicator


Out[17]:
'10X10'

In [5]:
x = np.array(block_data[0::2]).astype(float)
y = np.array(block_data[1::2]).astype(float)

plt.plot(x, y)
plt.axis("equal")


Out[5]:
(-50.0, 40.0, -30.0, 50.0)

In [ ]: