Segmentation UI for VTKjs.
See original GitHub issuePer IDC discussion yesterday:
We need the following 4 features for the segmentation panel whilst MPR 2D is open:
- Show/hide segment.
- Switch segmentation rendering options.
- Jump to segment.
- Switch segmentation.
Most of these operations require retreiving the API for the viewport, which can be grabbed from here:
https://github.com/OHIF/Viewers/blob/master/extensions/vtk/src/commandsModule.js#L103
Show/Hide segment
api.setSegmentAlpha can be used to set the segment alpha to 255 or 0. This is multiplied by the global alpha, so you can use this to show/hide segments. (In the future we may need a show/hide + individual segment opacity, but this will work for now).
Switch segmentation rendering options.
- Most of these are passed down as props here.
- Perhaps they should instead by API endpoints in the react-vtkjs-viewport, might have to have a look at how best to implement this.
Jump to segment:
We already have logic for finding the middle slice of the segment.
- Look through this slice and find the mean voxel position of that slice for the segment.
- Convert this voxel position to the world coordinates of the volume you can do this from the
vtkImageData
by getting itsgetIndexToWorld
matrix. - Add 0.5, 0.5, 0.5 to the index, before converting to world coordinates, so that we may jump to the middle of the voxel.
- On one API set the world position of the crosshairs, they are synced so this will update all 3 and jump the images to this location.
const api = apis[0];
api.svgWidgets.crosshairsWidget.moveCrosshairs =(worldPos, apis, 0)
Switch segmentation:
For this you’ll need to create+cache another labelmap volume in the process that ussually happens in extensions/vtk/src/OHIFVTKViewport.js
when props are initially passed in, and then update the props. The react-vtkjs-viewport should already support the switching of volumes once this labelmap is changed, but this hasn’t had much testing/usage, so this may require some changes to the original library.
As this has not yet been discussed, we will leave out rendering of multiple segmentations in vtkjs for now, as this is a tricky and memory intensive issue that I don’t think is important for the MVP. CC: @fedorov
Could @fedorov / @pieper verify this is as discussed/good to work on?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
I’d say not a high priority compared to ironing out UI quirks.
Let’s also keep in mind the option of having one offscreen render context and then blitting the results into the onscreen viewports. Probably simpler logic.