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

Auto flipping of disoriented Mammography images on stack viewport #4353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Adithyan-Dinesh-Trenser

Context

The feature is designed to flip the images in the stack viewport, which are initially stored in a flipped orientation. The images are flipped upon loading and when the viewport is reset. It relies on ImageOrientationPatient or PatientOrientation, and ImageLaterality or FrameLaterality to identify the necessary flipping. Primarily, this feature is aimed at MG images that are stored in an incorrect orientation. It is capable of correcting images through vertical and/or horizontal flips, but it does not handle images requiring rotation for correction.

Changes & Results

The activation of the feature is handled through CustomizationService. A function that accepts the metadata instance and returns whether auto-flipping is needed or not is provided in the CustomizationService.

A sample customization

function getCustomizationModule() {
	return [
		{
			name: 'default',
			value: [
				{ id: 'orientationCorrectionCriterion', criteria: isOrientationCorrectionNeeded }
			]
		}
	]
}

A demo recording of the feature

Auto-flipping-OHIF-upstream-demo.mp4

Testing

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • OS: Windows 11 Pro
  • Node version: 18.17.0
  • Browser: Chrome 127.0.6533.120 (Official Build) (64-bit)

Copy link

netlify bot commented Aug 30, 2024

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit 7763d5b
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/66fe9447c982330008cfda32
😎 Deploy Preview https://deploy-preview-4353--ohif-platform-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 30, 2024

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit 7763d5b
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/66fe9447994f6a00090a8afe
😎 Deploy Preview https://deploy-preview-4353--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Adithyan-Dinesh-Trenser
Copy link
Author

Cc : @Ouwen

@Ouwen
Copy link
Contributor

Ouwen commented Aug 30, 2024

@sedghi let us know if there are changes needed to this PR. @Adithyan-Dinesh-Trenser i would rebase to master in the meantime

@sedghi
Copy link
Member

sedghi commented Aug 30, 2024

CC'ing @wayfarer3130 since he has worked on a lot of MG hanging protocols recently

@sedghi sedghi requested a review from wayfarer3130 August 30, 2024 14:21
@@ -643,6 +644,18 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi

return viewport.setStack(imageIds, initialImageIndexToUse).then(() => {
viewport.setProperties({ ...properties });

const { customizationService } = this.servicesManager.services;
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't really belong here - this is adding specific behaviour for certain types of images in certain cases. I would suggest adding it to the split/sort rules as part of generating the splitting criteria, and add it into the series level splitting for MG type series that have this issue. Then, the hanging protocol rules can choose to pickup those values for the orientation/position. That is a much more generic approach, and doesn't cause the viewport service to have deep knowledge about how to handle orientation changes.
You could also create a custom orientation/position metadata module as an alternative, and use that module in CS3D as the initial flip setup if it isn't currently set, but if so you need to change the viewport handling so that a viewport with flipHorizontal/flipVertical/initial rotation works correctly when you flip the viewport - that is, flipping the viewport should flip the images FROM the original location.

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact I think this should also be calculated in the hanging protocol service because the same orientation isn't always shown for hanging protocols, and those should still work correctly - that is, left on right or right on left should both be supported by the hanging protocol, and NOT the viewport. Even if you create a default rule and add it into the default hanging protocol, I think doing it there is a better choice, although getting default values in the split/sort rules to apply at hte series level makes that easy to apply in the hanging protocol.

Copy link
Contributor

Choose a reason for hiding this comment

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

What you should do is compute the desired default initial flip state in the display set object, and export it as a metadata instance and apply it here when it is set for the image id/display set uid. It should be applied as the base data, and then rotation/flip etc on TOP of that applies relative to the base rotation etc. That change could actually go into the CS3D library in the stack/volume viewports, or it can be done here as an integrated value. That way, the image "flip" isn't shown by default unless the flip is changed relative to the base flip/rotate state. That is a robust way to specify the values correctly.

@Adithyan-Dinesh-Trenser Adithyan-Dinesh-Trenser force-pushed the feat/auto-flipping-of-mammogram-images-on-stack-viewport branch from 16453c2 to c6ac613 Compare September 27, 2024 11:27
@Adithyan-Dinesh-Trenser Adithyan-Dinesh-Trenser force-pushed the feat/auto-flipping-of-mammogram-images-on-stack-viewport branch from c6ac613 to 7763d5b Compare October 3, 2024 12:55
@sedghi
Copy link
Member

sedghi commented Oct 17, 2024

@wayfarer3130
So what is the decision on this? Do we need it in OHIF upstream?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants