react-cornerstone-viewport icon indicating copy to clipboard operation
react-cornerstone-viewport copied to clipboard

Proposal for compositional layer support

Open Ouwen opened this issue 4 years ago • 2 comments

Since cornerstonejs has layer API support (https://github.com/cornerstonejs/cornerstone/pull/68), the react-cornerstone-viewport could provide props support. This would allow for easy overlays of segmentation maps, heat maps, and other fusion based image information.

The current behaviour for react-cornsertone-viewport is to take in a list of imageIds as a stack and display some initial index.

https://github.com/cornerstonejs/react-cornerstone-viewport/blob/52703b9f23700d113ba0375526e248d66e135e34/src/CornerstoneViewport/CornerstoneViewport.js#L172-L188

However, it would be useful to take in layers as a prop where layers can contain many imageIds, but ultimately they are fused together as with the composite image example: https://rawgit.com/cornerstonejs/cornerstone/master/example/layers/index.html.

// layers prop
const layers = [{
            imageId: 'ct://1',
            options: {
                name: 'CT'
            }
        }, {
            imageId: 'pet://1',
            options: {
                name: 'PET',
                opacity: 0.7,
                viewport: {
                    colormap: 'hotIron',
                    voi: {
                        windowWidth: 30,
                        windowCenter: 16
                    }
                }
            }
        }
    ];

Alternatively, the imageIds could by default be added to a single element layer with that layer being set active.

A potential barrier is that the cornerstoneTools stack stateManagement relies on imageIds. Not sure if this would be a big deal though since the cornerstone layer API uses underlying imageIds, and tools can be applied to just the the active layer. I was wondering what would happen if we just provided the list of imageIds from the active layer.

Happy to put together a PR, but wanted to feel out opinions on better API design or caveats.

Ouwen avatar Mar 17 '21 20:03 Ouwen

Did you ever write a PR for this? I'm trying to implement the same thing.

shanebenlolo avatar Aug 10 '21 19:08 shanebenlolo

No I have not

Ouwen avatar Aug 10 '21 19:08 Ouwen