cornerstonejs / react-cornerstone-viewport

Cornerstone medical image viewport component for React
https://react.cornerstonejs.org/
MIT License
96 stars 75 forks source link

Proposal for compositional layer support #116

Open Ouwen opened 3 years ago

Ouwen commented 3 years ago

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.

shanebenlolo commented 2 years ago

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

Ouwen commented 2 years ago

No I have not