fix(dicom overlay): Handle special cases of ArrayBuffer for various DICOM overlay attributes. (#3684)
Co-authored-by: Alireza <ar.sedghi@gmail.com>
This commit is contained in:
1 parent
8a335bd03d
commit
e36a604331
5 files changed
+97
-55
No files matched your search
@@ -68,7 +68,7 @@ class MetadataProvider {
|
||||
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return (frameNumber && combineFrameInstance(frameNumber, instance)) || instance;
|
||||
}
|
||||
@@ -118,16 +118,15 @@ class MetadataProvider {
|
||||
* Adds a new handler for the given tag. The handler will be provided an
|
||||
* instance object that it can read values from.
|
||||
*/
|
||||
public addHandler(
|
||||
wadoImageLoaderTag: string,
|
||||
handler
|
||||
) {
|
||||
public addHandler(wadoImageLoaderTag: string, handler) {
|
||||
WADO_IMAGE_LOADER[wadoImageLoaderTag] = handler;
|
||||
}
|
||||
|
||||
_getCornerstoneDICOMImageLoaderTag(wadoImageLoaderTag, instance) {
|
||||
let metadata = WADO_IMAGE_LOADER[wadoImageLoaderTag]?.(instance);
|
||||
if (metadata) return metadata;
|
||||
if (metadata) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
switch (wadoImageLoaderTag) {
|
||||
case WADO_IMAGE_LOADER_TAGS.GENERAL_SERIES_MODULE:
|
||||
@@ -291,12 +290,42 @@ class MetadataProvider {
|
||||
const ROIStandardDeviationTag = `${groupStr}1303`;
|
||||
const OverlayOrigin = instance[OverlayOriginTag];
|
||||
|
||||
let rows = 0;
|
||||
if (instance[OverlayRowsTag] instanceof Array) {
|
||||
// The DICOM VR for overlay rows is US (unsigned short).
|
||||
const rowsInt16Array = new Uint16Array(instance[OverlayRowsTag][0]);
|
||||
rows = rowsInt16Array[0];
|
||||
} else {
|
||||
rows = instance[OverlayRowsTag];
|
||||
}
|
||||
|
||||
let columns = 0;
|
||||
if (instance[OverlayColumnsTag] instanceof Array) {
|
||||
// The DICOM VR for overlay columns is US (unsigned short).
|
||||
const columnsInt16Array = new Uint16Array(instance[OverlayColumnsTag][0]);
|
||||
columns = columnsInt16Array[0];
|
||||
} else {
|
||||
columns = instance[OverlayColumnsTag];
|
||||
}
|
||||
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
if (OverlayOrigin.length === 1) {
|
||||
// The DICOM VR for overlay origin is SS (signed short) with a multiplicity of 2.
|
||||
const originInt16Array = new Int16Array(OverlayOrigin[0]);
|
||||
x = originInt16Array[0];
|
||||
y = originInt16Array[1];
|
||||
} else {
|
||||
x = OverlayOrigin[0];
|
||||
y = OverlayOrigin[1];
|
||||
}
|
||||
|
||||
const overlay = {
|
||||
rows: instance[OverlayRowsTag],
|
||||
columns: instance[OverlayColumnsTag],
|
||||
rows: rows,
|
||||
columns: columns,
|
||||
type: instance[OverlayType],
|
||||
x: OverlayOrigin[0],
|
||||
y: OverlayOrigin[1],
|
||||
x,
|
||||
y,
|
||||
pixelData: OverlayData,
|
||||
description: instance[OverlayDescriptionTag],
|
||||
label: instance[OverlayLabelTag],
|
||||
@@ -444,7 +473,7 @@ class MetadataProvider {
|
||||
imageURI = imageURI.split('&frame=')[0];
|
||||
|
||||
const uids = this.imageURIToUIDs.get(imageURI);
|
||||
let frameNumber = this.getFrameInformationFromURL(imageId) || '1';
|
||||
const frameNumber = this.getFrameInformationFromURL(imageId) || '1';
|
||||
|
||||
if (uids && frameNumber !== undefined) {
|
||||
return { ...uids, frameNumber };
|
||||
@@ -489,9 +518,7 @@ const WADO_IMAGE_LOADER = {
|
||||
imageOrientationPatient: toNumber(ImageOrientationPatient),
|
||||
rowCosines: toNumber(rowCosines || [0, 1, 0]),
|
||||
columnCosines: toNumber(columnCosines || [0, 0, -1]),
|
||||
imagePositionPatient: toNumber(
|
||||
instance.ImagePositionPatient || [0, 0, 0]
|
||||
),
|
||||
imagePositionPatient: toNumber(instance.ImagePositionPatient || [0, 0, 0]),
|
||||
sliceThickness: toNumber(instance.SliceThickness),
|
||||
sliceLocation: toNumber(instance.SliceLocation),
|
||||
pixelSpacing: toNumber(PixelSpacing || 1),
|
||||
|
||||
Reference in new issue
Block a user