@cornerstonejs/polymorphic-segmentation 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/Contour/contourComputationStrategies.js +4 -2
- package/dist/esm/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +4 -2
- package/dist/esm/Labelmap/convertContourToLabelmap.js +1 -1
- package/dist/esm/Labelmap/labelmapComputationStrategies.js +3 -1
- package/dist/esm/Surface/surfaceComputationStrategies.js +5 -3
- package/dist/esm/canComputeRequestedRepresentation.js +3 -1
- package/dist/esm/utilities/clipAndCacheSurfacesForViewport.js +3 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workers/polySegConverters.js +8 -6
- package/package.json +6 -7
- package/LICENSE +0 -21
|
@@ -4,6 +4,8 @@ import { extractContourData } from './utils/extractContourData.js';
|
|
|
4
4
|
import { computeSurfaceFromLabelmapSegmentation } from '../Surface/surfaceComputationStrategies.js';
|
|
5
5
|
import { clipAndCacheSurfacesForViewport } from '../utilities/clipAndCacheSurfacesForViewport.js';
|
|
6
6
|
import { createAndAddContourSegmentationsFromClippedSurfaces } from './utils/createAndAddContourSegmentationsFromClippedSurfaces.js';
|
|
7
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
8
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('Contour.contourComputationStrategies');
|
|
7
9
|
const { getUniqueSegmentIndices } = utilities.segmentation;
|
|
8
10
|
const { getSegmentation } = segmentation.state;
|
|
9
11
|
const { segmentationStyle } = segmentation;
|
|
@@ -30,7 +32,7 @@ export async function computeContourData(segmentationId, options = {}) {
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
catch (error) {
|
|
33
|
-
|
|
35
|
+
cs3dLogger.error(error);
|
|
34
36
|
throw error;
|
|
35
37
|
}
|
|
36
38
|
if (!rawContourData) {
|
|
@@ -51,7 +53,7 @@ async function computeContourFromLabelmapSegmentation(segmentationId, options =
|
|
|
51
53
|
}
|
|
52
54
|
const results = await computeSurfaceFromLabelmapSegmentation(segmentationId, options);
|
|
53
55
|
if (!results?.length) {
|
|
54
|
-
|
|
56
|
+
cs3dLogger.error('Failed to convert labelmap to surface or labelmap is empty');
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
59
|
const { viewport } = options;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { utilities } from '@cornerstonejs/core';
|
|
2
2
|
import { PlanarFreehandContourSegmentationTool, annotation, } from '@cornerstonejs/tools';
|
|
3
3
|
import { vec3 } from 'gl-matrix';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('Contour.utils.createAndAddContourSegmentationsFromClippedSurfaces');
|
|
4
6
|
function findBestContourForNormalCalculation(lines, minPreferredPoints = 3) {
|
|
5
7
|
let bestContourIndex = 0;
|
|
6
8
|
let bestCount = 0;
|
|
@@ -84,12 +86,12 @@ const { addAnnotation } = annotation.state;
|
|
|
84
86
|
export function createAndAddContourSegmentationsFromClippedSurfaces(rawContourData, viewport, segmentationId) {
|
|
85
87
|
const annotationUIDsMap = new Map();
|
|
86
88
|
if (!viewport) {
|
|
87
|
-
|
|
89
|
+
cs3dLogger.warn('Invalid viewport given');
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
const camera = viewport.getCamera();
|
|
91
93
|
if (!camera) {
|
|
92
|
-
|
|
94
|
+
cs3dLogger.warn('Camera not available in viewport');
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
95
97
|
const planeNormal = camera.viewPlaneNormal;
|
|
@@ -107,7 +107,7 @@ export async function convertContourToStackLabelmap(contourRepresentationData, o
|
|
|
107
107
|
const segmentationInfo = segmentationsInfo.get(referencedImageId);
|
|
108
108
|
const { imageId: segImageId } = segmentationInfo;
|
|
109
109
|
const segImage = cache.getImage(segImageId);
|
|
110
|
-
segImage.voxelManager.
|
|
110
|
+
segImage.voxelManager.setFromScalarData(scalarData);
|
|
111
111
|
segImage.imageFrame?.pixelData?.set(scalarData);
|
|
112
112
|
segImageIds.push(segImageId);
|
|
113
113
|
});
|
|
@@ -3,6 +3,8 @@ import { utilities } from '@cornerstonejs/tools';
|
|
|
3
3
|
import * as cornerstoneTools from '@cornerstonejs/tools';
|
|
4
4
|
import { convertContourToStackLabelmap, convertContourToVolumeLabelmap, } from './convertContourToLabelmap.js';
|
|
5
5
|
import { convertSurfaceToVolumeLabelmap } from './convertSurfaceToLabelmap.js';
|
|
6
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
7
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('Labelmap.labelmapComputationStrategies');
|
|
6
8
|
const { computeStackLabelmapFromVolume, getUniqueSegmentIndices } = utilities.segmentation;
|
|
7
9
|
const { getSegmentation } = cornerstoneTools.segmentation.state;
|
|
8
10
|
export async function computeLabelmapData(segmentationId, options = {}) {
|
|
@@ -27,7 +29,7 @@ export async function computeLabelmapData(segmentationId, options = {}) {
|
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
catch (error) {
|
|
30
|
-
|
|
32
|
+
cs3dLogger.error(error);
|
|
31
33
|
throw error;
|
|
32
34
|
}
|
|
33
35
|
if (!rawLabelmapData) {
|
|
@@ -2,6 +2,8 @@ import * as cornerstoneTools from '@cornerstonejs/tools';
|
|
|
2
2
|
import { convertContourToSurface } from './convertContourToSurface.js';
|
|
3
3
|
import { createAndCacheSurfacesFromRaw } from './createAndCacheSurfacesFromRaw.js';
|
|
4
4
|
import { convertLabelmapToSurface } from './convertLabelmapToSurface.js';
|
|
5
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
6
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('Surface.surfaceComputationStrategies');
|
|
5
7
|
const { getUniqueSegmentIndices } = cornerstoneTools.utilities.segmentation;
|
|
6
8
|
const { getSegmentation } = cornerstoneTools.segmentation.state;
|
|
7
9
|
export async function computeSurfaceData(segmentationId, options = {}) {
|
|
@@ -26,7 +28,7 @@ export async function computeSurfaceData(segmentationId, options = {}) {
|
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
catch (error) {
|
|
29
|
-
|
|
31
|
+
cs3dLogger.error(error);
|
|
30
32
|
throw error;
|
|
31
33
|
}
|
|
32
34
|
if (!rawSurfacesData) {
|
|
@@ -38,7 +40,7 @@ export async function computeSurfaceData(segmentationId, options = {}) {
|
|
|
38
40
|
async function computeSurfaceFromLabelmapSegmentation(segmentationId, options = {}) {
|
|
39
41
|
const segmentation = getSegmentation(segmentationId);
|
|
40
42
|
if (!segmentation?.representationData?.Labelmap) {
|
|
41
|
-
|
|
43
|
+
cs3dLogger.warn('Only support surface update from labelmaps');
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
const labelmapRepresentationData = segmentation.representationData.Labelmap;
|
|
@@ -50,7 +52,7 @@ async function computeSurfaceFromLabelmapSegmentation(segmentationId, options =
|
|
|
50
52
|
const surfaces = await Promise.allSettled(promises);
|
|
51
53
|
const errors = surfaces.filter((p) => p.status === 'rejected');
|
|
52
54
|
if (errors.length > 0) {
|
|
53
|
-
|
|
55
|
+
cs3dLogger.error(errors);
|
|
54
56
|
throw new Error('Failed to convert labelmap to surface');
|
|
55
57
|
}
|
|
56
58
|
const rawSurfacesData = surfaces
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Enums, segmentation, utilities } from '@cornerstonejs/tools';
|
|
2
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
3
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('canComputeRequestedRepresentation');
|
|
2
4
|
const { getSegmentation } = segmentation.state;
|
|
3
5
|
const { validateLabelmap } = utilities.segmentation;
|
|
4
6
|
const conversionPaths = new Map([
|
|
@@ -42,7 +44,7 @@ function getExistingRepresentationTypes(representationData) {
|
|
|
42
44
|
supportedTypes.push(representationType);
|
|
43
45
|
}
|
|
44
46
|
catch (error) {
|
|
45
|
-
|
|
47
|
+
cs3dLogger.warn(`Validation failed for labelmap of type ${representationType}`);
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
else {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Enums, getWebWorkerManager, eventTarget, triggerEvent, } from '@cornerstonejs/core';
|
|
2
2
|
import { Enums as ToolsEnums, utilities } from '@cornerstonejs/tools';
|
|
3
3
|
import { registerPolySegWorker } from '../registerPolySegWorker.js';
|
|
4
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
5
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('utilities.clipAndCacheSurfacesForViewport');
|
|
4
6
|
const workerManager = getWebWorkerManager();
|
|
5
7
|
const { WorkerTypes } = ToolsEnums;
|
|
6
8
|
const { pointToString } = utilities;
|
|
@@ -51,7 +53,7 @@ export async function clipAndCacheSurfacesForViewport(surfacesInfo, viewport) {
|
|
|
51
53
|
],
|
|
52
54
|
})
|
|
53
55
|
.catch((error) => {
|
|
54
|
-
|
|
56
|
+
cs3dLogger.error(error);
|
|
55
57
|
});
|
|
56
58
|
triggerWorkerProgress(eventTarget, 100);
|
|
57
59
|
return polyDataCache;
|
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
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.10.3';
|
|
@@ -7,6 +7,8 @@ import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane.js';
|
|
|
7
7
|
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData.js';
|
|
8
8
|
import vtkContourLoopExtraction from '@kitware/vtk.js/Filters/General/ContourLoopExtraction.js';
|
|
9
9
|
import vtkCutter from '@kitware/vtk.js/Filters/Core/Cutter.js';
|
|
10
|
+
import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
|
|
11
|
+
const cs3dLogger = cornerstoneUtilities.logger.polySegLog.getLogger('workers.polySegConverters');
|
|
10
12
|
const { math: { polyline: { containsPoint, getAABB, projectTo2D }, }, geometricSurfaceUtils: { checkStandardBasis, rotatePoints }, boundingBox: { getBoundingBoxAroundShapeWorld }, planar: { isPlaneIntersectingAABB }, } = ToolsUtilities;
|
|
11
13
|
async function peerImport(moduleId) {
|
|
12
14
|
try {
|
|
@@ -15,7 +17,7 @@ async function peerImport(moduleId) {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
catch (error) {
|
|
18
|
-
|
|
20
|
+
cs3dLogger.warn('Error importing module:', error);
|
|
19
21
|
return null;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -29,8 +31,8 @@ const polySegConverters = {
|
|
|
29
31
|
ICRPolySeg = (await peerImport('@icr/polyseg-wasm')).default;
|
|
30
32
|
}
|
|
31
33
|
catch (error) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
cs3dLogger.error(error);
|
|
35
|
+
cs3dLogger.debug("Warning: '@icr/polyseg-wasm' module not found. Please install it separately.");
|
|
34
36
|
return;
|
|
35
37
|
}
|
|
36
38
|
if (this.polySegInitializing) {
|
|
@@ -357,7 +359,7 @@ const polySegConverters = {
|
|
|
357
359
|
cutter.update();
|
|
358
360
|
}
|
|
359
361
|
catch (e) {
|
|
360
|
-
|
|
362
|
+
cs3dLogger.warn('Error during clipping', e);
|
|
361
363
|
continue;
|
|
362
364
|
}
|
|
363
365
|
const polyData = cutter.getOutputData();
|
|
@@ -387,7 +389,7 @@ const polySegConverters = {
|
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
catch (loopError) {
|
|
390
|
-
|
|
392
|
+
cs3dLogger.warn('Error during loop extraction:', loopError);
|
|
391
393
|
continue;
|
|
392
394
|
}
|
|
393
395
|
}
|
|
@@ -396,7 +398,7 @@ const polySegConverters = {
|
|
|
396
398
|
}
|
|
397
399
|
}
|
|
398
400
|
catch (e) {
|
|
399
|
-
|
|
401
|
+
cs3dLogger.warn('Error during processing', e);
|
|
400
402
|
}
|
|
401
403
|
finally {
|
|
402
404
|
surfacesInfo = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/polymorphic-segmentation",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.3",
|
|
4
4
|
"description": "Polymorphic Segmentation utility for Cornerstone3D",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -55,13 +55,12 @@
|
|
|
55
55
|
"@icr/polyseg-wasm": "0.4.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@cornerstonejs/core": "5.
|
|
59
|
-
"@cornerstonejs/tools": "5.
|
|
58
|
+
"@cornerstonejs/core": "5.10.3",
|
|
59
|
+
"@cornerstonejs/tools": "5.10.3"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@cornerstonejs/core": "5.
|
|
63
|
-
"@cornerstonejs/tools": "5.
|
|
62
|
+
"@cornerstonejs/core": "5.10.3",
|
|
63
|
+
"@cornerstonejs/tools": "5.10.3",
|
|
64
64
|
"@kitware/vtk.js": "36.4.1"
|
|
65
|
-
}
|
|
66
|
-
"gitHead": "7034957b10f5e91ad8f4d7978591ef688e262d26"
|
|
65
|
+
}
|
|
67
66
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2019 Open Health Imaging Foundation
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|