View in #cornerstone3d on Slack
@Andy: i’m trying to give some hard coded metadata for jpeg xrays, and set rowPixelSpacing and columnPixelSpacing to null, but when I call get units by calling getCalibratedLengthUnitsAndScale, i still get mm units. Any thoughts on why that is the case?
as context I would like to be able to call something to fall back to px units if it is an uncalibrated jpeg xray, and fall back to mm units if it is a calibrated dicom image and using its calibration metadata
@Alireza_Sedghi: are you adding them to the packages/core/src/utilities/calibratedPixelSpacingMetadataProvider.ts
@Andy: I tried to add null to it, but it doesn’t change the unit
@Alireza_Sedghi: see this example
packages/tools/examples/calibrationTools/index.ts
https://www.cornerstonejs.org/docs/tutorials/examples
Examples | Cornerstone.js
@Peter_Newhook: I’ve been working with Andy on this.
We have a WebImageMetadataLoader based on https://github.com/cornerstonejs/cornerstone3D/blob/8fe548248197e61fba869257fdebdd33714e42f8/packages/core/examples/webLoader/hardcodedMetaDataProvider.ts
For the imagePlaneModule
we have the following metadata, notice the lack of pixelSpacing
, rowPixelSpacing
, or columnPixelSpacing
. Based on the example you linked to, we assumed this would lead to the image being considered uncalibrated and measurements would be given in pixels. However, we were still getting measurements in mm and a scale of 1.
{
columnCosines: [0, 1, 0],
columns: 2048,
frameOfReferenceUID: imageId,
imageOrientationPatient: [1, 0, 0, 0, 1, 0],
imagePositionPatient: [0, 0, 0],
rowCosines: [1, 0, 0],
rows: 1216,
}
Andy found that adding usingDefaultValues: true
to our metadata provider gives us the expected behaviour when pixelSpacing
is missing.
Digging into the example above, I think what’s happening in the example is the DICOM file is being loaded by the Cornerstone DICOM image loader, which sets usingDefaultValues
to true based on DICOM metadata. Then if the user selects “px units” in the calibration example, it overrides the pixel spacing, but leaves usingDefaultValues
to true.
usingDefaultValues
looks like an undocumented part of the API, is it safe to set that field?
@Alireza_Sedghi: > Andy found that adding usingDefaultValues: true
to our metadata provider gives us the expected behaviour when pixelSpacing
is missing.
I think you are right, the metadata provider needs to specify if it is defaulting or it is the original value. Would you mind creating a PR for us to add this to the web image metadata provider?
It is undocumented yes
@Peter_Newhook: Here’s a little MR https://github.com/cornerstonejs/cornerstone3D/pull/1771
@Alireza_Sedghi: Thanks!