@cornerstonejs/tools 1.41.0 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
- package/dist/cjs/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- package/dist/cjs/stateManagement/annotation/annotationState.js +3 -0
- package/dist/cjs/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/cjs/tools/annotation/BidirectionalTool.js +7 -6
- package/dist/cjs/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/utilities/contours/AnnotationToPointData.d.ts +11 -0
- package/dist/cjs/utilities/contours/AnnotationToPointData.js +44 -0
- package/dist/cjs/utilities/contours/AnnotationToPointData.js.map +1 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.d.ts +6 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js +43 -0
- package/dist/cjs/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
- package/dist/cjs/utilities/contours/contourFinder.d.ts +7 -0
- package/dist/cjs/utilities/contours/contourFinder.js +68 -0
- package/dist/cjs/utilities/contours/contourFinder.js.map +1 -0
- package/dist/cjs/utilities/contours/detectContourHoles.d.ts +5 -0
- package/dist/cjs/utilities/contours/detectContourHoles.js +78 -0
- package/dist/cjs/utilities/contours/detectContourHoles.js.map +1 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.d.ts +4 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js +124 -0
- package/dist/cjs/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
- package/dist/cjs/utilities/contours/index.d.ts +6 -0
- package/dist/cjs/utilities/contours/index.js +17 -0
- package/dist/cjs/utilities/contours/index.js.map +1 -0
- package/dist/cjs/utilities/contours/mergePoints.d.ts +8 -0
- package/dist/cjs/utilities/contours/mergePoints.js +77 -0
- package/dist/cjs/utilities/contours/mergePoints.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +1 -0
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js +31 -0
- package/dist/cjs/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.d.ts +14 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js +43 -0
- package/dist/cjs/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.d.ts +1 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.js +94 -0
- package/dist/cjs/utilities/segmentation/findLargestBidirectional.js.map +1 -0
- package/dist/cjs/utilities/segmentation/index.d.ts +4 -1
- package/dist/cjs/utilities/segmentation/index.js +7 -1
- package/dist/cjs/utilities/segmentation/index.js.map +1 -1
- package/dist/cjs/utilities/segmentation/isLineInSegment.d.ts +9 -0
- package/dist/cjs/utilities/segmentation/isLineInSegment.js +55 -0
- package/dist/cjs/utilities/segmentation/isLineInSegment.js.map +1 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.d.ts +17 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.js +122 -0
- package/dist/cjs/utilities/segmentation/segmentContourAction.js.map +1 -0
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js +2 -1
- package/dist/esm/eventDispatchers/keyboardEventHandlers/keyDown.js.map +1 -1
- package/dist/esm/stateManagement/annotation/annotationState.js +3 -0
- package/dist/esm/stateManagement/annotation/annotationState.js.map +1 -1
- package/dist/esm/tools/annotation/BidirectionalTool.js +7 -6
- package/dist/esm/tools/annotation/BidirectionalTool.js.map +1 -1
- package/dist/esm/utilities/contours/AnnotationToPointData.js +39 -0
- package/dist/esm/utilities/contours/AnnotationToPointData.js.map +1 -0
- package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js +41 -0
- package/dist/esm/utilities/contours/RectangleROIStartEndThreshold.js.map +1 -0
- package/dist/esm/utilities/contours/contourFinder.js +63 -0
- package/dist/esm/utilities/contours/contourFinder.js.map +1 -0
- package/dist/esm/utilities/contours/detectContourHoles.js +74 -0
- package/dist/esm/utilities/contours/detectContourHoles.js.map +1 -0
- package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js +117 -0
- package/dist/esm/utilities/contours/generateContourSetsFromLabelmap.js.map +1 -0
- package/dist/esm/utilities/contours/index.js +7 -0
- package/dist/esm/utilities/contours/index.js.map +1 -0
- package/dist/esm/utilities/contours/mergePoints.js +73 -0
- package/dist/esm/utilities/contours/mergePoints.js.map +1 -0
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js +25 -0
- package/dist/esm/utilities/segmentation/contourAndFindLargestBidirectional.js.map +1 -0
- package/dist/esm/utilities/segmentation/createBidirectionalToolData.js +40 -0
- package/dist/esm/utilities/segmentation/createBidirectionalToolData.js.map +1 -0
- package/dist/esm/utilities/segmentation/findLargestBidirectional.js +96 -0
- package/dist/esm/utilities/segmentation/findLargestBidirectional.js.map +1 -0
- package/dist/esm/utilities/segmentation/index.js +4 -1
- package/dist/esm/utilities/segmentation/index.js.map +1 -1
- package/dist/esm/utilities/segmentation/isLineInSegment.js +50 -0
- package/dist/esm/utilities/segmentation/isLineInSegment.js.map +1 -0
- package/dist/esm/utilities/segmentation/segmentContourAction.js +98 -0
- package/dist/esm/utilities/segmentation/segmentContourAction.js.map +1 -0
- package/dist/types/eventDispatchers/keyboardEventHandlers/keyDown.d.ts.map +1 -1
- package/dist/types/stateManagement/annotation/annotationState.d.ts.map +1 -1
- package/dist/types/tools/annotation/BidirectionalTool.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utilities/contours/AnnotationToPointData.d.ts +12 -0
- package/dist/types/utilities/contours/AnnotationToPointData.d.ts.map +1 -0
- package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts +7 -0
- package/dist/types/utilities/contours/RectangleROIStartEndThreshold.d.ts.map +1 -0
- package/dist/types/utilities/contours/contourFinder.d.ts +8 -0
- package/dist/types/utilities/contours/contourFinder.d.ts.map +1 -0
- package/dist/types/utilities/contours/detectContourHoles.d.ts +6 -0
- package/dist/types/utilities/contours/detectContourHoles.d.ts.map +1 -0
- package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts +5 -0
- package/dist/types/utilities/contours/generateContourSetsFromLabelmap.d.ts.map +1 -0
- package/dist/types/utilities/contours/index.d.ts +7 -0
- package/dist/types/utilities/contours/index.d.ts.map +1 -0
- package/dist/types/utilities/contours/mergePoints.d.ts +9 -0
- package/dist/types/utilities/contours/mergePoints.d.ts.map +1 -0
- package/dist/types/utilities/index.d.ts +2 -1
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts +2 -0
- package/dist/types/utilities/segmentation/contourAndFindLargestBidirectional.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts +15 -0
- package/dist/types/utilities/segmentation/createBidirectionalToolData.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts +2 -0
- package/dist/types/utilities/segmentation/findLargestBidirectional.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/index.d.ts +4 -1
- package/dist/types/utilities/segmentation/index.d.ts.map +1 -1
- package/dist/types/utilities/segmentation/isLineInSegment.d.ts +10 -0
- package/dist/types/utilities/segmentation/isLineInSegment.d.ts.map +1 -0
- package/dist/types/utilities/segmentation/segmentContourAction.d.ts +18 -0
- package/dist/types/utilities/segmentation/segmentContourAction.d.ts.map +1 -0
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +3 -3
- package/src/eventDispatchers/keyboardEventHandlers/keyDown.ts +7 -1
- package/src/stateManagement/annotation/annotationState.ts +3 -0
- package/src/tools/annotation/BidirectionalTool.ts +9 -5
- package/src/types/index.ts +2 -0
- package/src/utilities/contours/AnnotationToPointData.ts +61 -0
- package/src/utilities/contours/RectangleROIStartEndThreshold.ts +60 -0
- package/src/utilities/contours/contourFinder.ts +78 -0
- package/src/utilities/contours/detectContourHoles.ts +147 -0
- package/src/utilities/contours/generateContourSetsFromLabelmap.ts +160 -0
- package/src/utilities/contours/index.ts +14 -0
- package/src/utilities/contours/mergePoints.ts +108 -0
- package/src/utilities/index.ts +2 -0
- package/src/utilities/segmentation/contourAndFindLargestBidirectional.ts +46 -0
- package/src/utilities/segmentation/createBidirectionalToolData.ts +68 -0
- package/src/utilities/segmentation/findLargestBidirectional.ts +159 -0
- package/src/utilities/segmentation/index.ts +6 -0
- package/src/utilities/segmentation/isLineInSegment.ts +84 -0
- package/src/utilities/segmentation/segmentContourAction.ts +169 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateContourSetsFromLabelmap = void 0;
|
|
7
|
+
const core_1 = require("@cornerstonejs/core");
|
|
8
|
+
const ImageMarchingSquares_1 = __importDefault(require("@kitware/vtk.js/Filters/General/ImageMarchingSquares"));
|
|
9
|
+
const DataArray_1 = __importDefault(require("@kitware/vtk.js/Common/Core/DataArray"));
|
|
10
|
+
const ImageData_1 = __importDefault(require("@kitware/vtk.js/Common/DataModel/ImageData"));
|
|
11
|
+
const mergePoints_1 = require("./mergePoints");
|
|
12
|
+
const contourFinder_1 = require("./contourFinder");
|
|
13
|
+
const SegmentationRepresentations_1 = __importDefault(require("../../enums/SegmentationRepresentations"));
|
|
14
|
+
const { Labelmap } = SegmentationRepresentations_1.default;
|
|
15
|
+
function generateContourSetsFromLabelmap({ segmentations }) {
|
|
16
|
+
var _a;
|
|
17
|
+
const { representationData, segments = [0, 1] } = segmentations;
|
|
18
|
+
const { volumeId: segVolumeId } = representationData[Labelmap];
|
|
19
|
+
const vol = core_1.cache.getVolume(segVolumeId);
|
|
20
|
+
if (!vol) {
|
|
21
|
+
console.warn(`No volume found for ${segVolumeId}`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const numSlices = vol.dimensions[2];
|
|
25
|
+
const imageVol = core_1.cache.getVolume(vol.referencedVolumeId);
|
|
26
|
+
if (!imageVol) {
|
|
27
|
+
console.warn(`No volume found for ${vol.referencedVolumeId}`);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const segData = vol.imageData.getPointData().getScalars().getData();
|
|
31
|
+
const pixelsPerSlice = vol.dimensions[0] * vol.dimensions[1];
|
|
32
|
+
for (let z = 0; z < numSlices; z++) {
|
|
33
|
+
for (let y = 0; y < vol.dimensions[1]; y++) {
|
|
34
|
+
const index = y * vol.dimensions[0] + z * pixelsPerSlice;
|
|
35
|
+
segData[index] = 0;
|
|
36
|
+
segData[index + vol.dimensions[0] - 1] = 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const ContourSets = [];
|
|
40
|
+
const { FrameOfReferenceUID } = imageVol.metadata;
|
|
41
|
+
const numSegments = segments.length;
|
|
42
|
+
for (let segIndex = 0; segIndex < numSegments; segIndex++) {
|
|
43
|
+
const segment = segments[segIndex];
|
|
44
|
+
if (!segment) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const sliceContours = [];
|
|
48
|
+
const scalars = DataArray_1.default.newInstance({
|
|
49
|
+
name: 'Scalars',
|
|
50
|
+
numberOfComponents: 1,
|
|
51
|
+
size: pixelsPerSlice * numSlices,
|
|
52
|
+
dataType: 'Uint8Array',
|
|
53
|
+
});
|
|
54
|
+
const { containedSegmentIndices } = segment;
|
|
55
|
+
for (let sliceIndex = 0; sliceIndex < numSlices; sliceIndex++) {
|
|
56
|
+
if (isSliceEmptyForSegment(sliceIndex, segData, pixelsPerSlice, segIndex)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const frameStart = sliceIndex * pixelsPerSlice;
|
|
60
|
+
try {
|
|
61
|
+
for (let i = 0; i < pixelsPerSlice; i++) {
|
|
62
|
+
const value = segData[i + frameStart];
|
|
63
|
+
if (value === segIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value))) {
|
|
64
|
+
scalars.setValue(i + frameStart, 1);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
scalars.setValue(i, 0);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const mSquares = ImageMarchingSquares_1.default.newInstance({
|
|
71
|
+
slice: sliceIndex,
|
|
72
|
+
});
|
|
73
|
+
const imageDataCopy = ImageData_1.default.newInstance();
|
|
74
|
+
imageDataCopy.shallowCopy(vol.imageData);
|
|
75
|
+
imageDataCopy.getPointData().setScalars(scalars);
|
|
76
|
+
mSquares.setInputData(imageDataCopy);
|
|
77
|
+
const cValues = [1];
|
|
78
|
+
mSquares.setContourValues(cValues);
|
|
79
|
+
mSquares.setMergePoints(false);
|
|
80
|
+
const msOutput = mSquares.getOutputData();
|
|
81
|
+
const reducedSet = (0, mergePoints_1.removeDuplicatePoints)(msOutput);
|
|
82
|
+
if ((_a = reducedSet.points) === null || _a === void 0 ? void 0 : _a.length) {
|
|
83
|
+
const contours = (0, contourFinder_1.findContoursFromReducedSet)(reducedSet.lines);
|
|
84
|
+
sliceContours.push({
|
|
85
|
+
referencedImageId: imageVol.imageIds[sliceIndex],
|
|
86
|
+
contours,
|
|
87
|
+
polyData: reducedSet,
|
|
88
|
+
FrameNumber: sliceIndex + 1,
|
|
89
|
+
sliceIndex,
|
|
90
|
+
FrameOfReferenceUID,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
console.warn(sliceIndex);
|
|
96
|
+
console.warn(e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const metadata = {
|
|
100
|
+
referencedImageId: imageVol.imageIds[0],
|
|
101
|
+
FrameOfReferenceUID,
|
|
102
|
+
};
|
|
103
|
+
const ContourSet = {
|
|
104
|
+
label: segment.label,
|
|
105
|
+
color: segment.color,
|
|
106
|
+
metadata,
|
|
107
|
+
sliceContours,
|
|
108
|
+
};
|
|
109
|
+
ContourSets.push(ContourSet);
|
|
110
|
+
}
|
|
111
|
+
return ContourSets;
|
|
112
|
+
}
|
|
113
|
+
exports.generateContourSetsFromLabelmap = generateContourSetsFromLabelmap;
|
|
114
|
+
function isSliceEmptyForSegment(sliceIndex, segData, pixelsPerSlice, segIndex) {
|
|
115
|
+
const startIdx = sliceIndex * pixelsPerSlice;
|
|
116
|
+
const endIdx = startIdx + pixelsPerSlice;
|
|
117
|
+
for (let i = startIdx; i < endIdx; i++) {
|
|
118
|
+
if (segData[i] === segIndex) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=generateContourSetsFromLabelmap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateContourSetsFromLabelmap.js","sourceRoot":"","sources":["../../../../src/utilities/contours/generateContourSetsFromLabelmap.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAgE;AAChE,gHAA2F;AAC3F,sFAAiE;AACjE,2FAAsE;AAEtE,+CAAsD;AACtD,mDAA6D;AAC7D,0GAAkF;AAElF,MAAM,EAAE,QAAQ,EAAE,GAAG,qCAA2B,CAAC;AAEjD,SAAS,+BAA+B,CAAC,EAAE,aAAa,EAAE;;IACxD,MAAM,EAAE,kBAAkB,EAAE,QAAQ,GAA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iBAAiB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;YACvC,mBAAmB;SACpB,CAAC;QAEF,MAAM,UAAU,GAAG;YACjB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ;YACR,aAAa;SACd,CAAC;QAEF,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC9B;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAeQ,0EAA+B;AAbxC,SAAS,sBAAsB,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ;IAC3E,MAAM,QAAQ,GAAG,UAAU,GAAG,cAAc,CAAC;IAC7C,MAAM,MAAM,GAAG,QAAQ,GAAG,cAAc,CAAC;IAEzC,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;YAC3B,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import contourFinder from './contourFinder';
|
|
2
|
+
import mergePoints from './mergePoints';
|
|
3
|
+
import detectContourHoles from './detectContourHoles';
|
|
4
|
+
import { generateContourSetsFromLabelmap } from './generateContourSetsFromLabelmap';
|
|
5
|
+
import AnnotationToPointData from './AnnotationToPointData';
|
|
6
|
+
export { contourFinder, mergePoints, detectContourHoles, generateContourSetsFromLabelmap, AnnotationToPointData, };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AnnotationToPointData = exports.generateContourSetsFromLabelmap = exports.detectContourHoles = exports.mergePoints = exports.contourFinder = void 0;
|
|
7
|
+
const contourFinder_1 = __importDefault(require("./contourFinder"));
|
|
8
|
+
exports.contourFinder = contourFinder_1.default;
|
|
9
|
+
const mergePoints_1 = __importDefault(require("./mergePoints"));
|
|
10
|
+
exports.mergePoints = mergePoints_1.default;
|
|
11
|
+
const detectContourHoles_1 = __importDefault(require("./detectContourHoles"));
|
|
12
|
+
exports.detectContourHoles = detectContourHoles_1.default;
|
|
13
|
+
const generateContourSetsFromLabelmap_1 = require("./generateContourSetsFromLabelmap");
|
|
14
|
+
Object.defineProperty(exports, "generateContourSetsFromLabelmap", { enumerable: true, get: function () { return generateContourSetsFromLabelmap_1.generateContourSetsFromLabelmap; } });
|
|
15
|
+
const AnnotationToPointData_1 = __importDefault(require("./AnnotationToPointData"));
|
|
16
|
+
exports.AnnotationToPointData = AnnotationToPointData_1.default;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/contours/index.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA4C;AAQ1C,wBARK,uBAAa,CAQL;AAPf,gEAAwC;AAQtC,sBARK,qBAAW,CAQL;AAPb,8EAAsD;AAQpD,6BARK,4BAAkB,CAQL;AAPpB,uFAAoF;AAQlF,gHARO,iEAA+B,OAQP;AANjC,oFAA4D;AAO1D,gCAPK,+BAAqB,CAOL"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeDuplicatePoints = void 0;
|
|
4
|
+
function ptInArray(array, pt) {
|
|
5
|
+
let index = -1;
|
|
6
|
+
for (let i = 0; i < array.length; i++) {
|
|
7
|
+
if (isSamePoint(pt, array[i])) {
|
|
8
|
+
index = i;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return index;
|
|
12
|
+
}
|
|
13
|
+
function isSamePoint(ptA, ptB) {
|
|
14
|
+
if (ptA[0] == ptB[0] && ptA[1] == ptB[1] && ptA[2] == ptB[2]) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function replacePointIndexReferences(linesArray, oldIndex, newIndex) {
|
|
22
|
+
for (let i = 0; i < linesArray.length; i++) {
|
|
23
|
+
const line = linesArray[i];
|
|
24
|
+
if (line.a == oldIndex) {
|
|
25
|
+
line.a = newIndex;
|
|
26
|
+
}
|
|
27
|
+
else if (line.b == oldIndex) {
|
|
28
|
+
line.b = newIndex;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function removeDuplicatePoints(polyData, bypass = false) {
|
|
33
|
+
const points = polyData.getPoints();
|
|
34
|
+
const lines = polyData.getLines();
|
|
35
|
+
const pointsArray = [];
|
|
36
|
+
for (let i = 0; i < points.getNumberOfPoints(); i++) {
|
|
37
|
+
const pt = points.getPoint(i).slice();
|
|
38
|
+
pointsArray.push(pt);
|
|
39
|
+
}
|
|
40
|
+
const linesArray = [];
|
|
41
|
+
for (let i = 0; i < lines.getNumberOfCells(); i++) {
|
|
42
|
+
const cell = lines.getCell(i * 3).slice();
|
|
43
|
+
const a = cell[0];
|
|
44
|
+
const b = cell[1];
|
|
45
|
+
const line = {
|
|
46
|
+
a,
|
|
47
|
+
b,
|
|
48
|
+
};
|
|
49
|
+
linesArray.push(line);
|
|
50
|
+
}
|
|
51
|
+
if (bypass) {
|
|
52
|
+
return { points: pointsArray, lines: linesArray };
|
|
53
|
+
}
|
|
54
|
+
const newPoints = [];
|
|
55
|
+
for (let i = 0; i < pointsArray.length; i++) {
|
|
56
|
+
const pt = pointsArray[i];
|
|
57
|
+
let index = ptInArray(newPoints, pt);
|
|
58
|
+
if (index >= 0) {
|
|
59
|
+
replacePointIndexReferences(linesArray, i, index);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
index = newPoints.length;
|
|
63
|
+
newPoints.push(pt);
|
|
64
|
+
replacePointIndexReferences(linesArray, i, index);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const newLines = [];
|
|
68
|
+
linesArray.forEach((line) => {
|
|
69
|
+
if (line.a != line.b) {
|
|
70
|
+
newLines.push(line);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return { points: newPoints, lines: newLines };
|
|
74
|
+
}
|
|
75
|
+
exports.removeDuplicatePoints = removeDuplicatePoints;
|
|
76
|
+
exports.default = { removeDuplicatePoints };
|
|
77
|
+
//# sourceMappingURL=mergePoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergePoints.js","sourceRoot":"","sources":["../../../../src/utilities/contours/mergePoints.ts"],"names":[],"mappings":";;;AAMA,SAAS,SAAS,CAAC,KAAK,EAAE,EAAE;IAC1B,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;YAC7B,KAAK,GAAG,CAAC,CAAC;SACX;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAQD,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG;IAC3B,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;QAC5D,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAQD,SAAS,2BAA2B,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ;IACjE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IAAI,CAAC,IAAI,CAAC,CAAC;KACvB;IAED,IAAI,MAAM,EAAE;QACV,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;KACnD;IAGD,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAErC,IAAI,KAAK,IAAI,CAAC,EAAE;YAEd,2BAA2B,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;SACnD;aAAM;YACL,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC;YACzB,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnB,2BAA2B,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;SACnD;KACF;IAGD,MAAM,QAAQ,GAAG,EAAE,CAAC;IACpB,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE;YACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC;AAnDD,sDAmDC;AAED,kBAAe,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -14,6 +14,7 @@ import scroll from './scroll';
|
|
|
14
14
|
import roundNumber from './roundNumber';
|
|
15
15
|
import { pointToString } from './pointToString';
|
|
16
16
|
import annotationFrameRange from './annotationFrameRange';
|
|
17
|
+
import * as contours from './contours';
|
|
17
18
|
import * as segmentation from './segmentation';
|
|
18
19
|
import * as drawing from './drawing';
|
|
19
20
|
import * as math from './math';
|
|
@@ -31,4 +32,4 @@ import * as dynamicVolume from './dynamicVolume';
|
|
|
31
32
|
import * as polyDataUtils from './polyData/utils';
|
|
32
33
|
import * as voi from './voi';
|
|
33
34
|
import { triggerEvent } from '@cornerstonejs/core';
|
|
34
|
-
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnits, getCalibratedAreaUnits, getCalibratedScale, segmentation, triggerAnnotationRenderForViewportIds, triggerAnnotationRender, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, viewport, cine, clip, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, scroll, roundNumber, pointToString, polyDataUtils, voi, annotationFrameRange, };
|
|
35
|
+
export { math, planar, viewportFilters, drawing, debounce, dynamicVolume, throttle, orientation, isObject, touch, triggerEvent, calibrateImageSpacing, getCalibratedLengthUnits, getCalibratedAreaUnits, getCalibratedScale, segmentation, contours, triggerAnnotationRenderForViewportIds, triggerAnnotationRender, pointInShapeCallback, pointInSurroundingSphereCallback, getAnnotationNearPoint, getAnnotationNearPointOnEnabledElement, jumpToSlice, viewport, cine, clip, boundingBox, rectangleROITool, planarFreehandROITool, stackPrefetch, stackContextPrefetch, scroll, roundNumber, pointToString, polyDataUtils, voi, annotationFrameRange, };
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.annotationFrameRange = exports.voi = exports.polyDataUtils = exports.pointToString = exports.roundNumber = exports.scroll = exports.stackContextPrefetch = exports.stackPrefetch = exports.planarFreehandROITool = exports.rectangleROITool = exports.boundingBox = exports.clip = exports.cine = exports.viewport = exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRender = exports.triggerAnnotationRenderForViewportIds = exports.segmentation = exports.getCalibratedScale = exports.getCalibratedAreaUnits = exports.getCalibratedLengthUnits = exports.calibrateImageSpacing = exports.triggerEvent = exports.touch = exports.isObject = exports.orientation = exports.throttle = exports.dynamicVolume = exports.debounce = exports.drawing = exports.viewportFilters = exports.planar = exports.math = void 0;
|
|
29
|
+
exports.annotationFrameRange = exports.voi = exports.polyDataUtils = exports.pointToString = exports.roundNumber = exports.scroll = exports.stackContextPrefetch = exports.stackPrefetch = exports.planarFreehandROITool = exports.rectangleROITool = exports.boundingBox = exports.clip = exports.cine = exports.viewport = exports.jumpToSlice = exports.getAnnotationNearPointOnEnabledElement = exports.getAnnotationNearPoint = exports.pointInSurroundingSphereCallback = exports.pointInShapeCallback = exports.triggerAnnotationRender = exports.triggerAnnotationRenderForViewportIds = exports.contours = exports.segmentation = exports.getCalibratedScale = exports.getCalibratedAreaUnits = exports.getCalibratedLengthUnits = exports.calibrateImageSpacing = exports.triggerEvent = exports.touch = exports.isObject = exports.orientation = exports.throttle = exports.dynamicVolume = exports.debounce = exports.drawing = exports.viewportFilters = exports.planar = exports.math = void 0;
|
|
30
30
|
const getAnnotationNearPoint_1 = require("./getAnnotationNearPoint");
|
|
31
31
|
Object.defineProperty(exports, "getAnnotationNearPoint", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPoint; } });
|
|
32
32
|
Object.defineProperty(exports, "getAnnotationNearPointOnEnabledElement", { enumerable: true, get: function () { return getAnnotationNearPoint_1.getAnnotationNearPointOnEnabledElement; } });
|
|
@@ -62,6 +62,8 @@ const pointToString_1 = require("./pointToString");
|
|
|
62
62
|
Object.defineProperty(exports, "pointToString", { enumerable: true, get: function () { return pointToString_1.pointToString; } });
|
|
63
63
|
const annotationFrameRange_1 = __importDefault(require("./annotationFrameRange"));
|
|
64
64
|
exports.annotationFrameRange = annotationFrameRange_1.default;
|
|
65
|
+
const contours = __importStar(require("./contours"));
|
|
66
|
+
exports.contours = contours;
|
|
65
67
|
const segmentation = __importStar(require("./segmentation"));
|
|
66
68
|
exports.segmentation = segmentation;
|
|
67
69
|
const drawing = __importStar(require("./drawing"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAGkC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAGkC;AAoEhC,uGAtEA,+CAAsB,OAsEA;AACtB,uHAtEA,+DAAsC,OAsEA;AAlExC,0DAAkC;AAgDhC,mBAhDK,kBAAQ,CAgDL;AA/CV,0DAAkC;AAiDhC,mBAjDK,kBAAQ,CAiDL;AAhDV,0DAAkC;AAkDhC,mBAlDK,kBAAQ,CAkDL;AAjDV,kDAA0B;AAmExB,eAnEK,cAAI,CAmEL;AAlEN,oFAA4D;AAmD1D,gCAnDK,+BAAqB,CAmDL;AAlDvB,6DAI8B;AA+C5B,yGAlDA,6CAAwB,OAkDA;AACxB,uGAlDA,2CAAsB,OAkDA;AACtB,mGAlDA,uCAAkB,OAkDA;AAhDpB,oHAA4F;AAmD1F,gDAnDK,+CAAqC,CAmDL;AAlDvC,wFAAgE;AAmD9D,kCAnDK,iCAAuB,CAmDL;AAlDzB,yEAAiD;AAuD/C,sBAvDK,qBAAW,CAuDL;AArDb,kFAA0D;AAiDxD,+BAjDK,8BAAoB,CAiDL;AAhDtB,0GAAkF;AAiDhF,2CAjDK,0CAAgC,CAiDL;AAhDlC,sDAA8B;AA4D5B,iBA5DK,gBAAM,CA4DL;AA3DR,gEAAwC;AA4DtC,sBA5DK,qBAAW,CA4DL;AA3Db,mDAAgD;AA4D9C,8FA5DO,6BAAa,OA4DP;AA3Df,kFAA0D;AA8DxD,+BA9DK,8BAAoB,CA8DL;AA3DtB,qDAAuC;AAsCrC,4BAAQ;AArCV,6DAA+C;AAoC7C,oCAAY;AAnCd,mDAAqC;AAuBnC,0BAAO;AAtBT,6CAA+B;AAmB7B,oBAAI;AAlBN,iDAAmC;AAmBjC,wBAAM;AAlBR,mEAAqD;AAmBnD,0CAAe;AAlBjB,2DAA6C;AAuB3C,kCAAW;AAtBb,6CAA+B;AAwC7B,oBAAI;AAvCN,2DAA6C;AAyC3C,kCAAW;AAxCb,+EAAiE;AA0C/D,sDAAqB;AAzCvB,qEAAuD;AAwCrD,4CAAgB;AAvClB,mDAAsE;AAyCpE,8FAzCO,6BAAa,OAyCP;AACb,qGA1CsB,oCAAoB,OA0CtB;AAzCtB,qDAAuC;AAkCrC,4BAAQ;AAjCV,+CAAiC;AAkB/B,sBAAK;AAjBP,+DAAiD;AAa/C,sCAAa;AAZf,gEAAkD;AA0ChD,sCAAa;AAzCf,2CAA6B;AA0C3B,kBAAG;AAvCL,8CAAmD;AAajD,6FAbO,mBAAY,OAaP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function contourAndFindLargestBidirectional(segmentation: any): any;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const contours_1 = require("../contours");
|
|
7
|
+
const SegmentationRepresentations_1 = __importDefault(require("../../enums/SegmentationRepresentations"));
|
|
8
|
+
const findLargestBidirectional_1 = __importDefault(require("./findLargestBidirectional"));
|
|
9
|
+
const EPSILON = 1e-2;
|
|
10
|
+
const { Labelmap } = SegmentationRepresentations_1.default;
|
|
11
|
+
function contourAndFindLargestBidirectional(segmentation) {
|
|
12
|
+
const contours = (0, contours_1.generateContourSetsFromLabelmap)({
|
|
13
|
+
segmentations: segmentation,
|
|
14
|
+
});
|
|
15
|
+
if (!(contours === null || contours === void 0 ? void 0 : contours.length) || !contours[0].sliceContours.length) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { representationData, segments = [
|
|
19
|
+
null,
|
|
20
|
+
{ label: 'Unspecified', color: null, containedSegmentIndices: null },
|
|
21
|
+
], } = segmentation;
|
|
22
|
+
const { volumeId: segVolumeId } = representationData[Labelmap];
|
|
23
|
+
const segmentIndex = segments.findIndex((it) => !!it);
|
|
24
|
+
if (segmentIndex === -1) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
segments[segmentIndex].segmentIndex = segmentIndex;
|
|
28
|
+
return (0, findLargestBidirectional_1.default)(contours[0], segVolumeId, segments[segmentIndex]);
|
|
29
|
+
}
|
|
30
|
+
exports.default = contourAndFindLargestBidirectional;
|
|
31
|
+
//# sourceMappingURL=contourAndFindLargestBidirectional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contourAndFindLargestBidirectional.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/contourAndFindLargestBidirectional.ts"],"names":[],"mappings":";;;;;AAAA,0CAA8D;AAC9D,0GAAkF;AAClF,0FAAkE;AAElE,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,qCAA2B,CAAC;AAYjD,SAAwB,kCAAkC,CAAC,YAAY;IACrE,MAAM,QAAQ,GAAG,IAAA,0CAA+B,EAAC;QAC/C,aAAa,EAAE,YAAY;KAC5B,CAAC,CAAC;IAEH,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAA,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,EAAE;QAC1D,OAAO;KACR;IAED,MAAM,EACJ,kBAAkB,EAClB,QAAQ,GAAG;QACT,IAAI;QACJ,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE;KACrE,GACF,GAAG,YAAY,CAAC;IACjB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAE/D,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtD,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE;QACvB,OAAO;KACR;IACD,QAAQ,CAAC,YAAY,CAAC,CAAC,YAAY,GAAG,YAAY,CAAC;IACnD,OAAO,IAAA,kCAAwB,EAC7B,QAAQ,CAAC,CAAC,CAAC,EACX,WAAW,EACX,QAAQ,CAAC,YAAY,CAAC,CACvB,CAAC;AACJ,CAAC;AA5BD,qDA4BC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
import type { Annotation } from '../../types/AnnotationTypes';
|
|
3
|
+
export declare type BidirectionalData = {
|
|
4
|
+
majorAxis: [Types.Point3, Types.Point3];
|
|
5
|
+
minorAxis: [Types.Point3, Types.Point3];
|
|
6
|
+
maxMajor: number;
|
|
7
|
+
maxMinor: number;
|
|
8
|
+
segmentIndex: number;
|
|
9
|
+
label?: string;
|
|
10
|
+
color?: string | number[];
|
|
11
|
+
referencedImageId: string;
|
|
12
|
+
FrameOfReferenceUID: string;
|
|
13
|
+
};
|
|
14
|
+
export default function createBidirectionalToolData(bidirectionalData: BidirectionalData, viewport: any): Annotation;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function createBidirectionalToolData(bidirectionalData, viewport) {
|
|
4
|
+
const { majorAxis, minorAxis, label = '', FrameOfReferenceUID, referencedImageId, } = bidirectionalData;
|
|
5
|
+
const [major0, major1] = majorAxis;
|
|
6
|
+
const [minor0, minor1] = minorAxis;
|
|
7
|
+
const { viewUp, viewPlaneNormal } = viewport.getCamera();
|
|
8
|
+
const points = [major0, major1, minor0, minor1];
|
|
9
|
+
const bidirectionalToolData = {
|
|
10
|
+
highlighted: true,
|
|
11
|
+
invalidated: true,
|
|
12
|
+
metadata: {
|
|
13
|
+
toolName: 'Bidirectional',
|
|
14
|
+
viewPlaneNormal,
|
|
15
|
+
viewUp,
|
|
16
|
+
FrameOfReferenceUID,
|
|
17
|
+
referencedImageId,
|
|
18
|
+
},
|
|
19
|
+
data: {
|
|
20
|
+
handles: {
|
|
21
|
+
points,
|
|
22
|
+
textBox: {
|
|
23
|
+
hasMoved: false,
|
|
24
|
+
worldPosition: [0, 0, 0],
|
|
25
|
+
worldBoundingBox: {
|
|
26
|
+
topLeft: [0, 0, 0],
|
|
27
|
+
topRight: [0, 0, 0],
|
|
28
|
+
bottomLeft: [0, 0, 0],
|
|
29
|
+
bottomRight: [0, 0, 0],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
activeHandleIndex: null,
|
|
33
|
+
},
|
|
34
|
+
label,
|
|
35
|
+
cachedStats: {},
|
|
36
|
+
},
|
|
37
|
+
isLocked: false,
|
|
38
|
+
isVisible: true,
|
|
39
|
+
};
|
|
40
|
+
return bidirectionalToolData;
|
|
41
|
+
}
|
|
42
|
+
exports.default = createBidirectionalToolData;
|
|
43
|
+
//# sourceMappingURL=createBidirectionalToolData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createBidirectionalToolData.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/createBidirectionalToolData.ts"],"names":[],"mappings":";;AAmBA,SAAwB,2BAA2B,CACjD,iBAAoC,EACpC,QAAQ;IAER,MAAM,EACJ,SAAS,EACT,SAAS,EACT,KAAK,GAAG,EAAE,EACV,mBAAmB,EACnB,iBAAiB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use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
4
|
+
const isLineInSegment_1 = require("./isLineInSegment");
|
|
5
|
+
const EPSILON = 1e-2;
|
|
6
|
+
function findLargestBidirectional(contours, segVolumeId, segment) {
|
|
7
|
+
const { sliceContours } = contours;
|
|
8
|
+
const { segmentIndex, containedSegmentIndices } = segment;
|
|
9
|
+
let maxBidirectional;
|
|
10
|
+
const isInSegment = (0, isLineInSegment_1.createIsInSegment)(segVolumeId, segmentIndex, containedSegmentIndices);
|
|
11
|
+
for (const sliceContour of sliceContours) {
|
|
12
|
+
const bidirectional = createBidirectionalForSlice(sliceContour, isInSegment, maxBidirectional);
|
|
13
|
+
if (!bidirectional) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
maxBidirectional = bidirectional;
|
|
17
|
+
}
|
|
18
|
+
if (maxBidirectional) {
|
|
19
|
+
Object.assign(maxBidirectional, segment);
|
|
20
|
+
}
|
|
21
|
+
return maxBidirectional;
|
|
22
|
+
}
|
|
23
|
+
exports.default = findLargestBidirectional;
|
|
24
|
+
function createBidirectionalForSlice(sliceContour, isInSegment, currentMax = { maxMajor: 0, maxMinor: 0 }) {
|
|
25
|
+
const { points } = sliceContour.polyData;
|
|
26
|
+
const { maxMinor: currentMaxMinor, maxMajor: currentMaxMajor } = currentMax;
|
|
27
|
+
let maxMajor = currentMaxMajor * currentMaxMajor;
|
|
28
|
+
let maxMinor = currentMaxMinor * currentMaxMinor;
|
|
29
|
+
let maxMajorPoints;
|
|
30
|
+
for (let index1 = 0; index1 < points.length; index1++) {
|
|
31
|
+
for (let index2 = index1 + 1; index2 < points.length; index2++) {
|
|
32
|
+
const point1 = points[index1];
|
|
33
|
+
const point2 = points[index2];
|
|
34
|
+
const distance2 = gl_matrix_1.vec3.sqrDist(point1, point2);
|
|
35
|
+
if (distance2 < maxMajor) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (distance2 - EPSILON < maxMajor + EPSILON && maxMajorPoints) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!isInSegment.testCenter(point1, point2)) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (!(0, isLineInSegment_1.isLineInSegment)(point1, point2, isInSegment)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
maxMajor = distance2 - EPSILON;
|
|
48
|
+
maxMajorPoints = [index1, index2];
|
|
49
|
+
maxMinor = 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!maxMajorPoints) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
maxMajor = Math.sqrt(maxMajor + EPSILON);
|
|
56
|
+
const handle0 = points[maxMajorPoints[0]];
|
|
57
|
+
const handle1 = points[maxMajorPoints[1]];
|
|
58
|
+
const unitMajor = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), handle0, handle1);
|
|
59
|
+
gl_matrix_1.vec3.scale(unitMajor, unitMajor, 1 / maxMajor);
|
|
60
|
+
let maxMinorPoints;
|
|
61
|
+
for (let index1 = 0; index1 < points.length; index1++) {
|
|
62
|
+
for (let index2 = index1 + 1; index2 < points.length; index2++) {
|
|
63
|
+
const point1 = points[index1];
|
|
64
|
+
const point2 = points[index2];
|
|
65
|
+
const distance2 = gl_matrix_1.vec3.sqrDist(point1, point2);
|
|
66
|
+
if (distance2 <= maxMinor) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const delta = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), point1, point2);
|
|
70
|
+
const dot = Math.abs(gl_matrix_1.vec3.dot(delta, unitMajor)) / Math.sqrt(distance2);
|
|
71
|
+
if (dot > EPSILON) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (!isInSegment.testCenter(point1, point2)) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (!(0, isLineInSegment_1.isLineInSegment)(point1, point2, isInSegment)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
maxMinor = distance2;
|
|
81
|
+
maxMinorPoints = [index1, index2];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!maxMinorPoints) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
maxMinor = Math.sqrt(maxMinor);
|
|
88
|
+
const handle2 = points[maxMinorPoints[0]];
|
|
89
|
+
const handle3 = points[maxMinorPoints[1]];
|
|
90
|
+
const bidirectional = Object.assign({ majorAxis: [handle0, handle1], minorAxis: [handle2, handle3], maxMajor,
|
|
91
|
+
maxMinor }, sliceContour);
|
|
92
|
+
return bidirectional;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=findLargestBidirectional.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findLargestBidirectional.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/findLargestBidirectional.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AAEjC,uDAAuE;AAGvE,MAAM,OAAO,GAAG,IAAI,CAAC;AAqBrB,SAAwB,wBAAwB,CAC9C,QAAQ,EACR,WAAmB,EACnB,OAAO;IAEP,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAC;IACnC,MAAM,EAAE,YAAY,EAAE,uBAAuB,EAAE,GAAG,OAAO,CAAC;IAC1D,IAAI,gBAAgB,CAAC;IACrB,MAAM,WAAW,GAAG,IAAA,mCAAiB,EACnC,WAAW,EACX,YAAY,EACZ,uBAAuB,CACxB,CAAC;IACF,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;QACxC,MAAM,aAAa,GAAG,2BAA2B,CAC/C,YAAY,EACZ,WAAW,EACX,gBAAgB,CACjB,CAAC;QACF,IAAI,CAAC,aAAa,EAAE;YAClB,SAAS;SACV;QACD,gBAAgB,GAAG,aAAa,CAAC;KAClC;IACD,IAAI,gBAAgB,EAAE;Q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AI,CAAC,GAAG,CAAC,gBAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACxE,IAAI,GAAG,GAAG,OAAO,EAAE;gBACjB,SAAS;aACV;YAED,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;gBAG3C,SAAS;aACV;YACD,IAAI,CAAC,IAAA,iCAAe,EAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE;gBACjD,SAAS;aACV;YACD,QAAQ,GAAG,SAAS,CAAC;YACrB,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACnC;KACF;IAED,IAAI,CAAC,cAAc,EAAE;QAEnB,OAAO;KACR;IACD,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAE1C,MAAM,aAAa,GAAG,gBACpB,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAC7B,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,EAC7B,QAAQ;QACR,QAAQ,IACL,YAAY,CACK,CAAC;IACvB,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
|
@@ -9,4 +9,7 @@ import floodFill from './floodFill';
|
|
|
9
9
|
import { getBrushSizeForToolGroup, setBrushSizeForToolGroup } from './brushSizeForToolGroup';
|
|
10
10
|
import { getBrushThresholdForToolGroup, setBrushThresholdForToolGroup } from './brushThresholdForToolGroup';
|
|
11
11
|
import thresholdSegmentationByRange from './thresholdSegmentationByRange';
|
|
12
|
-
|
|
12
|
+
import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
|
|
13
|
+
import createBidirectionalToolData from './createBidirectionalToolData';
|
|
14
|
+
import segmentContourAction from './segmentContourAction';
|
|
15
|
+
export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.thresholdSegmentationByRange = exports.setBrushThresholdForToolGroup = exports.getBrushThresholdForToolGroup = exports.setBrushSizeForToolGroup = exports.getBrushSizeForToolGroup = exports.floodFill = exports.triggerSegmentationRender = exports.rectangleROIThresholdVolumeByRange = exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = void 0;
|
|
6
|
+
exports.segmentContourAction = exports.createBidirectionalToolData = exports.contourAndFindLargestBidirectional = exports.thresholdSegmentationByRange = exports.setBrushThresholdForToolGroup = exports.getBrushThresholdForToolGroup = exports.setBrushSizeForToolGroup = exports.getBrushSizeForToolGroup = exports.floodFill = exports.triggerSegmentationRender = exports.rectangleROIThresholdVolumeByRange = exports.createLabelmapVolumeForViewport = exports.getDefaultRepresentationConfig = exports.isValidRepresentationConfig = exports.createMergedLabelmapForIndex = exports.thresholdVolumeByRange = void 0;
|
|
7
7
|
const thresholdVolumeByRange_1 = __importDefault(require("./thresholdVolumeByRange"));
|
|
8
8
|
exports.thresholdVolumeByRange = thresholdVolumeByRange_1.default;
|
|
9
9
|
const rectangleROIThresholdVolumeByRange_1 = __importDefault(require("./rectangleROIThresholdVolumeByRange"));
|
|
@@ -28,4 +28,10 @@ Object.defineProperty(exports, "getBrushThresholdForToolGroup", { enumerable: tr
|
|
|
28
28
|
Object.defineProperty(exports, "setBrushThresholdForToolGroup", { enumerable: true, get: function () { return brushThresholdForToolGroup_1.setBrushThresholdForToolGroup; } });
|
|
29
29
|
const thresholdSegmentationByRange_1 = __importDefault(require("./thresholdSegmentationByRange"));
|
|
30
30
|
exports.thresholdSegmentationByRange = thresholdSegmentationByRange_1.default;
|
|
31
|
+
const contourAndFindLargestBidirectional_1 = __importDefault(require("./contourAndFindLargestBidirectional"));
|
|
32
|
+
exports.contourAndFindLargestBidirectional = contourAndFindLargestBidirectional_1.default;
|
|
33
|
+
const createBidirectionalToolData_1 = __importDefault(require("./createBidirectionalToolData"));
|
|
34
|
+
exports.createBidirectionalToolData = createBidirectionalToolData_1.default;
|
|
35
|
+
const segmentContourAction_1 = __importDefault(require("./segmentContourAction"));
|
|
36
|
+
exports.segmentContourAction = segmentContourAction_1.default;
|
|
31
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/index.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA8D;AAsB5D,iCAtBK,gCAAsB,CAsBL;AArBxB,8GAAsF;AA0BpF,6CA1BK,4CAAkC,CA0BL;AAzBpC,kGAA0E;AAqBxE,uCArBK,sCAA4B,CAqBL;AApB9B,gGAAwE;AAqBtE,sCArBK,qCAA2B,CAqBL;AApB7B,sGAA8E;AAqB5E,yCArBK,wCAA8B,CAqBL;AApBhC,wGAAgF;AAqB9E,0CArBK,yCAA+B,CAqBL;AApBjC,2EAAwE;AAsBtE,0GAtBO,qDAAyB,OAsBP;AArB3B,4DAAoC;AAsBlC,oBAtBK,mBAAS,CAsBL;AArBX,mEAGiC;AAmB/B,yGArBA,gDAAwB,OAqBA;AACxB,yGArBA,gDAAwB,OAqBA;AAnB1B,6EAGsC;AAiBpC,8GAnBA,0DAA6B,OAmBA;AAC7B,8GAnBA,0DAA6B,OAmBA;AAjB/B,kGAA0E;AAkBxE,uCAlBK,sCAA4B,CAkBL;AAjB9B,8GAAsF;AAkBpF,6CAlBK,4CAAkC,CAkBL;AAjBpC,gGAAwE;AAkBtE,sCAlBK,qCAA2B,CAkBL;AAjB7B,kFAA0D;AAkBxD,+BAlBK,8BAAoB,CAkBL"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Types } from '@cornerstonejs/core';
|
|
2
|
+
import { vec3 } from 'gl-matrix';
|
|
3
|
+
export default function isLineInSegment(point1: Types.Point3, point2: Types.Point3, isInSegment: any): boolean;
|
|
4
|
+
declare function createIsInSegment(segVolumeId: string, segmentIndex: number, containedSegmentIndices?: Set<number>): {
|
|
5
|
+
testCenter: (point1: any, point2: any) => boolean;
|
|
6
|
+
toIJK: (point: any) => vec3;
|
|
7
|
+
testIJK: (ijk: any) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export { createIsInSegment, isLineInSegment };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLineInSegment = exports.createIsInSegment = void 0;
|
|
4
|
+
const core_1 = require("@cornerstonejs/core");
|
|
5
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
6
|
+
function isLineInSegment(point1, point2, isInSegment) {
|
|
7
|
+
const ijk1 = isInSegment.toIJK(point1);
|
|
8
|
+
const ijk2 = isInSegment.toIJK(point2);
|
|
9
|
+
const testPoint = gl_matrix_1.vec3.create();
|
|
10
|
+
const { testIJK } = isInSegment;
|
|
11
|
+
const delta = gl_matrix_1.vec3.sub(gl_matrix_1.vec3.create(), ijk1, ijk2);
|
|
12
|
+
const testSize = Math.round(Math.max(...delta.map(Math.abs)));
|
|
13
|
+
if (testSize < 2) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
const unitDelta = gl_matrix_1.vec3.scale(gl_matrix_1.vec3.create(), delta, 1 / testSize);
|
|
17
|
+
for (let i = 1; i < testSize; i++) {
|
|
18
|
+
gl_matrix_1.vec3.scaleAndAdd(testPoint, ijk2, unitDelta, i);
|
|
19
|
+
if (!testIJK(testPoint)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
exports.default = isLineInSegment;
|
|
26
|
+
exports.isLineInSegment = isLineInSegment;
|
|
27
|
+
function createIsInSegment(segVolumeId, segmentIndex, containedSegmentIndices) {
|
|
28
|
+
const vol = core_1.cache.getVolume(segVolumeId);
|
|
29
|
+
if (!vol) {
|
|
30
|
+
console.warn(`No volume found for ${segVolumeId}`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const segData = vol.imageData.getPointData().getScalars().getData();
|
|
34
|
+
const width = vol.dimensions[0];
|
|
35
|
+
const pixelsPerSlice = width * vol.dimensions[1];
|
|
36
|
+
return {
|
|
37
|
+
testCenter: (point1, point2) => {
|
|
38
|
+
const point = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), point1, point2).map((it) => it / 2);
|
|
39
|
+
const ijk = vol.imageData.worldToIndex(point).map(Math.round);
|
|
40
|
+
const [i, j, k] = ijk;
|
|
41
|
+
const index = i + j * width + k * pixelsPerSlice;
|
|
42
|
+
const value = segData[index];
|
|
43
|
+
return value === segmentIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value));
|
|
44
|
+
},
|
|
45
|
+
toIJK: (point) => vol.imageData.worldToIndex(point),
|
|
46
|
+
testIJK: (ijk) => {
|
|
47
|
+
const [i, j, k] = ijk;
|
|
48
|
+
const index = Math.round(i) + Math.round(j) * width + Math.round(k) * pixelsPerSlice;
|
|
49
|
+
const value = segData[index];
|
|
50
|
+
return value === segmentIndex || (containedSegmentIndices === null || containedSegmentIndices === void 0 ? void 0 : containedSegmentIndices.has(value));
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.createIsInSegment = createIsInSegment;
|
|
55
|
+
//# sourceMappingURL=isLineInSegment.js.map
|