BF+ENH: Fixes to DICOM scaling, make frame filtering explicit #1342
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes how we handle DICOM scaling, particularly for Philips and multi-frame files. For Philips data scale factors without defined units should be avoided, and instead a private tag should be used to make image intensities comparable across series. For multi-frame DICOM, it is possible to have different scale factors (potentially coming from different tags) per-frame. We also prefer scale factors from a RealWorldValueMapping provided they have defined units.
The base Wrapper class now has a few new attributes and methods to support this functionality. In particular an attribute
scale_factors
that provides an array of slope/intercept pairs, and a methodget_unscaled_data
that will return the reordered/reshaped data but without the scaling applied. Avendor
attribute was also added to better support vendor-specific implementation details.For the MultiFrameWrapper I also added an attribute
frame_order
which exposes the order used to sort the frames, and use this to return thescale_factors
in sorted order. While implementing this I kept bumping into issues due to the (implicit) frame filtering that was happening in theimage_shape
property, so I made this filtering explicit and configurable and moved it into the class initialization.