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: Annotation and Measurements support on multi-frame DICOM #2973

Merged
merged 23 commits into from
Oct 13, 2022

Conversation

md-prog
Copy link
Contributor

@md-prog md-prog commented Oct 4, 2022

OHIFv3 lacks the support of annotations and measurements on multi-frame DICOM files particularly when we want to persist and load Measurement SRs on multi-frame DICOM files.

There are several issues being resolved in this PR:

  • Supporting of annotations and measurements on multi-frame files
  • Saving Measurement SRs on multi-frame DICOM files
  • Fixed loading of frames of multi-frame DICOM files : it was not loading the last frame ( loading Frame 1 twice, and not loading the last frame) , as you can guess, it was related to indexing of frames. Frame numbers are 1-based, not 0-based.
  • Fix jumping to the selected measurement/annotation on multi-frame files
  • Show correct instance id and frame number on the "Measurement Tracking" panel
  • Fixed a few "React" errors that was causing error logs in the browser console.

External dependencies:
This depends on the changes of dcmjs library: dcmjs-org/dcmjs#317
The changes has been merged and available on version 0.28.1, therefore updated the package.json for dcmjs library.

@netlify
Copy link

netlify bot commented Oct 4, 2022

Deploy Preview for ohif-platform-docs canceled.

Name Link
🔨 Latest commit 566ba8c
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/63407db027379600090a103a

@netlify
Copy link

netlify bot commented Oct 4, 2022

Deploy Preview for ohif-platform-viewer canceled.

Name Link
🔨 Latest commit 566ba8c
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-viewer/deploys/63407db06d104d0008e0a2b7

@codecov
Copy link

codecov bot commented Oct 4, 2022

Codecov Report

Merging #2973 (566ba8c) into v3-stable (9f1e813) will increase coverage by 12.38%.
The diff coverage is n/a.

Impacted file tree graph

@@              Coverage Diff               @@
##           v3-stable    #2973       +/-   ##
==============================================
+ Coverage      25.15%   37.54%   +12.38%     
==============================================
  Files            119      101       -18     
  Lines           2862     2152      -710     
  Branches         555      439      -116     
==============================================
+ Hits             720      808       +88     
+ Misses          1856     1101      -755     
+ Partials         286      243       -43     
Impacted Files Coverage Δ
...tform/core/src/services/CineService/CineService.js 12.50% <0.00%> (-6.25%) ⬇️
.../services/MeasurementService/MeasurementService.js 47.23% <0.00%> (-1.96%) ⬇️
platform/core/src/classes/CommandsManager.js 90.69% <0.00%> (-1.14%) ⬇️
platform/core/src/classes/MetadataProvider.js 4.54% <0.00%> (-0.72%) ⬇️
...core/src/services/ToolBarService/ToolBarService.js 1.36% <0.00%> (-0.13%) ⬇️
platform/viewer/src/index.js 0.00% <0.00%> (ø)
platform/viewer/src/appInit.js 0.00% <0.00%> (ø)
platform/core/src/utils/index.js 100.00% <0.00%> (ø)
platform/core/src/utils/isImage.js 100.00% <0.00%> (ø)
platform/core/src/services/ServicesManager.js 100.00% <0.00%> (ø)
... and 48 more

Continue to review full report at Codecov.

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

@fedorov
Copy link
Member

fedorov commented Oct 5, 2022

Do you have sample objects produced by the code proposed in this PR that would illustrate supporting of annotations and measurements on multi-frame files and saving Measurement SRs on multi-frame DICOM files?

@wayfarer3130
Copy link
Contributor

@md-prog - a few small changes, then it looks good to me.
@sedghi - this fixes some important issues with multiframe and annotations. It does not fix volume annotations yet - that is something we still need to discuss how to handle properly.

