Skip to content
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

Fallback to shared groups on missing per frame tag #632

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

TidalPaladin
Copy link

Some DICOMs provide tags under SharedFunctionalGroupsSequence that are not present under PerFrameFunctionalGroupsSequence. In such cases, getter functions like window_width() will return an empty vector rather than falling back to a check on SharedFunctionalGroupsSequence. Thus a guard is needed so that when PerFrameFunctionalGroupsSequence exists but does not contain the target tag, a fallback check on SharedFunctionalGroupsSequence will happen.

This PR implements such a guard by modifying get_from_per_frame() and get_from_shared() such that empty iterator returns are instead mapped to None. The existing logic of the getter functions will then fall back to a shared check.

@TidalPaladin TidalPaladin changed the title Get from empty guard Fallback to shared groups on missing per frame tag Feb 2, 2025
@TidalPaladin TidalPaladin marked this pull request as ready for review February 2, 2025 15:16
@Enet4 Enet4 self-requested a review February 3, 2025 16:04
@Enet4 Enet4 added A-lib Area: library C-pixeldata Crate: dicom-pixeldata labels Feb 3, 2025
Copy link
Owner

@Enet4 Enet4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this! Just leaving a minor suggestion inline and should be ready to merge.

Comment on lines +772 to +778
(
tags::SHARED_FUNCTIONAL_GROUPS_SEQUENCE,
0,
tags::PIXEL_VALUE_TRANSFORMATION_SEQUENCE,
0,
tags::RESCALE_INTERCEPT,
),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an impl of From<(Tag, Tag, Tag)> for attribute selectors, so this should work too.

Suggested change
(
tags::SHARED_FUNCTIONAL_GROUPS_SEQUENCE,
0,
tags::PIXEL_VALUE_TRANSFORMATION_SEQUENCE,
0,
tags::RESCALE_INTERCEPT,
),
(
tags::SHARED_FUNCTIONAL_GROUPS_SEQUENCE,
tags::PIXEL_VALUE_TRANSFORMATION_SEQUENCE,
tags::RESCALE_INTERCEPT,
),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lib Area: library C-pixeldata Crate: dicom-pixeldata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants