About creating Customslicer

Operating system: window 10
Slicer version: 5.2.1

Hi slicer users,

So far, I’ve been using it by developing a Python module and adding it as a module extension to Slicer.

However, if you use it like this, it doesn’t matter if you add a new function, but it seems to be a problem when you try to modify an existing function.

Therefore, I want to create a custom slicer.
(e.g. ‘slicerCat’, https://www.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/#step1)

This post seems out of date. Are there any other resources I should refer to to implement CustomSlicer?

EDIT:
Q1.
image
It seemed to say that if you do not modify the git tag, it will connect to the latest version, but there is a problem. Where do I get the git tag hash values for each slicer version?

Q2.
What is the difference between directly building the slicer 5.2.1 code in ‘GitHub - Slicer/Slicer: Multi-platform, free open source software for visualization and image computing.’ and using CustomSlicer?

Using the custom application template has the advantage that you can do lots of customizations without modifying anything in Slicer core. Since you don’t modify Slicer core source files, you can keep getting Slicer core updates without worrying having merge conflicts.

The instructions should be still up-to-date. But if you find anything outdated then let us know. Where did you get that git hash from that is in your screenshot?

You can find Slicer git tags and hashes in github. If you want to use Slicer-5.2.2 as the basis of your custom application then you can use 5.2.2 tag as GIT_TAG.

1 Like

Excellent, If so, is it possible to override functions such as the basic save function of slicer?
For example, is it possible to modify the save function that exists in slicer so that it does not operate unless certain conditions are met?

pip install cookiecutter jinja2-github
cookiecutter gh:KitwareMedical/SlicerCustomAppTemplate

The tag value of CmakeList.txt created when the above command was used was used as it is.

Looking for CustomSlicer, it seems to be divided into c++ and python versions.

When I make a c++ version of customslicer, if I make it based on version 5.2.2, can I use the python module in this customslicer? (Can I use python console in c++ custom slicer like normal slicer 5.2.2 above?)

Yes.

Scripted modules can be integrated in custom application built of both Slicer@v5.2.2 and the latest version Slicer@main

1 Like

In summary, if you use a custom slicer, you can use the existing method of adding modules(using extension wizard), and you can perform actions such as GUI and basic function overriding without touching the core.

All that’s left is for me to get this build done. Thank you both.

pip install cookiecutter jinja2-github
cookiecutter gh:KitwareMedical/SlicerCustomAppTemplate

Both ‘v5.2.2’ and ‘5.2.2’ do not work, but if the prompt input that appears when entering the above command is incorrect, does it not work?

Should the git tag have a value like ‘afdkljasflanvsaldslak5safd’ and not ‘5.2.2’?

v5.2.2 is a valid GIT_TAG for https://github.com/Slicer/Slicer and should successfully check out the source as long as you have a valid internet connection for it to download the source.

What is your value for GIT_REPOSITORY on the line just above GIT_TAG?

@jamesobutler
image

image

Could it be a problem if I put the settings wrong above? I don’t understand why this doesn’t work

    GIT_REPOSITORY ${EP_GIT_PROTOCOL}://github.com/Slicer/Slicer
-    GIT_TAG        '5.2.2'
+    GIT_TAG        "v5.2.2"
    GIT_PROGRESS   1

See https://github.com/Slicer/Slicer/tree/v5.2.2

Single quotes are not supported as a way to delimit a string, there will be part of string.

For reference, see https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#quoted-argument

To illustrate:

$ cat /tmp/test.cmake
set(tag_1 'v5.2.2')
message("tag_1 [${tag_1}]")

set(tag_2 "v5.2.2")
message("tag_2 [${tag_2}]")
$ cmake -P /tmp/test.cmake
tag_1 ['v5.2.2']
tag_2 [v5.2.2]

I think I saw that something said that the directory creation could not be done because the file name was too long.

Could this be a git tag issue? Could it be a file path issue? (It seems that the path is not in local…)

Could it be a file path issue?

Based on the reported message, this is most likely the problem.

See https://slicer.readthedocs.io/en/latest/developer_guide/build_instructions/windows.html#set-up-source-and-build-folders

Could this be a git tag issue?

I don’t think so. Per explanation above, the tag v5.2.2 is valid.

For future reference, this git-based screencast demonstrates the complete process:

  • create project using cookiecutter
  • update CMakeLists.txt setting v5.2.2
  • configure

SlicerCustomAppTemplate-x2.5-min

1 Like

I think you’re right, the git_tag problem seems to have been passed.

But another road was restricted, so I have two questions.

Q1. Does the project name (currently: Cslicer) always have to be one letter?

Q2. When I cloned and built the normal 3d slicer, I asked for qt 5.15 or higher. Is SlicerCat the same?

edit :

image

Isn’t this length limit too tight?

The path to build is automatically specified, but how do I solve the problem that the length is limited?

image

I followed the material you posted above, but in my case, there is a difference in that I am building through the "VS community " because I am building on the window OS, and can this cause a character limit?

And there is no process to send “git init, git commit msg” in the description of slicerCAT. Is this a necessary process?

Q1. Does the project name (currently: Cslicer) always have to be one letter?

The project name can have multiple letters.

What need to be short is the build and source directories which are independent of the project name.

As described in the documentation, use a short build directory.

- C:/S/out/build
+C:/SR

Or any other short name (e.g AR, BR, ... where R` stand for Release, or D would stand for Debug …

When I cloned and built the normal 3d slicer, I asked for qt 5.15 or higher. Is SlicerCat the same?

To clarify SlicerCat is an example of custom application illustrating a blog post. See explanation here

Now this is clarified, the requirement of the custom application you are building are based on the version of Slicer are you specifying in GIT_TAG.

It turns out that Slicer v5.2.2 and main are both tested and built using Qt 5.15

I followed the material you posted above, but in my case, there is a difference in that I am building through the "VS community " because I am building on the window OS, and can this cause a character limit?

Use shorter path then, this is a limitation of windows.

To summarize, these would be all valid pair of source and build directories:

C:\A
C:\AR

C:\A0
C:\A0R

C:\B
C:\BR

C:\C
C:\CR
...

@jcfr

Even if you set the directory path to ‘C:\S’(i mean one letter), it seems that the build does not work.

There are one reasons why I am trying to create a CustomSlicer.
It is easy to ‘add a new function’ to the slicer through the ‘extension wizard’, but to ‘overriding an existing function’, the code of the slicer itself must be modified.

Can I use a customslicer to modify the basic functionality of the slicer without modifying the core? (e.g. When saving data, saving is disabled if certain conditions are not satisfied)

It is possible to create a new save function in the form of adding a shortcut, but the intention is to directly modify some of the basic functions of 3d slicer.

If CustomSlicer can’t serve the purpose above, I guess I’ll have to build the slicer itself.

…?

I really don’t know what it is

Edit :

1.normal 5.2.1 slicer build (access denied)


2. SlicerCAT build


3.normal 5.2.2 slicer (access denied)

:sob:

There are lots of mechanisms in Slicer for customizing the behavior without the need to change the Slicer core source code. If you don’t find how to modify any specific behavior without Slicer core modifications then let us know.

You can replace the save dialog by your own by registering a custom qSlicerFileDialog for NoFile type (that refers to the scene save dialog).

You can change the behavior an application exit (by default: ask for confirmation and if scene is changed then offer saving) as shown here.

Please confirm if I am misunderstanding the slicer.

New function: Can be implemented by adding a module through ‘extension wizard’

Modification of existing functions: There is a way to customize without modifying the sclier core.

So why does CustomSlicer (SlicerCAT) exist?
Is the purpose of using it to customize the logo, GUI environment, etc. to suit my purpose without simply changing the slicer core?

For example, there are two ways to save work in slicer as far as I know.

  • Click the Save icon.
  • Shortcut (“Ctrl+s”)

This method seems to be a way to modify the filediaglog that pops up when the ‘SaveIcon’ is clicked.
However, if ‘override’ is applied to a shortcut that has already been designated, it will not be applied.

==============================================

‘Save function modification’ is just an example of a case where an existing function needs to be modified.

I thought it would be simpler to use the ‘Extension Wizard’ if you were adding your own modules(New function ) to the Slicer, and if you were customizing an existing function(save, load dicom, etc … ) , it would be simpler to directly access and modify the implementation part of the function.

I understand that if you are developing in the form of a ‘plugin’ in the current slicer, it will be more convenient to use CustomSlicer in this case because it is difficult to modify the existing function. Did I misunderstand?

Then, the purpose of CustomSlicer is to activate only the functions that the user wants in the slicer to make it light, and for direct modification of existing functions, is there no difference between building and using ‘Slicer’ or ‘CustomSlicer’?