Image pixel data and inversion after version 3.0

Hopefully the last in my recent string of planar imaging questions!

The posted documentation on changes to “Pixel Data & Inversion” after Pylinac v3.0 state that when the image has the rescale slope, rescale intercept, and pixel intensity relationship sign attributes: pixel values are set using Pcorrected = Sign∗Slope∗PPraw+Intercept.

However, the init method seems to be using Pcorrected = Sign∗**(Slope∗PPraw+Intercept)**. Ie:

if has_all_rescale_tags:

self.array = ((self.metadata.RescaleSlope*self.array) + self.metadata.RescaleIntercept**)***self.metadata.PixelIntensityRelationshipSign

elif is_ct_storage or has_some_rescale_tags:

self.array = (self.metadata.RescaleSlope*self.array) + self.metadata.RescaleIntercept


invert it

orig_array = self.array

self.array = -orig_array + orig_array.max() + orig_array.min()

Our TrueBeam linacs started including the “Sign” attribute after we upgraded to ARIA 15.6. For our new images the value is always -1. Images acquired prior to this upgrade look identical in ARIA but do not include this sign attribute. Per the documentation (and the code above) they will be interpreted as though the sign were +1, ie: Pcorrected=Slope∗PPraw+Intercept. For these images my pylinac pdf output files reverse the expected “higher pixel values == more radiation == lighter/whiter display” convention stated in the docs.

I wonder if I’m doing something wrong here. If not, I would be tempted to hard code in a default “Sign” of -1 for cases where the image has_some_rescale_tags to avoid contrast discontinuities and preserve the expected convention when analyzing older images.

I’ve been fighting inversion since the beginning. I wanted to follow the DICOM tags to the letter, but EPID images being inverted all the time means that internally all the algorithms end up inverting the image on their own. All this to say, I agree based on what I’ve seen but have thus far resisted because I’m a rule-follower. Let me see how the tests come out with this change and hopefully it won’t break things.