How to edit RTplan dicom file?

83 views
Skip to first unread message

Brenda

unread,
Apr 12, 2023, 9:53:53 AM4/12/23
to pydicom
Hello!

I'm quite new to pydicom and would require some assistance. I am trying to edit an RTplan to change the Gantry angle at each control point but i do not know how to proceed with it. Can someone provide me some tips and assistance with regards to that? 

I wanted to read the gantry angle at each control point, however was given the error that 'IS' cannot be indexed/'DSfloat' cannot be indexed when trying to print gantry angle.

Thanks in advance for your help! :))

Darcy Mason

unread,
Apr 12, 2023, 10:07:08 AM4/12/23
to pydicom

Here is one way to read gantry angle, using a nested loop over beams and control points:

for beam in ds.BeamSequence:
   for cp in beam.ControlPointSequence:
      print(cp.get("GantryAngle"))

It uses the `.get` method to return None if that control point does not have a GantryAngle data element.  If you know they exist, you could just use `cp.GantryAngle`.  For setting values, can just use `cp.GantryAngle = 90`, or whatever value.

Brenda

unread,
Apr 12, 2023, 8:11:35 PM4/12/23
to pydicom
Ah I see! Alright! Thanks for helping, ill give it a try :)
Reply all
Reply to author
Forward
0 new messages