Viewers icon indicating copy to clipboard operation
Viewers copied to clipboard

feat: add support to scoord3d

Open pedrokohler opened this issue 11 months ago • 5 comments

Context

TID.300 measurements can now be defined using either 2D or 3D points with the latest cs3d changes. This is controlled by the use of either SCOORD (2D) or SCOORD3D (3D) in the Measurement Value Sequence, as described in the TID.320 section of TID.300:
🔗 DICOM TID.320 Reference

TID.1501 defines the reference information for the SCOORD3D points: 🔗 DICOM TID.1501 Reference

This pull request introduces support for selecting between SCOORD and SCOORD3D encodings in several TID.300 measurement types, including:

  • Length
  • Bidirectional
  • Cobb Angle
  • Ellipse

Changes & Results

It's now possible to save and load SRs with annotations that were drawn on reconstructed views:

https://github.com/user-attachments/assets/b296d0a9-e3c8-406c-9b3b-19022cee67da

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:
  • [] Node version:
  • [] Browser:

pedrokohler avatar May 06 '25 12:05 pedrokohler

Deploy Preview for ohif-dev ready!

Name Link
Latest commit 5571b27ca4deb54205d42bfedf5becfeeda7ad9e
Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/6819fc61a466b70008f9d555
Deploy Preview https://deploy-preview-5016--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.

netlify[bot] avatar May 06 '25 12:05 netlify[bot]

Deploy Preview for ohif-dev canceled.

Name Link
Latest commit dd99a70eacffe50bb059a2eec188aca08c6171f6
Latest deploy log https://app.netlify.com/projects/ohif-dev/deploys/688aed362f624b00081bbd4e

netlify[bot] avatar May 06 '25 12:05 netlify[bot]

@pedrokohler, please try these changes with the IDC point dataset; otherwise, it this will break their scoord3d point support.

igoroctaviano avatar May 06 '25 19:05 igoroctaviano

@pedrokohler, please try these changes with the IDC point dataset; otherwise, it this will break their scoord3d point support.

I reintroduced the toolName assignment when there is no adapter for the trackingIdentifier. This way the feature is preserved:

image

pedrokohler avatar May 07 '25 12:05 pedrokohler

@pedrokohler @igoroctaviano is this added/supported by idc?

sedghi avatar Jun 07 '25 18:06 sedghi

@pedrokohler @igoroctaviano is this added/supported by idc?

I'd say this PR started because of FUBerlin, but now IDC is also supporting it.

pedrokohler avatar Jul 02 '25 11:07 pedrokohler

@pedrokohler @igoroctaviano is this added/supported by idc?

I'd say this PR started because of FUBerlin, but now IDC is also supporting it.

@pedrokohler sure, we need a test either way

sedghi avatar Jul 02 '25 12:07 sedghi

@sedghi - the save/load are both working, just there are some issues displaying annotations after load and jumping to them. Hope to finish that up early next week

wayfarer3130 avatar Jul 11 '25 21:07 wayfarer3130

@sedghi - this PR uses the CS3D SCOORD3D PR to allow navigating between 3d and 2d points.
I changed the jump to measurement quite a lot as it was broken, but the code is much more contained inside the cornerstone extension, and is a lot easier to understand now. Basically it tries to find a viewport to navigate to the view containing the image, otherwise it chooses a viewport to change to the updated display set and/or view position.
It works with Video, SM, Stack, orthographic Saving and loading both work now, and loading points displays them correctly. @pedrokohler - could you update the PR to be read for review?

wayfarer3130 avatar Jul 15 '25 20:07 wayfarer3130

@wayfarer3130 it's already 'ready for review'

pedrokohler avatar Jul 15 '25 20:07 pedrokohler

Hey @wayfarer3130 and @pedrokohler , I am sure you guys are still working on this PR, but I had a quick look at the failing playwright tests for you and it appears different images are loading in various scenarios than before. Please have a look, ensure that the correct image is being displayed now and if so create new screenshots. Thanks.

jbocce avatar Jul 16 '25 12:07 jbocce

Hey @wayfarer3130 and @pedrokohler , I am sure you guys are still working on this PR, but I had a quick look at the failing playwright tests for you and it appears different images are loading in various scenarios than before. Please have a look, ensure that the correct image is being displayed now and if so create new screenshots. Thanks.

Thanks for looking at that Joe - I will figure out why it is navigating incorrectly. Might add a new test for the MPR navigation as well since that seems to be broken

wayfarer3130 avatar Jul 17 '25 14:07 wayfarer3130

When do you think you can have a ready PR for review? please include test dicom studies as well

sedghi avatar Jul 21 '25 14:07 sedghi

@sedghi - this PR is ready for review other than needing the navigation images updated

wayfarer3130 avatar Jul 21 '25 17:07 wayfarer3130

@pedrokohler @wayfarer3130 can you update the Testing section on the PR with proper steps to test, and also dicom files

sedghi avatar Jul 21 '25 17:07 sedghi

Viewers    Run #5451

Run Properties:  status check passed Passed #5451  •  git commit 7900cf1ff0: Merge remote-tracking branch 'origin/master' into feat-add-support-to-scoord3d
Project Viewers
Branch Review feat-add-support-to-scoord3d
Run status status check passed Passed #5451
Run duration 02m 28s
Commit git commit 7900cf1ff0: Merge remote-tracking branch 'origin/master' into feat-add-support-to-scoord3d
Committer Joe Boccanfuso
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 37
View all changes introduced in this branch ↗︎

