@ohif/app 3.10.0-beta.113 → 3.10.0-beta.115
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/1568.bundle.af4308b321dfab0445e6.js +6562 -0
- package/dist/{1919.bundle.fae108d3c6ad35ed05ae.js → 1919.bundle.8bd683b21cbfe1cb71a7.js} +12 -8
- package/dist/1919.css +1 -1
- package/dist/{870.bundle.26a075bb828c43c13794.js → 2308.bundle.8db15bbd9d5833f21526.js} +54 -135
- package/dist/{870.css → 2308.css} +1 -1
- package/dist/{2701.bundle.c9ea5a2bd0df31dd3aaa.js → 2701.bundle.b68c4419910024a0758d.js} +14 -10
- package/dist/3480.bundle.22f8a106b17da4d7e826.js +7495 -0
- package/dist/{3677.bundle.22ecea02fae99fc4b073.js → 3677.bundle.4a319db2fd495efa4564.js} +1648 -1654
- package/dist/{5770.bundle.700382010763de7c58fd.js → 4113.bundle.8fccd7af6118fde173aa.js} +34 -80
- package/dist/{4202.bundle.add83801fbc8227d551b.js → 4202.bundle.c86958c59da67316127c.js} +1 -1
- package/dist/{4526.bundle.bf1047785c90ef0a9fec.js → 4526.bundle.7b394677fd5dc4fad06f.js} +6 -6
- package/dist/{99.bundle.f7e8de6d86029ec75605.js → 4675.bundle.b7e00e5915520885fa1f.js} +967 -2
- package/dist/4743.bundle.9faa6ddab058d9a939f4.js +6634 -0
- package/dist/{4759.bundle.0d60078f58f5a56c0157.js → 4759.bundle.e4ff22f9db3f555aad7b.js} +4 -0
- package/dist/4759.css +1 -1
- package/dist/{2236.bundle.2fbf9a607e380f3bdd7f.js → 4789.bundle.5bc2d9e5507319d9cadf.js} +22327 -22350
- package/dist/{4834.bundle.750ec176d0ef84772b0a.js → 4834.bundle.6b5e7e0fc3343ec1960a.js} +1 -1
- package/dist/{4991.bundle.aa561005b9bff1f391af.js → 4991.bundle.897fe8cb1e85dbf31543.js} +4 -0
- package/dist/5258.bundle.f95ab2e02467a734bdb6.js +4519 -0
- package/dist/{5915.bundle.84b8c2aa4d4a8c7e40a2.js → 5341.bundle.2f963b49a4856e342cd1.js} +48327 -48879
- package/dist/{5674.bundle.05e639d0871778c8093a.js → 5674.bundle.977cff87c10fbb29cbb3.js} +4 -0
- package/dist/5674.css +1 -1
- package/dist/{573.bundle.ae0bd4f3e1f4eac8ae43.js → 573.bundle.9549b3f7fa44438654f0.js} +1 -1
- package/dist/{6027.bundle.32be836eef7308434394.js → 6027.bundle.d85e8a6bae1085cda03e.js} +3 -5
- package/dist/{8888.bundle.f6a648dc743772c89787.js → 6139.bundle.12d9035382cda028683b.js} +26538 -32458
- package/dist/{6201.bundle.11e6c535543d13b0bb98.js → 6201.bundle.db75c77eb056cb88c2b0.js} +4 -4
- package/dist/6201.css +1 -1
- package/dist/{6341.bundle.5e868cc5104bc834fcbc.js → 6341.bundle.40ae99e784ab35e9407c.js} +11 -21
- package/dist/6341.css +1 -1
- package/dist/{5038.bundle.790dfe509bc9841701b0.js → 6727.bundle.ffc91186f23237ec35c4.js} +4022 -11619
- package/dist/{6734.bundle.1a6cfb006f9a16963b0d.js → 6734.bundle.6829e6ba782c290fb687.js} +2 -2
- package/dist/6734.css +1 -1
- package/dist/6752.bundle.e33e02dd8f006be51464.js +2249 -0
- package/dist/{7197.bundle.3503d1951304cac940fa.js → 7197.bundle.e8529fdc03c3cc927e38.js} +50 -41
- package/dist/7197.css +1 -1
- package/dist/{5692.bundle.22ae2ac093b6d6b65a6e.js → 7942.bundle.a76695b6bc780cbf0b23.js} +474 -513
- package/dist/{8008.bundle.74e51bdb02ff5d264f50.js → 8008.bundle.bbb188c7a9c5358b5682.js} +4 -9
- package/dist/{810.bundle.342fc8fac8ae665558c6.js → 810.bundle.e388d7b970d9622441c4.js} +10 -10
- package/dist/810.css +1 -1
- package/dist/{8228.bundle.4bcb42b49355447ef23c.js → 8228.bundle.9532c8d75799a8d9c093.js} +2 -2
- package/dist/{8259.bundle.39723f9c04717f80687e.js → 8259.bundle.0f474d990a129494e1df.js} +3 -3
- package/dist/8402.css +1 -1
- package/dist/{8558.bundle.56d667a6969a60bab102.js → 8558.bundle.ffb653dfb0104bdd128e.js} +5 -1
- package/dist/8834.bundle.88696f3afc37982b4273.js +14581 -0
- package/dist/{9026.bundle.90271a421048d1adc3db.js → 9026.bundle.317d3f9be65ef67b9bff.js} +15 -10
- package/dist/{9551.bundle.44d1426054e46cf5d673.js → 9551.bundle.92b13000deb4aa87f2fd.js} +4 -9
- package/dist/{9072.bundle.49293623f9ed4582eeeb.js → 9855.bundle.ba46a4315a78373262ad.js} +451 -393
- package/dist/{9862.bundle.a4ccc41bcff91a46d37e.js → 9862.bundle.e44946f8d28ded1e722f.js} +3 -3
- package/dist/{9890.bundle.07483064f31feb5718a4.js → 9890.bundle.711bf3486194cdd5c039.js} +6 -6
- package/dist/9890.css +1 -1
- package/dist/app-config.js +8 -1
- package/dist/{app.bundle.3dc9aa5b6077224cc394.js → app.bundle.aac0f76ff17b3e978aa1.js} +55160 -53512
- package/dist/app.bundle.css +2 -2
- package/dist/{polySeg.bundle.d41f5224f4efc124505a.js → compute.bundle.fa052dcf2ef82b4950ad.js} +4 -3
- package/dist/{histogram-worker.bundle.6b0dbbdb168d711efad4.js → histogram-worker.bundle.986106c30f091f2cef47.js} +2 -1
- package/dist/index.html +1 -1
- package/dist/polySeg.bundle.7d21e7dc9b361089e3a5.js +250 -0
- package/dist/{suv-peak-worker.bundle.4ca63044b76f51350d34.js → suv-peak-worker.bundle.f22f853b6599f7ec6f0c.js} +6 -5
- package/dist/sw.js +1 -1
- package/package.json +19 -19
- package/dist/2045.bundle.aaa10dff6d93bec47a45.js +0 -9708
- package/dist/6896.bundle.ca9b905abe733f279387.js +0 -7147
- /package/dist/{213.bundle.a98935570805e4a7b9b2.js → 213.bundle.533d331e72ec5aa85b1c.js} +0 -0
- /package/dist/{2424.bundle.4f1eeae6a8f248dd34c1.js → 2424.bundle.4f39ac6cdb1a28a0ded3.js} +0 -0
- /package/dist/{2825.bundle.a9ed7e8b46a92a157797.js → 2825.bundle.f6bfd4cc1a286ebb1b38.js} +0 -0
- /package/dist/{7955.bundle.eba45d4238f7e762545d.js → 7955.bundle.24dbe9de87056ecbb422.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[
|
|
1
|
+
(globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[4675],{
|
|
2
2
|
|
|
3
3
|
/***/ 19742:
|
|
4
4
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
/* harmony export */ });
|
|
11
11
|
/* harmony import */ var _cornerstoneStreamingImageVolumeLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55500);
|
|
12
12
|
/* harmony import */ var _cornerstoneStreamingDynamicImageVolumeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(55509);
|
|
13
|
-
/* harmony import */ var _geometryLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(
|
|
13
|
+
/* harmony import */ var _geometryLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89926);
|
|
14
14
|
/* harmony import */ var _imageLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80068);
|
|
15
15
|
/* harmony import */ var _volumeLoader__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(39561);
|
|
16
16
|
|
|
@@ -21,6 +21,971 @@
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
/***/ }),
|
|
25
|
+
|
|
26
|
+
/***/ 56983:
|
|
27
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
28
|
+
|
|
29
|
+
"use strict";
|
|
30
|
+
// ESM COMPAT FLAG
|
|
31
|
+
__webpack_require__.r(__webpack_exports__);
|
|
32
|
+
|
|
33
|
+
// EXPORTS
|
|
34
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
35
|
+
canComputeRequestedRepresentation: () => (/* reexport */ canComputeRequestedRepresentation),
|
|
36
|
+
computeContourData: () => (/* reexport */ computeContourData),
|
|
37
|
+
computeLabelmapData: () => (/* reexport */ computeLabelmapData),
|
|
38
|
+
computeSurfaceData: () => (/* reexport */ computeSurfaceData),
|
|
39
|
+
init: () => (/* binding */ init),
|
|
40
|
+
updateSurfaceData: () => (/* reexport */ updateSurfaceData)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js
|
|
44
|
+
var esm = __webpack_require__(81985);
|
|
45
|
+
// EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/index.js
|
|
46
|
+
var dist_esm = __webpack_require__(4667);
|
|
47
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Contour/utils/extractContourData.js
|
|
48
|
+
function extractContourData(polyDataCache) {
|
|
49
|
+
const rawResults = new Map();
|
|
50
|
+
for (const [segmentIndex, intersectionInfo] of polyDataCache) {
|
|
51
|
+
const segmentIndexNumber = Number(segmentIndex);
|
|
52
|
+
for (const [_, result] of intersectionInfo) {
|
|
53
|
+
if (!result) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!rawResults.has(segmentIndexNumber)) {
|
|
57
|
+
rawResults.set(segmentIndexNumber, []);
|
|
58
|
+
}
|
|
59
|
+
rawResults.get(segmentIndexNumber).push(result);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return rawResults;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Surface/convertContourToSurface.js
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const { WorkerTypes } = dist_esm.Enums;
|
|
69
|
+
const { getAnnotation } = dist_esm.annotation.state;
|
|
70
|
+
const workerManager = (0,esm.getWebWorkerManager)();
|
|
71
|
+
const triggerWorkerProgress = (eventTarget, progress, id) => {
|
|
72
|
+
(0,esm.triggerEvent)(eventTarget, esm.Enums.Events.WEB_WORKER_PROGRESS, {
|
|
73
|
+
progress,
|
|
74
|
+
type: WorkerTypes.POLYSEG_CONTOUR_TO_SURFACE,
|
|
75
|
+
id,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
async function convertContourToSurface(contourRepresentationData, segmentIndex) {
|
|
79
|
+
const { annotationUIDsMap } = contourRepresentationData;
|
|
80
|
+
const polylines = [];
|
|
81
|
+
const numPointsArray = [];
|
|
82
|
+
const annotationUIDs = annotationUIDsMap.get(segmentIndex);
|
|
83
|
+
for (const annotationUID of annotationUIDs) {
|
|
84
|
+
const annotation = getAnnotation(annotationUID);
|
|
85
|
+
const { polyline } = annotation.data.contour;
|
|
86
|
+
numPointsArray.push(polyline.length);
|
|
87
|
+
polyline.forEach((polyline) => polylines.push(...polyline));
|
|
88
|
+
}
|
|
89
|
+
triggerWorkerProgress(esm.eventTarget, 0, segmentIndex);
|
|
90
|
+
const results = await workerManager.executeTask('polySeg', 'convertContourToSurface', {
|
|
91
|
+
polylines,
|
|
92
|
+
numPointsArray,
|
|
93
|
+
}, {
|
|
94
|
+
callbacks: [
|
|
95
|
+
(progress) => {
|
|
96
|
+
triggerWorkerProgress(esm.eventTarget, progress, segmentIndex);
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
triggerWorkerProgress(esm.eventTarget, 100, segmentIndex);
|
|
101
|
+
return results;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Surface/createAndCacheSurfacesFromRaw.js
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
const { getSegmentation } = dist_esm.segmentation.state;
|
|
108
|
+
const { getSegmentIndexColor } = dist_esm.segmentation.config.color;
|
|
109
|
+
async function createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesData, options = {}) {
|
|
110
|
+
const segmentation = getSegmentation(segmentationId);
|
|
111
|
+
const geometryIds = new Map();
|
|
112
|
+
const promises = Object.keys(rawSurfacesData).map(async (index) => {
|
|
113
|
+
const rawSurfaceData = rawSurfacesData[index];
|
|
114
|
+
const segmentIndex = rawSurfaceData.segmentIndex;
|
|
115
|
+
const color = getSegmentIndexColor(options.viewport.id, segmentation.segmentationId, segmentIndex).slice(0, 3);
|
|
116
|
+
if (!color) {
|
|
117
|
+
throw new Error('No color found for segment index, unable to create surface');
|
|
118
|
+
}
|
|
119
|
+
const closedSurface = {
|
|
120
|
+
id: `segmentation_${segmentation.segmentationId}_surface_${segmentIndex}`,
|
|
121
|
+
color,
|
|
122
|
+
frameOfReferenceUID: 'test-frameOfReferenceUID',
|
|
123
|
+
points: rawSurfaceData.data.points,
|
|
124
|
+
polys: rawSurfaceData.data.polys,
|
|
125
|
+
segmentIndex,
|
|
126
|
+
};
|
|
127
|
+
const geometryId = closedSurface.id;
|
|
128
|
+
geometryIds.set(segmentIndex, geometryId);
|
|
129
|
+
return esm.geometryLoader.createAndCacheGeometry(geometryId, {
|
|
130
|
+
type: esm.Enums.GeometryType.SURFACE,
|
|
131
|
+
geometryData: closedSurface,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
await Promise.all(promises);
|
|
135
|
+
return {
|
|
136
|
+
geometryIds,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Surface/convertLabelmapToSurface.js
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
const { WorkerTypes: convertLabelmapToSurface_WorkerTypes } = dist_esm.Enums;
|
|
144
|
+
const { computeVolumeLabelmapFromStack } = dist_esm.utilities.segmentation;
|
|
145
|
+
const convertLabelmapToSurface_workerManager = (0,esm.getWebWorkerManager)();
|
|
146
|
+
const convertLabelmapToSurface_triggerWorkerProgress = (eventTarget, progress, id) => {
|
|
147
|
+
(0,esm.triggerEvent)(eventTarget, esm.Enums.Events.WEB_WORKER_PROGRESS, {
|
|
148
|
+
progress,
|
|
149
|
+
type: convertLabelmapToSurface_WorkerTypes.POLYSEG_LABELMAP_TO_SURFACE,
|
|
150
|
+
id,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
async function convertLabelmapToSurface(labelmapRepresentationData, segmentIndex) {
|
|
154
|
+
let volumeId;
|
|
155
|
+
if (labelmapRepresentationData
|
|
156
|
+
.volumeId) {
|
|
157
|
+
volumeId = labelmapRepresentationData.volumeId;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const { imageIds } = labelmapRepresentationData;
|
|
161
|
+
({ volumeId } = await computeVolumeLabelmapFromStack({
|
|
162
|
+
imageIds,
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
const volume = esm.cache.getVolume(volumeId);
|
|
166
|
+
const scalarData = volume.voxelManager.getCompleteScalarDataArray();
|
|
167
|
+
const { dimensions, spacing, origin, direction } = volume;
|
|
168
|
+
convertLabelmapToSurface_triggerWorkerProgress(esm.eventTarget, 0, segmentIndex);
|
|
169
|
+
const results = await convertLabelmapToSurface_workerManager.executeTask('polySeg', 'convertLabelmapToSurface', {
|
|
170
|
+
scalarData,
|
|
171
|
+
dimensions,
|
|
172
|
+
spacing,
|
|
173
|
+
origin,
|
|
174
|
+
direction,
|
|
175
|
+
segmentIndex,
|
|
176
|
+
}, {
|
|
177
|
+
callbacks: [
|
|
178
|
+
(progress) => {
|
|
179
|
+
convertLabelmapToSurface_triggerWorkerProgress(esm.eventTarget, progress, segmentIndex);
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
convertLabelmapToSurface_triggerWorkerProgress(esm.eventTarget, 100, segmentIndex);
|
|
184
|
+
return results;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Surface/surfaceComputationStrategies.js
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
const { getUniqueSegmentIndices } = dist_esm.utilities.segmentation;
|
|
193
|
+
const { getSegmentation: surfaceComputationStrategies_getSegmentation } = dist_esm.segmentation.state;
|
|
194
|
+
async function computeSurfaceData(segmentationId, options = {}) {
|
|
195
|
+
const segmentIndices = options.segmentIndices?.length
|
|
196
|
+
? options.segmentIndices
|
|
197
|
+
: getUniqueSegmentIndices(segmentationId);
|
|
198
|
+
let rawSurfacesData;
|
|
199
|
+
const segmentation = surfaceComputationStrategies_getSegmentation(segmentationId);
|
|
200
|
+
const representationData = segmentation.representationData;
|
|
201
|
+
try {
|
|
202
|
+
if (representationData.Contour) {
|
|
203
|
+
rawSurfacesData = await computeSurfaceFromContourSegmentation(segmentationId, {
|
|
204
|
+
segmentIndices,
|
|
205
|
+
...options,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else if (representationData.Labelmap) {
|
|
209
|
+
rawSurfacesData = await computeSurfaceFromLabelmapSegmentation(segmentation.segmentationId, {
|
|
210
|
+
segmentIndices,
|
|
211
|
+
...options,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.error(error);
|
|
217
|
+
throw error;
|
|
218
|
+
}
|
|
219
|
+
if (!rawSurfacesData) {
|
|
220
|
+
throw new Error('Not enough data to convert to surface, currently only support converting volume labelmap to surface if available');
|
|
221
|
+
}
|
|
222
|
+
const surfacesData = await createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesData, options);
|
|
223
|
+
return surfacesData;
|
|
224
|
+
}
|
|
225
|
+
async function computeSurfaceFromLabelmapSegmentation(segmentationId, options = {}) {
|
|
226
|
+
const segmentation = surfaceComputationStrategies_getSegmentation(segmentationId);
|
|
227
|
+
if (!segmentation?.representationData?.Labelmap) {
|
|
228
|
+
console.warn('Only support surface update from labelmaps');
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const labelmapRepresentationData = segmentation.representationData.Labelmap;
|
|
232
|
+
const segmentIndices = options.segmentIndices || getUniqueSegmentIndices(segmentationId);
|
|
233
|
+
const promises = segmentIndices.map((index) => {
|
|
234
|
+
const surface = convertLabelmapToSurface(labelmapRepresentationData, index);
|
|
235
|
+
return surface;
|
|
236
|
+
});
|
|
237
|
+
const surfaces = await Promise.allSettled(promises);
|
|
238
|
+
const errors = surfaces.filter((p) => p.status === 'rejected');
|
|
239
|
+
if (errors.length > 0) {
|
|
240
|
+
console.error(errors);
|
|
241
|
+
throw new Error('Failed to convert labelmap to surface');
|
|
242
|
+
}
|
|
243
|
+
const rawSurfacesData = surfaces
|
|
244
|
+
.map((surface, index) => {
|
|
245
|
+
if (surface.status === 'fulfilled') {
|
|
246
|
+
return { segmentIndex: segmentIndices[index], data: surface.value };
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
.filter(Boolean);
|
|
250
|
+
return rawSurfacesData;
|
|
251
|
+
}
|
|
252
|
+
async function computeSurfaceFromContourSegmentation(segmentationId, options = {}) {
|
|
253
|
+
const segmentation = surfaceComputationStrategies_getSegmentation(segmentationId);
|
|
254
|
+
const contourRepresentationData = segmentation.representationData.Contour;
|
|
255
|
+
const segmentIndices = options.segmentIndices || getUniqueSegmentIndices(segmentationId);
|
|
256
|
+
const promises = segmentIndices.map(async (index) => {
|
|
257
|
+
const surface = await convertContourToSurface(contourRepresentationData, index);
|
|
258
|
+
return { segmentIndex: index, data: surface };
|
|
259
|
+
});
|
|
260
|
+
const surfaces = await Promise.all(promises);
|
|
261
|
+
return surfaces;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/registerPolySegWorker.js
|
|
266
|
+
|
|
267
|
+
let registered = false;
|
|
268
|
+
function registerPolySegWorker() {
|
|
269
|
+
if (registered) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
registered = true;
|
|
273
|
+
const workerFn = () => {
|
|
274
|
+
return new Worker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u(572), __webpack_require__.b), {
|
|
275
|
+
name: 'polySeg',
|
|
276
|
+
type: undefined,
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
const workerManager = (0,esm.getWebWorkerManager)();
|
|
280
|
+
const options = {
|
|
281
|
+
maxWorkerInstances: 1,
|
|
282
|
+
autoTerminateOnIdle: {
|
|
283
|
+
enabled: true,
|
|
284
|
+
idleTimeThreshold: 2000,
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
workerManager.registerWorker('polySeg', workerFn, options);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/utilities/clipAndCacheSurfacesForViewport.js
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
const clipAndCacheSurfacesForViewport_workerManager = (0,esm.getWebWorkerManager)();
|
|
295
|
+
const { WorkerTypes: clipAndCacheSurfacesForViewport_WorkerTypes } = dist_esm.Enums;
|
|
296
|
+
const { pointToString } = dist_esm.utilities;
|
|
297
|
+
const polyDataCache = new Map();
|
|
298
|
+
const surfacesAABBCache = new Map();
|
|
299
|
+
const clipAndCacheSurfacesForViewport_triggerWorkerProgress = (eventTarget, progress) => {
|
|
300
|
+
(0,esm.triggerEvent)(eventTarget, esm.Enums.Events.WEB_WORKER_PROGRESS, {
|
|
301
|
+
progress,
|
|
302
|
+
type: clipAndCacheSurfacesForViewport_WorkerTypes.SURFACE_CLIPPING,
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
async function clipAndCacheSurfacesForViewport(surfacesInfo, viewport) {
|
|
306
|
+
registerPolySegWorker();
|
|
307
|
+
const planesInfo = viewport.getSlicesClippingPlanes?.();
|
|
308
|
+
if (!planesInfo) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const currentSliceIndex = viewport.getSliceIndex();
|
|
312
|
+
planesInfo.sort((a, b) => {
|
|
313
|
+
const diffA = Math.abs(a.sliceIndex - currentSliceIndex);
|
|
314
|
+
const diffB = Math.abs(b.sliceIndex - currentSliceIndex);
|
|
315
|
+
return diffA - diffB;
|
|
316
|
+
});
|
|
317
|
+
clipAndCacheSurfacesForViewport_triggerWorkerProgress(esm.eventTarget, 0);
|
|
318
|
+
await updateSurfacesAABBCache(surfacesInfo);
|
|
319
|
+
const surfacesAABB = new Map();
|
|
320
|
+
surfacesInfo.forEach((surface) => {
|
|
321
|
+
surfacesAABB.set(surface.id, surfacesAABBCache.get(surface.id));
|
|
322
|
+
});
|
|
323
|
+
const camera = viewport.getCamera();
|
|
324
|
+
await clipAndCacheSurfacesForViewport_workerManager
|
|
325
|
+
.executeTask('polySeg', 'cutSurfacesIntoPlanes', {
|
|
326
|
+
surfacesInfo,
|
|
327
|
+
planesInfo,
|
|
328
|
+
surfacesAABB,
|
|
329
|
+
}, {
|
|
330
|
+
callbacks: [
|
|
331
|
+
({ progress }) => {
|
|
332
|
+
clipAndCacheSurfacesForViewport_triggerWorkerProgress(esm.eventTarget, progress);
|
|
333
|
+
},
|
|
334
|
+
({ sliceIndex, polyDataResults }) => {
|
|
335
|
+
polyDataResults.forEach((polyDataResult, segmentIndex) => {
|
|
336
|
+
const segmentIndexNumber = Number(segmentIndex);
|
|
337
|
+
const cacheId = generateCacheId(viewport, camera.viewPlaneNormal, sliceIndex);
|
|
338
|
+
updatePolyDataCache(segmentIndexNumber, cacheId, polyDataResult);
|
|
339
|
+
});
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
})
|
|
343
|
+
.catch((error) => {
|
|
344
|
+
console.error(error);
|
|
345
|
+
});
|
|
346
|
+
clipAndCacheSurfacesForViewport_triggerWorkerProgress(esm.eventTarget, 100);
|
|
347
|
+
return polyDataCache;
|
|
348
|
+
}
|
|
349
|
+
async function updateSurfacesAABBCache(surfacesInfo) {
|
|
350
|
+
const surfacesWithoutAABB = surfacesInfo.filter((surface) => !surfacesAABBCache.has(surface.id));
|
|
351
|
+
if (!surfacesWithoutAABB.length) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const surfacesAABB = await clipAndCacheSurfacesForViewport_workerManager.executeTask('polySeg', 'getSurfacesAABBs', {
|
|
355
|
+
surfacesInfo: surfacesWithoutAABB,
|
|
356
|
+
}, {
|
|
357
|
+
callbacks: [
|
|
358
|
+
({ progress }) => {
|
|
359
|
+
clipAndCacheSurfacesForViewport_triggerWorkerProgress(esm.eventTarget, progress);
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
});
|
|
363
|
+
surfacesAABB.forEach((aabb, id) => {
|
|
364
|
+
surfacesAABBCache.set(id, aabb);
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
function generateCacheId(viewport, viewPlaneNormal, sliceIndex) {
|
|
368
|
+
return `${viewport.id}-${pointToString(viewPlaneNormal)}-${sliceIndex}`;
|
|
369
|
+
}
|
|
370
|
+
function updatePolyDataCache(segmentIndex, cacheId, polyDataResult) {
|
|
371
|
+
const { points, lines, numberOfCells } = polyDataResult;
|
|
372
|
+
let segmentCache = polyDataCache.get(segmentIndex);
|
|
373
|
+
if (!segmentCache) {
|
|
374
|
+
segmentCache = new Map();
|
|
375
|
+
polyDataCache.set(segmentIndex, segmentCache);
|
|
376
|
+
}
|
|
377
|
+
segmentCache.set(cacheId, { points, lines, numberOfCells });
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
const { addAnnotation } = dist_esm.annotation.state;
|
|
384
|
+
function createAndAddContourSegmentationsFromClippedSurfaces(rawContourData, viewport, segmentationId) {
|
|
385
|
+
const annotationUIDsMap = new Map();
|
|
386
|
+
for (const [segmentIndex, contoursData] of rawContourData) {
|
|
387
|
+
for (const contourData of contoursData) {
|
|
388
|
+
const { points } = contourData;
|
|
389
|
+
const { lineSegments, linesNumberOfPoints } = _extractLineSegments(contourData);
|
|
390
|
+
for (let i = 0; i < lineSegments.length; i++) {
|
|
391
|
+
const line = lineSegments[i];
|
|
392
|
+
const polyline = [];
|
|
393
|
+
for (let j = 0; j < linesNumberOfPoints[i]; j++) {
|
|
394
|
+
const pointIndex = line[j];
|
|
395
|
+
polyline.push([
|
|
396
|
+
points[3 * pointIndex],
|
|
397
|
+
points[3 * pointIndex + 1],
|
|
398
|
+
points[3 * pointIndex + 2],
|
|
399
|
+
]);
|
|
400
|
+
}
|
|
401
|
+
if (polyline.length < 3) {
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
404
|
+
const contourSegmentationAnnotation = {
|
|
405
|
+
annotationUID: esm.utilities.uuidv4(),
|
|
406
|
+
data: {
|
|
407
|
+
contour: {
|
|
408
|
+
closed: true,
|
|
409
|
+
polyline,
|
|
410
|
+
},
|
|
411
|
+
segmentation: {
|
|
412
|
+
segmentationId,
|
|
413
|
+
segmentIndex,
|
|
414
|
+
},
|
|
415
|
+
handles: {},
|
|
416
|
+
},
|
|
417
|
+
handles: {},
|
|
418
|
+
highlighted: false,
|
|
419
|
+
autoGenerated: false,
|
|
420
|
+
invalidated: false,
|
|
421
|
+
isLocked: false,
|
|
422
|
+
isVisible: true,
|
|
423
|
+
metadata: {
|
|
424
|
+
toolName: dist_esm.PlanarFreehandContourSegmentationTool.toolName,
|
|
425
|
+
...viewport.getViewReference(),
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
addAnnotation(contourSegmentationAnnotation, viewport.element);
|
|
429
|
+
const currentSet = annotationUIDsMap?.get(segmentIndex) || new Set();
|
|
430
|
+
currentSet.add(contourSegmentationAnnotation.annotationUID);
|
|
431
|
+
annotationUIDsMap.set(segmentIndex, currentSet);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return annotationUIDsMap;
|
|
436
|
+
}
|
|
437
|
+
const _extractLineSegments = (contourData) => {
|
|
438
|
+
const { numberOfCells, lines } = contourData;
|
|
439
|
+
const lineSegments = [];
|
|
440
|
+
const linesNumberOfPoints = [];
|
|
441
|
+
for (let i = 0; i < lines.length;) {
|
|
442
|
+
const pointsInLine = lines[i];
|
|
443
|
+
linesNumberOfPoints.push(pointsInLine);
|
|
444
|
+
lineSegments.push(lines.slice(i + 1, i + pointsInLine + 1));
|
|
445
|
+
i += pointsInLine + 1;
|
|
446
|
+
if (lineSegments.length === numberOfCells) {
|
|
447
|
+
break;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return { lineSegments, linesNumberOfPoints };
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Contour/contourComputationStrategies.js
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
const { getUniqueSegmentIndices: contourComputationStrategies_getUniqueSegmentIndices } = dist_esm.utilities.segmentation;
|
|
461
|
+
const { getSegmentation: contourComputationStrategies_getSegmentation } = dist_esm.segmentation.state;
|
|
462
|
+
const { segmentationStyle } = dist_esm.segmentation;
|
|
463
|
+
const { SegmentationRepresentations } = dist_esm.Enums;
|
|
464
|
+
async function computeContourData(segmentationId, options = {}) {
|
|
465
|
+
const segmentIndices = options.segmentIndices?.length
|
|
466
|
+
? options.segmentIndices
|
|
467
|
+
: contourComputationStrategies_getUniqueSegmentIndices(segmentationId);
|
|
468
|
+
let rawContourData;
|
|
469
|
+
const segmentation = contourComputationStrategies_getSegmentation(segmentationId);
|
|
470
|
+
const representationData = segmentation.representationData;
|
|
471
|
+
try {
|
|
472
|
+
if (representationData.Surface) {
|
|
473
|
+
rawContourData = await computeContourFromSurfaceSegmentation(segmentationId, {
|
|
474
|
+
segmentIndices,
|
|
475
|
+
...options,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
else if (representationData.Labelmap) {
|
|
479
|
+
rawContourData = await computeContourFromLabelmapSegmentation(segmentationId, {
|
|
480
|
+
segmentIndices,
|
|
481
|
+
...options,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
console.error(error);
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
489
|
+
if (!rawContourData) {
|
|
490
|
+
throw new Error('Not enough data to convert to contour, currently only support converting volume labelmap to contour if available');
|
|
491
|
+
}
|
|
492
|
+
const { viewport } = options;
|
|
493
|
+
const annotationUIDsMap = createAndAddContourSegmentationsFromClippedSurfaces(rawContourData, viewport, segmentationId);
|
|
494
|
+
segmentationStyle.setStyle({ segmentationId, type: SegmentationRepresentations.Contour }, {
|
|
495
|
+
fillAlpha: 0,
|
|
496
|
+
});
|
|
497
|
+
return {
|
|
498
|
+
annotationUIDsMap,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async function computeContourFromLabelmapSegmentation(segmentationId, options = {}) {
|
|
502
|
+
if (!options.viewport) {
|
|
503
|
+
throw new Error('Viewport is required to compute contour from labelmap');
|
|
504
|
+
}
|
|
505
|
+
const results = await computeSurfaceFromLabelmapSegmentation(segmentationId, options);
|
|
506
|
+
if (!results?.length) {
|
|
507
|
+
console.error('Failed to convert labelmap to surface or labelmap is empty');
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const { viewport } = options;
|
|
511
|
+
const pointsAndPolys = results.map((surface) => {
|
|
512
|
+
return {
|
|
513
|
+
id: surface.segmentIndex.toString(),
|
|
514
|
+
points: surface.data.points,
|
|
515
|
+
polys: surface.data.polys,
|
|
516
|
+
segmentIndex: surface.segmentIndex,
|
|
517
|
+
};
|
|
518
|
+
});
|
|
519
|
+
const polyDataCache = await clipAndCacheSurfacesForViewport(pointsAndPolys, viewport);
|
|
520
|
+
const rawResults = extractContourData(polyDataCache);
|
|
521
|
+
return rawResults;
|
|
522
|
+
}
|
|
523
|
+
async function computeContourFromSurfaceSegmentation(segmentationId, options = {}) {
|
|
524
|
+
if (!options.viewport) {
|
|
525
|
+
throw new Error('Viewport is required to compute contour from surface');
|
|
526
|
+
}
|
|
527
|
+
const { viewport } = options;
|
|
528
|
+
const segmentIndices = options.segmentIndices?.length
|
|
529
|
+
? options.segmentIndices
|
|
530
|
+
: contourComputationStrategies_getUniqueSegmentIndices(segmentationId);
|
|
531
|
+
const segmentIndexToSurfaceId = new Map();
|
|
532
|
+
const surfaceIdToSegmentIndex = new Map();
|
|
533
|
+
const segmentation = contourComputationStrategies_getSegmentation(segmentationId);
|
|
534
|
+
const representationData = segmentation.representationData.Surface;
|
|
535
|
+
const surfacesInfo = [];
|
|
536
|
+
representationData.geometryIds.forEach((geometryId, segmentIndex) => {
|
|
537
|
+
if (segmentIndices.includes(segmentIndex)) {
|
|
538
|
+
segmentIndexToSurfaceId.set(segmentIndex, geometryId);
|
|
539
|
+
const surface = esm.cache.getGeometry(geometryId)?.data;
|
|
540
|
+
if (surface) {
|
|
541
|
+
surfacesInfo.push({
|
|
542
|
+
id: geometryId,
|
|
543
|
+
points: surface.points,
|
|
544
|
+
polys: surface.polys,
|
|
545
|
+
segmentIndex,
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
segmentIndexToSurfaceId.forEach((surfaceId, segmentIndex) => {
|
|
551
|
+
surfaceIdToSegmentIndex.set(surfaceId, segmentIndex);
|
|
552
|
+
});
|
|
553
|
+
const polyDataCache = await clipAndCacheSurfacesForViewport(surfacesInfo, viewport);
|
|
554
|
+
const rawResults = extractContourData(polyDataCache);
|
|
555
|
+
return rawResults;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
// EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/index.js
|
|
560
|
+
var gl_matrix_esm = __webpack_require__(40230);
|
|
561
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Labelmap/convertContourToLabelmap.js
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
const { WorkerTypes: convertContourToLabelmap_WorkerTypes } = dist_esm.Enums;
|
|
566
|
+
const { getAnnotation: convertContourToLabelmap_getAnnotation } = dist_esm.annotation.state;
|
|
567
|
+
const convertContourToLabelmap_workerManager = (0,esm.getWebWorkerManager)();
|
|
568
|
+
const convertContourToLabelmap_triggerWorkerProgress = (eventTarget, progress) => {
|
|
569
|
+
(0,esm.triggerEvent)(eventTarget, esm.Enums.Events.WEB_WORKER_PROGRESS, {
|
|
570
|
+
progress,
|
|
571
|
+
type: convertContourToLabelmap_WorkerTypes.POLYSEG_CONTOUR_TO_LABELMAP,
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
async function convertContourToVolumeLabelmap(contourRepresentationData, options = {}) {
|
|
575
|
+
const viewport = options.viewport;
|
|
576
|
+
const volumeId = viewport.getVolumeId();
|
|
577
|
+
const imageIds = esm.utilities.getViewportImageIds(viewport);
|
|
578
|
+
if (!imageIds) {
|
|
579
|
+
throw new Error('No imageIds found, labelmap computation from contour requires viewports with imageIds');
|
|
580
|
+
}
|
|
581
|
+
const segmentationVolumeId = esm.utilities.uuidv4();
|
|
582
|
+
const segmentationVolume = esm.volumeLoader.createAndCacheDerivedLabelmapVolume(volumeId, {
|
|
583
|
+
volumeId: segmentationVolumeId,
|
|
584
|
+
});
|
|
585
|
+
const { dimensions, origin, direction, spacing, voxelManager } = segmentationVolume;
|
|
586
|
+
const { segmentIndices, annotationUIDsInSegmentMap } = _getAnnotationMapFromSegmentation(contourRepresentationData, options);
|
|
587
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, 0);
|
|
588
|
+
const newScalarData = await convertContourToLabelmap_workerManager.executeTask('polySeg', 'convertContourToVolumeLabelmap', {
|
|
589
|
+
segmentIndices,
|
|
590
|
+
dimensions,
|
|
591
|
+
scalarData: voxelManager.getCompleteScalarDataArray?.(),
|
|
592
|
+
origin,
|
|
593
|
+
direction,
|
|
594
|
+
spacing,
|
|
595
|
+
annotationUIDsInSegmentMap,
|
|
596
|
+
}, {
|
|
597
|
+
callbacks: [
|
|
598
|
+
(progress) => {
|
|
599
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, progress);
|
|
600
|
+
},
|
|
601
|
+
],
|
|
602
|
+
});
|
|
603
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, 100);
|
|
604
|
+
voxelManager.setCompleteScalarDataArray(newScalarData);
|
|
605
|
+
segmentationVolume.modified();
|
|
606
|
+
return {
|
|
607
|
+
volumeId: segmentationVolume.volumeId,
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
async function convertContourToStackLabelmap(contourRepresentationData, options = {}) {
|
|
611
|
+
if (!options.viewport) {
|
|
612
|
+
throw new Error('No viewport provided, labelmap computation from contour requires viewports');
|
|
613
|
+
}
|
|
614
|
+
const viewport = options.viewport;
|
|
615
|
+
const imageIds = viewport.getImageIds();
|
|
616
|
+
if (!imageIds) {
|
|
617
|
+
throw new Error('No imageIds found, labelmap computation from contour requires viewports with imageIds');
|
|
618
|
+
}
|
|
619
|
+
imageIds.forEach((imageId) => {
|
|
620
|
+
if (!esm.cache.getImageLoadObject(imageId)) {
|
|
621
|
+
throw new Error('ImageIds must be cached before converting contour to labelmap');
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
const segImages = await esm.imageLoader.createAndCacheDerivedLabelmapImages(imageIds);
|
|
625
|
+
const segmentationImageIds = segImages.map((it) => it.imageId);
|
|
626
|
+
const { segmentIndices, annotationUIDsInSegmentMap } = _getAnnotationMapFromSegmentation(contourRepresentationData, options);
|
|
627
|
+
const segmentationsInfo = new Map();
|
|
628
|
+
segmentationImageIds.forEach((segImageId, index) => {
|
|
629
|
+
const segImage = esm.cache.getImage(segImageId);
|
|
630
|
+
const imagePlaneModule = esm.metaData.get(esm.Enums.MetadataModules.IMAGE_PLANE, segImageId);
|
|
631
|
+
let { columnCosines, rowCosines, rowPixelSpacing, columnPixelSpacing, imagePositionPatient, } = imagePlaneModule;
|
|
632
|
+
columnCosines = columnCosines ?? [0, 1, 0];
|
|
633
|
+
rowCosines = rowCosines ?? [1, 0, 0];
|
|
634
|
+
rowPixelSpacing = rowPixelSpacing ?? 1;
|
|
635
|
+
columnPixelSpacing = columnPixelSpacing ?? 1;
|
|
636
|
+
imagePositionPatient = imagePositionPatient ?? [0, 0, 0];
|
|
637
|
+
const rowCosineVec = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(rowCosines[0], rowCosines[1], rowCosines[2]);
|
|
638
|
+
const colCosineVec = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(columnCosines[0], columnCosines[1], columnCosines[2]);
|
|
639
|
+
const scanAxisNormal = gl_matrix_esm/* vec3.create */.eR.create();
|
|
640
|
+
gl_matrix_esm/* vec3.cross */.eR.cross(scanAxisNormal, rowCosineVec, colCosineVec);
|
|
641
|
+
const direction = [...rowCosineVec, ...colCosineVec, ...scanAxisNormal];
|
|
642
|
+
const spacing = [rowPixelSpacing, columnPixelSpacing, 1];
|
|
643
|
+
const origin = imagePositionPatient;
|
|
644
|
+
segmentationsInfo.set(imageIds[index], {
|
|
645
|
+
direction,
|
|
646
|
+
spacing,
|
|
647
|
+
origin,
|
|
648
|
+
scalarData: segImage.voxelManager.getScalarData(),
|
|
649
|
+
imageId: segImageId,
|
|
650
|
+
dimensions: [segImage.width, segImage.height, 1],
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, 0);
|
|
654
|
+
const newSegmentationsScalarData = await convertContourToLabelmap_workerManager.executeTask('polySeg', 'convertContourToStackLabelmap', {
|
|
655
|
+
segmentationsInfo,
|
|
656
|
+
annotationUIDsInSegmentMap,
|
|
657
|
+
segmentIndices,
|
|
658
|
+
}, {
|
|
659
|
+
callbacks: [
|
|
660
|
+
(progress) => {
|
|
661
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, progress);
|
|
662
|
+
},
|
|
663
|
+
],
|
|
664
|
+
});
|
|
665
|
+
convertContourToLabelmap_triggerWorkerProgress(esm.eventTarget, 100);
|
|
666
|
+
const segImageIds = [];
|
|
667
|
+
newSegmentationsScalarData.forEach(({ scalarData }, referencedImageId) => {
|
|
668
|
+
const segmentationInfo = segmentationsInfo.get(referencedImageId);
|
|
669
|
+
const { imageId: segImageId } = segmentationInfo;
|
|
670
|
+
const segImage = esm.cache.getImage(segImageId);
|
|
671
|
+
segImage.voxelManager.getScalarData().set(scalarData);
|
|
672
|
+
segImage.imageFrame?.pixelData?.set(scalarData);
|
|
673
|
+
segImageIds.push(segImageId);
|
|
674
|
+
});
|
|
675
|
+
return {
|
|
676
|
+
imageIds: segImageIds,
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function _getAnnotationMapFromSegmentation(contourRepresentationData, options = {}) {
|
|
680
|
+
const annotationMap = contourRepresentationData.annotationUIDsMap;
|
|
681
|
+
const segmentIndices = options.segmentIndices?.length
|
|
682
|
+
? options.segmentIndices
|
|
683
|
+
: Array.from(annotationMap.keys());
|
|
684
|
+
const annotationUIDsInSegmentMap = new Map();
|
|
685
|
+
segmentIndices.forEach((index) => {
|
|
686
|
+
const annotationUIDsInSegment = annotationMap.get(index);
|
|
687
|
+
let uids = Array.from(annotationUIDsInSegment);
|
|
688
|
+
uids = uids.filter((uid) => !convertContourToLabelmap_getAnnotation(uid).parentAnnotationUID);
|
|
689
|
+
const annotations = uids.map((uid) => {
|
|
690
|
+
const annotation = convertContourToLabelmap_getAnnotation(uid);
|
|
691
|
+
const hasChildAnnotations = annotation.childAnnotationUIDs?.length;
|
|
692
|
+
return {
|
|
693
|
+
polyline: annotation.data.contour.polyline,
|
|
694
|
+
referencedImageId: annotation.metadata.referencedImageId,
|
|
695
|
+
holesPolyline: hasChildAnnotations &&
|
|
696
|
+
annotation.childAnnotationUIDs.map((childUID) => {
|
|
697
|
+
const childAnnotation = convertContourToLabelmap_getAnnotation(childUID);
|
|
698
|
+
return childAnnotation.data.contour.polyline;
|
|
699
|
+
}),
|
|
700
|
+
};
|
|
701
|
+
});
|
|
702
|
+
annotationUIDsInSegmentMap.set(index, annotations);
|
|
703
|
+
});
|
|
704
|
+
return { segmentIndices, annotationUIDsInSegmentMap };
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Labelmap/convertSurfaceToLabelmap.js
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
const { WorkerTypes: convertSurfaceToLabelmap_WorkerTypes } = dist_esm.Enums;
|
|
711
|
+
const convertSurfaceToLabelmap_workerManager = (0,esm.getWebWorkerManager)();
|
|
712
|
+
const convertSurfaceToLabelmap_triggerWorkerProgress = (eventTarget, progress) => {
|
|
713
|
+
(0,esm.triggerEvent)(eventTarget, esm.Enums.Events.WEB_WORKER_PROGRESS, {
|
|
714
|
+
progress,
|
|
715
|
+
type: convertSurfaceToLabelmap_WorkerTypes.POLYSEG_SURFACE_TO_LABELMAP,
|
|
716
|
+
});
|
|
717
|
+
};
|
|
718
|
+
async function convertSurfaceToVolumeLabelmap(surfaceRepresentationData, segmentationVolume) {
|
|
719
|
+
const { geometryIds } = surfaceRepresentationData;
|
|
720
|
+
if (!geometryIds?.size) {
|
|
721
|
+
throw new Error('No geometry IDs found for surface representation');
|
|
722
|
+
}
|
|
723
|
+
const segmentsInfo = new Map();
|
|
724
|
+
geometryIds.forEach((geometryId, segmentIndex) => {
|
|
725
|
+
const geometry = esm.cache.getGeometry(geometryId);
|
|
726
|
+
const geometryData = geometry.data;
|
|
727
|
+
const points = geometryData.points;
|
|
728
|
+
const polys = geometryData.polys;
|
|
729
|
+
segmentsInfo.set(segmentIndex, {
|
|
730
|
+
points,
|
|
731
|
+
polys,
|
|
732
|
+
});
|
|
733
|
+
});
|
|
734
|
+
const { dimensions, direction, origin, spacing, voxelManager } = segmentationVolume;
|
|
735
|
+
convertSurfaceToLabelmap_triggerWorkerProgress(esm.eventTarget, 0);
|
|
736
|
+
const newScalarData = await convertSurfaceToLabelmap_workerManager.executeTask('polySeg', 'convertSurfacesToVolumeLabelmap', {
|
|
737
|
+
segmentsInfo,
|
|
738
|
+
dimensions,
|
|
739
|
+
spacing,
|
|
740
|
+
direction,
|
|
741
|
+
origin,
|
|
742
|
+
}, {
|
|
743
|
+
callbacks: [
|
|
744
|
+
(progress) => {
|
|
745
|
+
convertSurfaceToLabelmap_triggerWorkerProgress(esm.eventTarget, progress);
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
});
|
|
749
|
+
convertSurfaceToLabelmap_triggerWorkerProgress(esm.eventTarget, 100);
|
|
750
|
+
voxelManager.setCompleteScalarDataArray(newScalarData);
|
|
751
|
+
segmentationVolume.modified();
|
|
752
|
+
return {
|
|
753
|
+
volumeId: segmentationVolume.volumeId,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
async function convertSurfaceToStackLabelmap() {
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Labelmap/labelmapComputationStrategies.js
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
const { computeStackLabelmapFromVolume, getUniqueSegmentIndices: labelmapComputationStrategies_getUniqueSegmentIndices } = dist_esm.utilities.segmentation;
|
|
766
|
+
const { getSegmentation: labelmapComputationStrategies_getSegmentation } = dist_esm.segmentation.state;
|
|
767
|
+
async function computeLabelmapData(segmentationId, options = {}) {
|
|
768
|
+
const segmentIndices = options.segmentIndices?.length
|
|
769
|
+
? options.segmentIndices
|
|
770
|
+
: labelmapComputationStrategies_getUniqueSegmentIndices(segmentationId);
|
|
771
|
+
let rawLabelmapData;
|
|
772
|
+
const segmentation = labelmapComputationStrategies_getSegmentation(segmentationId);
|
|
773
|
+
const representationData = segmentation.representationData;
|
|
774
|
+
try {
|
|
775
|
+
if (representationData.Contour) {
|
|
776
|
+
rawLabelmapData = await computeLabelmapFromContourSegmentation(segmentationId, {
|
|
777
|
+
segmentIndices,
|
|
778
|
+
...options,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
else if (representationData.Surface) {
|
|
782
|
+
rawLabelmapData = await computeLabelmapFromSurfaceSegmentation(segmentation.segmentationId, {
|
|
783
|
+
segmentIndices,
|
|
784
|
+
...options,
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
catch (error) {
|
|
789
|
+
console.error(error);
|
|
790
|
+
throw error;
|
|
791
|
+
}
|
|
792
|
+
if (!rawLabelmapData) {
|
|
793
|
+
throw new Error('Not enough data to convert to surface, currently only support converting volume labelmap to surface if available');
|
|
794
|
+
}
|
|
795
|
+
return rawLabelmapData;
|
|
796
|
+
}
|
|
797
|
+
async function computeLabelmapFromContourSegmentation(segmentationId, options = {}) {
|
|
798
|
+
const isVolume = options.viewport
|
|
799
|
+
? options.viewport instanceof esm.VolumeViewport
|
|
800
|
+
: true;
|
|
801
|
+
if (isVolume && !options.viewport) {
|
|
802
|
+
throw new Error('Cannot compute labelmap from contour segmentation without providing the viewport');
|
|
803
|
+
}
|
|
804
|
+
const segmentIndices = options.segmentIndices?.length
|
|
805
|
+
? options.segmentIndices
|
|
806
|
+
: labelmapComputationStrategies_getUniqueSegmentIndices(segmentationId);
|
|
807
|
+
const segmentation = labelmapComputationStrategies_getSegmentation(segmentationId);
|
|
808
|
+
const representationData = segmentation.representationData.Contour;
|
|
809
|
+
const convertFunction = isVolume
|
|
810
|
+
? convertContourToVolumeLabelmap
|
|
811
|
+
: convertContourToStackLabelmap;
|
|
812
|
+
const result = await convertFunction(representationData, {
|
|
813
|
+
segmentIndices,
|
|
814
|
+
viewport: options.viewport,
|
|
815
|
+
});
|
|
816
|
+
return result;
|
|
817
|
+
}
|
|
818
|
+
async function computeLabelmapFromSurfaceSegmentation(segmentationId, options = {}) {
|
|
819
|
+
const { viewport } = options;
|
|
820
|
+
const isVolume = viewport ? viewport instanceof esm.VolumeViewport : true;
|
|
821
|
+
const segmentIndices = options.segmentIndices?.length
|
|
822
|
+
? options.segmentIndices
|
|
823
|
+
: labelmapComputationStrategies_getUniqueSegmentIndices(segmentationId);
|
|
824
|
+
const segmentation = labelmapComputationStrategies_getSegmentation(segmentationId);
|
|
825
|
+
const segmentsGeometryIds = new Map();
|
|
826
|
+
const representationData = segmentation.representationData.Surface;
|
|
827
|
+
representationData.geometryIds.forEach((geometryId, segmentIndex) => {
|
|
828
|
+
if (segmentIndices.includes(segmentIndex)) {
|
|
829
|
+
segmentsGeometryIds.set(segmentIndex, geometryId);
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
if (isVolume && !viewport) {
|
|
833
|
+
throw new Error('Cannot compute labelmap from surface segmentation without providing the viewport');
|
|
834
|
+
}
|
|
835
|
+
let segmentationVolume;
|
|
836
|
+
if (isVolume) {
|
|
837
|
+
const volumeId = viewport.getVolumeId();
|
|
838
|
+
segmentationVolume =
|
|
839
|
+
esm.volumeLoader.createAndCacheDerivedLabelmapVolume(volumeId);
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
const imageIds = options.viewport.getImageIds();
|
|
843
|
+
const segImages = esm.imageLoader.createAndCacheDerivedLabelmapImages(imageIds);
|
|
844
|
+
const segImageIds = segImages.map((image) => image.imageId);
|
|
845
|
+
segmentationVolume = await esm.volumeLoader.createAndCacheVolumeFromImages('generatedSegmentationVolumeId', segImageIds);
|
|
846
|
+
}
|
|
847
|
+
const result = await convertSurfaceToVolumeLabelmap({ geometryIds: segmentsGeometryIds }, segmentationVolume);
|
|
848
|
+
if (isVolume) {
|
|
849
|
+
return result;
|
|
850
|
+
}
|
|
851
|
+
const stackData = (await computeStackLabelmapFromVolume({
|
|
852
|
+
volumeId: segmentationVolume.volumeId,
|
|
853
|
+
}));
|
|
854
|
+
return stackData;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/canComputeRequestedRepresentation.js
|
|
859
|
+
|
|
860
|
+
const { SegmentationRepresentations: canComputeRequestedRepresentation_SegmentationRepresentations } = dist_esm.Enums;
|
|
861
|
+
const { getSegmentation: canComputeRequestedRepresentation_getSegmentation } = dist_esm.segmentation.state;
|
|
862
|
+
const { validateLabelmap } = dist_esm.utilities.segmentation;
|
|
863
|
+
const conversionPaths = new Map([
|
|
864
|
+
[
|
|
865
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Labelmap,
|
|
866
|
+
new Set([
|
|
867
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Surface,
|
|
868
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Contour,
|
|
869
|
+
]),
|
|
870
|
+
],
|
|
871
|
+
[
|
|
872
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Contour,
|
|
873
|
+
new Set([
|
|
874
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Labelmap,
|
|
875
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Surface,
|
|
876
|
+
]),
|
|
877
|
+
],
|
|
878
|
+
[
|
|
879
|
+
canComputeRequestedRepresentation_SegmentationRepresentations.Surface,
|
|
880
|
+
new Set([canComputeRequestedRepresentation_SegmentationRepresentations.Labelmap]),
|
|
881
|
+
],
|
|
882
|
+
]);
|
|
883
|
+
function canComputeRequestedRepresentation(segmentationId, type) {
|
|
884
|
+
const { representationData } = canComputeRequestedRepresentation_getSegmentation(segmentationId);
|
|
885
|
+
const existingRepresentationTypes = getExistingRepresentationTypes(representationData);
|
|
886
|
+
return existingRepresentationTypes.some((existingRepresentationType) => canConvertFromTo(existingRepresentationType, type));
|
|
887
|
+
}
|
|
888
|
+
function getExistingRepresentationTypes(representationData) {
|
|
889
|
+
const supportedTypes = [];
|
|
890
|
+
Object.keys(representationData).forEach((representationType) => {
|
|
891
|
+
const representationTypeData = representationData[representationType];
|
|
892
|
+
let validateFn;
|
|
893
|
+
switch (representationType) {
|
|
894
|
+
case canComputeRequestedRepresentation_SegmentationRepresentations.Labelmap:
|
|
895
|
+
validateFn = validateLabelmap.validate;
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
if (validateFn) {
|
|
899
|
+
try {
|
|
900
|
+
validateFn(representationTypeData);
|
|
901
|
+
supportedTypes.push(representationType);
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
console.warn(`Validation failed for labelmap of type ${representationType}`);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
supportedTypes.push(representationType);
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
return supportedTypes;
|
|
912
|
+
}
|
|
913
|
+
async function canConvertFromTo(fromRepresentationType, toRepresentationType) {
|
|
914
|
+
return (conversionPaths.get(fromRepresentationType)?.has(toRepresentationType) ||
|
|
915
|
+
false);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/Surface/updateSurfaceData.js
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
const { utilities: { segmentation: { getUniqueSegmentIndices: updateSurfaceData_getUniqueSegmentIndices }, }, segmentation: { state: { getViewportIdsWithSegmentation, getSegmentation: updateSurfaceData_getSegmentation, getSegmentationRepresentation, }, triggerSegmentationEvents: { triggerSegmentationModified }, }, Enums: { SegmentationRepresentations: updateSurfaceData_SegmentationRepresentations }, } = dist_esm;
|
|
925
|
+
async function updateSurfaceData(segmentationId) {
|
|
926
|
+
const surfacesObj = await computeSurfaceFromLabelmapSegmentation(segmentationId);
|
|
927
|
+
if (!surfacesObj) {
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
const segmentation = updateSurfaceData_getSegmentation(segmentationId);
|
|
931
|
+
const indices = updateSurfaceData_getUniqueSegmentIndices(segmentationId);
|
|
932
|
+
if (!indices.length) {
|
|
933
|
+
const geometryIds = segmentation.representationData.Surface.geometryIds;
|
|
934
|
+
geometryIds.forEach((geometryId) => {
|
|
935
|
+
const geometry = esm.cache.getGeometry(geometryId);
|
|
936
|
+
const surface = geometry.data;
|
|
937
|
+
surface.points = [];
|
|
938
|
+
surface.polys = [];
|
|
939
|
+
});
|
|
940
|
+
triggerSegmentationModified(segmentationId);
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
const promises = surfacesObj.map(({ data, segmentIndex }) => {
|
|
944
|
+
const geometryId = `segmentation_${segmentationId}_surface_${segmentIndex}`;
|
|
945
|
+
const geometry = esm.cache.getGeometry(geometryId);
|
|
946
|
+
if (!geometry) {
|
|
947
|
+
const viewportIds = getViewportIdsWithSegmentation(segmentationId);
|
|
948
|
+
return viewportIds.map((viewportId) => {
|
|
949
|
+
const surfaceRepresentation = getSegmentationRepresentation(viewportId, {
|
|
950
|
+
segmentationId,
|
|
951
|
+
type: updateSurfaceData_SegmentationRepresentations.Surface,
|
|
952
|
+
});
|
|
953
|
+
return [surfaceRepresentation].map((surfaceRepresentation) => {
|
|
954
|
+
segmentation.representationData.Surface.geometryIds.set(segmentIndex, geometryId);
|
|
955
|
+
return createAndCacheSurfacesFromRaw(segmentationId, [{ segmentIndex, data }], {
|
|
956
|
+
segmentationId: surfaceRepresentation.segmentationId,
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
else if (indices.includes(segmentIndex)) {
|
|
962
|
+
const surface = geometry.data;
|
|
963
|
+
surface.points = data.points;
|
|
964
|
+
surface.polys = data.polys;
|
|
965
|
+
}
|
|
966
|
+
else {
|
|
967
|
+
const surface = geometry.data;
|
|
968
|
+
surface.points = [];
|
|
969
|
+
surface.polys = [];
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
await Promise.all(promises);
|
|
973
|
+
triggerSegmentationModified(segmentationId);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/polymorphic-segmentation/dist/esm/index.js
|
|
977
|
+
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
function init() {
|
|
984
|
+
registerPolySegWorker();
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
|
|
24
989
|
/***/ }),
|
|
25
990
|
|
|
26
991
|
/***/ 91037:
|