8000 Improve logic to match segmentation frames to source images by CPBridge · Pull Request #361 · ImagingDataCommons/highdicom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve logic to match segmentation frames to source images #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: v0.26.0dev
Choose a base branch
from

Conversation

CPBridge
Copy link
Collaborator
@CPBridge CPBridge commented Jun 16, 2025

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:

  • The user provides no spatial information for the segmentation array, so it is inferred from the source images and assumed to match exactly.
  • The user provides spatial information for the segmentation and it matches that extracted from the source images exactly

However, this is somewhat limiting and there are important other situations where it would be desirable to have per-frame source image references established:

  • The user provides spatial metadata (for example, but not limited to, in the case of passing a Volume) that differs from that in the source image only by permutation. This is a common scenario in the case of a volume because the frames of a volume may have been re-ordered by highdicom to match a given handedness (right handed in the default behaviour) but the source images may have been recorded within the source image/series with a different convention
  • The user provides spatial metadata that differs very slightly from that in the source image due to the accumulation of small numerical errors during processing. This is often the case with volumes, where the spatial metadata is re-computed from the volume's affine matrix, typically leading to very small changes

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.

@CPBridge CPBridge added the enhancement New feature or request label Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0