Improve logic to match segmentation frames to source images #361
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.
The source image references with the Per Frame Functional Groups of a segmentation (specifically the Derivation Image Sequence and the Source Image Sequence within it) are an important method to record links to source images, and are required by some viewers to correctly display segmentation overlays.
Currently highdicom only records these links in a limited set of circumstances, either:
However, this is somewhat limiting and there are important other situations where it would be desirable to have per-frame source image references established:
One particular downside of this is that users are discouraged from using
Volumes
because they often lead to the loss of per-frame references in the derived file.This PR adds logic to "match" segmentation frames to source images/frames based on spatial information, allowing for arbitrary permutations wrt the source image list and using a tolerance to account for small deviations. Additionally, matches are allowed where the spatial locations are not preserved due to cropping/rotating wrt the source images.
Additionally, there has been some significant refactoring of the relevant spatial metadata handling code and much of it has been moved to the
Image
class in preparation for using the same logic for other derived images (Parametric Maps in particular) in a future release.