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

feat(ImageOverlayViewerTool) - add ImageOverlayViewer tool that can render image overlay (pixel overlay) of the DICOM images #3163

Merged
merged 17 commits into from
Sep 6, 2023

Conversation

md-prog
Copy link
Contributor

@md-prog md-prog commented Feb 10, 2023

Context

DICOM images can have Overlay Plane and this overlay can be one of two types: "G" for graphics, and "R" for "ROI".
We want to be able to render "G" type overlays: image overlays or pixel overlays, over the DICOM image.

Changes & Results

  • Add new tool ImageOverlayViewerTool to @ohif/extension-cornerstone extension
  • Add commands to "toggle" the image overlays

image

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 10
  • Node version: 16.15.0
  • Browser: Version 109.0.5414.121 (Official Build) (64-bit)

@netlify
Copy link

netlify bot commented Feb 10, 2023

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit f9a9029
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/64f78e7b005b6c0008579aa1
😎 Deploy Preview https://deploy-preview-3163--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.

@netlify
Copy link

netlify bot commented Feb 10, 2023

Deploy Preview for ohif-platform-viewer canceled.

Name Link
🔨 Latest commit 1d94630
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-viewer/deploys/6446f6d58cb4cd00086bbc65

@md-prog
Copy link
Contributor Author

md-prog commented Feb 10, 2023

@sedghi As I left into the code comment, we would need a new icon to enable the toggle button for image overlays on the toolbar.

@codecov
Copy link

codecov bot commented Feb 10, 2023

Codecov Report

Merging #3163 (f9a9029) into master (3ce7225) will not change coverage.
Report is 2 commits behind head on master.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3163   +/-   ##
=======================================
  Coverage   41.94%   41.94%           
=======================================
  Files          79       79           
  Lines        1421     1421           
  Branches      341      341           
=======================================
  Hits          596      596           
  Misses        658      658           
  Partials      167      167           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef58893...f9a9029. Read the comment docs.

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.

Great work.
See my minor comments. The major comment is to clean up all the cachedStats, canvases, svg nodes etc. that you create on destroy. Maybe this is something we need to add at cs3d level that when a toolGroup is destroyed each tool should run their own destroy as we see here it is storing a lot of state that will later cause memory leak IMO

@md-prog md-prog force-pushed the feat/image-overlay-coloring branch from c827fa7 to 6b1c305 Compare April 17, 2023 18:34
this._renderingViewport = viewport;

const imageId = this._getReferencedImageId(viewport);
if (!imageId) return;
Copy link
Member

Choose a reason for hiding this comment

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

please follow the new eslint rule -> no same line if statement

const imageId = this._getReferencedImageId(viewport);
if (!imageId) return;

const { overlays } = metaData.get('overlayPlaneModule', imageId);
Copy link
Member

Choose a reason for hiding this comment

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

we should cache this, as we hit this A LOT! so this.overlayCache.get(imageId) if not found grab from metadata and add it to the cache

const getCachedStat = async (
imageId: string,
overlayMetadata: any[],
color: number[] = [127, 127, 127, 255]
Copy link
Member

Choose a reason for hiding this comment

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

there is no need for default color here, as the configuration has a default

Comment on lines 93 to 96
if (
!cachedStats[imageId] ||
!isSameColor(cachedStats[imageId].color, color)
) {
Copy link
Member

Choose a reason for hiding this comment

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

I prefer less indentation. So can we early return on the opposite condition and make indentation one less?

Comment on lines 271 to 284
private _getReferencedImageId(
viewport: Types.IStackViewport | Types.IVolumeViewport
): string {
const targetId = this.getTargetId(viewport);

let referencedImageId;

if (viewport instanceof StackViewport) {
referencedImageId = targetId.split('imageId:')[1];
}

return referencedImageId;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think this is already implemented in either BaseAnnotationTool or AnnotationTool

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.

@jbocce Please see my comments

Joe Boccanfuso added 2 commits September 5, 2023 09:24
- added new icon for toggle DICOM overlay
- use new exported classes and functions from CS3D
- allow ToolbarService to initialize toggles
- setToolActive command now handles toggles
- reference lines tool and DICOM overlay tool use the setToolActive command
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.

one last iteration and we are done

@jbocce jbocce requested a review from sedghi September 5, 2023 20:24
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 taking care of this long awaiting PR Joe

@sedghi sedghi merged commit 69115da into OHIF:master Sep 6, 2023
8 of 9 checks passed
Sofien-Sellami pushed a commit to Sofien-Sellami/Viewers that referenced this pull request Oct 5, 2023
…nder image overlay (pixel overlay) of the DICOM images (OHIF#3163)

Co-authored-by: Joe Boccanfuso <[email protected]>
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.

3 participants