@cornerstonejs/adapters 3.23.0 → 3.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -853,6 +853,18 @@ function unpackPixelData(multiframe, options) {
|
|
|
853
853
|
// MAX 2GB is the limit right now to allocate a buffer
|
|
854
854
|
return getUnpackedChunks(data, options.maxBytesPerChunk);
|
|
855
855
|
}
|
|
856
|
+
if (segType === "LABELMAP") {
|
|
857
|
+
// For LABELMAP, we can return the data as is, since it is already in a
|
|
858
|
+
// format that Cornerstone can handle. Also here we are returning the
|
|
859
|
+
// whole data at once, since the storage is more efficent than BINARY mode
|
|
860
|
+
if (multiframe.BitsStored === 8) {
|
|
861
|
+
return new Uint8Array(data);
|
|
862
|
+
} else if (multiframe.BitsStored === 16) {
|
|
863
|
+
return new Uint16Array(data);
|
|
864
|
+
} else {
|
|
865
|
+
return new Uint8Array(data);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
856
868
|
const pixelData = new Uint8Array(data);
|
|
857
869
|
const max = multiframe.MaximumFractionalValue;
|
|
858
870
|
const onlyMaxAndZero = pixelData.find(element => element !== 0 && element !== max) === undefined;
|
|
@@ -267,7 +267,72 @@ function insertPixelDataPlanar(_ref4) {
|
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
269
|
};
|
|
270
|
-
|
|
270
|
+
const processLabelmapChunk = firstIndex => {
|
|
271
|
+
const pfSeq = multiframe.PerFrameFunctionalGroupsSequence;
|
|
272
|
+
const sharedPlaneOrientation = multiframe.SharedFunctionalGroupsSequence.PlaneOrientationSequence?.ImageOrientationPatient;
|
|
273
|
+
for (let i = firstIndex; i < firstIndex + imagesPerChunk && i < groupsLen; i++) {
|
|
274
|
+
const PerFrameFunctionalGroups = pfSeq[i];
|
|
275
|
+
const ImageOrientationPatientI = sharedPlaneOrientation || PerFrameFunctionalGroups.PlaneOrientationSequence.ImageOrientationPatient;
|
|
276
|
+
const view = pixelDataChunks.subarray(i * sliceLength, (i + 1) * sliceLength);
|
|
277
|
+
const pixelDataI2D = ndarray(view, [Rows, Columns]);
|
|
278
|
+
const alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
|
|
279
|
+
if (!alignedPixelDataI) {
|
|
280
|
+
throw new Error("Individual Labelmap SEG frames are out of plane with respect to the first SEG frame. " + "This is not yet supported. Aborting segmentation loading.");
|
|
281
|
+
}
|
|
282
|
+
const imageId = findReferenceSourceImageId(multiframe, i, referencedImageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
283
|
+
if (!imageId) {
|
|
284
|
+
console.warn(`Image not present in stack, can't import frame : ${i}.`);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const sourceImageMetadata = imageIdMaps.metadata[imageId];
|
|
288
|
+
if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
|
|
289
|
+
throw new Error("Individual Labelmap SEG frames have different geometry dimensions (Rows and Columns) " + "respect to the source image reference frame. This is not yet supported. " + "Aborting segmentation loading. ");
|
|
290
|
+
}
|
|
291
|
+
const imageIdIndex = imageIdMaps.indices[imageId];
|
|
292
|
+
const labelmapImage = labelMapImages[imageIdIndex];
|
|
293
|
+
const labelmap2DView = labelmapImage.getPixelData();
|
|
294
|
+
const data = alignedPixelDataI.data;
|
|
295
|
+
let segmentsOnFrameArr = segmentsOnFrame[imageIdIndex];
|
|
296
|
+
if (!segmentsOnFrameArr) {
|
|
297
|
+
segmentsOnFrameArr = [];
|
|
298
|
+
segmentsOnFrame[imageIdIndex] = segmentsOnFrameArr;
|
|
299
|
+
}
|
|
300
|
+
const segSet = new Set(segmentsOnFrameArr);
|
|
301
|
+
for (let k = 0, len = data.length; k < len; ++k) {
|
|
302
|
+
const segIdx = data[k];
|
|
303
|
+
if (segIdx !== 0) {
|
|
304
|
+
labelmap2DView[k] = segIdx;
|
|
305
|
+
if (!segSet.has(segIdx)) {
|
|
306
|
+
segmentsOnFrameArr.push(segIdx);
|
|
307
|
+
segSet.add(segIdx);
|
|
308
|
+
}
|
|
309
|
+
if (!segmentsPixelIndices.has(segIdx)) {
|
|
310
|
+
segmentsPixelIndices.set(segIdx, {});
|
|
311
|
+
}
|
|
312
|
+
const segmentPixelInfo = segmentsPixelIndices.get(segIdx);
|
|
313
|
+
if (!segmentPixelInfo[imageIdIndex]) {
|
|
314
|
+
segmentPixelInfo[imageIdIndex] = [];
|
|
315
|
+
}
|
|
316
|
+
segmentPixelInfo[imageIdIndex].push(k);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const percentComplete = Math.round(firstIndex / groupsLen * 100);
|
|
321
|
+
throttledTriggerLoadProgressEvent(percentComplete);
|
|
322
|
+
if (firstIndex < groupsLen) {
|
|
323
|
+
setTimeout(() => processLabelmapChunk(firstIndex + imagesPerChunk), 0);
|
|
324
|
+
} else {
|
|
325
|
+
resolve({
|
|
326
|
+
hasOverlappingSegments: false,
|
|
327
|
+
arrayOfLabelMapImages: [labelMapImages]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
if (multiframe.SegmentationType === "LABELMAP") {
|
|
332
|
+
processLabelmapChunk(0);
|
|
333
|
+
} else {
|
|
334
|
+
processChunk(0);
|
|
335
|
+
}
|
|
271
336
|
});
|
|
272
337
|
}
|
|
273
338
|
const getAlignedPixelData = _ref5 => {
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.
|
|
1
|
+
export declare const version = "3.24.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/adapters",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.24.0",
|
|
4
4
|
"description": "Adapters for Cornerstone3D to/from formats including DICOM SR and others",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@babel/runtime-corejs2": "^7.17.8",
|
|
87
87
|
"buffer": "^6.0.3",
|
|
88
|
-
"dcmjs": "^0.
|
|
88
|
+
"dcmjs": "^0.42.0",
|
|
89
89
|
"gl-matrix": "^3.4.3",
|
|
90
90
|
"ndarray": "^1.0.19"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
|
-
"@cornerstonejs/core": "^3.
|
|
94
|
-
"@cornerstonejs/tools": "^3.
|
|
93
|
+
"@cornerstonejs/core": "^3.24.0",
|
|
94
|
+
"@cornerstonejs/tools": "^3.24.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "c5fbc9b942368afc0e6835ca3f3747b1e4510182"
|
|
97
97
|
}
|