Describe the Bug
Hi, I'm trying to display DTI FA (Fractional Anisotropy) DICOM images using StackViewport, but the viewport shows only black. These images display correctly in other viewers like RadiAnt.
After debugging, I noticed that all pixel values become 0 after image loading.
getPixelDataTypeFromMinMax selects Uint8Array for float-scaled data
During preScale in decodeImageFrameWorker.js, _handlePreScaleSetup computes the scaled min/max:
scaledMin = 0 * 0.001 = 0.0
scaledMax = 1000 * 0.001 = 1.0
Then getPixelDataTypeFromMinMax(0.0, 1.0) runs:
if (Number.isInteger(min) && Number.isInteger(max)) { // Number.isInteger(0.0) → true,
Number.isInteger(1.0) → true
if (max <= 255) {
pixelDataType = Uint8Array; // ← chosen here
}
}
Since JavaScript treats 0.0 and 1.0 as integers, Uint8Array is selected. But the actual pixel values after rescaling are floats like 0.013, 0.5 0.999 — these all truncate to 0 in Uint8Array.
The legacy Cornerstone had a similar float RescaleSlope issue: cornerstonejs/cornerstone#302
I may be wrong about some of the details above — please correct me if I've misunderstood anything. Any guidance would be greatly appreciated. Thank you!
Steps to Reproduce
This is the dicom info I tried to use:
Modality: MR
BitsAllocated / BitsStored: 16 / 12
Raw pixel range: 0 – 1000
RescaleSlope: 0.001
RescaleIntercept: 0.0
WindowCenter / WindowWidth: 0.5 / 1.0
The current behavior
The expected behavior
I want to show MRI fa dicom with floating rescaleSlope just like other usual dicom.
System Information
I used version below:
"@cornerstonejs/core": "^4.15.33",
"@cornerstonejs/dicom-image-loader": "^4.15.33",
"@cornerstonejs/nifti-volume-loader": "^4.15.33",
"@cornerstonejs/tools": "^4.15.33",
Describe the Bug
Hi, I'm trying to display DTI FA (Fractional Anisotropy) DICOM images using StackViewport, but the viewport shows only black. These images display correctly in other viewers like RadiAnt.
After debugging, I noticed that all pixel values become 0 after image loading.
getPixelDataTypeFromMinMax selects Uint8Array for float-scaled data
During preScale in decodeImageFrameWorker.js, _handlePreScaleSetup computes the scaled min/max:
scaledMin = 0 * 0.001 = 0.0
scaledMax = 1000 * 0.001 = 1.0
Then getPixelDataTypeFromMinMax(0.0, 1.0) runs:
Since JavaScript treats 0.0 and 1.0 as integers, Uint8Array is selected. But the actual pixel values after rescaling are floats like 0.013, 0.5 0.999 — these all truncate to 0 in Uint8Array.
The legacy Cornerstone had a similar float RescaleSlope issue: cornerstonejs/cornerstone#302
I may be wrong about some of the details above — please correct me if I've misunderstood anything. Any guidance would be greatly appreciated. Thank you!
Steps to Reproduce
This is the dicom info I tried to use:
Modality: MR
BitsAllocated / BitsStored: 16 / 12
Raw pixel range: 0 – 1000
RescaleSlope: 0.001
RescaleIntercept: 0.0
WindowCenter / WindowWidth: 0.5 / 1.0
The current behavior
The expected behavior
I want to show MRI fa dicom with floating rescaleSlope just like other usual dicom.
System Information
I used version below:
"@cornerstonejs/core": "^4.15.33",
"@cornerstonejs/dicom-image-loader": "^4.15.33",
"@cornerstonejs/nifti-volume-loader": "^4.15.33",
"@cornerstonejs/tools": "^4.15.33",