@cornerstonejs/tools 2.0.0-beta.19 → 2.0.0-beta.20

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.
Files changed (45) hide show
  1. package/dist/esm/eventListeners/segmentation/imageChangeEventListener.js +45 -72
  2. package/dist/esm/eventListeners/segmentation/labelmap/onLabelmapSegmentationDataModified.js +9 -6
  3. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +5 -0
  4. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +102 -1
  5. package/dist/esm/stateManagement/segmentation/config/segmentationVisibility.js +0 -2
  6. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.d.ts +2 -2
  7. package/dist/esm/stateManagement/segmentation/convertStackToVolumeSegmentation.js +7 -14
  8. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.d.ts +3 -3
  9. package/dist/esm/stateManagement/segmentation/convertVolumeToStackSegmentation.js +14 -15
  10. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.d.ts +1 -1
  11. package/dist/esm/stateManagement/segmentation/polySeg/Labelmap/convertContourToLabelmap.js +3 -3
  12. package/dist/esm/stateManagement/segmentation/polySeg/Surface/convertLabelmapToSurface.js +2 -2
  13. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +3 -1
  14. package/dist/esm/stateManagement/segmentation/segmentationState.js +9 -1
  15. package/dist/esm/store/ToolGroupManager/ToolGroup.d.ts +2 -0
  16. package/dist/esm/store/ToolGroupManager/ToolGroup.js +10 -0
  17. package/dist/esm/tools/base/BaseTool.js +1 -1
  18. package/dist/esm/tools/displayTools/Labelmap/addLabelmapToElement.js +3 -1
  19. package/dist/esm/tools/displayTools/Labelmap/labelmapDisplay.js +2 -3
  20. package/dist/esm/tools/displayTools/Labelmap/validateLabelmap.js +3 -3
  21. package/dist/esm/tools/segmentation/BrushTool.d.ts +5 -5
  22. package/dist/esm/tools/segmentation/BrushTool.js +6 -5
  23. package/dist/esm/tools/segmentation/CircleScissorsTool.d.ts +1 -1
  24. package/dist/esm/tools/segmentation/CircleScissorsTool.js +0 -2
  25. package/dist/esm/tools/segmentation/PaintFillTool.js +3 -5
  26. package/dist/esm/tools/segmentation/RectangleScissorsTool.d.ts +1 -1
  27. package/dist/esm/tools/segmentation/RectangleScissorsTool.js +1 -3
  28. package/dist/esm/tools/segmentation/SphereScissorsTool.d.ts +1 -1
  29. package/dist/esm/tools/segmentation/SphereScissorsTool.js +1 -3
  30. package/dist/esm/tools/segmentation/strategies/compositions/dynamicThreshold.js +5 -1
  31. package/dist/esm/tools/segmentation/strategies/utils/getStrategyData.js +5 -3
  32. package/dist/esm/tools/segmentation/strategies/utils/stackVolumeCheck.js +5 -5
  33. package/dist/esm/types/LabelmapTypes.d.ts +2 -2
  34. package/dist/esm/utilities/annotationHydration.js +1 -1
  35. package/dist/esm/utilities/segmentation/getSegmentIndexAtLabelmapBorder.js +2 -3
  36. package/dist/esm/utilities/segmentation/getSegmentIndexAtWorldPoint.js +2 -4
  37. package/dist/esm/utilities/segmentation/getUniqueSegmentIndices.js +3 -3
  38. package/dist/esm/utilities/segmentation/index.d.ts +1 -2
  39. package/dist/esm/utilities/segmentation/index.js +1 -2
  40. package/dist/esm/utilities/stackPrefetch/stackContextPrefetch.js +0 -2
  41. package/dist/umd/index.js +1 -1
  42. package/dist/umd/index.js.map +1 -1
  43. package/package.json +3 -3
  44. package/dist/esm/utilities/segmentation/createImageIdReferenceMap.d.ts +0 -2
  45. package/dist/esm/utilities/segmentation/createImageIdReferenceMap.js +0 -7
