Hi everyone,
I am working on a custom scripted module in 3D Slicer tailored for Pre-Post surgical maxillofacial and orthognathic studies.
My goal is to automate the export workflow for clinical web visualization:
- Combine and center multiple quantification models (such as Airway and Mandible distance maps) into a single
.glbfile with baked vertex colors. - Export clean, transparent individual
Color Legendimages corresponding to each model’s active scalars.
What I have achieved so far:
I have successfully built the core logic of the script, handling the VTK coordinate transformations (-Y orientation and centering), scalar extraction, vertex color baking, and mesh combination into GLB using trimesh.
The roadblock I am facing:
When trying to capture the individual color legends (Color Legend / color bars) by isolating models and grabbing/cropping the 3D view widget, the resulting PNGs either cut off parts of the 3D model, fail to capture the left-side legend cleanly, or end up with rendering artifacts. I haven’t been able to get this part fully right.
What I would love to achieve / Need help with:
- Someone to help me spot and fix the bug in my legend-export approach (or point me to the native Slicer API to directly export a model’s active color legend as a clean transparent PNG).
- Guidance on how to properly structure this into a GUI module where I can interactively select specific models, adjust display parameters (like opacity/transparencies), and trigger the batch export of the GLB and its scalar color legends.
Here is a snippet of my current approach:
# Iterating visible models, isolating them, and attempting to grab the view/legend
for modelNode in quantificationModels:
# ... isolation and mesh baking ...
fullImage = ctk.ctkWidgetsUtils.grabWidget(viewWidget)
# ... cropping logic that currently struggles with clean isolation ...