Description:
I’ve encountered an issue where Cornerstone insists on saving annotation points as Float32Array instead of regular arrays of numbers. This issue arose after changing the image loading process from cornerstoneWadoImageLoader to cornerstoneWebImageLoader so the Photometric Interpretation is RGB (I followed this code). Despite attempts to convert these arrays back to regular arrays, it continue to revert to Float32Array.
Code:
static getMeasurementData(
MeasurementGroup,
sopInstanceUIDToImageIdMap,
imageToWorldCoords,
metadata
) {
const { MeasurementReport } = dcmjs.adapters.Cornerstone3D;
const { defaultState, NUMGroup, SCOORDGroup, ReferencedFrameNumber } =
MeasurementReport.getSetupMeasurementData(
MeasurementGroup,
sopInstanceUIDToImageIdMap,
metadata,
LengthAdapter.toolType
);
const referencedImageId =
defaultState.annotation.metadata.referencedImageId;
const { GraphicData } = SCOORDGroup;
const worldCoords = [];
for (let i = 0; i < GraphicData.length; i += 2) {
const point = imageToWorldCoords(referencedImageId, [
GraphicData[i],
GraphicData[i + 1],
]);
worldCoords.push(point);
}
const state = defaultState;
state.annotation.data = {
handles: {
points: [...worldCoords],
activeHandleIndex: 0,
textBox: {
hasMoved: false,
},
},
cachedStats: {
[`imageId:${referencedImageId}`]: {
length: NUMGroup
? NUMGroup.MeasuredValueSequence?.[0]?.NumericValue
: 0,
unit: NUMGroup?.MeasuredValueSequence?.[0]
?.MeasurementUnitsCodeSequence?.[0]?.CodeValue,
color: NUMGroup?.ContentSequence?.[0]?.TextValue.split(":")[1],
},
},
frameNumber: ReferencedFrameNumber,
};
return state;
}
Observed Behavior:
state.annotation.data.handles.points
is logged as Float32Array in the console not regular array of numbers as worldCoords
Could you provide guidance on how to prevent Float32Array conversion when switching from MONOCHROME to RGB in DICOM images? & Thank you for your assistance!