Issue saving ImageOrientationPatient

148 views
Skip to first unread message

Jeremy Donaghue

unread,
Aug 19, 2010, 11:13:38 PM8/19/10
to pydicom
I'm trying to flip around the cooridantes for the ImagePositionPatient
and ImageOrientationPatient tags, but when I save the file, the
changes do not get saved.

I have tried (abridged)

plan=dicom.read_file(filename)
plan.ImageOrientationPatient[0]=-1*plan.ImageOrientationPatient[0]
plan.save_as(filename)

If you print the tag out after the change, it shows appropriately, but
the data is not getting written to the saved dicom file.

Thanks for the help.

Jeremy


Darcy Mason

unread,
Aug 20, 2010, 6:41:53 PM8/20/10
to pydicom
The current version of pydicom stores the original string version of
some VR types (like "DS") so they can be written back exactly.
Unfortunately when one item in a list like this is changed, it doesn't
recognize that and writes the original string out.

The work-around is to set the entire list rather than a sub-item, so
something like this should work for your case:
orient = plan.ImageOrientationPatient
orient[0] = -1 * orient[0]
plan.ImageOrientationPatient = orient

The key is the last line which sets the list itself, forcing pydicom
to recognize the change.

This problem should go away with a change to using python's Decimal
type, which is on the issues list for a near future version.

Hope that helps,
Darcy

Lei Qiu

unread,
Oct 12, 2018, 4:03:02 PM10/12/18
to pydicom
HI Man,

My code works!! I am searching the forum trying to directly write the RTstructure into a dicom file. I will email you
Reply all
Reply to author
Forward
0 new messages