@@ -381,6 +381,16 @@ export default class ToolGroup {
381
381
  getPrevActivePrimaryToolName() {
382
382
  return this.prevActivePrimaryToolName;
383
383
  }
384
+ setActivePrimaryTool(toolName) {
385
+ const activeToolName = this.getCurrentActivePrimaryToolName();
386
+ this.setToolDisabled(activeToolName);
387
+ this.setToolActive(toolName, {
388
+ bindings: [{ mouseButton: MouseBindings.Primary }],
389
+ });
390
+ }
391
+ getCurrentActivePrimaryToolName() {
392
+ return this.currentActivePrimaryToolName;
393
+ }
384
394
  clone(newToolGroupId, fnToolFilter = null) {
385
395
  let toolGroup = ToolGroupManager.getToolGroup(newToolGroupId);
386
396
  if (toolGroup) {
@@ -82,7 +82,7 @@ class BaseTool {
82
82
  }
83
83
  }
84
84
  getTargetId(viewport) {
85
- const targetId = viewport.getReferenceId?.();
85
+ const targetId = viewport.getViewReferenceId?.();
86
86
  if (targetId) {
87
87
  return targetId;
88
88
  }
@@ -1,5 +1,6 @@
1
1
  import { getEnabledElement, addVolumesToViewports, addImageSlicesToViewports, Enums, } from '@cornerstonejs/core';
2
2
  import { isVolumeSegmentation } from '../../segmentation/strategies/utils/stackVolumeCheck';
3
+ import { getLabelmapImageIdsForViewport, getRepresentation, } from '../../../stateManagement/segmentation/segmentationState';
3
4
  async function addLabelmapToElement(element, labelMapData, segmentationRepresentationUID) {
4
5
  const enabledElement = getEnabledElement(element);
5
6
  const { renderingEngine, viewport } = enabledElement;
@@ -19,7 +20,8 @@ async function addLabelmapToElement(element, labelMapData, segmentationRepresent
19
20
  await addVolumesToViewports(renderingEngine, volumeInputs, [viewportId], immediateRender, suppressEvents);
20
21
  }
21
22
  else {
22
- const segmentationImageId = labelMapData.imageIdReferenceMap.get(viewport.getCurrentImageId());
23
+ const representation = getRepresentation(segmentationRepresentationUID);
24
+ const segmentationImageId = getLabelmapImageIdsForViewport(viewport.id, representation.segmentationId);
23
25
  const stackInputs = [
24
26
  {
25
27
  imageId: segmentationImageId,
@@ -99,9 +99,8 @@ async function render(viewport, representation) {
99
99
  if (viewport instanceof VolumeViewport) {
100
100
  return;
101
101
  }
102
- const imageId = viewport.getCurrentImageId();
103
- const { imageIdReferenceMap } = labelmapData;
104
- if (!imageIdReferenceMap.has(imageId)) {
102
+ const labelmapImageId = SegmentationState.getLabelmapImageIdsForViewport(viewport.id, segmentationId);
103
+ if (!labelmapImageId) {
105
104
  return;
106
105
  }
107
106
  if (!actorEntry) {
@@ -8,11 +8,11 @@ function validateRepresentationData(segmentationRepresentationData) {
8
8
  throw new Error(`volumeId of ${segmentationRepresentationData.volumeId} not found in cache, you should load and cache volume before adding segmentation`);
9
9
  }
10
10
  }
11
- else if ('imageIdReferenceMap' in segmentationRepresentationData) {
11
+ else if ('imageIds' in segmentationRepresentationData) {
12
12
  segmentationRepresentationData =
13
13
  segmentationRepresentationData;
14
- if (!segmentationRepresentationData.imageIdReferenceMap) {
15
- throw new Error('The segmentationInput.representationData.imageIdReferenceMap is undefined, please provide a valid representationData.imageIdReferenceMap');
14
+ if (!segmentationRepresentationData.imageIds) {
15
+ throw new Error('The segmentationInput.representationData.imageIds is undefined, please provide a valid representationData.imageIds for stack data');
16
16
  }
17
17
  }
18
18
  else {
@@ -23,9 +23,9 @@ declare class BrushTool extends BaseTool {
23
23
  volumeId: string;
24
24
  referencedVolumeId: any;
25
25
  segmentsLocked: number[] | [];
26
- imageIdReferenceMap?: undefined;
26
+ imageId?: undefined;
27
27
  } | {
28
- imageIdReferenceMap: Map<string, string>;
28
+ imageId: string;
29
29
  segmentsLocked: number[] | [];
30
30
  volumeId?: undefined;
31
31
  referencedVolumeId?: undefined;
@@ -49,7 +49,7 @@ declare class BrushTool extends BaseTool {
49
49
  strategySpecificConfiguration: any;
50
50
  preview: unknown;
51
51
  segmentsLocked: number[];
52
- imageIdReferenceMap?: Map<string, string>;
52
+ imageId?: string;
53
53
  volumeId?: string;
54
54
  referencedVolumeId?: string;
55
55
  } | {
@@ -66,7 +66,7 @@ declare class BrushTool extends BaseTool {
66
66
  volumeId: string;
67
67
  referencedVolumeId: any;
68
68
  segmentsLocked: number[] | [];
69
- imageIdReferenceMap?: undefined;
69
+ imageId?: undefined;
70
70
  } | {
71
71
  points: any;
72
72
  segmentIndex: number;
@@ -78,7 +78,7 @@ declare class BrushTool extends BaseTool {
78
78
  viewUp: any;
79
79
  strategySpecificConfiguration: any;
80
80
  preview: unknown;
81
- imageIdReferenceMap: Map<string, string>;
81
+ imageId: string;
82
82
  segmentsLocked: number[] | [];
83
83
  volumeId?: undefined;
84
84
  referencedVolumeId?: undefined;
@@ -11,6 +11,7 @@ import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCur
11
11
  import triggerAnnotationRenderForViewportUIDs from '../../utilities/triggerAnnotationRenderForViewportIds';
12
12
  import { config as segmentationConfig, segmentLocking, segmentIndex as segmentIndexController, state as segmentationState, activeSegmentation, } from '../../stateManagement/segmentation';
13
13
  import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
14
+ import { getLabelmapImageIdsForViewport } from '../../stateManagement/segmentation/segmentationState';
14
15
  class BrushTool extends BaseTool {
15
16
  constructor(toolProps = {}, defaultToolProps = {
16
17
  supportedInteractionTypes: ['Mouse', 'Touch'],
@@ -90,7 +91,8 @@ class BrushTool extends BaseTool {
90
91
  this._previewData.timerStart = Date.now();
91
92
  const hoverData = this._hoverData || this.createHoverData(element);
92
93
  triggerAnnotationRenderForViewportUIDs(hoverData.viewportIdsToRender);
93
- this.applyActiveStrategyCallback(enabledElement, this.getOperationData(element), StrategyCallbacks.OnInteractionStart);
94
+ const operationData = this.getOperationData(element);
95
+ this.applyActiveStrategyCallback(enabledElement, operationData, StrategyCallbacks.OnInteractionStart);
94
96
  return true;
95
97
  };
96
98
  this.mouseMoveCallback = (evt) => {
@@ -226,16 +228,15 @@ class BrushTool extends BaseTool {
226
228
  };
227
229
  }
228
230
  else {
229
- const { imageIdReferenceMap } = labelmapData;
230
- const currentImageId = viewport.getCurrentImageId();
231
- if (!imageIdReferenceMap.get(currentImageId)) {
231
+ const segmentationImageId = getLabelmapImageIdsForViewport(viewport.id, segmentationId);
232
+ if (!segmentationImageId) {
232
233
  return;
233
234
  }
234
235
  if (this.configuration.activeStrategy.includes('SPHERE')) {
235
236
  throw new Error('Sphere manipulation is not supported for stacks of image segmentations yet');
236
237
  }
237
238
  return {
238
- imageIdReferenceMap,
239
+ imageId: segmentationImageId,
239
240
  segmentsLocked,
240
241
  };
241
242
  }
@@ -8,7 +8,7 @@ declare class CircleScissorsTool extends BaseTool {
8
8
  segmentIndex: number;
9
9
  volumeId: string;
10
10
  referencedVolumeId: string;
11
- imageIdReferenceMap: Map<string, string>;
11
+ imageId: string;
12
12
  segmentsLocked: number[];
13
13
  segmentColor: [number, number, number, number];
14
14
  viewportIdsToRender: string[];
@@ -93,10 +93,8 @@ class CircleScissorsTool extends BaseTool {
93
93
  };
94
94
  }
95
95
  else {
96
- const { imageIdReferenceMap } = labelmapData;
97
96
  this.editData = {
98
97
  ...this.editData,
99
- imageIdReferenceMap,
100
98
  };
101
99
  }
102
100
  this._activateDraw(element);
@@ -4,7 +4,7 @@ import { SegmentationRepresentations } from '../../enums';
4
4
  import { triggerSegmentationDataModified } from '../../stateManagement/segmentation/triggerSegmentationEvents';
5
5
  import { segmentLocking, activeSegmentation, segmentIndex as segmentIndexController, } from '../../stateManagement/segmentation';
6
6
  import floodFill from '../../utilities/segmentation/floodFill';
7
- import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
7
+ import { getLabelmapImageIdsForViewport, getSegmentation, } from '../../stateManagement/segmentation/segmentationState';
8
8
  import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
9
9
  const { transformWorldToIndex, isEqual } = csUtils;
10
10
  class PaintFillTool extends BaseTool {
@@ -24,7 +24,7 @@ class PaintFillTool extends BaseTool {
24
24
  if (!activeSegmentationRepresentation) {
25
25
  throw new Error('No active segmentation detected, create one before using scissors tool');
26
26
  }
27
- const { segmentationId, type } = activeSegmentationRepresentation;
27
+ const { segmentationId, type, segmentationRepresentationUID } = activeSegmentationRepresentation;
28
28
  const segmentIndex = segmentIndexController.getActiveSegmentIndex(segmentationId);
29
29
  const segmentsLocked = segmentLocking.getLockedSegments(segmentationId);
30
30
  const { representationData } = getSegmentation(segmentationId);
@@ -41,9 +41,7 @@ class PaintFillTool extends BaseTool {
41
41
  index = transformWorldToIndex(segmentation.imageData, worldPos);
42
42
  }
43
43
  else {
44
- const { imageIdReferenceMap } = labelmapData;
45
- const currentImageId = enabledElement.viewport.getCurrentImageId();
46
- const currentSegmentationImageId = imageIdReferenceMap.get(currentImageId);
44
+ const currentSegmentationImageId = getLabelmapImageIdsForViewport(viewport.id, segmentationId);
47
45
  if (!currentSegmentationImageId) {
48
46
  throw new Error('No active segmentation imageId detected, create one before using scissors tool');
49
47
  }
@@ -5,9 +5,9 @@ declare class RectangleScissorsTool extends BaseTool {
5
5
  static toolName: any;
6
6
  _throttledCalculateCachedStats: any;
7
7
  editData: {
8
- imageIdReferenceMap: Map<string, string>;
9
8
  volumeId: string;
10
9
  referencedVolumeId: string;
10
+ imageId: string;
11
11
  annotation: any;
12
12
  segmentationId: string;
13
13
  segmentIndex: number;
@@ -8,7 +8,7 @@ import { drawRect as drawRectSvg } from '../../drawingSvg';
8
8
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
9
9
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
10
10
  import { config as segmentationConfig, segmentLocking, segmentIndex as segmentIndexController, activeSegmentation, } from '../../stateManagement/segmentation';
11
- import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
11
+ import { getSegmentation, } from '../../stateManagement/segmentation/segmentationState';
12
12
  import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
13
13
  class RectangleScissorsTool extends BaseTool {
14
14
  constructor(toolProps = {}, defaultToolProps = {
@@ -92,10 +92,8 @@ class RectangleScissorsTool extends BaseTool {
92
92
  };
93
93
  }
94
94
  else {
95
- const { imageIdReferenceMap } = labelmapData;
96
95
  this.editData = {
97
96
  ...this.editData,
98
- imageIdReferenceMap,
99
97
  };
100
98
  }
101
99
  this._activateDraw(element);
@@ -10,7 +10,7 @@ declare class SphereScissorsTool extends BaseTool {
10
10
  segmentationRepresentationUID: string;
11
11
  volumeId: string;
12
12
  referencedVolumeId: string;
13
- imageIdReferenceMap: Map<string, string>;
13
+ imageId: string;
14
14
  toolGroupId: string;
15
15
  segmentColor: [number, number, number, number];
16
16
  viewportIdsToRender: string[];
@@ -7,7 +7,7 @@ import { drawCircle as drawCircleSvg } from '../../drawingSvg';
7
7
  import { resetElementCursor, hideElementCursor, } from '../../cursors/elementCursor';
8
8
  import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnotationRenderForViewportIds';
9
9
  import { config as segmentationConfig, segmentLocking, segmentIndex as segmentIndexController, activeSegmentation, } from '../../stateManagement/segmentation';
10
- import { getSegmentation } from '../../stateManagement/segmentation/segmentationState';
10
+ import { getSegmentation, } from '../../stateManagement/segmentation/segmentationState';
11
11
  import { isVolumeSegmentation } from './strategies/utils/stackVolumeCheck';
12
12
  class SphereScissorsTool extends BaseTool {
13
13
  constructor(toolProps = {}, defaultToolProps = {
@@ -91,10 +91,8 @@ class SphereScissorsTool extends BaseTool {
91
91
  };
92
92
  }
93
93
  else {
94
- const { imageIdReferenceMap } = labelmapData;
95
94
  this.editData = {
96
95
  ...this.editData,
97
- imageIdReferenceMap,
98
96
  };
99
97
  }
100
98
  this._activateDraw(element);
@@ -43,7 +43,11 @@ export default {
43
43
  if (dynamicRadius === 0) {
44
44
  return;
45
45
  }
46
- const { spacing } = viewport.getImageData();
46
+ const imageData = viewport.getImageData();
47
+ if (!imageData) {
48
+ return;
49
+ }
50
+ const { spacing } = imageData;
47
51
  const centerCanvas = [
48
52
  viewport.element.clientWidth / 2,
49
53
  viewport.element.clientHeight / 2,
@@ -1,5 +1,6 @@
1
1
  import { cache, utilities } from '@cornerstonejs/core';
2
2
  import { isVolumeSegmentation } from './stackVolumeCheck';
3
+ import { getLabelmapImageIdsForViewport } from '../../../../stateManagement/segmentation/segmentationState';
3
4
  const { VoxelManager } = utilities;
4
5
  function getStrategyData({ operationData, viewport }) {
5
6
  let segmentationImageData, segmentationScalarData, imageScalarData;
@@ -24,8 +25,9 @@ function getStrategyData({ operationData, viewport }) {
24
25
  segmentationDimensions = segmentationVolume.dimensions;
25
26
  }
26
27
  else {
27
- const { imageIdReferenceMap, segmentationRepresentationUID } = operationData;
28
- if (!imageIdReferenceMap) {
28
+ const { segmentationRepresentationUID, segmentationId } = operationData;
29
+ const labelmapImageId = getLabelmapImageIdsForViewport(viewport.id, segmentationId);
30
+ if (!labelmapImageId) {
29
31
  return;
30
32
  }
31
33
  const currentImageId = viewport.getCurrentImageId();
@@ -38,7 +40,7 @@ function getStrategyData({ operationData, viewport }) {
38
40
  }
39
41
  segmentationImageData = actor.actor.getMapper().getInputData();
40
42
  segmentationVoxelManager = segmentationImageData.voxelManager;
41
- const currentSegmentationImageId = imageIdReferenceMap.get(currentImageId);
43
+ const currentSegmentationImageId = operationData.imageId;
42
44
  const segmentationImage = cache.getImage(currentSegmentationImageId);
43
45
  if (!segmentationImage) {
44
46
  return;
@@ -1,15 +1,15 @@
1
1
  import { VolumeViewport } from '@cornerstonejs/core';
2
2
  function isVolumeSegmentation(operationData, viewport) {
3
- const { imageIdReferenceMap } = operationData;
3
+ const { imageIds } = operationData;
4
4
  const { volumeId } = operationData;
5
- if (volumeId && !imageIdReferenceMap) {
5
+ if (volumeId && !imageIds) {
6
6
  return true;
7
7
  }
8
- if (imageIdReferenceMap && !volumeId) {
8
+ if (imageIds && !volumeId) {
9
9
  return false;
10
10
  }
11
- if (volumeId && imageIdReferenceMap && !viewport) {
12
- throw new Error('isVolumeSegmentation: viewport is required when both volumeId and imageIdReferenceMap are provided');
11
+ if (volumeId && imageIds && !viewport) {
12
+ throw new Error('isVolumeSegmentation: viewport is required when both volumeId and imageIds are provided');
13
13
  }
14
14
  return viewport instanceof VolumeViewport;
15
15
  }
@@ -21,10 +21,10 @@ export type LabelmapSegmentationDataVolume = {
21
21
  referencedVolumeId?: string;
22
22
  };
23
23
  export type LabelmapSegmentationDataStack = {
24
- imageIdReferenceMap: Map<string, string>;
24
+ imageIds: string[];
25
25
  };
26
26
  export type LabelmapSegmentationData = LabelmapSegmentationDataVolume | LabelmapSegmentationDataStack | {
27
27
  volumeId?: string;
28
28
  referencedVolumeId?: string;
29
- imageIdReferenceMap?: Map<string, string>;
29
+ imageIds?: string[];
30
30
  };
@@ -44,7 +44,7 @@ function getReferencedImageId(viewport, worldPos, viewPlaneNormal) {
44
44
  return referencedImageId;
45
45
  }
46
46
  function getTargetId(viewport) {
47
- const targetId = viewport.getReferenceId?.();
47
+ const targetId = viewport.getViewReferenceId?.();
48
48
  if (targetId) {
49
49
  return targetId;
50
50
  }
@@ -1,5 +1,5 @@
1
1
  import { cache, utilities } from '@cornerstonejs/core';
2
- import { getSegmentation, getRepresentationsBySegmentationId, } from '../../stateManagement/segmentation/segmentationState';
2
+ import { getSegmentation, getRepresentationsBySegmentationId, getLabelmapImageIdsForViewport, } from '../../stateManagement/segmentation/segmentationState';
3
3
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
4
4
  export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { viewport, searchRadius }) {
5
5
  const segmentation = getSegmentation(segmentationId);
@@ -16,9 +16,8 @@ export function getSegmentIndexAtLabelmapBorder(segmentationId, worldPoint, { vi
16
16
  const onEdge = isSegmentOnEdgeCanvas(canvasPoint, segmentIndex, viewport, imageData, searchRadius);
17
17
  return onEdge ? segmentIndex : undefined;
18
18
  }
19
- const { imageIdReferenceMap } = labelmapData;
19
+ const segmentationImageId = getLabelmapImageIdsForViewport(viewport.id, segmentationId);
20
20
  const currentImageId = viewport.getCurrentImageId();
21
- const segmentationImageId = imageIdReferenceMap.get(currentImageId);
22
21
  const image = cache.getImage(segmentationImageId);
23
22
  if (!image) {
24
23
  return;
@@ -1,6 +1,6 @@
1
1
  import { cache, utilities } from '@cornerstonejs/core';
2
2
  import { SegmentationRepresentations } from '../../enums';
3
- import { getSegmentation, getRepresentationsBySegmentationId, } from '../../stateManagement/segmentation/segmentationState';
3
+ import { getSegmentation, getRepresentationsBySegmentationId, getLabelmapImageIdsForViewport, } from '../../stateManagement/segmentation/segmentationState';
4
4
  import { isVolumeSegmentation } from '../../tools/segmentation/strategies/utils/stackVolumeCheck';
5
5
  import { getAnnotation } from '../../stateManagement';
6
6
  import { isPointInsidePolyline3D } from '../math/polyline';
@@ -31,9 +31,7 @@ export function getSegmentIndexAtWorldForLabelmap(segmentation, worldPoint, { vi
31
31
  const segmentIndex = segmentationVolume.imageData.getScalarValueFromWorld(worldPoint);
32
32
  return segmentIndex;
33
33
  }
34
- const { imageIdReferenceMap } = labelmapData;
35
- const currentImageId = viewport.getCurrentImageId();
36
- const segmentationImageId = imageIdReferenceMap.get(currentImageId);
34
+ const segmentationImageId = getLabelmapImageIdsForViewport(viewport.id, segmentation.segmentationId);
37
35
  const image = cache.getImage(segmentationImageId);
38
36
  if (!image) {
39
37
  return;
@@ -55,7 +55,7 @@ function handleLabelmapSegmentation(segmentation, segmentationId) {
55
55
  addVolumeSegmentIndices(keySet, segmentationId);
56
56
  }
57
57
  else {
58
- addImageSegmentIndices(keySet, labelmapData.imageIdReferenceMap);
58
+ addImageSegmentIndices(keySet, labelmapData.imageIds);
59
59
  }
60
60
  return Array.from(keySet)
61
61
  .map(Number)
@@ -70,8 +70,8 @@ function addVolumeSegmentIndices(keySet, segmentationId) {
70
70
  }
71
71
  });
72
72
  }
73
- function addImageSegmentIndices(keySet, imageIdReferenceMap) {
74
- imageIdReferenceMap.forEach((segmentationImageId) => {
73
+ function addImageSegmentIndices(keySet, imageIds) {
74
+ imageIds.forEach((segmentationImageId) => {
75
75
  const image = cache.getImage(segmentationImageId);
76
76
  const scalarData = image.getPixelData();
77
77
  scalarData.forEach((segmentIndex) => {
@@ -9,7 +9,6 @@ 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
- import { createImageIdReferenceMap } from './createImageIdReferenceMap';
13
12
  import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
14
13
  import createBidirectionalToolData from './createBidirectionalToolData';
15
14
  import segmentContourAction from './segmentContourAction';
@@ -19,4 +18,4 @@ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
19
18
  import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
20
19
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
21
20
  import { getBrushToolInstances } from './utilities';
22
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
21
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
@@ -9,7 +9,6 @@ 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
- import { createImageIdReferenceMap } from './createImageIdReferenceMap';
13
12
  import contourAndFindLargestBidirectional from './contourAndFindLargestBidirectional';
14
13
  import createBidirectionalToolData from './createBidirectionalToolData';
15
14
  import segmentContourAction from './segmentContourAction';
@@ -19,4 +18,4 @@ import { getSegmentIndexAtWorldPoint } from './getSegmentIndexAtWorldPoint';
19
18
  import { getSegmentIndexAtLabelmapBorder } from './getSegmentIndexAtLabelmapBorder';
20
19
  import { getHoveredContourSegmentationAnnotation } from './getHoveredContourSegmentationAnnotation';
21
20
  import { getBrushToolInstances } from './utilities';
22
- export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, createImageIdReferenceMap, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
21
+ export { thresholdVolumeByRange, createMergedLabelmapForIndex, isValidRepresentationConfig, getDefaultRepresentationConfig, createLabelmapVolumeForViewport, rectangleROIThresholdVolumeByRange, triggerSegmentationRender, floodFill, getBrushSizeForToolGroup, setBrushSizeForToolGroup, getBrushThresholdForToolGroup, setBrushThresholdForToolGroup, thresholdSegmentationByRange, contourAndFindLargestBidirectional, createBidirectionalToolData, segmentContourAction, invalidateBrushCursor, getUniqueSegmentIndices, getSegmentIndexAtWorldPoint, getSegmentIndexAtLabelmapBorder, getHoveredContourSegmentationAnnotation, getBrushToolInstances, };
@@ -1,7 +1,6 @@
1
1
  import { imageLoader, Enums, eventTarget, imageLoadPoolManager, cache, getConfiguration as getCoreConfiguration, } from '@cornerstonejs/core';
2
2
  import { addToolState, getToolState } from './state';
3
3
  import { getStackData, requestType, priority, clearFromImageIds, getPromiseRemovedHandler, } from './stackPrefetchUtils';
4
- import { roundNumber } from '../../utilities';
5
4
  let configuration = {
6
5
  maxImagesToPrefetch: Infinity,
7
6
  minBefore: 2,
@@ -93,7 +92,6 @@ function prefetch(element) {
93
92
  stats.fillTime = Date.now() - stats.start;
94
93
  const { size } = stats.imageIds;
95
94
  stats.fillSize = size;
96
- console.log('Done cache fill', stats.fillTime, 'ms', size, 'items', 'average total time', roundNumber(stats.fillTime / size), 'ms', 'average load', roundNumber(stats.loadTimeInMS / size), 'ms', 'average decode', roundNumber(stats.decodeTimeInMS / size), 'ms');
97
95
  }
98
96
  }
99
97
  }