@cornerstonejs/tools 3.0.0-beta.2 → 3.0.0-beta.4
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/config.d.ts +29 -0
- package/dist/esm/config.js +23 -0
- package/dist/esm/enums/StrategyCallbacks.d.ts +3 -1
- package/dist/esm/enums/StrategyCallbacks.js +2 -0
- package/dist/esm/enums/WorkerTypes.d.ts +3 -1
- package/dist/esm/enums/WorkerTypes.js +2 -0
- package/dist/esm/init.d.ts +2 -1
- package/dist/esm/init.js +2 -0
- package/dist/esm/stateManagement/segmentation/helpers/normalizeSegmentationInput.js +1 -1
- package/dist/esm/stateManagement/segmentation/helpers/validateSegmentationInput.js +1 -1
- package/dist/esm/stateManagement/segmentation/index.d.ts +3 -2
- package/dist/esm/stateManagement/segmentation/index.js +3 -2
- package/dist/esm/tools/displayTools/Contour/contourDisplay.js +8 -6
- package/dist/esm/tools/displayTools/Labelmap/index.d.ts +1 -1
- package/dist/esm/tools/displayTools/Labelmap/index.js +1 -1
- package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +14 -5
- package/dist/esm/tools/displayTools/Surface/surfaceDisplay.js +13 -8
- package/dist/esm/tools/segmentation/BrushTool.js +1 -9
- package/dist/esm/tools/segmentation/CircleScissorsTool.js +0 -1
- package/dist/esm/tools/segmentation/LabelmapBaseTool.d.ts +1 -2
- package/dist/esm/tools/segmentation/LabelmapBaseTool.js +10 -49
- package/dist/esm/tools/segmentation/RectangleScissorsTool.js +0 -1
- package/dist/esm/tools/segmentation/SphereScissorsTool.js +0 -1
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.d.ts +21 -10
- package/dist/esm/tools/segmentation/strategies/BrushStrategy.js +8 -8
- package/dist/esm/tools/segmentation/strategies/compositions/determineSegmentIndex.js +7 -10
- package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +15 -14
- package/dist/esm/tools/segmentation/strategies/compositions/ensureImageVolume.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/compositions/ensureImageVolume.js +35 -0
- package/dist/esm/tools/segmentation/strategies/compositions/ensureSegmentationVolume.d.ts +4 -0
- package/dist/esm/tools/segmentation/strategies/compositions/ensureSegmentationVolume.js +20 -0
- package/dist/esm/tools/segmentation/strategies/compositions/index.d.ts +7 -10
- package/dist/esm/tools/segmentation/strategies/compositions/index.js +4 -2
- package/dist/esm/tools/segmentation/strategies/compositions/islandRemovalComposition.js +3 -2
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapStatistics.d.ts +1 -1
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapStatistics.js +6 -97
- package/dist/esm/tools/segmentation/strategies/compositions/preview.js +3 -3
- package/dist/esm/tools/segmentation/strategies/compositions/threshold.js +5 -6
- package/dist/esm/tools/segmentation/strategies/fillCircle.js +2 -2
- package/dist/esm/tools/segmentation/strategies/fillSphere.js +3 -3
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.d.ts +7 -3
- package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +78 -34
- package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.d.ts +2 -7
- package/dist/esm/tools/segmentation/strategies/utils/isWithinThreshold.js +5 -4
- package/dist/esm/types/CalculatorTypes.d.ts +2 -0
- package/dist/esm/types/LabelmapToolOperationData.d.ts +1 -1
- package/dist/esm/types/index.d.ts +3 -4
- package/dist/esm/utilities/getPixelValueUnits.d.ts +2 -1
- package/dist/esm/utilities/getPixelValueUnits.js +5 -1
- package/dist/esm/utilities/index.d.ts +3 -2
- package/dist/esm/utilities/index.js +3 -2
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.d.ts +6 -1
- package/dist/esm/utilities/math/basic/BasicStatsCalculator.js +27 -2
- package/dist/esm/utilities/math/vec2/liangBarksyClip.d.ts +1 -1
- package/dist/esm/utilities/registerComputeWorker.d.ts +1 -0
- package/dist/esm/{stateManagement/segmentation/polySeg/registerPolySegWorker.js → utilities/registerComputeWorker.js} +4 -4
- package/dist/esm/utilities/segmentation/brushThresholdForToolGroup.d.ts +5 -1
- package/dist/esm/utilities/segmentation/brushThresholdForToolGroup.js +12 -13
- package/dist/esm/{stateManagement/segmentation/polySeg → utilities/segmentation}/computeAndAddRepresentation.d.ts +1 -1
- package/dist/esm/{stateManagement/segmentation/polySeg → utilities/segmentation}/computeAndAddRepresentation.js +4 -6
- package/dist/esm/utilities/segmentation/getOrCreateSegmentationVolume.d.ts +2 -0
- package/dist/esm/utilities/segmentation/getOrCreateSegmentationVolume.js +21 -0
- package/dist/esm/utilities/segmentation/getStatistics.d.ts +5 -0
- package/dist/esm/utilities/segmentation/getStatistics.js +210 -0
- package/dist/esm/utilities/segmentation/index.d.ts +6 -1
- package/dist/esm/utilities/segmentation/index.js +6 -1
- package/dist/esm/{tools/displayTools/Labelmap → utilities/segmentation}/validateLabelmap.d.ts +2 -2
- package/dist/esm/workers/computeWorker.js +78 -0
- package/package.json +3 -3
- package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.d.ts +0 -16
- package/dist/esm/stateManagement/segmentation/helpers/clipAndCacheSurfacesForViewport.js +0 -88
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.d.ts +0 -4
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation.js +0 -6
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.d.ts +0 -8
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/contourComputationStrategies.js +0 -103
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/createAndAddContourSegmentationsFromClippedSurfaces.js +0 -71
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/extractContourData.js +0 -16
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.d.ts +0 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Contour/utils/updateContoursOnCameraModified.js +0 -25
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/computeAndAddLabelmapRepresentation.d.ts +0 -2
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/computeAndAddLabelmapRepresentation.js +0 -13
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.d.ts +0 -7
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +0 -143
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.d.ts +0 -6
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertSurfaceToLabelmap.js +0 -49
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.d.ts +0 -6
- package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/labelmapComputationStrategies.js +0 -96
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/computeAndAddSurfaceRepresentation.d.ts +0 -4
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/computeAndAddSurfaceRepresentation.js +0 -7
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertContourToSurface.js +0 -37
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +0 -44
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.d.ts +0 -5
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +0 -33
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/surfaceComputationStrategies.d.ts +0 -12
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/surfaceComputationStrategies.js +0 -75
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.d.ts +0 -1
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/updateSurfaceData.js +0 -59
- package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.d.ts +0 -3
- package/dist/esm/stateManagement/segmentation/polySeg/canComputeRequestedRepresentation.js +0 -58
- package/dist/esm/stateManagement/segmentation/polySeg/index.d.ts +0 -5
- package/dist/esm/stateManagement/segmentation/polySeg/index.js +0 -5
- package/dist/esm/stateManagement/segmentation/polySeg/registerPolySegWorker.d.ts +0 -1
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapInterpolation.d.ts +0 -12
- package/dist/esm/tools/segmentation/strategies/compositions/labelmapInterpolation.js +0 -60
- package/dist/esm/tools/segmentation/strategies/utils/getItkImage.d.ts +0 -1
- package/dist/esm/tools/segmentation/strategies/utils/getItkImage.js +0 -49
- package/dist/esm/types/PolySeg.d.ts +0 -6
- package/dist/esm/types/PolySeg.js +0 -0
- package/dist/esm/workers/polySegConverters.js +0 -382
- /package/dist/esm/{geometricSurfaceUtils.d.ts → utilities/geometricSurfaceUtils.d.ts} +0 -0
- /package/dist/esm/{geometricSurfaceUtils.js → utilities/geometricSurfaceUtils.js} +0 -0
- /package/dist/esm/{tools/displayTools/Labelmap → utilities/segmentation}/validateLabelmap.js +0 -0
- /package/dist/esm/workers/{polySegConverters.d.ts → computeWorker.d.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ContourSegmentationData } from './types';
|
|
2
|
+
import type { Types } from '@cornerstonejs/core';
|
|
3
|
+
import type { LabelmapSegmentationData } from './types/LabelmapTypes';
|
|
4
|
+
import type { SurfaceSegmentationData } from './types/SurfaceTypes';
|
|
5
|
+
export type PolySegConversionOptions = {
|
|
6
|
+
segmentIndices?: number[];
|
|
7
|
+
segmentationId?: string;
|
|
8
|
+
viewport?: Types.IStackViewport | Types.IVolumeViewport;
|
|
9
|
+
};
|
|
10
|
+
type ComputeRepresentationFn<T> = (segmentationId: string, options: PolySegConversionOptions) => Promise<T>;
|
|
11
|
+
type PolySegAddOn = {
|
|
12
|
+
canComputeRequestedRepresentation: (segmentationId: string, representationType: string) => boolean;
|
|
13
|
+
init: () => void;
|
|
14
|
+
computeContourData: ComputeRepresentationFn<ContourSegmentationData>;
|
|
15
|
+
computeLabelmapData: ComputeRepresentationFn<LabelmapSegmentationData>;
|
|
16
|
+
computeSurfaceData: ComputeRepresentationFn<SurfaceSegmentationData>;
|
|
17
|
+
updateSurfaceData: ComputeRepresentationFn<SurfaceSegmentationData>;
|
|
18
|
+
};
|
|
19
|
+
type AddOns = {
|
|
20
|
+
polySeg: PolySegAddOn;
|
|
21
|
+
};
|
|
22
|
+
export type Config = {
|
|
23
|
+
addons: AddOns;
|
|
24
|
+
};
|
|
25
|
+
export declare function getConfig(): Config;
|
|
26
|
+
export declare function setConfig(newConfig: Config): void;
|
|
27
|
+
export declare function getAddOns(): AddOns;
|
|
28
|
+
export declare function getPolySeg(): PolySegAddOn;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
let config = {};
|
|
2
|
+
export function getConfig() {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
export function setConfig(newConfig) {
|
|
6
|
+
config = newConfig;
|
|
7
|
+
}
|
|
8
|
+
export function getAddOns() {
|
|
9
|
+
return config.addons;
|
|
10
|
+
}
|
|
11
|
+
let polysegInitialized = false;
|
|
12
|
+
export function getPolySeg() {
|
|
13
|
+
if (!config.addons?.polySeg) {
|
|
14
|
+
console.warn('PolySeg add-on not configured. This will prevent automatic conversion between segmentation representations (labelmap, contour, surface). To enable these features, install @cornerstonejs/polymorphic-segmentation and register it during initialization: cornerstoneTools.init({ addons: { polySeg } }).');
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const polyseg = config.addons.polySeg;
|
|
18
|
+
if (!polysegInitialized) {
|
|
19
|
+
polyseg.init();
|
|
20
|
+
polysegInitialized = true;
|
|
21
|
+
}
|
|
22
|
+
return polyseg;
|
|
23
|
+
}
|
|
@@ -12,6 +12,8 @@ declare enum StrategyCallbacks {
|
|
|
12
12
|
INTERNAL_setValue = "setValue",
|
|
13
13
|
AddPreview = "addPreview",
|
|
14
14
|
ComputeInnerCircleRadius = "computeInnerCircleRadius",
|
|
15
|
-
GetStatistics = "getStatistics"
|
|
15
|
+
GetStatistics = "getStatistics",
|
|
16
|
+
EnsureImageVolumeFor3DManipulation = "ensureImageVolumeFor3DManipulation",
|
|
17
|
+
EnsureSegmentationVolumeFor3DManipulation = "ensureSegmentationVolumeFor3DManipulation"
|
|
16
18
|
}
|
|
17
19
|
export default StrategyCallbacks;
|
|
@@ -14,5 +14,7 @@ var StrategyCallbacks;
|
|
|
14
14
|
StrategyCallbacks["AddPreview"] = "addPreview";
|
|
15
15
|
StrategyCallbacks["ComputeInnerCircleRadius"] = "computeInnerCircleRadius";
|
|
16
16
|
StrategyCallbacks["GetStatistics"] = "getStatistics";
|
|
17
|
+
StrategyCallbacks["EnsureImageVolumeFor3DManipulation"] = "ensureImageVolumeFor3DManipulation";
|
|
18
|
+
StrategyCallbacks["EnsureSegmentationVolumeFor3DManipulation"] = "ensureSegmentationVolumeFor3DManipulation";
|
|
17
19
|
})(StrategyCallbacks || (StrategyCallbacks = {}));
|
|
18
20
|
export default StrategyCallbacks;
|
|
@@ -3,6 +3,8 @@ declare enum ChangeTypes {
|
|
|
3
3
|
POLYSEG_SURFACE_TO_LABELMAP = "Converting Surfaces to Labelmap",
|
|
4
4
|
POLYSEG_CONTOUR_TO_SURFACE = "Converting Contour to Surface",
|
|
5
5
|
POLYSEG_LABELMAP_TO_SURFACE = "Converting Labelmap to Surface",
|
|
6
|
-
SURFACE_CLIPPING = "Clipping Surfaces"
|
|
6
|
+
SURFACE_CLIPPING = "Clipping Surfaces",
|
|
7
|
+
COMPUTE_STATISTICS = "Computing Statistics",
|
|
8
|
+
INTERPOLATE_LABELMAP = "Interpolating Labelmap"
|
|
7
9
|
}
|
|
8
10
|
export default ChangeTypes;
|
|
@@ -5,5 +5,7 @@ var ChangeTypes;
|
|
|
5
5
|
ChangeTypes["POLYSEG_CONTOUR_TO_SURFACE"] = "Converting Contour to Surface";
|
|
6
6
|
ChangeTypes["POLYSEG_LABELMAP_TO_SURFACE"] = "Converting Labelmap to Surface";
|
|
7
7
|
ChangeTypes["SURFACE_CLIPPING"] = "Clipping Surfaces";
|
|
8
|
+
ChangeTypes["COMPUTE_STATISTICS"] = "Computing Statistics";
|
|
9
|
+
ChangeTypes["INTERPOLATE_LABELMAP"] = "Interpolating Labelmap";
|
|
8
10
|
})(ChangeTypes || (ChangeTypes = {}));
|
|
9
11
|
export default ChangeTypes;
|
package/dist/esm/init.d.ts
CHANGED
package/dist/esm/init.js
CHANGED
|
@@ -8,11 +8,13 @@ import { annotationInterpolationEventDispatcher } from './eventDispatchers';
|
|
|
8
8
|
import * as ToolGroupManager from './store/ToolGroupManager';
|
|
9
9
|
import { defaultSegmentationStateManager } from './stateManagement/segmentation/SegmentationStateManager';
|
|
10
10
|
import segmentationRepresentationModifiedListener from './eventListeners/segmentation/segmentationRepresentationModifiedListener';
|
|
11
|
+
import { setConfig } from './config';
|
|
11
12
|
let csToolsInitialized = false;
|
|
12
13
|
export function init(defaultConfiguration = {}) {
|
|
13
14
|
if (csToolsInitialized) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
17
|
+
setConfig(defaultConfiguration);
|
|
16
18
|
_addCornerstoneEventListeners();
|
|
17
19
|
_addCornerstoneToolsEventListeners();
|
|
18
20
|
csToolsInitialized = true;
|
|
@@ -51,7 +51,7 @@ function normalizeSegments(segmentsConfig, type, data) {
|
|
|
51
51
|
}
|
|
52
52
|
function normalizeSurfaceSegments(normalizedSegments, surfaceData) {
|
|
53
53
|
const { geometryIds } = surfaceData;
|
|
54
|
-
geometryIds
|
|
54
|
+
geometryIds?.forEach((geometryId) => {
|
|
55
55
|
const geometry = cache.getGeometry(geometryId);
|
|
56
56
|
if (geometry?.data) {
|
|
57
57
|
const { segmentIndex } = geometry.data;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Enums from '../../../enums';
|
|
2
|
-
import { validatePublic as validatePublicLabelmap } from '../../../
|
|
2
|
+
import { validatePublic as validatePublicLabelmap } from '../../../utilities/segmentation/validateLabelmap';
|
|
3
3
|
function validateSegmentationInput(segmentationInputArray) {
|
|
4
4
|
if (!segmentationInputArray || segmentationInputArray.length === 0) {
|
|
5
5
|
throw new Error('The segmentationInputArray is undefined or an empty array');
|
|
@@ -11,17 +11,18 @@ import * as segmentIndex from './segmentIndex';
|
|
|
11
11
|
import * as triggerSegmentationEvents from './triggerSegmentationEvents';
|
|
12
12
|
import { convertStackToVolumeLabelmap } from './helpers/convertStackToVolumeLabelmap';
|
|
13
13
|
import { computeVolumeLabelmapFromStack } from './helpers/computeVolumeLabelmapFromStack';
|
|
14
|
-
import * as polySegManager from './polySeg';
|
|
15
14
|
import { clearSegmentValue } from './helpers/clearSegmentValue';
|
|
16
15
|
import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume';
|
|
17
16
|
import { removeSegment } from './removeSegment';
|
|
18
17
|
import { getLabelmapImageIds } from './getLabelmapImageIds';
|
|
19
18
|
import * as strategies from './../../tools/segmentation/strategies';
|
|
20
19
|
import { removeAllSegmentations, removeSegmentation } from './removeSegmentation';
|
|
20
|
+
import { segmentationStyle } from './SegmentationStyle';
|
|
21
|
+
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
21
22
|
declare const helpers: {
|
|
22
23
|
clearSegmentValue: typeof clearSegmentValue;
|
|
23
24
|
convertStackToVolumeLabelmap: typeof convertStackToVolumeLabelmap;
|
|
24
25
|
computeVolumeLabelmapFromStack: typeof computeVolumeLabelmapFromStack;
|
|
25
26
|
convertVolumeToStackLabelmap: typeof convertVolumeToStackLabelmap;
|
|
26
27
|
};
|
|
27
|
-
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers,
|
|
28
|
+
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, };
|
|
@@ -11,17 +11,18 @@ import * as segmentIndex from './segmentIndex';
|
|
|
11
11
|
import * as triggerSegmentationEvents from './triggerSegmentationEvents';
|
|
12
12
|
import { convertStackToVolumeLabelmap } from './helpers/convertStackToVolumeLabelmap';
|
|
13
13
|
import { computeVolumeLabelmapFromStack } from './helpers/computeVolumeLabelmapFromStack';
|
|
14
|
-
import * as polySegManager from './polySeg';
|
|
15
14
|
import { clearSegmentValue } from './helpers/clearSegmentValue';
|
|
16
15
|
import { convertVolumeToStackLabelmap } from './helpers/computeStackLabelmapFromVolume';
|
|
17
16
|
import { removeSegment } from './removeSegment';
|
|
18
17
|
import { getLabelmapImageIds } from './getLabelmapImageIds';
|
|
19
18
|
import * as strategies from './../../tools/segmentation/strategies';
|
|
20
19
|
import { removeAllSegmentations, removeSegmentation, } from './removeSegmentation';
|
|
20
|
+
import { segmentationStyle } from './SegmentationStyle';
|
|
21
|
+
import { defaultSegmentationStateManager } from './SegmentationStateManager';
|
|
21
22
|
const helpers = {
|
|
22
23
|
clearSegmentValue,
|
|
23
24
|
convertStackToVolumeLabelmap,
|
|
24
25
|
computeVolumeLabelmapFromStack,
|
|
25
26
|
convertVolumeToStackLabelmap,
|
|
26
27
|
};
|
|
27
|
-
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers,
|
|
28
|
+
export { removeSegmentationRepresentation, removeContourRepresentation, removeLabelmapRepresentation, removeSurfaceRepresentation, removeAllSegmentations, removeSegmentation, removeSegmentationRepresentations, addLabelmapRepresentationToViewport, addLabelmapRepresentationToViewportMap, addSegmentationRepresentations, removeAllSegmentationRepresentations, addContourRepresentationToViewport, addContourRepresentationToViewportMap, addSurfaceRepresentationToViewport, addSurfaceRepresentationToViewportMap, addSegmentations, updateSegmentations, state, activeSegmentation, segmentLocking, config, segmentIndex, triggerSegmentationEvents, helpers, removeSegment, getLabelmapImageIds, addRepresentationData, strategies, segmentationStyle, defaultSegmentationStateManager, };
|
|
@@ -2,9 +2,9 @@ import { getEnabledElementByViewportId } from '@cornerstonejs/core';
|
|
|
2
2
|
import Representations from '../../../enums/SegmentationRepresentations';
|
|
3
3
|
import { handleContourSegmentation } from './contourHandler/handleContourSegmentation';
|
|
4
4
|
import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation';
|
|
5
|
-
import { canComputeRequestedRepresentation } from '../../../stateManagement/segmentation/polySeg/canComputeRequestedRepresentation';
|
|
6
|
-
import { computeAndAddContourRepresentation } from '../../../stateManagement/segmentation/polySeg/Contour/computeAndAddContourRepresentation';
|
|
7
5
|
import removeContourFromElement from './removeContourFromElement';
|
|
6
|
+
import { getPolySeg } from '../../../config';
|
|
7
|
+
import { computeAndAddRepresentation } from '../../../utilities/segmentation/computeAndAddRepresentation';
|
|
8
8
|
let polySegConversionInProgress = false;
|
|
9
9
|
const processedViewportSegmentations = new Map();
|
|
10
10
|
function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
|
|
@@ -27,14 +27,16 @@ async function render(viewport, contourRepresentation) {
|
|
|
27
27
|
}
|
|
28
28
|
let contourData = segmentation.representationData[Representations.Contour];
|
|
29
29
|
if (!contourData &&
|
|
30
|
-
canComputeRequestedRepresentation(segmentationId, Representations.Contour) &&
|
|
30
|
+
getPolySeg()?.canComputeRequestedRepresentation(segmentationId, Representations.Contour) &&
|
|
31
31
|
!polySegConversionInProgress) {
|
|
32
32
|
polySegConversionInProgress = true;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
33
|
+
const polySeg = getPolySeg();
|
|
34
|
+
contourData = await computeAndAddRepresentation(segmentationId, Representations.Contour, () => polySeg.computeContourData(segmentationId, { viewport }), () => undefined);
|
|
36
35
|
polySegConversionInProgress = false;
|
|
37
36
|
}
|
|
37
|
+
else if (!contourData && !getPolySeg()) {
|
|
38
|
+
console.debug(`No contour data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to contour. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
|
|
39
|
+
}
|
|
38
40
|
if (!contourData) {
|
|
39
41
|
return;
|
|
40
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import labelmapDisplay from './labelmapDisplay';
|
|
2
2
|
import labelmapConfig from './labelmapConfig';
|
|
3
|
-
import { validate as validateLabelmap, validatePublic as validateLabelmapPublic } from '
|
|
3
|
+
import { validate as validateLabelmap, validatePublic as validateLabelmapPublic } from '../../../utilities/segmentation/validateLabelmap';
|
|
4
4
|
export { labelmapDisplay, labelmapConfig, validateLabelmap, validateLabelmapPublic, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import labelmapDisplay from './labelmapDisplay';
|
|
2
2
|
import labelmapConfig from './labelmapConfig';
|
|
3
|
-
import { validate as validateLabelmap, validatePublic as validateLabelmapPublic, } from '
|
|
3
|
+
import { validate as validateLabelmap, validatePublic as validateLabelmapPublic, } from '../../../utilities/segmentation/validateLabelmap';
|
|
4
4
|
export { labelmapDisplay, labelmapConfig, validateLabelmap, validateLabelmapPublic, };
|
|
@@ -5,13 +5,15 @@ import { getActiveSegmentation } from '../../../stateManagement/segmentation/act
|
|
|
5
5
|
import { getColorLUT } from '../../../stateManagement/segmentation/getColorLUT';
|
|
6
6
|
import { getCurrentLabelmapImageIdForViewport } from '../../../stateManagement/segmentation/getCurrentLabelmapImageIdForViewport';
|
|
7
7
|
import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation';
|
|
8
|
-
import { canComputeRequestedRepresentation } from '../../../stateManagement/segmentation/polySeg/canComputeRequestedRepresentation';
|
|
9
|
-
import { computeAndAddLabelmapRepresentation } from '../../../stateManagement/segmentation/polySeg/Labelmap/computeAndAddLabelmapRepresentation';
|
|
10
8
|
import { segmentationStyle } from '../../../stateManagement/segmentation/SegmentationStyle';
|
|
11
9
|
import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
|
|
12
10
|
import { internalGetHiddenSegmentIndices } from '../../../stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices';
|
|
13
11
|
import { getActiveSegmentIndex } from '../../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
14
12
|
import { getLabelmapActorEntry } from '../../../stateManagement/segmentation/helpers/getSegmentationActor';
|
|
13
|
+
import { getPolySeg } from '../../../config';
|
|
14
|
+
import { computeAndAddRepresentation } from '../../../utilities/segmentation/computeAndAddRepresentation';
|
|
15
|
+
import { triggerSegmentationDataModified } from '../../../stateManagement/segmentation/triggerSegmentationEvents';
|
|
16
|
+
import { defaultSegmentationStateManager } from '../../../stateManagement/segmentation/SegmentationStateManager';
|
|
15
17
|
export const MAX_NUMBER_COLORS = 255;
|
|
16
18
|
const labelMapConfigCache = new Map();
|
|
17
19
|
let polySegConversionInProgress = false;
|
|
@@ -42,17 +44,24 @@ async function render(viewport, representation) {
|
|
|
42
44
|
let labelmapData = segmentation.representationData[SegmentationRepresentations.Labelmap];
|
|
43
45
|
let labelmapActorEntry = getLabelmapActorEntry(viewport.id, segmentationId);
|
|
44
46
|
if (!labelmapData &&
|
|
45
|
-
canComputeRequestedRepresentation(segmentationId, SegmentationRepresentations.Labelmap) &&
|
|
47
|
+
getPolySeg()?.canComputeRequestedRepresentation(segmentationId, SegmentationRepresentations.Labelmap) &&
|
|
46
48
|
!polySegConversionInProgress) {
|
|
47
49
|
polySegConversionInProgress = true;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const polySeg = getPolySeg();
|
|
51
|
+
labelmapData = await computeAndAddRepresentation(segmentationId, SegmentationRepresentations.Labelmap, () => polySeg.computeLabelmapData(segmentationId, { viewport }), () => null, () => {
|
|
52
|
+
defaultSegmentationStateManager.processLabelmapRepresentationAddition(viewport.id, segmentationId);
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
triggerSegmentationDataModified(segmentationId);
|
|
55
|
+
}, 0);
|
|
50
56
|
});
|
|
51
57
|
if (!labelmapData) {
|
|
52
58
|
throw new Error(`No labelmap data found for segmentationId ${segmentationId}.`);
|
|
53
59
|
}
|
|
54
60
|
polySegConversionInProgress = false;
|
|
55
61
|
}
|
|
62
|
+
else if (!labelmapData && !getPolySeg()) {
|
|
63
|
+
console.debug(`No labelmap data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to labelmap. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
|
|
64
|
+
}
|
|
56
65
|
if (!labelmapData) {
|
|
57
66
|
return;
|
|
58
67
|
}
|
|
@@ -4,9 +4,8 @@ import removeSurfaceFromElement from './removeSurfaceFromElement';
|
|
|
4
4
|
import addOrUpdateSurfaceToElement from './addOrUpdateSurfaceToElement';
|
|
5
5
|
import { getSegmentation } from '../../../stateManagement/segmentation/getSegmentation';
|
|
6
6
|
import { getColorLUT } from '../../../stateManagement/segmentation/getColorLUT';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
const { ViewportType } = Enums;
|
|
7
|
+
import { getPolySeg } from '../../../config';
|
|
8
|
+
import { computeAndAddRepresentation } from '../../../utilities/segmentation/computeAndAddRepresentation';
|
|
10
9
|
function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
|
|
11
10
|
const enabledElement = getEnabledElementByViewportId(viewportId);
|
|
12
11
|
if (!enabledElement) {
|
|
@@ -27,14 +26,20 @@ async function render(viewport, representation) {
|
|
|
27
26
|
}
|
|
28
27
|
let SurfaceData = segmentation.representationData[Representations.Surface];
|
|
29
28
|
if (!SurfaceData &&
|
|
30
|
-
canComputeRequestedRepresentation(segmentationId, Representations.Surface)) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
29
|
+
getPolySeg()?.canComputeRequestedRepresentation(segmentationId, Representations.Surface)) {
|
|
30
|
+
const polySeg = getPolySeg();
|
|
31
|
+
SurfaceData = await computeAndAddRepresentation(segmentationId, Representations.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport }), () => polySeg.updateSurfaceData(segmentationId, { viewport }));
|
|
34
32
|
if (!SurfaceData) {
|
|
35
|
-
throw new Error(`No Surface data found for segmentationId ${segmentationId}
|
|
33
|
+
throw new Error(`No Surface data found for segmentationId ${segmentationId} even we tried to compute it`);
|
|
36
34
|
}
|
|
37
35
|
}
|
|
36
|
+
else if (!SurfaceData && !getPolySeg()) {
|
|
37
|
+
console.debug(`No surface data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to surface. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
|
|
38
|
+
}
|
|
39
|
+
if (!SurfaceData) {
|
|
40
|
+
console.warn(`No Surface data found for segmentationId ${segmentationId}. Skipping render.`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
38
43
|
const { geometryIds } = SurfaceData;
|
|
39
44
|
if (!geometryIds?.size) {
|
|
40
45
|
console.warn(`No Surfaces found for segmentationId ${segmentationId}. Skipping render.`);
|
|
@@ -22,14 +22,8 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
22
22
|
THRESHOLD_INSIDE_SPHERE: thresholdInsideSphere,
|
|
23
23
|
THRESHOLD_INSIDE_SPHERE_WITH_ISLAND_REMOVAL: thresholdInsideSphereIsland,
|
|
24
24
|
},
|
|
25
|
-
strategySpecificConfiguration: {
|
|
26
|
-
THRESHOLD: {
|
|
27
|
-
threshold: [-150, -70],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
25
|
defaultStrategy: 'FILL_INSIDE_CIRCLE',
|
|
31
26
|
activeStrategy: 'FILL_INSIDE_CIRCLE',
|
|
32
|
-
thresholdVolumeId: null,
|
|
33
27
|
brushSize: 25,
|
|
34
28
|
preview: {
|
|
35
29
|
enabled: false,
|
|
@@ -346,9 +340,7 @@ class BrushTool extends LabelmapBaseTool {
|
|
|
346
340
|
drawCircleSvg(svgDrawingHelper, annotationUID, circleUID, center, radius, {
|
|
347
341
|
color,
|
|
348
342
|
});
|
|
349
|
-
const
|
|
350
|
-
const { dynamicRadiusInCanvas } = this.configuration
|
|
351
|
-
.strategySpecificConfiguration[activeStrategy] || {
|
|
343
|
+
const { dynamicRadiusInCanvas } = this.configuration?.threshold || {
|
|
352
344
|
dynamicRadiusInCanvas: 0,
|
|
353
345
|
};
|
|
354
346
|
if (dynamicRadiusInCanvas) {
|
|
@@ -56,12 +56,11 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
56
56
|
protected get _previewData(): PreviewData;
|
|
57
57
|
createMemo(segmentId: string, segmentationVoxelManager: any, preview: any): LabelmapMemo.LabelmapMemo;
|
|
58
58
|
protected createEditData(element: any): EditDataReturnType;
|
|
59
|
-
protected getEditData({ viewport, representationData, segmentsLocked, segmentationId,
|
|
59
|
+
protected getEditData({ viewport, representationData, segmentsLocked, segmentationId, }: {
|
|
60
60
|
viewport: any;
|
|
61
61
|
representationData: any;
|
|
62
62
|
segmentsLocked: any;
|
|
63
63
|
segmentationId: any;
|
|
64
|
-
volumeOperation?: boolean;
|
|
65
64
|
}): EditDataReturnType;
|
|
66
65
|
protected createHoverData(element: any, centerCanvas?: any): {
|
|
67
66
|
brushCursor: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEnabledElement, cache, utilities as csUtils, Enums, eventTarget, BaseVolumeViewport,
|
|
1
|
+
import { getEnabledElement, cache, utilities as csUtils, Enums, eventTarget, BaseVolumeViewport, } from '@cornerstonejs/core';
|
|
2
2
|
import { BaseTool } from '../base';
|
|
3
3
|
import SegmentationRepresentations from '../../enums/SegmentationRepresentations';
|
|
4
4
|
import { getActiveSegmentation } from '../../stateManagement/segmentation/getActiveSegmentation';
|
|
@@ -6,7 +6,6 @@ import { getLockedSegmentIndices } from '../../stateManagement/segmentation/segm
|
|
|
6
6
|
import { getSegmentation } from '../../stateManagement/segmentation/getSegmentation';
|
|
7
7
|
import { getClosestImageIdForStackViewport } from '../../utilities/annotationHydration';
|
|
8
8
|
import { getCurrentLabelmapImageIdForViewport } from '../../stateManagement/segmentation/getCurrentLabelmapImageIdForViewport';
|
|
9
|
-
import { getStackSegmentationImageIdsForViewport } from '../../stateManagement/segmentation/getStackSegmentationImageIdsForViewport';
|
|
10
9
|
import { getSegmentIndexColor } from '../../stateManagement/segmentation/config/segmentationColor';
|
|
11
10
|
import { getActiveSegmentIndex } from '../../stateManagement/segmentation/getActiveSegmentIndex';
|
|
12
11
|
import { StrategyCallbacks } from '../../enums';
|
|
@@ -61,7 +60,7 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
61
60
|
});
|
|
62
61
|
return editData;
|
|
63
62
|
}
|
|
64
|
-
getEditData({ viewport, representationData, segmentsLocked, segmentationId,
|
|
63
|
+
getEditData({ viewport, representationData, segmentsLocked, segmentationId, }) {
|
|
65
64
|
if (viewport instanceof BaseVolumeViewport) {
|
|
66
65
|
const { volumeId } = representationData[SegmentationRepresentations.Labelmap];
|
|
67
66
|
const actors = viewport.getActors();
|
|
@@ -82,7 +81,8 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
82
81
|
const referencedVolumeIdToThreshold = volumes.find((volume) => csUtils.isEqual(volume.dimensions, segmentationVolume.dimensions))?.volumeId || volumes[0]?.volumeId;
|
|
83
82
|
return {
|
|
84
83
|
volumeId,
|
|
85
|
-
referencedVolumeId: this.configuration.
|
|
84
|
+
referencedVolumeId: this.configuration.threshold?.volumeId ??
|
|
85
|
+
referencedVolumeIdToThreshold,
|
|
86
86
|
segmentsLocked,
|
|
87
87
|
};
|
|
88
88
|
}
|
|
@@ -91,50 +91,10 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
91
91
|
if (!segmentationImageId) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (!isValidVolumeForSphere) {
|
|
99
|
-
throw new Error('Volume is not reconstructable for sphere manipulation');
|
|
100
|
-
}
|
|
101
|
-
const volumeId = `${segmentationId}_${viewport.id}`;
|
|
102
|
-
const volume = cache.getVolume(volumeId);
|
|
103
|
-
if (volume) {
|
|
104
|
-
return {
|
|
105
|
-
imageId: segmentationImageId,
|
|
106
|
-
segmentsLocked,
|
|
107
|
-
override: {
|
|
108
|
-
voxelManager: volume.voxelManager,
|
|
109
|
-
imageData: volume.imageData,
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const { imageIds: labelmapImageIds } = representationData.Labelmap;
|
|
115
|
-
if (!labelmapImageIds || labelmapImageIds.length === 1) {
|
|
116
|
-
return {
|
|
117
|
-
imageId: segmentationImageId,
|
|
118
|
-
segmentsLocked,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
const volume = volumeLoader.createAndCacheVolumeFromImagesSync(volumeId, labelmapImageIds);
|
|
122
|
-
return {
|
|
123
|
-
imageId: segmentationImageId,
|
|
124
|
-
segmentsLocked,
|
|
125
|
-
override: {
|
|
126
|
-
voxelManager: volume.voxelManager,
|
|
127
|
-
imageData: volume.imageData,
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return {
|
|
134
|
-
imageId: segmentationImageId,
|
|
135
|
-
segmentsLocked,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
94
|
+
return {
|
|
95
|
+
imageId: segmentationImageId,
|
|
96
|
+
segmentsLocked,
|
|
97
|
+
};
|
|
138
98
|
}
|
|
139
99
|
}
|
|
140
100
|
createHoverData(element, centerCanvas) {
|
|
@@ -199,7 +159,8 @@ export default class LabelmapBaseTool extends BaseTool {
|
|
|
199
159
|
toolGroupId: this.toolGroupId,
|
|
200
160
|
segmentationId,
|
|
201
161
|
viewUp,
|
|
202
|
-
|
|
162
|
+
activeStrategy: this.configuration.activeStrategy,
|
|
163
|
+
configuration: this.configuration,
|
|
203
164
|
preview: this._previewData?.preview,
|
|
204
165
|
createMemo: this.createMemo.bind(this),
|
|
205
166
|
};
|
|
@@ -17,7 +17,19 @@ export type InitializedOperationData = LabelmapToolOperationDataAny & {
|
|
|
17
17
|
previewVoxelManager: Types.IVoxelManager<number>;
|
|
18
18
|
previewSegmentIndex?: number;
|
|
19
19
|
brushStrategy: BrushStrategy;
|
|
20
|
-
|
|
20
|
+
activeStrategy: string;
|
|
21
|
+
configuration?: {
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
centerSegmentIndex?: {
|
|
24
|
+
segmentIndex: number;
|
|
25
|
+
};
|
|
26
|
+
threshold?: {
|
|
27
|
+
range?: number[];
|
|
28
|
+
isDynamic: boolean;
|
|
29
|
+
dynamicRadius: number;
|
|
30
|
+
dynamicRadiusInCanvas?: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
21
33
|
memo?: LabelmapMemo;
|
|
22
34
|
};
|
|
23
35
|
export type StrategyFunction = (operationData: InitializedOperationData, ...args: any[]) => unknown;
|
|
@@ -64,16 +76,13 @@ export default class BrushStrategy {
|
|
|
64
76
|
labelmapStatistics: {
|
|
65
77
|
getStatistics: (enabledElement: any, operationData: InitializedOperationData, options?: {
|
|
66
78
|
indices?: number | number[];
|
|
67
|
-
}) =>
|
|
79
|
+
}) => void;
|
|
80
|
+
};
|
|
81
|
+
ensureSegmentationVolumeFor3DManipulation: {
|
|
82
|
+
ensureSegmentationVolumeFor3DManipulation: (data: any) => void;
|
|
68
83
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
label?: number;
|
|
72
|
-
axis?: number;
|
|
73
|
-
noHeuristicAlignment?: boolean;
|
|
74
|
-
noUseDistanceTransform?: boolean;
|
|
75
|
-
useCustomSlicePositions?: boolean;
|
|
76
|
-
}) => Promise<InitializedOperationData>;
|
|
84
|
+
ensureImageVolumeFor3DManipulation: {
|
|
85
|
+
ensureImageVolumeFor3DManipulation: (data: any) => void;
|
|
77
86
|
};
|
|
78
87
|
};
|
|
79
88
|
protected static childFunctions: {
|
|
@@ -88,6 +97,8 @@ export default class BrushStrategy {
|
|
|
88
97
|
setValue: (brushStrategy: any, func: any) => void;
|
|
89
98
|
preview: (brushStrategy: any, func: any) => void;
|
|
90
99
|
computeInnerCircleRadius: (brushStrategy: any, func: any) => void;
|
|
100
|
+
ensureSegmentationVolumeFor3DManipulation: (brushStrategy: any, func: any) => void;
|
|
101
|
+
ensureImageVolumeFor3DManipulation: (brushStrategy: any, func: any) => void;
|
|
91
102
|
addPreview: (brushStrategy: any, func: any) => void;
|
|
92
103
|
getStatistics: (brushStrategy: any, func: any) => void;
|
|
93
104
|
compositions: any;
|
|
@@ -18,6 +18,8 @@ export default class BrushStrategy {
|
|
|
18
18
|
[StrategyCallbacks.INTERNAL_setValue]: addSingletonMethod(StrategyCallbacks.INTERNAL_setValue),
|
|
19
19
|
[StrategyCallbacks.Preview]: addSingletonMethod(StrategyCallbacks.Preview, false),
|
|
20
20
|
[StrategyCallbacks.ComputeInnerCircleRadius]: addListMethod(StrategyCallbacks.ComputeInnerCircleRadius),
|
|
21
|
+
[StrategyCallbacks.EnsureSegmentationVolumeFor3DManipulation]: addListMethod(StrategyCallbacks.EnsureSegmentationVolumeFor3DManipulation),
|
|
22
|
+
[StrategyCallbacks.EnsureImageVolumeFor3DManipulation]: addListMethod(StrategyCallbacks.EnsureImageVolumeFor3DManipulation),
|
|
21
23
|
[StrategyCallbacks.AddPreview]: addListMethod(StrategyCallbacks.AddPreview),
|
|
22
24
|
[StrategyCallbacks.GetStatistics]: addSingletonMethod(StrategyCallbacks.GetStatistics),
|
|
23
25
|
compositions: null,
|
|
@@ -31,12 +33,12 @@ export default class BrushStrategy {
|
|
|
31
33
|
if (!initializedData) {
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
|
-
const {
|
|
35
|
-
if (csUtils.isEqual(centerIJK,
|
|
36
|
+
const { configuration = {}, centerIJK } = initializedData;
|
|
37
|
+
if (csUtils.isEqual(centerIJK, configuration.centerIJK)) {
|
|
36
38
|
return operationData.preview;
|
|
37
39
|
}
|
|
38
40
|
else {
|
|
39
|
-
|
|
41
|
+
configuration.centerIJK = centerIJK;
|
|
40
42
|
}
|
|
41
43
|
this._fill.forEach((func) => func(initializedData));
|
|
42
44
|
const { segmentationVoxelManager, previewVoxelManager, previewSegmentIndex, segmentIndex, } = initializedData;
|
|
@@ -90,14 +92,12 @@ export default class BrushStrategy {
|
|
|
90
92
|
}
|
|
91
93
|
initialize(enabledElement, operationData, operationName) {
|
|
92
94
|
const { viewport } = enabledElement;
|
|
93
|
-
const data = getStrategyData({ operationData, viewport });
|
|
95
|
+
const data = getStrategyData({ operationData, viewport, strategy: this });
|
|
94
96
|
if (!data) {
|
|
95
97
|
console.warn('No data found for BrushStrategy');
|
|
96
98
|
return operationData.preview;
|
|
97
99
|
}
|
|
98
100
|
const { imageVoxelManager, segmentationVoxelManager, segmentationImageData, } = data;
|
|
99
|
-
const segmentationVoxelManagerToUse = operationData.override?.voxelManager || segmentationVoxelManager;
|
|
100
|
-
const segmentationImageDataToUse = operationData.override?.imageData || segmentationImageData;
|
|
101
101
|
const previewVoxelManager = operationData.preview?.previewVoxelManager ||
|
|
102
102
|
VoxelManager.createRLEHistoryVoxelManager(segmentationVoxelManager);
|
|
103
103
|
const previewEnabled = !!operationData.previewColors;
|
|
@@ -108,8 +108,8 @@ export default class BrushStrategy {
|
|
|
108
108
|
...operationData,
|
|
109
109
|
enabledElement,
|
|
110
110
|
imageVoxelManager,
|
|
111
|
-
segmentationVoxelManager
|
|
112
|
-
segmentationImageData
|
|
111
|
+
segmentationVoxelManager,
|
|
112
|
+
segmentationImageData,
|
|
113
113
|
previewVoxelManager,
|
|
114
114
|
viewport,
|
|
115
115
|
centerWorld: null,
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import StrategyCallbacks from '../../../../enums/StrategyCallbacks';
|
|
2
2
|
export default {
|
|
3
3
|
[StrategyCallbacks.Initialize]: (operationData) => {
|
|
4
|
-
const {
|
|
5
|
-
if (!
|
|
4
|
+
const { centerSegmentIndex } = operationData.configuration || {};
|
|
5
|
+
if (!centerSegmentIndex) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
if (centerSegmentIndex) {
|
|
10
|
-
operationData.segmentIndex = centerSegmentIndex.segmentIndex;
|
|
11
|
-
}
|
|
8
|
+
operationData.segmentIndex = centerSegmentIndex.segmentIndex;
|
|
12
9
|
},
|
|
13
10
|
[StrategyCallbacks.OnInteractionStart]: (operationData) => {
|
|
14
|
-
const { segmentIndex, previewSegmentIndex, segmentationVoxelManager, centerIJK,
|
|
15
|
-
if (!
|
|
11
|
+
const { segmentIndex, previewSegmentIndex, segmentationVoxelManager, centerIJK, viewPlaneNormal, segmentationImageData, preview, configuration, } = operationData;
|
|
12
|
+
if (!configuration?.useCenterSegmentIndex) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
|
-
delete
|
|
15
|
+
delete configuration.centerSegmentIndex;
|
|
19
16
|
let hasSegmentIndex = false;
|
|
20
17
|
let hasPreviewIndex = false;
|
|
21
18
|
const nestedBounds = [
|
|
@@ -55,7 +52,7 @@ export default {
|
|
|
55
52
|
existingValue = null;
|
|
56
53
|
}
|
|
57
54
|
operationData.segmentIndex = existingValue;
|
|
58
|
-
|
|
55
|
+
configuration.centerSegmentIndex = {
|
|
59
56
|
segmentIndex: existingValue,
|
|
60
57
|
};
|
|
61
58
|
},
|