I’m new to 3D Slicer, and now I am learning how to develop a new module in 3D Slicer to implement new features.
This module’s main function/feature will be: it can be used to calculate the proportion of the confocal regions(overlapping regions) of Z-stack image data displayed in volume rendering mode. For example, if the image data displayed in volume rendering contains red and green channels, the confocal region(overlapping region) will be displayed in yellow. Then, this module will help to calculate the volume and volume percentage of the yellow region. In other words, to achieve the proportion calculation of the intersecting region of multiple volumes.
As I’ve learned, the modules in 3D Slicer include 3 types: CLI, Scripted(in Python), Loadable(in C++), and I noticed that the ‘volume rendering’ belongs to the ‘loadable’ type and is written in C++.
Therefore, if I want to add a module to the ‘volume rendering’ to calculate the volume and proportion of the intersection regions, can this module be of ‘scripted’ type? In other words, can this new module be written in Python or it must be written in C++?
I look forward to and appreciate any help! Thank you!
Volume rendering is only a visualization technique. It does not help with any kind of measurements. Instead, you can specify regions using Segmentations module (probably Thresholding effect will suffice), get difference, intersection, etc. of the segments (using “Logical operators” effect), and then get volumes using “Segment statistics” module.
Thank you for your quick and kind reply!
Maybe I didn’t fully elaborate.
I see that the ‘segment statistics’ module can be used to calculate the volume. But letting the user also be able to measure the volume of a specific region in the 3D view/scene of volume rendering is what I want to do.
For example, the user can define an ROI box in the 3D view/scene of volume rendering(Or a similar way) to get the specific region to be measured and then click a button to get the volume value and proportion enclosed by the box. (In the 3D scene of volume rendering, the volume proportion of the intersecting region can be judged and calculated by the ray segmentation. A similar principle is shown in the figure below)
Therefore, for example, if I want to extend a new module that achieves the above features to the existing ‘Volume rendering’ (A loadable module in C++) in 3D Slicer, Can it be of ‘Scripted’ type(written in Python)? Or it must also be of loadable type(written in C++)?
Thank you so much!
This is exactly what segmentations are for. You can specify and edit regions using Segment Editor module (and you can also import regions from models or labelmap volumes).
You can easily split up a region (a segment) into subregion (several segments), for example by using the scissor tool (see for example here).
If you want to make things very convenient for users then you can create a simple Python scripted module that takes a segmentation, maybe some additional inputs, such as a planes or lines, and then computes all the volumes you need.
Thank you for your kind reply and materials!
Therefore, in other words, for example, if I want to extend a new module to the ‘Volume rendering’ module, this new module created by me can also be the type of ‘scripted’ written in Python (even the ‘volume rendering’ in 3D Slicer is a loadable module written in C++), right?
You would not change any Slicer core module, but create your own scripted module. Modules provide high-level widgets that you can place into your own module’s GUI in Qt Designer. To get started you can use the PerkLab Slicer Bootcamp programming tutorial.
Got you, thank you!
You would not change any Slicer core module, but create your own scripted module.
I am also a beginner in learning 3D Slicer, and I also have an idea similar to @CharlesChen: To create a new extension/module in 3D Slicer so that users can directly add visual annotation marks on the 3D images in the volume rendering scene.
So, what you mean is that the ‘Volume rendering’ is a core module of 3D Slicer, so we can’t add/expand new features/modules for it but can only develop a new extension/module in addition (Completely independent of this module)?
If so, does it mean that I should re-implement the volume rendering effect first in my own module (then other features I want)?
Could you please just give a further clarify?
Thank you so much!
Slicer core modules expose a lot of features in the most general-purpose way possible. If you want to add custom features or implement custom workflows then you don’t modify existing core modules but add custom modules - regardless of what programming language a Slicer core module is implemented in.
If you want to implement a workflow where the user places markups on a volume-rendered image in a 3D view then you’ll add a custom module that has a simple GUI, for example with a volume node selector and a markups place widget. When the user selects an image, the module sets up the views, volume rendering display, etc. Then the user can click the place button to place markups in the views.
No need to reimplement any core module, because you can use features of any module from any other module. In term of user interface, usually in a custom end-user workflow you only need to expose a tiny fraction of the options that you see in a core module, because you know a lot about what data you work with and what the user wants to do with it. For example, you probably all the features you need from volume rendering module is a checkbox to show/hide volume rendering and maybe the “Offset” slider.
Thank you for your brief but clear explanation on this issue, which further deepened my understanding of developing new modules in 3D Slicer. It makes me feel that the features I want to achieve are quite doable(by customizing my own Python scripted module in 3D Slicer).
@WilliamDaniel Thank you for your further consultation to make this question more specific and clear
That’s more clear to me, thank you very much!
@CharlesChen Thanks for the discussion with both of you!