From d26c23a64e0616bbd6d9f44037a7cbbc59830c93 Mon Sep 17 00:00:00 2001 From: Adnane Belmadiaf Date: Sat, 28 Dec 2024 22:45:12 +0100 Subject: [PATCH 1/2] fix: take into account storePointData setting fix #1709 --- .../src/tools/annotation/EllipticalROITool.ts | 22 ++++++++++--------- .../src/tools/annotation/RectangleROITool.ts | 18 ++++++++------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/tools/src/tools/annotation/EllipticalROITool.ts b/packages/tools/src/tools/annotation/EllipticalROITool.ts index 11e4427d0..a6826c982 100644 --- a/packages/tools/src/tools/annotation/EllipticalROITool.ts +++ b/packages/tools/src/tools/annotation/EllipticalROITool.ts @@ -1134,16 +1134,18 @@ class EllipticalROITool extends AnnotationTool { pixelUnitsOptions ); - const pointsInShape = voxelManager.forEach( - this.configuration.statsCalculator.statsCallback, - { - boundsIJK, - imageData, - isInObject: (pointLPS) => - pointInEllipse(ellipseObj, pointLPS, { fast: true }), - returnPoints: this.configuration.storePointData, - } - ); + const pointsInShape = this.configuration.storePointData + ? voxelManager.forEach( + this.configuration.statsCalculator.statsCallback, + { + boundsIJK, + imageData, + isInObject: (pointLPS) => + pointInEllipse(ellipseObj, pointLPS, { fast: true }), + returnPoints: this.configuration.storePointData, + } + ) + : null; const stats = this.configuration.statsCalculator.getStatistics(); cachedStats[targetId] = { diff --git a/packages/tools/src/tools/annotation/RectangleROITool.ts b/packages/tools/src/tools/annotation/RectangleROITool.ts index 1ccf3a550..0f2ca16c3 100644 --- a/packages/tools/src/tools/annotation/RectangleROITool.ts +++ b/packages/tools/src/tools/annotation/RectangleROITool.ts @@ -945,14 +945,16 @@ class RectangleROITool extends AnnotationTool { pixelUnitsOptions ); - const pointsInShape = voxelManager.forEach( - this.configuration.statsCalculator.statsCallback, - { - boundsIJK, - imageData, - returnPoints: this.configuration.storePointData, - } - ); + const pointsInShape = this.configuration.storePointData + ? voxelManager.forEach( + this.configuration.statsCalculator.statsCallback, + { + boundsIJK, + imageData, + returnPoints: this.configuration.storePointData, + } + ) + : null; const stats = this.configuration.statsCalculator.getStatistics(); cachedStats[targetId] = { From d3c3017b07412b3e147291eb15b31ffaa3dfca40 Mon Sep 17 00:00:00 2001 From: sedghi Date: Tue, 21 Jan 2025 14:04:18 -0500 Subject: [PATCH 2/2] fix --- packages/core/src/utilities/VoxelManager.ts | 1 + .../src/utilities/pointInShapeCallback.ts | 15 ++++++++----- .../src/tools/annotation/EllipticalROITool.ts | 22 +++++++++---------- .../src/tools/annotation/RectangleROITool.ts | 18 +++++++-------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/core/src/utilities/VoxelManager.ts b/packages/core/src/utilities/VoxelManager.ts index ce9f3498d..225557b44 100644 --- a/packages/core/src/utilities/VoxelManager.ts +++ b/packages/core/src/utilities/VoxelManager.ts @@ -279,6 +279,7 @@ export default class VoxelManager { ], pointInShapeFn: isInObject, callback, + returnPoints, }); return pointsInShape; } diff --git a/packages/core/src/utilities/pointInShapeCallback.ts b/packages/core/src/utilities/pointInShapeCallback.ts index f2be19c08..3ef5200d6 100644 --- a/packages/core/src/utilities/pointInShapeCallback.ts +++ b/packages/core/src/utilities/pointInShapeCallback.ts @@ -168,6 +168,7 @@ export function iterateOverPointsInShapeVoxelManager({ imageData, pointInShapeFn, callback, + returnPoints, }) { const [[iMin, iMax], [jMin, jMax], [kMin, kMax]] = bounds; const indexToWorld = createPositionCallback(imageData); @@ -188,12 +189,14 @@ export function iterateOverPointsInShapeVoxelManager({ const index = voxelManager.toIndex(pointIJK); const value = voxelManager.getAtIndex(index); - pointsInShape.push({ - value, - index, - pointIJK: [...pointIJK], - pointLPS: pointLPS.slice(), - }); + if (returnPoints) { + pointsInShape.push({ + value, + index, + pointIJK: [...pointIJK], + pointLPS: pointLPS.slice(), + }); + } callback?.({ value, index, pointIJK, pointLPS }); } diff --git a/packages/tools/src/tools/annotation/EllipticalROITool.ts b/packages/tools/src/tools/annotation/EllipticalROITool.ts index a6826c982..11e4427d0 100644 --- a/packages/tools/src/tools/annotation/EllipticalROITool.ts +++ b/packages/tools/src/tools/annotation/EllipticalROITool.ts @@ -1134,18 +1134,16 @@ class EllipticalROITool extends AnnotationTool { pixelUnitsOptions ); - const pointsInShape = this.configuration.storePointData - ? voxelManager.forEach( - this.configuration.statsCalculator.statsCallback, - { - boundsIJK, - imageData, - isInObject: (pointLPS) => - pointInEllipse(ellipseObj, pointLPS, { fast: true }), - returnPoints: this.configuration.storePointData, - } - ) - : null; + const pointsInShape = voxelManager.forEach( + this.configuration.statsCalculator.statsCallback, + { + boundsIJK, + imageData, + isInObject: (pointLPS) => + pointInEllipse(ellipseObj, pointLPS, { fast: true }), + returnPoints: this.configuration.storePointData, + } + ); const stats = this.configuration.statsCalculator.getStatistics(); cachedStats[targetId] = { diff --git a/packages/tools/src/tools/annotation/RectangleROITool.ts b/packages/tools/src/tools/annotation/RectangleROITool.ts index 0f2ca16c3..1ccf3a550 100644 --- a/packages/tools/src/tools/annotation/RectangleROITool.ts +++ b/packages/tools/src/tools/annotation/RectangleROITool.ts @@ -945,16 +945,14 @@ class RectangleROITool extends AnnotationTool { pixelUnitsOptions ); - const pointsInShape = this.configuration.storePointData - ? voxelManager.forEach( - this.configuration.statsCalculator.statsCallback, - { - boundsIJK, - imageData, - returnPoints: this.configuration.storePointData, - } - ) - : null; + const pointsInShape = voxelManager.forEach( + this.configuration.statsCalculator.statsCallback, + { + boundsIJK, + imageData, + returnPoints: this.configuration.storePointData, + } + ); const stats = this.configuration.statsCalculator.getStatistics(); cachedStats[targetId] = {