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(image loaders): Allow reusing DICOM image loader code for custom image loaders #1509

Merged
merged 6 commits into from
Oct 25, 2024

Conversation

sgielen
Copy link
Contributor

@sgielen sgielen commented Oct 22, 2024

NOTE: This PR is currently set to merge into the beta branch. We may want to await the merge of beta into main first and then merge this PR into main afterwards?

Context

This PR makes it easier to write DICOM-based custom image loaders that work with DICOM files, but do not use WADO-RS or WADO-URI directly. An example is added to show this functionality.

Relevant issues / PRs:

See also a partially related documentation PR: #1508

Changes & Results

  • The WADOURI metadata provider is now externally exposed. This allows any custom metadata provider based on DICOM files to expose its metadata to Cornerstone without duplicating its code.
    • There is a lot of duplication between the WADOURI and WADO-RS metadata providers - they all pull the same tags towards the same object fields in metadata providers. However, one pulls the tags from dicomParser and the other from a Record<string, any> and in the latter, the individual byte array and element references are not available. This difference makes it nontrivial to generalize well, but I still think there is some value there.
  • The WADOURI pixel provider is also externally exposed. This allows any custom image loader based on DICOM files to retrieve pixel data and create Cornerstone image loading objects.
  • I've added an example custom image loader that uses both components to load DICOM files as ByteArrays from other sources (e.g. a caching layer, websockets, etc) and displays them as individual stack images, stack volumes or actual volumes.

There are some open points:

Testing

Run the new example DICOM custom image loader. Drag and drop slices into the image drop area, and click them to display.

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.

See #1508

Tested Environment

  • OS: macOS 15
  • Node version: v22.8
  • Browser: Chrome 129, Safari 18

It allows dropping instances or series into an image drop area, and loading the
DICOMs from there.

The current version fails, because it tries to load the DICOMs as browser image
objects. Instead, it should use the DICOM parsing from the dicomImageLoader.
This isn't exposed yet, at the moment, which is the next thing I'm going to
address.
…ge loader.

The two parts of the DICOM Image Loader our custom image loader has to use are:

- Convert a dicomParser.DataSet to a Cornerstone image object
- Convert a dicomParser.DataSet to metadata as requested by Cornerstone (among
  others)

I'm not too happy with the tight coupling we have yet, but at least this shows
basic functionality and provides an idea to the design changes necessary to
prevent tight coupling.
…ssible.

Also some small cosmetic improvements to the example.
Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for cornerstone-3d-docs failed. Why did it fail? →

Name Link
🔨 Latest commit b631614
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/6717a960523ef00008d4fa87

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.

These are all great examples, thanks a lot!

@sedghi sedghi merged commit f670229 into cornerstonejs:beta Oct 25, 2024
2 of 10 checks passed
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