cypress[bot] avatar Jul 28 '25 16:07 cypress[bot]

Going through the steps for testing. Note my testing environment...

OS: Windows 11 Browser: Google Chrome 138.0.7204.169 Node: 23.9.0 Data source: orthanc

jbocce avatar Jul 29 '25 17:07 jbocce

When rehydrating the generated report, several annotation geometries and/or text/label/measurement info are missing or are not as expected. In master the geometry and text were as expected. Rectangle…

Actual: image

Expected: image

Angle… image

Probe… image

I also noticed that the spline and livewire annotations did NOT save. However, this is consistent with master.

jbocce avatar Jul 29 '25 17:07 jbocce

The testing has been paused because several attempts to get passed step 4 of the testing instructions listed in the PR description.

The testing could not proceed past step 4 because during step 4 (i.e. adding and saving annotations on MPR) the following exception was thrown several times. The app would crash and the browser window was completely black.

Error: getDisplaySetByUID: displaySetInstanceUid must be a string, you passed undefined
    at DisplaySetService.getDisplaySetByUID (index.js:9025:19)
    at getItemStudyInstanceUID (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5177:46)
    at http://localhost:3000/static/js/async/extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5182:26
    at Array.forEach (<anonymous>)
    at Object.groupByStudy [as groupingFunction] (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5181:11)
    at AccordionGroup (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:2262:29)
    at renderWithHooks (lib-react.js:15842:18)
    at mountIndeterminateComponent (lib-react.js:20454:13)
    at beginWork (lib-react.js:21977:16)
    at beginWork$1 (lib-react.js:27816:14)

jbocce avatar Jul 30 '25 00:07 jbocce

I also got this exception when navigating to the cobb angle using the arrow buttons in the top-right of the viewport…

TypeError: Cannot read properties of undefined (reading 'canvas')
    at CobbAngleTool.renderAnnotation (vendors-node_modules_cornerstonejs_ai_dist_esm_index_js-node_modules_cornerstonejs_core_dist_-e01bb2.js:31105:102)
    at handleDrawSvg (vendors-node_modules_cornerstonejs_tools_dist_esm_utilities_contourSegmentation_addContourSeg-671368.js:198:43)
    at Array.forEach (<anonymous>)
    at http://localhost:3000/static/js/async/vendors-node_modules_cornerstonejs_tools_dist_esm_utilities_contourSegmentation_addContourSeg-671368.js:202:26
    at draw (vendors-node_modules_cornerstonejs_tools_dist_esm_utilities_contourSegmentation_addContourSeg-671368.js:12:5)
    at AnnotationRenderingEngine._triggerRender (vendors-node_modules_cornerstonejs_tools_dist_esm_utilities_contourSegmentation_addContourSeg-671368.js:194:64)
    at AnnotationRenderingEngine._renderFlaggedViewports (vendors-node_modules_cornerstonejs_tools_dist_esm_ut

jbocce avatar Jul 30 '25 00:07 jbocce

The testing has been paused because several attempts to get passed step 4 of the testing instructions listed in the PR description.

The testing could not proceed past step 4 because during step 4 (i.e. adding and saving annotations on MPR) the following exception was thrown several times. The app would crash and the browser window was completely black.

Error: getDisplaySetByUID: displaySetInstanceUid must be a string, you passed undefined
    at DisplaySetService.getDisplaySetByUID (index.js:9025:19)
    at getItemStudyInstanceUID (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5177:46)
    at http://localhost:3000/static/js/async/extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5182:26
    at Array.forEach (<anonymous>)
    at Object.groupByStudy [as groupingFunction] (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:5181:11)
    at AccordionGroup (extensions_cornerstone_src_components_NavigationComponent_NavigationComponent_tsx-extensions_-535d7c.js:2262:29)
    at renderWithHooks (lib-react.js:15842:18)
    at mountIndeterminateComponent (lib-react.js:20454:13)
    at beginWork (lib-react.js:21977:16)
    at beginWork$1 (lib-react.js:27816:14)

The items without display set instance uids should be filtered out now.

wayfarer3130 avatar Jul 30 '25 01:07 wayfarer3130

When linked with https://github.com/cornerstonejs/cornerstone3D/pull/2233 and updated, this should have a number of issues fixed.

wayfarer3130 avatar Jul 30 '25 01:07 wayfarer3130

Here is a video that best shows the problems encountered with annotations in MPR. The video starts by showing where each annotation is located in each view. The browser is then refreshed, the SR hydrated, MPR launched and then the measurement side panel is used to navigate to each markup one-by-one. In general one of the following typically occurs...

  • the view is NOT navigated
  • the annotation appears on the current image (or a different image) and NOT on the correct image
  • an annotation different than the one clicked appears - typically on the wrong image and/or location
  • the annotation appears on the correct image but in the wrong location

To obtain the behaviour in the video...

  1. Add each annotation seen in the video to the images seen in the video.
  2. Save the SR
  3. refresh the browser
  4. Hydrate the saved SR
  5. Click each markup one-by-one in the side panel
  6. Notice the weirdness

https://github.com/user-attachments/assets/8651fd6f-f71c-40a3-92a5-93abdc098aef

jbocce avatar Jul 30 '25 23:07 jbocce

I tested everything in https://github.com/OHIF/Viewers/pull/5016#issuecomment-3138140465 it works fine after the changes i made, i will merge after tests passes

sedghi avatar Jul 31 '25 04:07 sedghi