diff --git a/packages/tools/examples/rectangleROIThreshold/index.ts b/packages/tools/examples/rectangleROIThreshold/index.ts index 585db9e16..1cc057fdb 100644 --- a/packages/tools/examples/rectangleROIThreshold/index.ts +++ b/packages/tools/examples/rectangleROIThreshold/index.ts @@ -149,7 +149,6 @@ addButtonToToolbar({ const ctVolume = cache.getVolume(ctVolumeId); const ptVolume = cache.getVolume(ptVolumeId); const segmentationVolume = cache.getVolume(segmentationId); - csToolsUtils.segmentation.rectangleROIThresholdVolumeByRange( selectedAnnotationUIDs, segmentationVolume, diff --git a/packages/tools/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts b/packages/tools/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts index 761ea090b..e61fd37d3 100644 --- a/packages/tools/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts +++ b/packages/tools/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts @@ -8,6 +8,7 @@ import getBoundsIJKFromRectangleAnnotations from '../rectangleROITool/getBoundsI import type { ThresholdInformation } from './utilities'; export type ThresholdOptions = { + segmentationId: string; numSlicesToProject?: number; // number of slices to project before and after current slice overwrite: boolean; overlapType?: number; // type of the voxel overlap @@ -67,7 +68,7 @@ function rectangleROIThresholdVolumeByRange( const outputSegmentationVolume = thresholdVolumeByRange( segmentationVolume, thresholdVolumeInformation, - { ...options, boundsIJK } + { ...options, boundsIJK, segmentationId: options.segmentationId } ); outputSegmentationVolume.modified(); diff --git a/packages/tools/src/utilities/segmentation/thresholdSegmentationByRange.ts b/packages/tools/src/utilities/segmentation/thresholdSegmentationByRange.ts index 10097054d..cb0da9891 100644 --- a/packages/tools/src/utilities/segmentation/thresholdSegmentationByRange.ts +++ b/packages/tools/src/utilities/segmentation/thresholdSegmentationByRange.ts @@ -18,8 +18,14 @@ function thresholdSegmentationByRange( segmentationVolume: Types.IImageVolume, segmentationIndex: number, thresholdVolumeInformation: ThresholdInformation[], - overlapType: number + overlapType: number, + segmentationId: string ): Types.IImageVolume { + if (!segmentationId) { + throw new Error( + 'Segmentation ID is required to be passed inside thresholdSegmentationByRange' + ); + } // prepare a list of volume information objects for callback functions const { baseVolumeIdx, volumeInfoList } = processVolumes( segmentationVolume, @@ -66,7 +72,7 @@ function thresholdSegmentationByRange( } }); - triggerSegmentationDataModified(segmentationVolume.volumeId); + triggerSegmentationDataModified(segmentationId); return segmentationVolume; } diff --git a/packages/tools/src/utilities/segmentation/thresholdVolumeByRange.ts b/packages/tools/src/utilities/segmentation/thresholdVolumeByRange.ts index 1d1f1da1d..6901ba0e9 100644 --- a/packages/tools/src/utilities/segmentation/thresholdVolumeByRange.ts +++ b/packages/tools/src/utilities/segmentation/thresholdVolumeByRange.ts @@ -6,6 +6,7 @@ import { getVoxelOverlap, processVolumes } from './utilities'; export type ThresholdRangeOptions = { overwrite: boolean; + segmentationId: string; boundsIJK: BoundsIJK; overlapType?: number; segmentIndex?: number; @@ -37,7 +38,12 @@ function thresholdVolumeByRange( ): Types.IImageVolume { const { imageData: segmentationImageData } = segmentationVolume; - const { overwrite, boundsIJK } = options; + const { overwrite, boundsIJK, segmentationId } = options; + if (!segmentationId) { + throw new Error( + 'Segmentation ID is required to be passed inside thresholdVolumeByRange as options' + ); + } const overlapType = options?.overlapType || 0; const segVoxelManager = segmentationVolume.voxelManager as Types.IVoxelManager; @@ -153,7 +159,7 @@ function thresholdVolumeByRange( boundsIJK, }); - triggerSegmentationDataModified(segmentationVolume.volumeId); + triggerSegmentationDataModified(options.segmentationId); return segmentationVolume; }