Skip to content

[Bug] When used at the same time CircularBrush and PlanarFreehandContourSegmentationTool, brush can't real-time segmentation #1883

Open
@jiuyuer

Description

@jiuyuer

Describe the Bug

When I was at the same time use CircularBrush and PlanarFreehandContourSegmentationTool, brush can't real-time segmentation, however, When I switch to the PlanarFreehandContourSegmentationTool or switch the next figure, CircularBrush segmentation can echo again

but....

I based on the https://www.cornerstonejs.org/live-examples/toolhistory demo, adjusted the part of the code, here are can display normally

This is my main transformation point up there

async function run() {
  // Init Cornerstone and related libraries
  await initDemo();

  // Define a tool group, which defines how mouse events map to tool commands for
  // Any viewport using the group
  const toolGroup = ToolGroupManager.createToolGroup(toolGroupId);
  addManipulationBindings(toolGroup, { toolMap });

  // Get Cornerstone imageIds and fetch metadata into RAM
  const imageIds = await createImageIdsAndCacheMetaData({
    StudyInstanceUID:
      '1.3.6.1.4.1.14519.5.2.1.7009.2403.334240657131972136850343327463',
    SeriesInstanceUID:
      '1.3.6.1.4.1.14519.5.2.1.7009.2403.226151125820845824875394858561',
    wadoRsRoot: 'https://d14fa38qiwhyfd.cloudfront.net/dicomweb',
  });

  // Define a volume in memory
  // const volume = await volumeLoader.createAndCacheVolume(volumeId, {
  //   imageIds,
  // });

  // Instantiate a rendering engine
  const renderingEngine = new RenderingEngine(renderingEngineId);

  // Create a stack viewport
  const viewportInput = {
    viewportId,
    type: ViewportType.STACK,
    element,
    defaultOptions: {
      background: <Types.Point3>[0.2, 0, 0.2],
    },
  };

  renderingEngine.enableElement(viewportInput);

  // Set the tool group on the viewport
  toolGroup.addViewport(viewportId, renderingEngineId);

  // Get the stack viewport that was created
  const viewport: any = renderingEngine.getViewport(viewportId);
  // volume.load();
  const ctImageIds = imageIds.slice(0, 3);
  const ctSegImages = await imageLoader.createAndCacheDerivedLabelmapImages(
    ctImageIds
  );
  await viewport.setStack(ctImageIds, 0);
  // Set volumes on the viewports
  // await setVolumesForViewports(renderingEngine, [{ volumeId }], [viewportId]);

  // Render the image
  viewport.render();
  segmentation.addSegmentations([
    {
      segmentationId: labelmapSegmentationId,
      representation: {
        // The type of segmentation
        type: csToolsEnums.SegmentationRepresentations.Labelmap,
        // The actual segmentation data, in the case of labelmap this is a
        // reference to the source volume of the segmentation.
        data: {
          imageIds: ctSegImages.map((it) => it.imageId),
        },
      },
    },
    {
      segmentationId: contourSegmentationId,
      representation: {
        type: csToolsEnums.SegmentationRepresentations.Contour,
      },
    },
  ]);

  segmentation.addLabelmapRepresentationToViewport(viewportId, [
    { segmentationId: labelmapSegmentationId },
  ]);

  segmentation.addContourRepresentationToViewport(viewportId, [
    { segmentationId: contourSegmentationId },
  ]);
  // segmentation.activeSegmentation.setActiveSegmentation(
  //   viewportId,
  //   labelmapSegmentationId
  // );
}
Jietu20250309-050943-HD.mp4

Steps to Reproduce

  1. addTool , CircularBrush , PlanarFreehandContourSegmentationTool
  2. toolGroup.addTool ...
  3. addSegmentations and addSegmentationRepresentations
  4. todo...

The current behavior

This is not normal...

491_1741468954.mp4

The expected behavior

Video description above

OS

macOs 14.6.1

Node version

18.20.0

Browser

Chrome 133.0.6943.142

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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