as that doesn't assume anything about the layout/design and just gets next until done.
…an array that happens to have attributes of child zero when of length 1, but you shouldn't count on that.
…rameNumber parameter for future usage : now they are just ignored as we are not supporting multiframe splits
@sedghi sedghi changed the title Multi-frame DICOM support feat: multi-frame DICOM support Oct 7, 2022
@@ -61,6 +68,7 @@ export default function addMeasurement(
TrackingUniqueIdentifier: measurementData.TrackingUniqueIdentifier,
renderableData: measurementData.renderableData,
},
frameNumber: frameNumber,
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 not stick the frameNumber here, it is not a data per se. can't we just infer it from the referencedImageId? seeing if it has frames/... at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to conform with the changes we've made to dcmjs - cornerstone3D adapter: dcmjs-org/dcmjs#317

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 @md-prog this is a great PR.

I put couple of comments above. There are couple of other issues

  1. When I try it locally it is not able to hydrate the SR for multiframe. It can draw and jump, but saving and hydration just puts everything ins the first slice (instance).
    To reproduce: open a multiframe study (I opened the brain MRI you gave me), draw length on two separate slices. Save report (to generate SR). 1) At this time the cornerstone viewport is unmounted and SR viewport mounts, which uses the SRDisplayTool (not hydrated yet), and as you see below it does not work 2) You can click on the -> to hydrate (or alternatively you can refresh the page and drag and drop SR and -> to hydrate), and that does not work either (don't have screenshot for it (but the same issue)

image

  1. This might not be the issue in your PR but noticed the modalities are coming back as OT (Other) for some of the multiframes. Also the number of instances it says 1 (which is technically the case), but I guess we can show the number of frames here alternatively for the multiframe

image

@md-prog
Copy link
Contributor Author

md-prog commented Oct 7, 2022

@sedghi, the issue No.1 mentioned in your last comment is related to dcmjs library's "lack of features" (if not defect).

dcmjs-org/dcmjs#318

Basically, the lines of dcmjs library mentioned in above Github issue, are blocking us to save the annotations made on to the multi-frame file with the correct frame number information.

With this issue resolved, the issue should go. (During my development, I had to temporarily use the locally cloned dcmjs with the temporary fix to the issue.)

Fix has been proposed in dcmjs-org/dcmjs#320

No.2 is not a new thing, I think.

@md-prog md-prog changed the title feat: multi-frame DICOM support feat: Annotation and Measurements support on multi-frame DICOM Oct 13, 2022
@sedghi sedghi merged commit b93067b into OHIF:v3-stable Oct 13, 2022
m00n620 added a commit to new-lantern/nl-ohif that referenced this pull request Oct 14, 2022
…2973) (#79)

* added utilities to get frameNumber from imageId and add frameNumber to per-frame instance copy

* Fix measurements' display texts on the Measurements Panel to have the correct instance number and frame number

* fixed minor React bugs (errors on console)

* fixed React's console bugs that are logged for some series that doesn't have "description"

* bug fix - multi-frame files was not loading frames correctly. It was loading Frame 1 twice, and not loading the last frame. Due to wrong frame number indexing (frame number begins with 1, not 0)

* metadata parser fix - providing default values of imagePlaneModule

* measurement SR support on multi-frame DICOM

* bug fix - jumping to the selected measurment on multi-frame DICOM

* upgrade dcmjs dependency to 2.8.1

* StudySummary component - allow "description" to be null

* make getUIDsFromImageID() method public from MetadataProvider

* imageId usage fixes to be more stable

* change the variable name to be more meaningful

* fix metaProvider importing

* for(...of) instead of for(i=0;i<length;..)
as that doesn't assume anything about the layout/design and just gets next until done.

* use Array.findIndex instead of plain for loop

* use ReferencedSOPSequence[0] - because the ReferencedSOPSequence is an array that happens to have attributes of child zero when of length 1, but you shouldn't count on that.

* DisplaySetService.getDisplaySetForSOPInstanceUID() - added optional frameNumber parameter for future usage : now they are just ignored as we are not supporting multiframe splits

* simple code refactoring

* refactoring for checking undefined values - mappedAnnotations

* remove unreachable code

* code refactoring  - prefer conditional chaining

* fix how we access imageIds of viewport (StackViewport)

Co-authored-by: md-prog <[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.

4 participants