All files / tools/src/stateManagement/segmentation/helpers computeStackLabelmapFromVolume.ts

0% Statements 0/8
0% Branches 0/2
0% Functions 0/2
0% Lines 0/8

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 42 43 44 45 46 47                                                                                             
import type { Types } from '@cornerstonejs/core';
import { cache } from '@cornerstonejs/core';
import { getSegmentation } from '../getSegmentation';
import { updateStackSegmentationState } from '../helpers/updateStackSegmentationState';
import type { LabelmapSegmentationDataVolume } from '../../../types/LabelmapTypes';
 
// This function is responsible for the conversion calculations
export async function computeStackLabelmapFromVolume({
  volumeId,
}: {
  volumeId: string;
}): Promise<{ imageIds: string[] }> {
  const segmentationVolume = cache.getVolume(volumeId) as Types.IImageVolume;
 
  return { imageIds: segmentationVolume.imageIds };
}
 
// Updated original function to call the new separate functions
export function convertVolumeToStackLabelmap({
  segmentationId,
  options,
}: {
  segmentationId: string;
  options?: {
    viewportId: string;
    newSegmentationId?: string;
    removeOriginal?: boolean;
  };
}): Promise<void> {
  const segmentation = getSegmentation(segmentationId);
 
  if (!segmentation) {
    return;
  }
 
  const { volumeId } = segmentation.representationData
    .Labelmap as LabelmapSegmentationDataVolume;
  const segmentationVolume = cache.getVolume(volumeId) as Types.IImageVolume;
 
  return updateStackSegmentationState({
    segmentationId,
    viewportId: options.viewportId,
    imageIds: segmentationVolume.imageIds,
    options,
  });
}