@cornerstonejs/adapters 5.8.2 → 5.10.3
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.
- package/dist/esm/adapters/Cornerstone/MeasurementReport.js +7 -5
- package/dist/esm/adapters/Cornerstone/ParametricMap.js +4 -3
- package/dist/esm/adapters/Cornerstone/Segmentation.js +6 -3
- package/dist/esm/adapters/Cornerstone/Segmentation_3X.js +10 -8
- package/dist/esm/adapters/Cornerstone/Segmentation_4X.js +38 -37
- package/dist/esm/adapters/Cornerstone3D/MeasurementReport.js +9 -8
- package/dist/esm/adapters/Cornerstone3D/RTStruct/RTSS.js +6 -5
- package/dist/esm/adapters/Cornerstone3D/Segmentation/generateSegmentation.js +5 -4
- package/dist/esm/adapters/Cornerstone3D/Segmentation/labelmapImagesFromBuffer.js +28 -16
- package/dist/esm/utilities/createInstance.d.ts +0 -1
- package/dist/esm/utilities/createInstance.js +13 -23
- package/dist/esm/utilities/index.js +1 -1
- package/dist/esm/utilities/referencedMetadataProvider.d.ts +1 -1
- package/dist/esm/utilities/referencedMetadataProvider.js +23 -7
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +8 -7
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { utilities, derivations, normalizers, data } from 'dcmjs';
|
|
1
|
+
import { utilities as utilities$1, derivations, normalizers, data } from 'dcmjs';
|
|
2
2
|
import { toArray } from '../helpers/toArray.js';
|
|
3
3
|
import { codeMeaningEquals } from '../helpers/codeMeaningEquals.js';
|
|
4
4
|
import '../helpers/downloadDICOMData.js';
|
|
5
5
|
import '../helpers/toScoordType.js';
|
|
6
6
|
import '../helpers/scoordToWorld.js';
|
|
7
|
+
import { utilities } from '@cornerstonejs/core';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.MeasurementReport');
|
|
10
|
+
const TID1500 = utilities$1.TID1500,
|
|
11
|
+
addAccessors = utilities$1.addAccessors;
|
|
10
12
|
const StructuredReport = derivations.StructuredReport;
|
|
11
13
|
const Normalizer = normalizers.Normalizer;
|
|
12
14
|
const TID1500MeasurementReport = TID1500.TID1500MeasurementReport,
|
|
@@ -231,8 +233,8 @@ class MeasurementReport {
|
|
|
231
233
|
const toolClass = hooks.getToolClass ? hooks.getToolClass(measurementGroup, dataset, registeredToolClasses) : registeredToolClasses.find(tc => tc.isValidCornerstoneTrackingIdentifier(TrackingIdentifierValue));
|
|
232
234
|
if (toolClass) {
|
|
233
235
|
const measurement = toolClass.getMeasurementData(measurementGroup);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
cs3dLogger.info("=== ".concat(toolClass.toolType, " ==="));
|
|
237
|
+
cs3dLogger.info(measurement);
|
|
236
238
|
measurementData[toolClass.toolType].push(measurement);
|
|
237
239
|
}
|
|
238
240
|
});
|
|
@@ -2,6 +2,7 @@ import { data, normalizers, log } from 'dcmjs';
|
|
|
2
2
|
import checkOrientation from '../helpers/checkOrientation.js';
|
|
3
3
|
import { utilities } from '@cornerstonejs/core';
|
|
4
4
|
|
|
5
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.ParametricMap');
|
|
5
6
|
const DicomMessage = data.DicomMessage,
|
|
6
7
|
DicomMetaDictionary = data.DicomMetaDictionary;
|
|
7
8
|
const Normalizer = normalizers.Normalizer;
|
|
@@ -13,7 +14,7 @@ async function generateToolState(imageIds, arrayBuffer, metadataProvider) {
|
|
|
13
14
|
const multiframe = Normalizer.normalizeToDataset([dataset]);
|
|
14
15
|
const imagePlaneModule = metadataProvider.get('imagePlaneModule', imageIds[0]);
|
|
15
16
|
if (!imagePlaneModule) {
|
|
16
|
-
|
|
17
|
+
cs3dLogger.warn('Insufficient metadata, imagePlaneModule missing.');
|
|
17
18
|
}
|
|
18
19
|
const ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [...imagePlaneModule.rowCosines, ...imagePlaneModule.columnCosines] : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
|
|
19
20
|
const validOrientations = [ImageOrientationPatient];
|
|
@@ -56,7 +57,7 @@ function insertPixelDataPlanar(sourcePixelData, multiframe, imageIds, metadataPr
|
|
|
56
57
|
const sourceSliceDataView = new sourcePixelData.constructor(sourcePixelData.buffer, i * sliceLength, sliceLength);
|
|
57
58
|
const imageId = findReferenceSourceImageId(multiframe, i, imageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
58
59
|
if (!imageId) {
|
|
59
|
-
|
|
60
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : " + i + '.');
|
|
60
61
|
continue;
|
|
61
62
|
}
|
|
62
63
|
const sourceImageMetadata = imageIdMaps.metadata[imageId];
|
|
@@ -130,7 +131,7 @@ function findReferenceSourceImageId(multiframe, frameSegment, imageIds, metadata
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
} else if (SourceImageSequence && SourceImageSequence.length !== 0) {
|
|
133
|
-
|
|
134
|
+
cs3dLogger.warn('DerivationImageSequence not present, using SourceImageSequence assuming SEG has the same geometry as the source image.');
|
|
134
135
|
frameSourceImageSequence = SourceImageSequence[frameSegment];
|
|
135
136
|
}
|
|
136
137
|
if (frameSourceImageSequence) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import Segmentation$1 from './Segmentation_3X.js';
|
|
2
2
|
import Segmentation from './Segmentation_4X.js';
|
|
3
|
+
import { utilities } from '@cornerstonejs/core';
|
|
4
|
+
|
|
5
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.Segmentation');
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* generateSegmentation - Generates a DICOM Segmentation object given cornerstoneTools data.
|
|
@@ -21,7 +24,7 @@ function generateSegmentation(images, labelmaps3DorBrushData) {
|
|
|
21
24
|
if (cornerstoneToolsVersion === 3) {
|
|
22
25
|
return Segmentation$1.generateSegmentation(images, labelmaps3DorBrushData, options);
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
cs3dLogger.warn("No generateSegmentation adapter for cornerstone version ".concat(cornerstoneToolsVersion, ", exiting."));
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
@@ -48,7 +51,7 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
|
|
|
48
51
|
if (cornerstoneToolsVersion === 3) {
|
|
49
52
|
return Segmentation$1.generateToolState(imageIds, arrayBuffer, metadataProvider);
|
|
50
53
|
}
|
|
51
|
-
|
|
54
|
+
cs3dLogger.warn("No generateToolState adapter for cornerstone version ".concat(cornerstoneToolsVersion, ", exiting."));
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/**
|
|
@@ -67,7 +70,7 @@ function fillSegmentation(segmentation, inputLabelmaps3D) {
|
|
|
67
70
|
if (cornerstoneToolsVersion === 4) {
|
|
68
71
|
return Segmentation.fillSegmentation(segmentation, inputLabelmaps3D, options);
|
|
69
72
|
}
|
|
70
|
-
|
|
73
|
+
cs3dLogger.warn("No generateSegmentation adapter for cornerstone version ".concat(cornerstoneToolsVersion, ", exiting."));
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
export { fillSegmentation, generateSegmentation, generateToolState };
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { utilities, normalizers, derivations, log } from 'dcmjs';
|
|
1
|
+
import { utilities as utilities$1, normalizers, derivations, log } from 'dcmjs';
|
|
2
2
|
import ndarray from 'ndarray';
|
|
3
3
|
import getDatasetsFromImages from '../helpers/getDatasetsFromImages.js';
|
|
4
|
+
import { utilities } from '@cornerstonejs/core';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.Segmentation_3X');
|
|
7
|
+
const _utilities$orientatio = utilities$1.orientation,
|
|
6
8
|
rotateDirectionCosinesInPlane = _utilities$orientatio.rotateDirectionCosinesInPlane,
|
|
7
9
|
flipIOP = _utilities$orientatio.flipImageOrientationPatient,
|
|
8
10
|
flipMatrix2D = _utilities$orientatio.flipMatrix2D,
|
|
9
11
|
rotateMatrix902D = _utilities$orientatio.rotateMatrix902D;
|
|
10
|
-
const datasetToBlob = utilities.datasetToBlob,
|
|
11
|
-
BitArray = utilities.BitArray,
|
|
12
|
-
DicomMessage = utilities.DicomMessage,
|
|
13
|
-
DicomMetaDictionary = utilities.DicomMetaDictionary;
|
|
12
|
+
const datasetToBlob = utilities$1.datasetToBlob,
|
|
13
|
+
BitArray = utilities$1.BitArray,
|
|
14
|
+
DicomMessage = utilities$1.DicomMessage,
|
|
15
|
+
DicomMetaDictionary = utilities$1.DicomMetaDictionary;
|
|
14
16
|
const Normalizer = normalizers.Normalizer;
|
|
15
17
|
const SegmentationDerivation = derivations.Segmentation;
|
|
16
18
|
const Segmentation = {
|
|
@@ -156,7 +158,7 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
|
|
|
156
158
|
const multiframe = Normalizer.normalizeToDataset([dataset]);
|
|
157
159
|
const imagePlaneModule = metadataProvider.get('imagePlaneModule', imageIds[0]);
|
|
158
160
|
if (!imagePlaneModule) {
|
|
159
|
-
|
|
161
|
+
cs3dLogger.warn('Insufficient metadata, imagePlaneModule missing.');
|
|
160
162
|
}
|
|
161
163
|
const ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [...imagePlaneModule.rowCosines, ...imagePlaneModule.columnCosines] : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
|
|
162
164
|
|
|
@@ -176,7 +178,7 @@ function generateToolState(imageIds, arrayBuffer, metadataProvider) {
|
|
|
176
178
|
const pixelDataI2D = ndarray(new Uint8Array(pixelData.buffer, i * sliceLength, sliceLength), [multiframe.Rows, multiframe.Columns]);
|
|
177
179
|
const alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations);
|
|
178
180
|
if (!alignedPixelDataI) {
|
|
179
|
-
|
|
181
|
+
cs3dLogger.warn("This segmentation object is not in-plane with the source data. Bailing out of IO. It'd be better to render this with vtkjs. ");
|
|
180
182
|
inPlane = false;
|
|
181
183
|
break;
|
|
182
184
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
|
-
import { utilities, data, normalizers, derivations, log } from 'dcmjs';
|
|
2
|
+
import { utilities as utilities$1, data, normalizers, derivations, log } from 'dcmjs';
|
|
3
3
|
import ndarray from 'ndarray';
|
|
4
4
|
import getDatasetsFromImages from '../helpers/getDatasetsFromImages.js';
|
|
5
5
|
import checkOrientation from '../helpers/checkOrientation.js';
|
|
6
|
-
import { utilities
|
|
6
|
+
import { utilities } from '@cornerstonejs/core';
|
|
7
7
|
import { getReferencedSourceImageSequenceItem, applyPerFrameFunctionalGroups } from '../Cornerstone3D/Segmentation/perFrameFunctionalGroups.js';
|
|
8
8
|
import { getBitmapFramesFromDataset, encodeFramesToTransferSyntax, RLE_LOSSLESS_TRANSFER_SYNTAX_UID as RLE_LOSSLESS_TRANSFER_SYNTAX_UID$1 } from '../Cornerstone3D/encodePixelData.js';
|
|
9
9
|
import { Events } from '../enums/Events.js';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone.Segmentation_4X');
|
|
12
|
+
const _utilities$orientatio = utilities$1.orientation,
|
|
12
13
|
rotateDirectionCosinesInPlane = _utilities$orientatio.rotateDirectionCosinesInPlane,
|
|
13
14
|
flipIOP = _utilities$orientatio.flipImageOrientationPatient,
|
|
14
15
|
flipMatrix2D = _utilities$orientatio.flipMatrix2D,
|
|
@@ -18,7 +19,7 @@ const BitArray = data.BitArray,
|
|
|
18
19
|
DicomMetaDictionary = data.DicomMetaDictionary;
|
|
19
20
|
const Normalizer = normalizers.Normalizer;
|
|
20
21
|
const SegmentationDerivation = derivations.Segmentation;
|
|
21
|
-
const _utilities$compressio = utilities.compression,
|
|
22
|
+
const _utilities$compressio = utilities$1.compression,
|
|
22
23
|
encode = _utilities$compressio.encode,
|
|
23
24
|
decode = _utilities$compressio.decode;
|
|
24
25
|
const RLE_LOSSLESS_TRANSFER_SYNTAX_UID = '1.2.840.10008.1.2.5';
|
|
@@ -308,7 +309,7 @@ async function generateToolState(referencedImageIds, arrayBuffer, metadataProvid
|
|
|
308
309
|
const generalSeriesModule = metadataProvider.get('generalSeriesModule', referencedImageIds[0]);
|
|
309
310
|
const SeriesInstanceUID = generalSeriesModule.seriesInstanceUID;
|
|
310
311
|
if (!imagePlaneModule) {
|
|
311
|
-
|
|
312
|
+
cs3dLogger.warn('Insufficient metadata, imagePlaneModule missing.');
|
|
312
313
|
}
|
|
313
314
|
const ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [...imagePlaneModule.rowCosines, ...imagePlaneModule.columnCosines] : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
|
|
314
315
|
|
|
@@ -323,7 +324,7 @@ async function generateToolState(referencedImageIds, arrayBuffer, metadataProvid
|
|
|
323
324
|
const rleEncodedFrames = Array.isArray(multiframe.PixelData) ? multiframe.PixelData : [multiframe.PixelData];
|
|
324
325
|
pixelData = decode(rleEncodedFrames, multiframe.Rows, multiframe.Columns);
|
|
325
326
|
if (multiframe.BitsStored === 1) {
|
|
326
|
-
|
|
327
|
+
cs3dLogger.warn('No implementation for rle + bitbacking.');
|
|
327
328
|
return;
|
|
328
329
|
}
|
|
329
330
|
|
|
@@ -441,17 +442,11 @@ async function generateToolState(referencedImageIds, arrayBuffer, metadataProvid
|
|
|
441
442
|
// imageIds[imageIds.length - 1]
|
|
442
443
|
// );
|
|
443
444
|
|
|
444
|
-
// console.log(firstImagePlaneModule);
|
|
445
|
-
// console.log(lastImagePlaneModule);
|
|
446
|
-
|
|
447
445
|
// const corners = [
|
|
448
446
|
// ...getCorners(firstImagePlaneModule),
|
|
449
447
|
// ...getCorners(lastImagePlaneModule)
|
|
450
448
|
// ];
|
|
451
449
|
|
|
452
|
-
// console.log(`corners:`);
|
|
453
|
-
// console.log(corners);
|
|
454
|
-
|
|
455
450
|
// const indexToWorld = mat4.create();
|
|
456
451
|
|
|
457
452
|
// const ippFirstFrame = firstImagePlaneModule.imagePositionPatient;
|
|
@@ -538,7 +533,6 @@ async function generateToolState(referencedImageIds, arrayBuffer, metadataProvid
|
|
|
538
533
|
// }
|
|
539
534
|
|
|
540
535
|
// function getCorners(imagePlaneModule) {
|
|
541
|
-
// // console.log(imagePlaneModule);
|
|
542
536
|
|
|
543
537
|
// const {
|
|
544
538
|
// rows,
|
|
@@ -634,7 +628,7 @@ function findReferenceSourceImageId(multiframe, frameSegment, imageIds, metadata
|
|
|
634
628
|
}
|
|
635
629
|
}
|
|
636
630
|
} else if (SourceImageSequence && SourceImageSequence.length !== 0) {
|
|
637
|
-
|
|
631
|
+
cs3dLogger.warn('DerivationImageSequence not present, using SourceImageSequence assuming SEG has the same geometry as the source image.');
|
|
638
632
|
frameSourceImageSequence = SourceImageSequence[frameSegment];
|
|
639
633
|
}
|
|
640
634
|
if (frameSourceImageSequence) {
|
|
@@ -677,12 +671,12 @@ function checkSEGsOverlapping(pixelData, multiframe, imageIds, validOrientations
|
|
|
677
671
|
for (let frameSegment = 0; frameSegment < groupsLen; ++frameSegment) {
|
|
678
672
|
const segmentIndex = getSegmentIndex(multiframe, frameSegment);
|
|
679
673
|
if (segmentIndex === undefined) {
|
|
680
|
-
|
|
674
|
+
cs3dLogger.warn('Could not retrieve the segment index for frame segment ' + frameSegment + ', skipping this frame.');
|
|
681
675
|
continue;
|
|
682
676
|
}
|
|
683
677
|
const imageId = findReferenceSourceImageId(multiframe, frameSegment, imageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
684
678
|
if (!imageId) {
|
|
685
|
-
|
|
679
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : " + frameSegment + '.');
|
|
686
680
|
continue;
|
|
687
681
|
}
|
|
688
682
|
const imageIdIndex = imageIds.findIndex(element => element === imageId);
|
|
@@ -708,7 +702,7 @@ function checkSEGsOverlapping(pixelData, multiframe, imageIds, validOrientations
|
|
|
708
702
|
const pixelDataI2D = ndarray(view, [Rows, Columns]);
|
|
709
703
|
const alignedPixelDataI = alignPixelDataWithSourceData(pixelDataI2D, ImageOrientationPatientI, validOrientations, tolerance);
|
|
710
704
|
if (!alignedPixelDataI) {
|
|
711
|
-
|
|
705
|
+
cs3dLogger.warn('Individual SEG frames are out of plane with respect to the first SEG frame, this is not yet supported, skipping this frame.');
|
|
712
706
|
continue;
|
|
713
707
|
}
|
|
714
708
|
const data = alignedPixelDataI.data;
|
|
@@ -775,7 +769,7 @@ function insertOverlappingPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray,
|
|
|
775
769
|
}
|
|
776
770
|
const imageId = findReferenceSourceImageId(multiframe, i, imageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
777
771
|
if (!imageId) {
|
|
778
|
-
|
|
772
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : " + i + '.');
|
|
779
773
|
continue;
|
|
780
774
|
}
|
|
781
775
|
const sourceImageMetadata = metadataProvider.get('instance', imageId);
|
|
@@ -887,7 +881,7 @@ function insertPixelDataPlanar(segmentsOnFrame, segmentsOnFrameArray, labelmapBu
|
|
|
887
881
|
}
|
|
888
882
|
const imageId = findReferenceSourceImageId(multiframe, i, imageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
889
883
|
if (!imageId) {
|
|
890
|
-
|
|
884
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : " + i + '.');
|
|
891
885
|
continue;
|
|
892
886
|
}
|
|
893
887
|
const sourceImageMetadata = imageIdMaps.metadata[imageId];
|
|
@@ -1018,7 +1012,7 @@ function getImageIdOfSourceImageBySourceImageSequence(SourceImageSequence, sopUI
|
|
|
1018
1012
|
ReferencedFrameNumber = SourceImageSequence.ReferencedFrameNumber;
|
|
1019
1013
|
const baseImageId = sopUIDImageIdIndexMap[ReferencedSOPInstanceUID];
|
|
1020
1014
|
if (!baseImageId) {
|
|
1021
|
-
|
|
1015
|
+
cs3dLogger.warn("No imageId found for SOPInstanceUID: ".concat(ReferencedSOPInstanceUID));
|
|
1022
1016
|
return undefined;
|
|
1023
1017
|
}
|
|
1024
1018
|
if (ReferencedFrameNumber !== undefined) {
|
|
@@ -1084,10 +1078,10 @@ function getImageIdOfSourceImagebyGeometry(ReferencedSeriesInstanceUID, FrameOfR
|
|
|
1084
1078
|
if (isMultiframe) {
|
|
1085
1079
|
var _metadataProvider$get2;
|
|
1086
1080
|
const framePosition = (_metadataProvider$get2 = metadataProvider.get('imagePlaneModule', imageId)) === null || _metadataProvider$get2 === void 0 ? void 0 : _metadataProvider$get2.imagePositionPatient;
|
|
1087
|
-
if (framePosition && utilities
|
|
1081
|
+
if (framePosition && utilities.isEqual(segFramePosition, framePosition, tolerance)) {
|
|
1088
1082
|
return imageId;
|
|
1089
1083
|
}
|
|
1090
|
-
} else if (utilities
|
|
1084
|
+
} else if (utilities.isEqual(segFramePosition, sourceImageMetadata.ImagePositionPatient, tolerance)) {
|
|
1091
1085
|
return imageId;
|
|
1092
1086
|
}
|
|
1093
1087
|
}
|
|
@@ -1129,38 +1123,38 @@ function getValidOrientations(iop) {
|
|
|
1129
1123
|
* @return {Ndarray} The aligned pixelData.
|
|
1130
1124
|
*/
|
|
1131
1125
|
function alignPixelDataWithSourceData(pixelData2D, iop, orientations, tolerance) {
|
|
1132
|
-
if (utilities
|
|
1126
|
+
if (utilities.isEqual(iop, orientations[0], tolerance)) {
|
|
1133
1127
|
return pixelData2D;
|
|
1134
|
-
} else if (utilities
|
|
1128
|
+
} else if (utilities.isEqual(iop, orientations[1], tolerance)) {
|
|
1135
1129
|
// Flipped vertically.
|
|
1136
1130
|
|
|
1137
1131
|
// Undo Flip
|
|
1138
1132
|
return flipMatrix2D.v(pixelData2D);
|
|
1139
|
-
} else if (utilities
|
|
1133
|
+
} else if (utilities.isEqual(iop, orientations[2], tolerance)) {
|
|
1140
1134
|
// Flipped horizontally.
|
|
1141
1135
|
|
|
1142
1136
|
// Unfo flip
|
|
1143
1137
|
return flipMatrix2D.h(pixelData2D);
|
|
1144
|
-
} else if (utilities
|
|
1138
|
+
} else if (utilities.isEqual(iop, orientations[3], tolerance)) {
|
|
1145
1139
|
//Rotated 90 degrees
|
|
1146
1140
|
|
|
1147
1141
|
// Rotate back
|
|
1148
1142
|
return rotateMatrix902D(pixelData2D);
|
|
1149
|
-
} else if (utilities
|
|
1143
|
+
} else if (utilities.isEqual(iop, orientations[4], tolerance)) {
|
|
1150
1144
|
//Rotated 90 degrees and fliped horizontally.
|
|
1151
1145
|
|
|
1152
1146
|
// Undo flip and rotate back.
|
|
1153
1147
|
return rotateMatrix902D(flipMatrix2D.h(pixelData2D));
|
|
1154
|
-
} else if (utilities
|
|
1148
|
+
} else if (utilities.isEqual(iop, orientations[5], tolerance)) {
|
|
1155
1149
|
// Rotated 90 degrees and fliped vertically
|
|
1156
1150
|
|
|
1157
1151
|
// Unfo flip and rotate back.
|
|
1158
1152
|
return rotateMatrix902D(flipMatrix2D.v(pixelData2D));
|
|
1159
|
-
} else if (utilities
|
|
1153
|
+
} else if (utilities.isEqual(iop, orientations[6], tolerance)) {
|
|
1160
1154
|
// Rotated 180 degrees. // TODO -> Do this more effeciently, there is a 1:1 mapping like 90 degree rotation.
|
|
1161
1155
|
|
|
1162
1156
|
return rotateMatrix902D(rotateMatrix902D(pixelData2D));
|
|
1163
|
-
} else if (utilities
|
|
1157
|
+
} else if (utilities.isEqual(iop, orientations[7], tolerance)) {
|
|
1164
1158
|
// Rotated 270 degrees
|
|
1165
1159
|
|
|
1166
1160
|
// Rotate back.
|
|
@@ -1169,12 +1163,19 @@ function alignPixelDataWithSourceData(pixelData2D, iop, orientations, tolerance)
|
|
|
1169
1163
|
}
|
|
1170
1164
|
function getSegmentMetadata(multiframe, seriesInstanceUid) {
|
|
1171
1165
|
const segmentSequence = multiframe.SegmentSequence;
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1166
|
+
const data = [];
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Index segments by their SegmentNumber rather than array position.
|
|
1170
|
+
* This is required for LABELMAP segmentations where SegmentNumber may
|
|
1171
|
+
* start at 0 (for background) or have gaps. The DICOM standard only
|
|
1172
|
+
* requires SegmentNumber >= 1 for BINARY/FRACTIONAL types, but LABELMAP
|
|
1173
|
+
* allows more flexibility (see DICOM Part 3, Section C.8.20.2.4).
|
|
1174
|
+
*/
|
|
1175
|
+
for (const segment of utilities.asArray(segmentSequence)) {
|
|
1176
|
+
if ((segment === null || segment === void 0 ? void 0 : segment.SegmentNumber) >= 0) {
|
|
1177
|
+
data[segment.SegmentNumber] = segment;
|
|
1178
|
+
}
|
|
1178
1179
|
}
|
|
1179
1180
|
return {
|
|
1180
1181
|
seriesInstanceUid,
|
|
@@ -1271,7 +1272,7 @@ function calculateCentroid(imageIdIndexBufferIndex, multiframe, metadataProvider
|
|
|
1271
1272
|
const imageId = imageIds[z];
|
|
1272
1273
|
const imagePlaneModule = metadataProvider.get('imagePlaneModule', imageId);
|
|
1273
1274
|
if (!imagePlaneModule) {
|
|
1274
|
-
|
|
1275
|
+
cs3dLogger.debug('Missing imagePlaneModule metadata for centroid calculation');
|
|
1275
1276
|
continue;
|
|
1276
1277
|
}
|
|
1277
1278
|
const imagePositionPatient = imagePlaneModule.imagePositionPatient,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { utilities, derivations, normalizers, data } from 'dcmjs';
|
|
3
|
-
import {
|
|
2
|
+
import { utilities as utilities$1, derivations, normalizers, data } from 'dcmjs';
|
|
3
|
+
import { utilities, Enums, cache } from '@cornerstonejs/core';
|
|
4
4
|
import CORNERSTONE_3D_TAG from './cornerstone3DTag.js';
|
|
5
5
|
import { toArray } from '../helpers/toArray.js';
|
|
6
6
|
import { codeMeaningEquals } from '../helpers/codeMeaningEquals.js';
|
|
@@ -17,9 +17,10 @@ import LabelData from './LabelData.js';
|
|
|
17
17
|
var _MeasurementReport;
|
|
18
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
19
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
20
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone3D.MeasurementReport');
|
|
20
21
|
const MetadataModules = Enums.MetadataModules;
|
|
21
|
-
const TID1500 = utilities.TID1500,
|
|
22
|
-
addAccessors = utilities.addAccessors;
|
|
22
|
+
const TID1500 = utilities$1.TID1500,
|
|
23
|
+
addAccessors = utilities$1.addAccessors;
|
|
23
24
|
const StructuredReport = derivations.StructuredReport;
|
|
24
25
|
const Normalizer = normalizers.Normalizer;
|
|
25
26
|
const TID1500MeasurementReport = TID1500.TID1500MeasurementReport,
|
|
@@ -169,7 +170,7 @@ class MeasurementReport {
|
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
};
|
|
172
|
-
utilities
|
|
173
|
+
utilities.updatePlaneRestriction(toPoint3(SCOORD3DGroup.GraphicData), toolData.state.annotation.metadata);
|
|
173
174
|
return toolData;
|
|
174
175
|
}
|
|
175
176
|
static getSpatialCoordinatesState(_ref3) {
|
|
@@ -430,13 +431,13 @@ class MeasurementReport {
|
|
|
430
431
|
const measurement = toolAdapter.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata, trackingIdentifierValue);
|
|
431
432
|
measurement.TrackingUniqueIdentifier = trackingUniqueIdentifierValue;
|
|
432
433
|
measurement.predecessorImageId = predecessorImageId;
|
|
433
|
-
|
|
434
|
-
|
|
434
|
+
cs3dLogger.info("=== ".concat(toolAdapter.toolType, " ==="));
|
|
435
|
+
cs3dLogger.info(measurement);
|
|
435
436
|
measurementData[_toolAdapter$toolType = toolAdapter.toolType] || (measurementData[_toolAdapter$toolType] = []);
|
|
436
437
|
measurementData[toolAdapter.toolType].push(measurement);
|
|
437
438
|
}
|
|
438
439
|
} catch (e) {
|
|
439
|
-
|
|
440
|
+
cs3dLogger.warn('Unable to generate tool state for', measurementGroup, e);
|
|
440
441
|
}
|
|
441
442
|
});
|
|
442
443
|
return measurementData;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { Enums, metaData } from '@cornerstonejs/core';
|
|
3
|
-
import { utilities, annotation } from '@cornerstonejs/tools';
|
|
2
|
+
import { utilities, Enums, metaData } from '@cornerstonejs/core';
|
|
3
|
+
import { utilities as utilities$1, annotation } from '@cornerstonejs/tools';
|
|
4
4
|
import getReferencedFrameOfReferenceSequence from './utilities/getReferencedFrameOfReferenceSequence.js';
|
|
5
5
|
import getReferencedSeriesSequence from './utilities/getReferencedSeriesSequence.js';
|
|
6
6
|
import getRTROIObservationsSequence from './utilities/getRTROIObservationsSequence.js';
|
|
@@ -10,7 +10,8 @@ import { createInstance } from '../../../utilities/createInstance.js';
|
|
|
10
10
|
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
const
|
|
13
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone3D.RTStruct.RTSS');
|
|
14
|
+
const _utilities$contours = utilities$1.contours,
|
|
14
15
|
generateContourSetsFromLabelmap = _utilities$contours.generateContourSetsFromLabelmap,
|
|
15
16
|
AnnotationToPointData = _utilities$contours.AnnotationToPointData;
|
|
16
17
|
const MetadataModules = Enums.MetadataModules;
|
|
@@ -88,7 +89,7 @@ function generateRTSSFromAnnotations(segmentations, annotations, options) {
|
|
|
88
89
|
annotations.forEach((annotation, index) => {
|
|
89
90
|
const segmentation = annotation.data.segmentation;
|
|
90
91
|
if (!segmentation) {
|
|
91
|
-
|
|
92
|
+
cs3dLogger.warn('Annotation is not a segmentation:', annotation);
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
const segmentationId = segmentation.segmentationId,
|
|
@@ -139,7 +140,7 @@ function generateRTSSFromContour(segmentations, options) {
|
|
|
139
140
|
for (const annotationUID of annotationSet.values()) {
|
|
140
141
|
const annotation$1 = annotation.state.getAnnotation(annotationUID);
|
|
141
142
|
if (!annotation$1) {
|
|
142
|
-
|
|
143
|
+
cs3dLogger.error('Unable to find an annotation for UID', annotationUID);
|
|
143
144
|
continue;
|
|
144
145
|
}
|
|
145
146
|
annotations.push(annotation$1);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { normalizers, derivations } from 'dcmjs';
|
|
4
|
-
import { Enums } from '@cornerstonejs/core';
|
|
4
|
+
import { utilities, Enums } from '@cornerstonejs/core';
|
|
5
5
|
import { fillSegmentation } from '../../Cornerstone/Segmentation_4X.js';
|
|
6
6
|
import { getBitmapFramesFromDataset, encodeFramesToTransferSyntax, EXPLICIT_VR_LITTLE_ENDIAN_TRANSFER_SYNTAX_UID } from '../encodePixelData.js';
|
|
7
7
|
import { normalizeSharedFunctionalGroupsSequence, getReferencedSourceImageSequenceItem, applyPerFrameFunctionalGroups } from './perFrameFunctionalGroups.js';
|
|
8
8
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone3D.Segmentation.generateSegmentation');
|
|
11
12
|
const MetadataModules = Enums.MetadataModules;
|
|
12
13
|
const SEGImageNormalizer = normalizers.SEGImageNormalizer;
|
|
13
14
|
const SegmentationDerivation = derivations.Segmentation;
|
|
@@ -175,7 +176,7 @@ function fillLabelmapSegmentation(segmentation, inputLabelmaps3D, metadata, imag
|
|
|
175
176
|
continue;
|
|
176
177
|
}
|
|
177
178
|
if (frame[i] !== 0 && frame[i] !== value && !overlapWarned) {
|
|
178
|
-
|
|
179
|
+
cs3dLogger.warn('generateSegmentation: overlapping labelmap segments detected on the ' + 'same voxel while exporting a LABELMAP SEG; the later labelmap wins.');
|
|
179
180
|
overlapWarned = true;
|
|
180
181
|
}
|
|
181
182
|
frame[i] = value;
|
|
@@ -281,7 +282,7 @@ function generateSegmentation(images, labelmaps, metadata) {
|
|
|
281
282
|
const predecessorImageId = options === null || options === void 0 ? void 0 : options.predecessorImageId;
|
|
282
283
|
if (predecessorImageId) {
|
|
283
284
|
const predecessor = metadata.get(MetadataModules.PREDECESSOR_SEQUENCE, predecessorImageId);
|
|
284
|
-
Object.assign(segmentationResult, predecessor);
|
|
285
|
+
Object.assign(segmentationResult.dataset, predecessor);
|
|
285
286
|
}
|
|
286
287
|
return segmentationResult;
|
|
287
288
|
}
|
|
@@ -292,7 +293,7 @@ function generateSegmentation(images, labelmaps, metadata) {
|
|
|
292
293
|
const predecessorImageId = options === null || options === void 0 ? void 0 : options.predecessorImageId;
|
|
293
294
|
if (predecessorImageId) {
|
|
294
295
|
const predecessor = metadata.get(MetadataModules.PREDECESSOR_SEQUENCE, predecessorImageId);
|
|
295
|
-
Object.assign(segmentationResult, predecessor);
|
|
296
|
+
Object.assign(segmentationResult.dataset, predecessor);
|
|
296
297
|
}
|
|
297
298
|
return segmentationResult;
|
|
298
299
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { triggerEvent, eventTarget, imageLoader } from '@cornerstonejs/core';
|
|
3
|
-
import { utilities } from '@cornerstonejs/tools';
|
|
2
|
+
import { utilities, triggerEvent, eventTarget, imageLoader } from '@cornerstonejs/core';
|
|
3
|
+
import { utilities as utilities$1 } from '@cornerstonejs/tools';
|
|
4
4
|
import { data, normalizers } from 'dcmjs';
|
|
5
5
|
import ndarray from 'ndarray';
|
|
6
6
|
import checkOrientation from '../../helpers/checkOrientation.js';
|
|
@@ -12,6 +12,7 @@ import { Events } from '../../enums/Events.js';
|
|
|
12
12
|
|
|
13
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
const cs3dLogger = utilities.logger.adaptersLog.getLogger('Cornerstone3D.Segmentation.labelmapImagesFromBuffer');
|
|
15
16
|
const DicomMessage = data.DicomMessage,
|
|
16
17
|
DicomMetaDictionary = data.DicomMetaDictionary;
|
|
17
18
|
const Normalizer = normalizers.Normalizer;
|
|
@@ -437,7 +438,7 @@ async function createLabelmapsFromSegImageIds(referencedImageIds, segImageId, me
|
|
|
437
438
|
const generalSeriesModule = metadataProvider.get('generalSeriesModule', referencedImageIds[0]);
|
|
438
439
|
const SeriesInstanceUID = generalSeriesModule.seriesInstanceUID;
|
|
439
440
|
if (!imagePlaneModule) {
|
|
440
|
-
|
|
441
|
+
cs3dLogger.warn('Insufficient metadata, imagePlaneModule missing.');
|
|
441
442
|
}
|
|
442
443
|
const ImageOrientationPatient = Array.isArray(imagePlaneModule.rowCosines) ? [...imagePlaneModule.rowCosines, ...imagePlaneModule.columnCosines] : [imagePlaneModule.rowCosines.x, imagePlaneModule.rowCosines.y, imagePlaneModule.rowCosines.z, imagePlaneModule.columnCosines.x, imagePlaneModule.columnCosines.y, imagePlaneModule.columnCosines.z];
|
|
443
444
|
const validOrientations = getValidOrientations(ImageOrientationPatient);
|
|
@@ -529,7 +530,7 @@ async function createLabelmapsFromSegImageIds(referencedImageIds, segImageId, me
|
|
|
529
530
|
overlappingSegments: hasOverlappingSegments
|
|
530
531
|
};
|
|
531
532
|
}
|
|
532
|
-
const throttledTriggerLoadProgressEvent = utilities.throttle(percentComplete => {
|
|
533
|
+
const throttledTriggerLoadProgressEvent = utilities$1.throttle(percentComplete => {
|
|
533
534
|
triggerEvent(eventTarget, Events.SEGMENTATION_LOAD_PROGRESS, {
|
|
534
535
|
percentComplete
|
|
535
536
|
});
|
|
@@ -584,17 +585,17 @@ function insertPixelDataPlanar(_ref0) {
|
|
|
584
585
|
}
|
|
585
586
|
let imageId = findReferenceSourceImageId(multiframe, i, referencedImageIds, metadataProvider, tolerance, sopUIDImageIdIndexMap);
|
|
586
587
|
if (!imageId) {
|
|
587
|
-
|
|
588
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : " + i + '.');
|
|
588
589
|
continue;
|
|
589
590
|
}
|
|
590
591
|
const stackImageId = ensureImageIdMapsEntry(imageId, referencedImageIds, imageIdMaps, metadataProvider);
|
|
591
592
|
if (!stackImageId) {
|
|
592
|
-
|
|
593
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : ".concat(i, "."));
|
|
593
594
|
continue;
|
|
594
595
|
}
|
|
595
596
|
const sourceImageMetadata = imageIdMaps.metadata[stackImageId];
|
|
596
597
|
if (!sourceImageMetadata) {
|
|
597
|
-
|
|
598
|
+
cs3dLogger.warn("No instance metadata for referenced image at frame : ".concat(i, "."));
|
|
598
599
|
continue;
|
|
599
600
|
}
|
|
600
601
|
if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
|
|
@@ -602,15 +603,15 @@ function insertPixelDataPlanar(_ref0) {
|
|
|
602
603
|
}
|
|
603
604
|
const imageIdIndex = imageIdMaps.indices[stackImageId];
|
|
604
605
|
const labelmapImage = labelMapImages[imageIdIndex];
|
|
605
|
-
const labelmap2DView = labelmapImage.getPixelData();
|
|
606
606
|
const imageVoxelManager = labelmapImage.voxelManager;
|
|
607
|
+
const labelmap2DView = imageVoxelManager ? imageVoxelManager.getWritableScalarData() : labelmapImage.getPixelData();
|
|
607
608
|
const data = alignedPixelDataI.data;
|
|
608
609
|
const indexCache = [];
|
|
609
610
|
for (let k = 0, len = alignedPixelDataI.data.length; k < len; ++k) {
|
|
610
611
|
if (data[k]) {
|
|
611
612
|
for (let x = k; x < len; ++x) {
|
|
612
613
|
if (data[x]) {
|
|
613
|
-
if (!overlapping && labelmap2DView[x] !== 0) {
|
|
614
|
+
if (!overlapping && (labelmap2DView ? labelmap2DView[x] : imageVoxelManager.getAtIndex(x)) !== 0) {
|
|
614
615
|
overlapping = true;
|
|
615
616
|
return resolve(insertOverlappingPixelDataPlanar({
|
|
616
617
|
segmentsOnFrame,
|
|
@@ -678,17 +679,17 @@ function insertPixelDataPlanar(_ref0) {
|
|
|
678
679
|
});
|
|
679
680
|
}
|
|
680
681
|
if (!imageId) {
|
|
681
|
-
|
|
682
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : ".concat(i, "."));
|
|
682
683
|
continue;
|
|
683
684
|
}
|
|
684
685
|
const stackImageId = ensureImageIdMapsEntry(imageId, referencedImageIds, imageIdMaps, metadataProvider);
|
|
685
686
|
if (!stackImageId) {
|
|
686
|
-
|
|
687
|
+
cs3dLogger.warn("Image not present in stack, can't import frame : ".concat(i, "."));
|
|
687
688
|
continue;
|
|
688
689
|
}
|
|
689
690
|
const sourceImageMetadata = imageIdMaps.metadata[stackImageId];
|
|
690
691
|
if (!sourceImageMetadata) {
|
|
691
|
-
|
|
692
|
+
cs3dLogger.warn("No instance metadata for referenced image at frame : ".concat(i, "."));
|
|
692
693
|
continue;
|
|
693
694
|
}
|
|
694
695
|
if (Rows !== sourceImageMetadata.Rows || Columns !== sourceImageMetadata.Columns) {
|
|
@@ -696,8 +697,8 @@ function insertPixelDataPlanar(_ref0) {
|
|
|
696
697
|
}
|
|
697
698
|
const imageIdIndex = imageIdMaps.indices[stackImageId];
|
|
698
699
|
const labelmapImage = labelMapImages[imageIdIndex];
|
|
699
|
-
const labelmap2DView = labelmapImage.getPixelData();
|
|
700
700
|
const imageVoxelManager = labelmapImage.voxelManager;
|
|
701
|
+
const labelmap2DView = imageVoxelManager ? undefined : labelmapImage.getPixelData();
|
|
701
702
|
const data = alignedPixelDataI.data;
|
|
702
703
|
let segmentsOnFrameArr = segmentsOnFrame[imageIdIndex];
|
|
703
704
|
if (!segmentsOnFrameArr) {
|
|
@@ -790,10 +791,21 @@ const getArrayOfLabelMapImagesWithSegmentData = _ref11 => {
|
|
|
790
791
|
const labelMapImages = referencedImageIds.map((referencedImageId, i) => {
|
|
791
792
|
const hasEmptySegmentData = !arr[i];
|
|
792
793
|
const labelMapImage = imageLoader.createAndCacheDerivedLabelmapImage(referencedImageId);
|
|
793
|
-
const pixelData = labelMapImage.getPixelData();
|
|
794
794
|
if (!hasEmptySegmentData) {
|
|
795
|
-
|
|
796
|
-
|
|
795
|
+
const segmentData = arr[i];
|
|
796
|
+
const voxelManager = labelMapImage.voxelManager;
|
|
797
|
+
const frame = voxelManager ? voxelManager.getWritableScalarData() : labelMapImage.getPixelData();
|
|
798
|
+
if (frame) {
|
|
799
|
+
const length = Math.min(frame.length, segmentData.length);
|
|
800
|
+
for (let j = 0; j < length; j++) {
|
|
801
|
+
frame[j] = segmentData[j];
|
|
802
|
+
}
|
|
803
|
+
} else {
|
|
804
|
+
for (let j = 0; j < segmentData.length; j++) {
|
|
805
|
+
if (segmentData[j]) {
|
|
806
|
+
voxelManager.setAtIndex(j, segmentData[j]);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
797
809
|
}
|
|
798
810
|
}
|
|
799
811
|
return labelMapImage;
|
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import { Enums, metaData } from '@cornerstonejs/core';
|
|
3
|
+
import { utilities } from '@cornerstonejs/metadata';
|
|
3
4
|
|
|
4
5
|
const MetadataModules = Enums.MetadataModules;
|
|
5
|
-
|
|
6
|
-
if (!source) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
for (const _ref of Object.entries(source)) {
|
|
10
|
-
var _ref2 = _slicedToArray(_ref, 2);
|
|
11
|
-
const key = _ref2[0];
|
|
12
|
-
const value = _ref2[1];
|
|
13
|
-
if (value === undefined) {
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (dest[key] === undefined && options !== null && options !== void 0 && options.requireDestinationKey) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
dest[key] = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
6
|
+
const definedAttributesOf = utilities.definedAttributesOf;
|
|
22
7
|
function createInstance(instanceKey, studyExemplarImageId, base, options) {
|
|
23
8
|
const _options$metadataProv = options.metadataProvider,
|
|
24
9
|
metadataProvider = _options$metadataProv === void 0 ? metaData : _options$metadataProv,
|
|
25
10
|
predecessorImageId = options.predecessorImageId;
|
|
26
11
|
const result = {};
|
|
27
12
|
const instanceBase = metadataProvider.get(instanceKey, studyExemplarImageId);
|
|
28
|
-
Object.assign(result, instanceBase);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
Object.assign(result, instanceBase, definedAttributesOf(base));
|
|
14
|
+
const instance = result;
|
|
15
|
+
for (const _ref of Object.entries(definedAttributesOf(options))) {
|
|
16
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
17
|
+
const key = _ref2[0];
|
|
18
|
+
const value = _ref2[1];
|
|
19
|
+
if (instance[key] !== undefined) {
|
|
20
|
+
instance[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
33
23
|
if (predecessorImageId) {
|
|
34
24
|
const predecessor = metadataProvider.get(MetadataModules.PREDECESSOR_SEQUENCE, predecessorImageId);
|
|
35
25
|
Object.assign(result, predecessor);
|
|
@@ -37,4 +27,4 @@ function createInstance(instanceKey, studyExemplarImageId, base, options) {
|
|
|
37
27
|
return result;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
export {
|
|
30
|
+
export { createInstance };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { IMAGE_MODULES, SERIES_MODULES, STUDY_MODULES, metadataProvider } from './referencedMetadataProvider.js';
|
|
2
|
-
export {
|
|
2
|
+
export { createInstance } from './createInstance.js';
|
|
@@ -19,7 +19,7 @@ export declare const metadataProvider: {
|
|
|
19
19
|
ReferencedSOPInstanceUID: any;
|
|
20
20
|
}[];
|
|
21
21
|
};
|
|
22
|
-
PredecessorSequence: (imageId: any) => any
|
|
22
|
+
PredecessorSequence: (imageId: any) => Partial<any>;
|
|
23
23
|
StudyData: (imageId: any) => {};
|
|
24
24
|
SeriesData: (imageId: any) => {};
|
|
25
25
|
ImageData: (imageId: any) => {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { Enums, metaData } from '@cornerstonejs/core';
|
|
2
|
+
import { Enums, utilities as utilities$1, metaData } from '@cornerstonejs/core';
|
|
3
|
+
import { utilities } from '@cornerstonejs/metadata';
|
|
3
4
|
import dcmjs from 'dcmjs';
|
|
4
5
|
import { metaRTSSContour, metaSRAnnotation } from '../adapters/Cornerstone3D/constants/index.js';
|
|
5
6
|
|
|
@@ -7,6 +8,8 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
7
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
9
|
const DicomMetaDictionary = dcmjs.data.DicomMetaDictionary;
|
|
9
10
|
const MetadataModules = Enums.MetadataModules;
|
|
11
|
+
const definedAttributesOf = utilities.definedAttributesOf;
|
|
12
|
+
const cs3dLogger = utilities$1.logger.adaptersLog.getLogger('utilities.referencedMetadataProvider');
|
|
10
13
|
const STUDY_MODULES = [MetadataModules.GENERAL_STUDY, MetadataModules.PATIENT_STUDY, MetadataModules.PATIENT];
|
|
11
14
|
const SERIES_MODULES = [MetadataModules.GENERAL_SERIES];
|
|
12
15
|
const IMAGE_MODULES = [MetadataModules.GENERAL_IMAGE, MetadataModules.IMAGE_PLANE, MetadataModules.CINE, MetadataModules.VOI_LUT, MetadataModules.MODALITY_LUT, MetadataModules.SOP_COMMON];
|
|
@@ -45,17 +48,30 @@ const metadataProvider = {
|
|
|
45
48
|
};
|
|
46
49
|
},
|
|
47
50
|
[MetadataModules.PREDECESSOR_SEQUENCE]: imageId => {
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
var _metaData$get, _metaData$get2;
|
|
52
|
+
const sopModule = metaData.get(MetadataModules.SOP_COMMON, imageId);
|
|
53
|
+
if (!(sopModule !== null && sopModule !== void 0 && sopModule.sopInstanceUID) || !sopModule.sopClassUID) {
|
|
54
|
+
cs3dLogger.warn("No metadata provider holds the predecessor ".concat(imageId, ", so the ") + "instance names no predecessor and joins no existing series. " + "The instance goes into the new series that the derivation made.");
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const generalImage = (_metaData$get = metaData.get(MetadataModules.GENERAL_IMAGE, imageId)) !== null && _metaData$get !== void 0 ? _metaData$get : {};
|
|
58
|
+
const study = (_metaData$get2 = metaData.get(MetadataModules.GENERAL_STUDY, imageId)) !== null && _metaData$get2 !== void 0 ? _metaData$get2 : {};
|
|
59
|
+
const result = definedAttributesOf(metaData.get(MetadataModules.SERIES_DATA, imageId));
|
|
60
|
+
if (result.SeriesInstanceUID === undefined) {
|
|
61
|
+
throw new Error("The predecessor ".concat(imageId, " carries no SeriesInstanceUID, which ") + "PredecessorDocumentsSequence requires. Refusing to write an " + "instance that names an incomplete predecessor.");
|
|
62
|
+
}
|
|
63
|
+
if (study.studyInstanceUID === undefined) {
|
|
64
|
+
throw new Error("The predecessor ".concat(imageId, " carries no StudyInstanceUID, which ") + "PredecessorDocumentsSequence requires. Refusing to write an " + "instance that names an incomplete predecessor.");
|
|
65
|
+
}
|
|
66
|
+
const predecessorNumber = Number(generalImage.instanceNumber);
|
|
67
|
+
result.InstanceNumber = Number.isFinite(predecessorNumber) ? 1 + predecessorNumber : 1;
|
|
52
68
|
result.PredecessorDocumentsSequence = {
|
|
53
69
|
StudyInstanceUID: study.studyInstanceUID,
|
|
54
70
|
ReferencedSeriesSequence: {
|
|
55
71
|
SeriesInstanceUID: result.SeriesInstanceUID,
|
|
56
72
|
ReferencedSOPSequence: {
|
|
57
|
-
ReferencedSOPClassUID:
|
|
58
|
-
ReferencedSOPInstanceUID:
|
|
73
|
+
ReferencedSOPClassUID: sopModule.sopClassUID,
|
|
74
|
+
ReferencedSOPInstanceUID: sopModule.sopInstanceUID
|
|
59
75
|
}
|
|
60
76
|
}
|
|
61
77
|
};
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.10.3";
|
package/dist/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/adapters",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.3",
|
|
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",
|
|
@@ -99,12 +99,13 @@
|
|
|
99
99
|
"ndarray": "1.0.19"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@cornerstonejs/core": "5.
|
|
103
|
-
"@cornerstonejs/
|
|
102
|
+
"@cornerstonejs/core": "5.10.3",
|
|
103
|
+
"@cornerstonejs/metadata": "5.10.3",
|
|
104
|
+
"@cornerstonejs/tools": "5.10.3"
|
|
104
105
|
},
|
|
105
106
|
"peerDependencies": {
|
|
106
|
-
"@cornerstonejs/core": "5.
|
|
107
|
-
"@cornerstonejs/
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
"@cornerstonejs/core": "5.10.3",
|
|
108
|
+
"@cornerstonejs/metadata": "5.10.3",
|
|
109
|
+
"@cornerstonejs/tools": "5.10.3"
|
|
110
|
+
}
|
|
110
111
|
}
|