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

**URL:** https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607
**Category:** Development
**Created:** [April 17, 2018, 10:49am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607 "2018-04-17T10:49:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 17, 2018, 10:49am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/1 "2018-04-17T10:49:46Z")

</div>

Operating system:Win 7  
Slicer version:4.8

I wanna to develop my own GUI that uses benefits of 3d\_slicer and also ITK image processing classes. What should I do? Is it possible?

---

<div class="post-metadata">

### Author: ![adamrankin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/adamrankin/32/155_2.png) [@adamrankin](https://discourse.slicer.org/u/adamrankin)
#### Post date: [April 17, 2018, 1:26pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/2 "2018-04-17T13:26:42Z")

</div>

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Slicelets)

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 17, 2018, 6:35am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/3 "2018-04-17T06:35:30Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)
#### Post date: [April 17, 2018, 1:30pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/4 "2018-04-17T13:30:27Z")

</div>

See also:

[https://www.slicer.org/wiki/Documentation/Nightly/Developers](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](https://www.slicer.org/wiki/Documentation/Nightly/Extensions)

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 17, 2018, 2:15pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/5 "2018-04-17T14:15:41Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 17, 2018, 2:21pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/6 "2018-04-17T14:21:11Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)
#### Post date: [April 17, 2018, 2:33pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/7 "2018-04-17T14:33:19Z")

</div>

> [@rasoul](#):
>
> 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](https://discourse.slicer.org/t/a-free-biomedical-image-analysis-and-visualization-2-day-course/2584/10).

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.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [April 17, 2018, 9:32pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/8 "2018-04-17T21:32:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 18, 2018, 7:40am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/9 "2018-04-18T07:40:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 18, 2018, 7:45am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/10 "2018-04-18T07:45:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 18, 2018, 12:22pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/11 "2018-04-18T12:22:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)
#### Post date: [April 18, 2018, 1:06pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/12 "2018-04-18T13:06:06Z")

</div>

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](https://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt)

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 19, 2018, 7:50am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/13 "2018-04-19T07:50:01Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [April 19, 2018, 12:37pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/14 "2018-04-19T12:37:05Z")

</div>

> [@rasoul](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 25, 2018, 5:35am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/15 "2018-04-25T05:35:25Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [April 25, 2018, 4:21pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/16 "2018-04-25T16:21:23Z")

</div>

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

> **[Slicer/Applications/SlicerApp at main · Slicer/Slicer](https://github.com/Slicer/Slicer/tree/main/Applications/SlicerApp)**
>
> main/Applications/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.

---

<div class="post-metadata">

### Author: ![rasoul](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rasoul/32/1493_2.png) [@rasoul](https://discourse.slicer.org/u/rasoul)
#### Post date: [April 26, 2018, 9:36pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/17 "2018-04-26T21:36:38Z")

</div>

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.**

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [April 27, 2018, 3:27am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/18 "2018-04-27T03:27:21Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![Phong\_Tran](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/phong_tran/32/4827_2.png) [@Phong\_Tran](https://discourse.slicer.org/u/Phong_Tran)
#### Post date: [September 26, 2019, 10:59am UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/19 "2019-09-26T10:59:59Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 27, 2019, 10:42pm UTC](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607/20 "2019-09-27T22:42:49Z")

</div>

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).

[Next page](https://discourse.slicer.org/t/is-there-any-way-to-use-3d-slicer-libraries-and-make-my-own-gui/2607.md?page=2)
