Skip to content

Commit da441c8

Browse files
committed
fix(segmentation): Add segmentation ID requirement for threshold operations
1 parent 51cb78e commit da441c8

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

packages/tools/examples/rectangleROIThreshold/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ addButtonToToolbar({
149149
const ctVolume = cache.getVolume(ctVolumeId);
150150
const ptVolume = cache.getVolume(ptVolumeId);
151151
const segmentationVolume = cache.getVolume(segmentationId);
152-
153152
csToolsUtils.segmentation.rectangleROIThresholdVolumeByRange(
154153
selectedAnnotationUIDs,
155154
segmentationVolume,

packages/tools/src/utilities/segmentation/rectangleROIThresholdVolumeByRange.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import getBoundsIJKFromRectangleAnnotations from '../rectangleROITool/getBoundsI
88
import type { ThresholdInformation } from './utilities';
99

1010
export type ThresholdOptions = {
11+
segmentationId: string;
1112
numSlicesToProject?: number; // number of slices to project before and after current slice
1213
overwrite: boolean;
1314
overlapType?: number; // type of the voxel overlap
@@ -67,7 +68,7 @@ function rectangleROIThresholdVolumeByRange(
6768
const outputSegmentationVolume = thresholdVolumeByRange(
6869
segmentationVolume,
6970
thresholdVolumeInformation,
70-
{ ...options, boundsIJK }
71+
{ ...options, boundsIJK, segmentationId: options.segmentationId }
7172
);
7273

7374
outputSegmentationVolume.modified();

packages/tools/src/utilities/segmentation/thresholdSegmentationByRange.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ function thresholdSegmentationByRange(
1818
segmentationVolume: Types.IImageVolume,
1919
segmentationIndex: number,
2020
thresholdVolumeInformation: ThresholdInformation[],
21-
overlapType: number
21+
overlapType: number,
22+
segmentationId: string
2223
): Types.IImageVolume {
24+
if (!segmentationId) {
25+
throw new Error(
26+
'Segmentation ID is required to be passed inside thresholdSegmentationByRange'
27+
);
28+
}
2329
// prepare a list of volume information objects for callback functions
2430
const { baseVolumeIdx, volumeInfoList } = processVolumes(
2531
segmentationVolume,
@@ -66,7 +72,7 @@ function thresholdSegmentationByRange(
6672
}
6773
});
6874

69-
triggerSegmentationDataModified(segmentationVolume.volumeId);
75+
triggerSegmentationDataModified(segmentationId);
7076

7177
return segmentationVolume;
7278
}

packages/tools/src/utilities/segmentation/thresholdVolumeByRange.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getVoxelOverlap, processVolumes } from './utilities';
66

77
export type ThresholdRangeOptions = {
88
overwrite: boolean;
9+
segmentationId: string;
910
boundsIJK: BoundsIJK;
1011
overlapType?: number;
1112
segmentIndex?: number;
@@ -37,7 +38,12 @@ function thresholdVolumeByRange(
3738
): Types.IImageVolume {
3839
const { imageData: segmentationImageData } = segmentationVolume;
3940

40-
const { overwrite, boundsIJK } = options;
41+
const { overwrite, boundsIJK, segmentationId } = options;
42+
if (!segmentationId) {
43+
throw new Error(
44+
'Segmentation ID is required to be passed inside thresholdVolumeByRange as options'
45+
);
46+
}
4147
const overlapType = options?.overlapType || 0;
4248
const segVoxelManager =
4349
segmentationVolume.voxelManager as Types.IVoxelManager<number>;
@@ -153,7 +159,7 @@ function thresholdVolumeByRange(
153159
boundsIJK,
154160
});
155161

156-
triggerSegmentationDataModified(segmentationVolume.volumeId);
162+
triggerSegmentationDataModified(options.segmentationId);
157163

158164
return segmentationVolume;
159165
}

0 commit comments

Comments
 (0)