All files / packages/tools/src/tools/segmentation/strategies/utils stackVolumeCheck.ts

44.44% Statements 4/9
23.07% Branches 3/13
100% Functions 1/1
44.44% Lines 4/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                    71x 71x   71x 71x                                    
import {
  LabelmapSegmentationData,
  LabelmapSegmentationDataVolume,
} from '../../../../types/LabelmapTypes';
import {
  LabelmapToolOperationData,
  LabelmapToolOperationDataStack,
  LabelmapToolOperationDataVolume,
} from '../../../../types';
import { Types, VolumeViewport } from '@cornerstonejs/core';
 
function isVolumeSegmentation(
  operationData: LabelmapToolOperationData | LabelmapSegmentationData,
  viewport?: Types.IViewport
): operationData is
  | LabelmapToolOperationDataVolume
  | LabelmapSegmentationDataVolume {
  const { imageIdReferenceMap } =
    operationData as LabelmapToolOperationDataStack;
  const { volumeId } = operationData as LabelmapToolOperationDataVolume;
 
  Eif (volumeId && !imageIdReferenceMap) {
    return true;
  }
 
  if (imageIdReferenceMap && !volumeId) {
    return false;
  }
 
  if (volumeId && imageIdReferenceMap && !viewport) {
    throw new Error(
      'isVolumeSegmentation: viewport is required when both volumeId and imageIdReferenceMap are provided'
    );
  }
 
  // we can get the viewport to decide
  return viewport instanceof VolumeViewport;
}
 
export { isVolumeSegmentation };