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

Allow segmentations of images without a frame of reference UID #183

Merged
merged 9 commits into from
Jul 11, 2022

Conversation

CPBridge
Copy link
Collaborator

@CPBridge CPBridge commented Jul 9, 2022

Addresses #159

Following the discussion and extremely useful input from @fedorov and @dclunie on #159 this PR generalizes the Segmentation class to allow it to encode segmentations of source images that do not have frame of reference UIDs, such as projection radiography images.

There were two major changes required to make this possible.
(1) Prevent the inclusion of PixelMeasuresSequence, PlanePositionSequence/PlanePositionSlideSequence and PlaneOrientationSequence when the source images have no frame of reference within which these values could be defined.
(2) Alter the dimension indexing mechanism in the case of no frame of reference.

The chosen approach for (2) is to allow only input series or multiframe images with a single instance/frame, and use a single dimension index value: Segment Number. This is a little limited but I imagine will cover the vast majority of use cases. Generalizing beyond this in the future (using mechanisms suggested by @dclunie in #159) may be possible but would dramatically increase complexity. Note that it does allow multiple segments of the (single) input image.

I have tested this with the test file kindly provided by @KarolBorkowski (who originally opened #159) and run the output through dciodvfy. This seems to work fine, apart from some compliance issues with the original file (notably I had to change the PatientSex in the source image file from 'U' to 'O', since 'U' is not a defined value for this attribute and highdicom raises an error as a result). I also tested on a CR image from the pydicom testfiles and that also seems to be working fine.

Any feedback from @KarolBorkowski would also be gratefully received.

@CPBridge CPBridge requested a review from hackermd July 9, 2022 19:25
@CPBridge CPBridge added the enhancement New feature or request label Jul 9, 2022
Copy link
Collaborator

@hackermd hackermd left a comment

Choose a reason for hiding this comment

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

Thanks @CPBridge! This looks great. It turned out to be much more challenging than initially anticipated. I only have one very minor suggestion.

src/highdicom/seg/sop.py Show resolved Hide resolved
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.

2 participants