cornerstonejs / cornerstone3D

Cornerstone is a set of JavaScript libraries that can be used to build web-based medical imaging applications. It provides a framework to build radiology applications such as the OHIF Viewer.
https://cornerstonejs.org
MIT License
565 stars 288 forks source link

[Bug] How to resolve "Multiple segmentation representations detected for this tool group. The first one will be used." #1390

Open prerakmody opened 3 months ago

prerakmody commented 3 months ago

Describe the Bug

Error context

I add two CONTOURS to my segmentations.

image

Error 1

And then I get an error pointing to my script.

image
// This is Line 1978
const segReprUIDs = await cornerstone3DTools.segmentation.addSegmentationRepresentations(toolGroupIdContours, [
        {segmentationId:segmentationIdParam, type: segType, }, // options: { polySeg: { enabled: true, }, },
    ]);

Error 2

If I scroll through the contours, I then get the same error, but pointing to internal cornerstone3D code

image
// This is line 152
 _getSegmentationRepresentation(segmentationId) {
        const segmentationRepresentations = segmentationState.getSegmentationRepresentations(this.toolGroupId);
        const validSegmentationRepresentations = segmentationRepresentations.filter((representation) => representation.segmentationId === segmentationId);
        if (!validSegmentationRepresentations) {
            console.warn(`No segmentation representation found for toolGroupId: ${this.toolGroupId}`);
            return;
        }
        if (segmentationState.getSegmentationRepresentations(this.toolGroupId)
            .length > 1) {
            console.warn('Multiple segmentation representations detected for this tool group. The first one will be used.');
        }
        return validSegmentationRepresentations[0];
    }

Steps to Reproduce

  1. Add two cornerstone3DTools.Enums.SegmentationRepresentations.Contour by using cornerstone3DTools.segmentation.addSegmentationRepresentations()

The current behavior

Throws an error: Multiple segmentation representations detected for this tool group. The first one will be used. However, when I have two cornerstone3DTools.Enums.SegmentationRepresentations.Labelmap along with another cornerstone3DTools.Enums.SegmentationRepresentations.Contour, I do not face any such errors.

The expected behavior

There should be no error thrown

OS

MacOS v14.2 (Sonoma)

Node version

20.8.0

Browser

Brave (Version 1.66.118)

sedghi commented 3 months ago

can you create a mini example for us showcasing it?