OHIF + VTK.js
OHIF + VTK.js
Acknowledgments
Funding Sources
Course Outline
What is OHIF?
What is OHIF? Live demo!
Where is OHIF being used?
OHIF project has collaborated with ITCR-funded projects, such as C-BIBOP, QIICR, TCIA, and Radiomics, as well as QIN tools such as ePAD. In addition to third party implementations, including:
To name a few!
Extensibility
Core extensions: Cornerstone
Core extensions: dicom-microscopy
Core extensions: dicom-html and dicom-pdf
Core extensions: VTK
VTK Extension Overview
Extensions are configurable through an extension object.��We’ll use the VTK extension for these examples, although the knowledge gained here is applicable to other extensions as well.
If you’d like a broader look at OHIF extensions,they are documented here.
VTK Extension Overview
getViewportModule returns the viewport component associated with the extension.
VTK Extension Overview
getToolbarModule should return an object which contains UI buttons to be put on the main OHIF toolbar.
VTK Extension Overview
getCommandsModule provides a list of commands which may either be bound to toolbar buttons in the toolbarModule or to hotkeys.
VTK Extension Overview
The VTK.js extension does not currently make use of it, but it is good to note that extensions can also add custom UI components to either of OHIF side panels through the panelModule. component.
VTK toolbarModule
Here we show the VTK.js toolbarModule. It is a "plain old JavaScript Object" with some key words OHIF recognises and consumes.
It constructs the UI that allows execution of commands from the commandModule.
VTK toolbarModule
The definitions object defines buttons to be placed in the toolbar. This includes the icon, label and command to be executed, as well as options to pass that command.
Two basic button types are available for extensions.
VTK toolbarModule
setToolActive - Defines the button as a toggleable tool, which lets OHIF know to untoggle other buttons of the same type to signify a change in tool. These may be interaction styles or widgets in the context of the VTK.js viewport.
VTK toolbarModule
Command - Executes the given command from the command module.
VTK toolbarModule
Custom UI components can be injected into the toolbar to change its look. Here we inject the SlabThicknessToolbarComponent to MIP controller seen above to the toolbar.
VTK toolbarModule
The toolbarModule consists of the definitions and the defaultContext. This is the context in which the defined buttons will appear in the toolbar. Here this is when the context is ACTIVE_VIEWPORT:VTK, which means these buttons will only be displayed when the active viewport is a VTK.js viewport.
VTK commandsModule
Here we show the VTK.js commandsModule. It comprises of actions and definitions and the defaultContext.
VTK commandsModule
The definitions object defines commands which can be used by the toolbarModule or bound to hotkeys.
storeContexts can be passed to commands, such that the commands may have access to data from within the redux store.
VTK commandsModule
The actions object defines the actions associated with each definition. These are functions that may change the active tool, perform an operation, or change the state in some way.
VTK commandsModule
Again, this module exposes definitions and the defaultContext to which the definitions apply.
VTK viewportModule: OHIFVTKViewport
OHIFVTKViewport
In Progress Reconstruction
react-vtkjs-viewport
The react-vtkjs-viewport contains two major elements:
The interactor styles and widgets are not deeply integrated with the viewport components, such that consumers of the library can choose which tools to attach, and to allow extensibility in the future.
OHIFVTKViewport
Apart from state hydration, the OHIFVTKViewport just exposes an API for interacting with the react-vtkjs-viewport state via OHIF commands.
As much functionality is pushed down to the react-vtkjs-viewport library as possible, so that it is reusable in applications other than the OHIF Viewer.
Completed Reconstruction
react-vtkjs-viewport
View2D:
View3D:
Interactor Styles and Widgets
In react-vtkjs-viewport the following are exposed:
We use these in OHIF to implement:
Developing for VTK.js in OHIF
The VTK extension is the primary injection point for extending VTK.js functionality in OHIF.
After reviewing the extension structure we can now see that a new interactor style or widget can be injected by:
Check the react-vtkjs-viewport interactor styles and widgets for example implementations.
Developing for VTK.js in OHIF
Using commands is also a great place to start injecting more complex VTK functionality into OHIF.
For example you may want to have a button which opens a side panel component which provides custom UI that allows the user to define the parameters for an auto segmentation routine, or apply some filtering process to the dataset and display this in the VTK.js viewport.
Developing for VTK.js in OHIF
If you wish to make changes to how the viewport itself operates (e.g. projection method, improvements to how sample distance is calculated, etc), this is best done within react-vtkjs-viewport library, or perhaps even VTK.js itself.
Potential Future Functionality
The react-vtkjs-viewport and its integration into OHIF has opened up lots of interesting possibilities. On the list to be implemented:
Potential Future Functionality
At the time of reading perhaps some new features have already made it live. viewer.ohif.org for a demo of the currently available features!