Is there any way to use 3d slicer libraries and make my own GUI

https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets

Hi every one
I am new to slicer so my question maybe a beginner one,
I wanna use libraries of slicer in c++ to use its benefits in my image processing program.
For example I wanna have an Interface like what it is available in slicer to load my images, choose my ROI edit it and … .
I have built ITK, VTK, Opencv and I hope I Would combine these three libraries with 3d_Slicer together.
Is it possible?

See also:

https://www.slicer.org/wiki/Documentation/Nightly/Developers

Note that Slicer already builds ITK and VTK, and there is an OpenCV extension. Look at the examples of existing extensions at the link below, all of which should have links to the source code:

https://www.slicer.org/wiki/Documentation/Nightly/Extensions

thank you adamrankin, It seems what I am searching about.
But two more questions:
As I see Slicelets could help me to choose my image tools from 3d_slicer. Am I right? How? Is there more comprehensive tutorial?
As I understand Slicelets should be used in python. Is there any c++ equivalent?

Thanks a lot Nortron,
But I wanna develop my own GUI using these libraries not using extensions. 3d_slicer give me too much more than I want. Do you have any suggestion? Is my way logical?

This is a really broad question. You need to learn Qt or another GUI framework, learn to build C++ code, etc. There are many tutorials on the internet. To start, see some nice links @lassoan just compiled here.

We provide a lot of support for building modules within Slicer, and the goal is to make development faster and easier than building everything from scratch (especially if you use Python). If you want to do something else you are free to do that, of course – the code is all open source under a completely permissive license (BSD like) so you can use the pieces you need, under the license, or read the code to learn.

For commercial applications we often replace the entire Slicer GUI, use customized main window, custom branding, etc. Even in these cases, custom code is still bundled with Slicer as an extension.

1 Like

Thanks lassoan,
How we can do that?
I mean replacing the entire Slicer GUI and customizing it but using Slicer image tools.

Is it possible to use those pieces that I want in Qt or another GUI framework? Any useful link would be grateful.

Both @lassoan and @adamrankin are talking about slicelets:
https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets

There are many snippets to start from in the VTK examples, from the links listed by Andras. In particular:

https://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt

I concluded from these comments that there is no way to use 3d_slicer libraries in c++. I can just use VTK and ITK libraries and make my GUI with Qt or use Slicelets to make GUI in python.
Am I right?

No, that’s not right - you can definitely write a new C++ application using any of the Slicer libraries. You can look at the existing Slicer main application or at the corresponding tests as examples for how to structure an executable that links to the Slicer libraries. Much of the core of Slicer is intentionally written to avoid dependencies on python (however some modules do require python).

Just to be clear, we suggest people consider Slicelets for most use case because there are many challenges when trying to package an application for installation on user computers, particularly if you wish to support cross-platform installation. Slicelets allow you to leverage the significant infrastructure Slicer already provides.

The advantages of a non-Slicelet approach could be smaller installation package and faster startup times, so that’s worth considering if those are priorities for you.

1 Like

Thanks a lot pieper,
Your answer was so hopefull. Could you please give me the example links that use 3dslicer C++ libraries?

I am searching for something like itk or opencv libraries usage.

Do you have any suggestion about combining itk and vtk librarues in a GUI?

A C++ example for an application that uses Slicer libraries is SlicerApp:

ITK does not provide a GUI, and VTK provides viewers for 2D and 3D data visualization. You’ll need a generic UI toolkit like Qt to do your application. This is also what Slicer uses.

Can you please tell us the reason why you’re so reluctant to rely on Slicer to build your own GUI? It would be much simpler overall, and I’m sure you’d save a ton of time doing that.

1 Like

Thank you a lot @cpinter,
I am searching to find a way to do “an application that is like a commercial one.” @lassoan said : " we often replace the entire Slicer GUI, use customized main window, custom branding, etc. Even in these cases, custom code is still bundled with Slicer as an extension."
That’s so good, but I want to make something that is not an extension of Slicer because I think in this way I still have its main GUI.
In another word It would be more beautiful if it would be independent of Slicer in GUI layer, But use its benefits in background layer.

You don’t need to change a single line in Slicer core to completely replace the user interface. You can just hide any or all user interface elements of the application and display yours instead.

However, if you work primarily in C++ then you can also replace the application main window instead of customizing it, as described here: https://github.com/KitwareMedical/SlicerCustomAppTemplate

Either way, your modules will be built as an extension, the same way as many other built-in Slicer modules are. You just specify location of your extension’s source code in Slicer_EXTENSION_SOURCE_DIRS variable and your extension will be built into your application.

1 Like

Hi,
I am new to this world. I am in charge of developing a micro service which handles dicom files as input and output to frontend via RESTful API. I am not sure if I can use the 3D slicer library without QT GUI and import them to my service ?

Hi Phong -

Yes, you certainly can do this, but it’s not the main use case for which Slicer was created and you may find that some featured are not available. Slicer’s code is layered, so you can access MRML (data) and Logic VTK classes.

In my experience most use cases probably require functionality that is only available in a full running Slicer, so it’s maybe not a “micro” service, but you can run slicer inside docker and expose whatever interface you want (e.g. VNC).

DICOM indexing and database uses Qt (database is used to resolve cross-references between DICOM files). So, for loading complex data sets, such as radiation therapy plans or structured reports you need these Qt based classes, but showing GUI is not necessary.

1 Like