Skip to content

[Bug] converting surface to Labelmap gives "Cannot read properties of undefined (reading 'voxelManager')" #2516

@iweinbau

Description

@iweinbau

Describe the Bug

When converting surface to labelmap, the following error occurs:

Cannot read properties of undefined (reading voxelManager)

at addVolumeSegmentIndices (chunk-I2VXNDFL.js?v=e40045c4:846:10) at handleLabelmapSegmentation (chunk-I2VXNDFL.js?v=e40045c4:840:5) at getUniqueSegmentIndices (chunk-I2VXNDFL.js?v=e40045c4:823:15) at computeSurfaceFromLabelmapSegmentation (surfaceComputationStrategies.js?v=e40045c4:45:54) at Module.updateSurfaceData (updateSurfaceData.js?v=e40045c4:7:31) at @cornerstonejs_tools.js?v=e40045c4:3487:38 at @cornerstonejs_tools.js?v=e40045c4:13578:7 at invokeFunc (@cornerstonejs_tools.js?v=e40045c4:9622:19) at trailingEdge (@cornerstonejs_tools.js?v=e40045c4:9663:14) at timerExpired (@cornerstonejs_tools.js?v=e40045c4:9656:14)


Steps to Reproduce

// --- Register segmentation in cornerstone-tools ---
    segmentation.addSegmentations([
        {
            segmentationId: this.MY_SEGMENTATION,
            representation: {
                type: SegmentationRepresentations.Surface,
                data: {
                    geometryIds: segmentsIds,
                },
            },
        },
    ]);
    
    console.log(getUniqueSegmentIndices(this.MY_SEGMENTATION))
    setCachedSegmentIndices(this.MY_SEGMENTATION, getUniqueSegmentIndices(this.MY_SEGMENTATION))
    console.log(getCachedSegmentIndices(this.MY_SEGMENTATION))
    
    // --- Precompute contour + labelmap ---
    const axialView = this.cornerstoneService.getViewport(
        'axial'
    ) as VolumeViewport;

    const contourData = await computeContourData(this.MY_SEGMENTATION, {
        viewport: axialView,
        segmentationId: this.MY_SEGMENTATION,
        segmentIndices: getUniqueSegmentIndices(this.MY_SEGMENTATION)
    });

    segmentation.addRepresentationData({
        segmentationId: this.MY_SEGMENTATION,
        type: SegmentationRepresentations.Contour,
        data: contourData,
    });

    const labelmapData = await computeLabelmapData(this.MY_SEGMENTATION, {
        viewport: axialView,
        segmentationId: this.MY_SEGMENTATION,
        segmentIndices: getUniqueSegmentIndices(this.MY_SEGMENTATION),
    }) as LabelmapSegmentationDataVolume;

    const labelmapVolume = cache.getVolume(labelmapData.volumeId)
    
    const labelmapSegData = {
        volumeId: labelmapVolume?.volumeId,
        referencedVolumeId: labelmapVolume?.referencedVolumeId,
        referencedImageIds: labelmapVolume?.referencedImageIds,
        imageId: labelmapVolume?.imageIds,
    }

    segmentation.addRepresentationData({
        segmentationId: this.MY_SEGMENTATION,
        type: SegmentationRepresentations.Labelmap,
        data: labelmapSegData
    });

The Current Behavior

An error is thrown when attempting to add a surface representation to the VOLUME_3D viewport:

segmentation.addSurfaceRepresentationToViewportMap({ view3d: [{segmentationId: this.MY_SEGMENTATION }], });


The Expected Behavior

The surface representation should be added successfully, since the segmentation already has both surface and labelmap representations.


System Information

  • Vite

  • macOS

  • React

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions