Skip to content

Commit

Permalink
fix(segmentation): Add segmentation ID requirement for threshold oper…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
sedghi committed Mar 6, 2025
1 parent 51cb78e commit da441c8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/tools/examples/rectangleROIThreshold/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,7 +68,7 @@ function rectangleROIThresholdVolumeByRange(
const outputSegmentationVolume = thresholdVolumeByRange(
segmentationVolume,
thresholdVolumeInformation,
{ ...options, boundsIJK }
{ ...options, boundsIJK, segmentationId: options.segmentationId }
);

outputSegmentationVolume.modified();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -66,7 +72,7 @@ function thresholdSegmentationByRange(
}
});

triggerSegmentationDataModified(segmentationVolume.volumeId);
triggerSegmentationDataModified(segmentationId);

return segmentationVolume;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getVoxelOverlap, processVolumes } from './utilities';

export type ThresholdRangeOptions = {
overwrite: boolean;
segmentationId: string;
boundsIJK: BoundsIJK;
overlapType?: number;
segmentIndex?: number;
Expand Down Expand Up @@ -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<number>;
Expand Down Expand Up @@ -153,7 +159,7 @@ function thresholdVolumeByRange(
boundsIJK,
});

triggerSegmentationDataModified(segmentationVolume.volumeId);
triggerSegmentationDataModified(options.segmentationId);

return segmentationVolume;
}
Expand Down

0 comments on commit da441c8

Please sign in to comment.