OHIF / Viewers

OHIF zero-footprint DICOM viewer and oncology specific Lesion Tracker, plus shared extension packages
https://docs.ohif.org/
MIT License
3.38k stars 3.42k forks source link

[Bug] cameraPosition sync works weirdly when orientation is not specified #3986

Open m00n620 opened 8 months ago

m00n620 commented 8 months ago

Describe the Bug

cameraPosition synchronizing is not working, series are super zoomed in custom hanging protocol.

Here's the viewports configuration in custom hanging protocol.

viewports: [
  {
    viewportOptions: {
      viewportId: 'mip-0',
      viewportType: 'volume',
      // orientation: 'axial',
      toolGroupId: 'mip',
      initialImageOptions: {
        preset: 'middle',
      },
      syncGroups: [
        {
          type: 'cameraPosition',
          id: 'axialSync',
          source: true,
          target: true,
        },
        {
          type: 'voi',
          id: 'wlSync',
          source: true,
          target: true,
        },
      ],
    },
    displaySets: [
      {
        id: 'activeDisplaySet',
      },
    ],
  },
  {
    viewportOptions: {
      viewportId: 'mip-1',
      viewportType: 'volume',
      // orientation: 'axial',
      toolGroupId: 'mip',
      initialImageOptions: {
        preset: 'middle',
      },
      syncGroups: [
        {
          type: 'cameraPosition',
          id: 'axialSync',
          source: true,
          target: true,
        },
        {
          type: 'voi',
          id: 'wlSync',
          source: true,
          target: true,
        },
      ],
    },
    displaySets: [
      {
        id: 'activeDisplaySet',
        options: {
          blendMode: 'MIP',
          slabThickness: 5,
        },
      },
    ],
  },
]

But, if I enable the orientation, everything works correctly.

However, I want to use the protocol for all orientations(axial, coronal and sagittal).

Steps to Reproduce

  1. Enable custom hanging protocol(1x2).
  2. Drag Series 1 into Viewport 1, everything works fine.
  3. Drag Series 2 into Viewport 1, still fine.
  4. Drag Series 1 again into Viewport 1, the viewport loses the zoom level, images are super zoomed.

The current behavior

The viewport loses the zoom level, images are super zoomed when orientation is not specified.

The expected behavior

cameraPosition sync should be working whenever orientation is set or not.

OS

Windows 11

Node version

18.16.0

Browser

Chrome 120.0.6099.217

sedghi commented 8 months ago

I tried to reproduce it but can't, can you please add more details or ideally more code?

m00n620 commented 8 months ago

This is our custom hanging protocol. We are turn this on/off using toggleHangingProtocol like MPR.

export const mip: Types.HangingProtocol.Protocol = {
  id: 'mip',
  name: 'mip',
  imageLoadStrategy: 'nth',
  protocolMatchingRules: [],
  callbacks: {
    // Switches out of MIP mode when the layout change button is used
    onLayoutChange: [
      {
        commandName: 'toggleHangingProtocol',
        commandOptions: { protocolId: 'mip' },
        context: 'DEFAULT',
      },
    ],
    // Turns off crosshairs when switching out of MPR mode
    // onProtocolExit: [
    //   {
    //     commandName: 'cleanUpCrosshairs',
    //   },
    // ],
  },
  displaySetSelectors: {
    activeDisplaySet: {
      seriesMatchingRules: [
        {
          weight: 1,
          attribute: 'isReconstructable',
          constraint: {
            equals: {
              value: true,
            },
          },
          required: true,
        },
      ],
    },
  },
  stages: [
    {
      name: '2D MIP',
      viewportStructure: {
        layoutType: 'grid',
        properties: {
          rows: 1,
          columns: 2,
          layoutOptions: [
            {
              x: 0,
              y: 0,
              width: 1 / 2,
              height: 1,
            },
            {
              x: 1 / 2,
              y: 0,
              width: 1 / 2,
              height: 1,
            },
          ],
        },
      },
      viewports: [
        {
          viewportOptions: {
            toolGroupId: 'mip',
            viewportType: 'volume',
            initialImageOptions: {
              preset: 'middle',
            },
            syncGroups: [
              {
                type: 'cameraPosition',
                id: 'mip-sync-cameraPosition',
                source: true,
                target: true,
              },
              {
                type: 'voi',
                id: 'mip-sync-voi',
                source: true,
                target: true,
              },
            ],
          },
          displaySets: [
            {
              id: 'activeDisplaySet',
            },
          ],
        },
        {
          viewportOptions: {
            toolGroupId: 'mip',
            viewportType: 'volume',
            initialImageOptions: {
              preset: 'middle',
            },
            syncGroups: [
              {
                type: 'cameraPosition',
                id: 'mip-sync-cameraPosition',
                source: true,
                target: true,
              },
              {
                type: 'voi',
                id: 'mip-sync-voi',
                source: true,
                target: true,
              },
            ],
          },
          displaySets: [
            {
              id: 'activeDisplaySet',
              options: {
                blendMode: 'MIP',
                slabThickness: 5,
              },
            },
          ],
        },
      ],
    },
  ],
};
sedghi commented 8 months ago

seems like when we are storing the presentations, it does it one by one and by the time that we store the first (left) viewport, the left viewport gets a new displayset and the synchronizer try to sync the right (old layout) camera with the new display set(left), and as a result an incorrect presentation will get saved for the right viewport at the exit

m00n620 commented 8 months ago

@sedghi , can you please share the timeline for this bug?

sedghi commented 4 weeks ago

Can you check the latest OHIF viewer, which now includes Cornerstone 3D 2.0?

Here are the migration guides:

Try OHIF locally: https://viewer-dev.ohif.org/localbasic
Try Cornerstone3D 2.0 locally: https://www.cornerstonejs.org/live-examples/local.html

https://docs.ohif.org/migration-guide/3p8-to-3p9/