I would like to show the result of my experiment of compiling entire Slicer using webassembly and running natively in the browser. The results are quite shocking (in a good way).
When using alpha blending or reverse alpha blending it looks like the background colormap influences the blend beyond the bounds of the background. Is this how it should be?
This seems like a choice that could go either way, and we couldnβt think of any usage that would be affected, so a change is probably okay.
Slicer in webassembly
This is experimental work done by Andras over a weekend. All of Slicer, except for Qt, compiled into webassembly and running in a browser! No rendering or computations happen on the server, everything is done locally in userβs the browser, no data leaves the userβs computer.
Python is well supported. Python runs in the browser using Pyodide. The web application has a Python console, Python packages can be installed anytime (pip_install installs packages work from the Pyodide distribution, from PyPI through micropip, or from custom-built packages).
Scripted modules work without changes. Claude created a mock Qt layer to make this pretty seamless.
C++ modules work with no changes to MRML and logic classes. Shared Qt widgets are reproduced by Claude using Vue. Module-specific widgets are recreated by Claude.
Extensions are supported. All extensions that contain only Python scripted modules should work without any source code changes (just need to be repackaged). Very complex extension that contain VTK and ITK based compiled code work well, too (see for example VMTK).
The amount of code generated to achieve this was very small β this is not a re-implementation of everything but reuses the same C++ components that make up Slicer. The only source code that is not shared between desktop and web builds of Slicer are the Qt widgets.
This shows how much can be achieved in a short time in terms of porting slicer functionality to the web browser, and how mature webassembly and pyodide are.
Next steps: integrate necessary patches into upstream repositories, extend to include more modules and extensions.
@ebrahim What is to maintain the existing default to clip to the background or uncontroversial to change the default to no longer by default clip to the background?
Agreed, disabling clipping would be useful in most cases (esp. when manually moving / registering multiple volumes in Slice views).
Regarding the blending issue, I also find the current behavior very unnintuitive and not blending the volumes where they donβt overlap would make sense to me.
@lassoan thanks for the demo yesterday and for sharing the code!
Iβll probably repost for next weekβs meeting, but Iβd like to discuss roadmap / architecture and design for the components that should be refactored in pure VTK C++ so that they can be reused in SlicerWeb / trame-slicer usage.
Looking at the code, I think there are at least the following to factorize and propagate in upstream:
Main slicer application (initialization / connection of the core modules)