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

fix: Annotations showing up on incorrect images #1460

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

plt-joey
Copy link

Context

Fixes issue described here: #1455

Changes & Results

Modified the image URI check in the isReferenceViewable function in StackViewport from an endsWith match to an exact match. This stops annotations on images with IDs like dicom:126 (which is the format used by the wadoURI filemanager) from displaying on the images dicom:26 and dicom:6 as well.

Testing

The repro provided in the linked issue demonstrates the bug, replacing the UMD build of @cornerstonejs/core with one containing this change will fix the bug.

Checklist

PR

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

Code

Public Documentation Updates

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

Tested Environment

  • "OS: Windows 11"
  • "Node version: 18.12.1"
  • "Browser: Chrome 128.0.6613.120"

Copy link

netlify bot commented Sep 10, 2024

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit b1c78ca
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/672299a401b7680008b34133
😎 Deploy Preview https://deploy-preview-1460--cornerstone-3d-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.

const endsWith = referencedImageId?.endsWith(imageURI);
if (endsWith) {
return endsWith;
const referenceColonIndex = referencedImageId.indexOf(':');
Copy link
Member

Choose a reason for hiding this comment

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

can you use this one packages/core/src/utilities/imageIdToURI.ts

Copy link
Author

Choose a reason for hiding this comment

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

Sure can, updated this check as well as the check above it (and fixed some redundancy there)

@plt-joey plt-joey force-pushed the fix/annotationsOnIncorrectImages branch from 12e5cc8 to c7c51fe Compare October 30, 2024 16:19
if (endsWith) {
return endsWith;
imageURI = imageIdToURI(referencedImageId);
return true;
Copy link
Member

Choose a reason for hiding this comment

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

why return true here? I don't understand

Copy link
Author

Choose a reason for hiding this comment

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

just removes a redundant check

before when it looked like:

if (!imageURI) {
    imageURI = imageIdToURI(referencedImageId);
}

if (imageIdToURI(referencedImageId) === imageURI) {
    return true;
}

if the first if (!imageURI) was true then the second would always be true, so simplifying it to

if (!imageURI) {
    imageURI = imageIdToURI(referencedImageId);
    return true;
} else if (imageIdToURI(referencedImageId) === imageURI) {
    return true;
}

saves a call to imageIdToURI(referencedImageId) and an extra equivalency check

Copy link
Member

Choose a reason for hiding this comment

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

can you do this instead

const { imageURI } = options;
  
  // Direct URI match check
  const currentImageURI = imageIdToURI(referencedImageId);
  if (!imageURI || currentImageURI === imageURI) {
    return true;
  }

Copy link
Author

Choose a reason for hiding this comment

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

updated to use that instead

Copy link
Member

@sedghi sedghi left a comment

Choose a reason for hiding this comment

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

Thanks for your PR and patience

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.

2 participants