cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
571 stars 291 forks source link

[Bug] Colorspace incorrect with color spectral doppler image #792

Open joeshao1 opened 1 year ago

joeshao1 commented 1 year ago

Describe the Bug

Very similar to https://github.com/cornerstonejs/cornerstone3D/pull/730. We have an ultrasound image (spectral color doppler) that is a single frame, SOP Class UID == 1.2.840.10008.5.1.4.1.1.6.1. When loading the image using cornerstoneDicomImageLoader and the corresponding image metadata, the image looks mostly correct except that the color is off; most obviously, black maps to a somewhat teal color. According to the fix mentioned above, color conversion is only performed on a few types of transferSyntax types. Our image has a transfer syntax of jpeg lossless, 1.2.840.10008.1.2.4.70. As a naive fix, I simply added our transfer syntax uid to the map. This resulted in at least the color conversion performing, however our image has what seems to be an incorrect planarConfiguration of 1 (according to the dicom standard https://dicom.nema.org/medical/Dicom/2018d/output/chtml/part03/sect_C.8.5.6.html#sect_C.8.5.6.1.16) while our photometricInterpretation == YBR_FULL. If I force the planarConfiguration to 0 by tampering with our own metadataProvider, our image is displayed properly.

I am not an expert at dicom so I was hoping to defer to the cornerstone team to determine how best to proceed with a fix given the above scenario.

Our dicom images are private so I am working with our regulatory team to find out how we can get an anonymized sample image for you to test with.

Steps to Reproduce

Using the setup for cornerstoneDicomImageLoader. This includes using our own simple metadataProvider that we populate with values manually copied over from the dicom file (includes photometricInterpretation, planarConfiguration, samplesPerPixel, etc). Following https://docs.cornerstonejs.org/concepts/metadata-providers.html.

Use the renderingEngine to setStack to a single imageID (the wadors URL to our dicomstore).

Create a simple div to host the viewport.render() call.

The current behavior

Image shows discolored (black seems to map to a teal). Exactly what was seen in https://user-images.githubusercontent.com/7490180/259408941-e35519f7-60b8-4680-9096-f4e5d590ed52.png from the pull request mentioned in the description.

The expected behavior

Spectral color doppler image should be mostly black

OS

Debian GNU/Linux

Node version

v18.13.0

Browser

Chrome Version 117.0.5938.62 (Official Build) (64-bit)

sedghi commented 1 year ago

Can you share anonymized data?

joeshao1 commented 1 year ago

I'm still in talks with our regulatory team to see what we can release