Documentation/Nightly/Developers/FAQ/Extensions
For the latest Slicer documentation, visit the read-the-docs. |
Contents
- 1 Extensions
- 1.1 What is an extension description file ?
- 1.2 Can an extension contain different types of modules ?
- 1.3 Should the name of the source repository match the name of the extension ?
- 1.4 What is the Extensions Index ?
- 1.5 What is an API Key ?
- 1.6 How to obtain an API key to submit on the extension server ?
- 1.7 How to cache API credentials ?
- 1.8 Where can I find the extension templates ?
- 1.9 How to build an extension ?
- 1.10 Is there a way to automatically set CMAKE_OSX_* variables ?
- 1.11 How to run extension tests ?
- 1.12 How to package an extension ?
- 1.13 How are Superbuild extension packaged ?
- 1.14 How to upload an extension ?
- 1.15 How to build Slicer bundling extensions ?
- 1.16 Can an extension depend on other extensions ?
- 1.17 What are the extension specific targets: ExperimentalUpload, ExperimentalUploadOnly, ... ?
- 1.18 Is --launch flag available for a MacOSX installed Slicer.app ?
- 1.19 What is the difference between Documentation/Nightly/Modules and Documentation/Nightly/Extensions ?
- 1.20 Which URL should be associated with EXTENSION_HOMEPAGE metadata ?
- 1.21 How to check if an extension is built by Slicer Extensions build system ?
- 1.22 How often extensions are uploaded on the extensions server ?
- 1.23 Will an extension be uploaded if associated tests are failing ?
- 1.24 How do I associate a remote with my local extension git source directory ?
- 1.25 Which remote name is expected for extension git checkout ?
- 1.26 Why ExtensionWizard failed to describe extension: "script does not set 'EXTENSION_HOMEPAGE'" ?
- 1.27 Is project() statement allowed in extension CMakeLists.txt ?
- 1.28 Is call to "if(NOT Slicer_SOURCE_DIR)" required to protect "find_package(Slicer)" in extension CMakeLists.txt ?
- 1.29 Why is the --contribute option is not available with the ExtensionWizard ?
- 1.30 How dependent extensions are configured and built ?
- 1.31 How to package third party libraries ?
- 1.32 Can I use C++11/14/17 language features ?
- 1.33 How do I publish a paper about my extension ?
- 1.34 How to force a different Slicer revision for downloading different extension ?
- 1.35 How to address ITK test driver caught an ITK exception "Could not create IO object for reading file" ?
Extensions
What is an extension description file ?
See Description file description
Can an extension contain different types of modules ?
Yes. Extensions are used to package together all types of Slicer modules.
See also What_is_an_extension ?
Should the name of the source repository match the name of the extension ?
Assuming your extension is named AwesomeFilter
, generally, we suggest to name the extension repository SlicerAwesomeFilter
. Note that the following variations are also possible Slicer-AwesomeFilter
, Slicer_AwesomeFilter
, SlicerExtension-AwesomeFilter
, SlicerExtension_AwesomeFilter
.
We suggest you keep the Slicer prefix in the extension name when the extension is a Slicer interface to some third-party library (SlicerOpenIGTLink, SlicerElastix, SlicerOpenCV, …).
Doing so will minimize confusion by clearly stating that the code base is associated with Slicer.
What is the Extensions Index ?
What is an API Key ?
See http://en.wikipedia.org/wiki/Application_programming_interface_key
How to obtain an API key to submit on the extension server ?
In order to upload extensions on the slicer extensions server, it is required to:
Create an account on the extension server: http://slicer.kitware.com by clicking on the
Register
link in the top right cornerGo to NA-MIC community and click on
Join community
Retrieve your API key looking at your account details:
- Go to http://slicer.kitware.com. If needed, signin by clicking on
Login
in the top right corner. - Click on your name in the top right corner.
- Click on
My account
. - Click on
API
tab. Copy the
API Key
associated withDefault
application.There is currently a bug preventing api key containing non alpanumeric characters from being used.
If your Default api key contain for example a/
, try to delete the api key and regenerate one that is not containing "/" and is namedDefault
.
We are working on the issue to update the build system so that it properly escape "/" and also get in touch with Midas team so that api key containing just number and letter are generated.
- Go to http://slicer.kitware.com. If needed, signin by clicking on
This image shows the top portion of http://slicer.kitware.com after it has been expanded by clicking the Register
button.
How to cache API credentials ?
There is now a new feature that allow you to "cache" your credential [1]. If you set the two environment variables, MIDAS_PACKAGE_EMAIL
and MIDAS_PACKAGE_API_KEY
, you would simply need to configure your extension using:
cd MyExtension-build cmake -DCMAKE_BUILD_TYPE:STRING=Release -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build ../MyExtension make ExperimentalUpload
[1] http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=22457
Where can I find the extension templates ?
The module and extension templates are available in the Slicer source tree: https://github.com/Slicer/Slicer/tree/master/Utilities/Templates/
Using the Extension Wizard, you could easily create a new extension without having to copy, rename and update manually every files.
How to build an extension ?
Note: to build C++ extensions you need to have built Slicer from source on your machine; they cannot be built against a binary download.
Assuming that the source code of your extension is located in folder MyExtension
, this could be achieved doing:
Linux or MacOSX (Makefile) | Windows (Visual Studio) |
---|---|
Start a terminal. $ mkdir MyExtension-build $ cd MyExtension-build $ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DSlicer_DIR:PATH=/path/to/Slicer-Superbuild/Slicer-build ../MyExtension $ make MaxOSX: Extension must be configured specifying
|
Run CMake (cmake-gui) from the Windows Start menu.
Start Windows Explorer. Need help?
|
Is there a way to automatically set CMAKE_OSX_* variables ?
Within your extension, including the ConfigurePrerequisites
component before the project statement should ensure it uses the same CMAKE_OSX_* variables as Slicer:
find_package(Slicer COMPONENTS ConfigurePrerequisites REQUIRED) project(Foo) [...] find_package(Slicer REQUIRED) include(${Slicer_USE_FILE}) [...]
Note: The ConfigurePrerequisites
component should be considered experimental and could change without notice.
For more details, see here.
How to run extension tests ?
Assuming your extension has been built into folder MyExtension-build
, this could be achieved doing:
Linux or MacOSX (Makefile) | Windows (Visual Studio) |
---|---|
Start a terminal. $ ctest -j<NUMBEROFCORES> |
To run all tests, start Windows Explorer. Need help?
To run test individually, open Command Line Prompt. Need help? > cd C:\path\to\MyExtension-build > ctest -R NameOfTest -V
To debug individual tests.
|
How to package an extension ?
Assuming your extension has been built into folder MyExtension-build
, this could be achieved doing:
Linux or MacOSX (Makefile) | Windows (Visual Studio) |
---|---|
Start a terminal. $ make package |
Start Windows Explorer. Need help?
|
How are Superbuild extension packaged ?
Extensions using the Superbuild mechanism build projects in two steps:
- First, the project dependencies are built in an outer-build directory.
- Then, the project itself is built in an inner-build directory
Extensions can use the Superbuild mechanism. However, developers have to be careful that the packaging macros clean the project before reconfiguring it. This means that if ones uses the Slicer extension packaging macros inside the inner-build directory, when packaging and uploading the extension package, the project will be reconfigured, and variables passed from the outer-build directory will be lost. If the project only depends on libraries that Slicer builds, this is not an issue. If the project has specific dependencies that Slicer does not compile on its own, the developer should be careful to instantiate the Slicer extension packaging macros only in the outer-build directory. This only means that in the latter case, tests should be instantiated in the outer-build directory to allow the Slicer extension building process to test the extension before uploading the extension and the tests results.
How to upload an extension ?
If not already done, send an email on the slicer developers list asking to be granted write permission on the experimental folder.
To: slicer-devel@bwh.harvard.edu Subject: Extension NAME-OF-YOUR-EXTENSION - Asking permission to write to the Experimental folder Hi, This extension will allow to [...] Could you grant user YourUserName write access to the Experimental folder ?
Assuming your extension has been built and packaged into folder MyExtension-build
, this could be achieved by first re-configuring the project providing your midas credentials and then building the packageupload
target:
Linux or MacOSX (Makefile) | Windows (Visual Studio) |
---|---|
Start a terminal. $ cmake -DMIDAS_PACKAGE_EMAIL:STRING=<YOUR-MIDAS-LOGIN> -DMIDAS_PACKAGE_API_KEY:STRING=<YOUR-MIDAS-APIKEY> . $ make packageupload |
Run CMake (cmake-gui) from the Windows Start menu.
Start Windows Explorer. Need help?
|
Alternatively, you could also cache your API credentials.
How to build Slicer bundling extensions ?
Configuring Slicer specifying option EXTENSION_SOURCE_DIRS as a list of extension source directories will do it. Multiple extension source paths need to be separated using semicolons.
Note that Superbuild-type extensions expected to be bundled have to be updated to explicitly list Slicer dependencies. More specifically, the External_*.cmake files that were implicitly depending on project built by Slicer have to be updated.
For example, the file External_VTKRenderingOpenVR.cmake available in the SlicerVirtualReality extension was updated to append VTKv9 to the list of dependencies if bundled in Slicer:
[...] set(${proj}_DEPENDENCIES OpenVR) if(DEFINED Slicer_SOURCE_DIR) list(APPEND ${proj}_DEPENDENCIES VTKv9) endif() [...]
Can an extension depend on other extensions ?
Yes. An ExtensionFoo
can depend on ExtensionBar
The dependency should be specified as a list by setting the variable EXTENSION_DEPENDS
in the extension CMakeLists.txt
.
For example, if you have ModuleA
, ModuleB
and ModuleC
and ModuleA
can be used as standalone one. You could create the following extensions:
Extension1
containingModuleA
Extension2
containingModuleB
andModuleC
and add the following variable to Extension2/CMakeLists.txt
:
set(EXTENSION_DEPENDS Extension1)
User:
- If user installs
Extension2
,Extension1
will automatically be installed first.
Developer:
- The generated extension description file have a
depends
field. See here for details. - The extension framework will build the extension in order. When building
Extension2
, it will pass the CMake option-DExtension1_DIR:PATH=/path/to/Extension1-build
.
What are the extension specific targets: ExperimentalUpload, ExperimentalUploadOnly, ... ?
Slicer extension build system provides the developer with a set of convenient targets allowing to build and upload extensions.
Target name | Description |
---|---|
test or BUILD_TESTS |
Locally execute the test |
package or PACKAGE |
Locally package the extension |
packageupload |
Locally package and upload the extension |
Experimental |
Configure, build, test the extension and publish result on CDash. |
|
|
|
packageupload . Removed in r26271 |
Is --launch flag available for a MacOSX installed Slicer.app ?
On MacOSx, running Slicer with the --help argument does NOT list the usual launcher related options.
$ ./Slicer.app/Contents/MacOS/Slicer --help Usage Slicer [options] Options --, --ignore-rest Ignores the rest of the labeled arguments following this flag. (default: false) -h, --help Display available command line arguments. [...] --version Displays version information and exits.
To provide some background information, when generating the package that will be distributed, an application bundle Slicer.app
is created. As explained here, a bundle is a directory with a standardized hierarchical structure that holds executable code and the resources used by that code. It means that since all libraries contained within a bundle are referenced relatively to the location of either the CLI or the Slicer executable, the use of launcher does NOT make sens.
To help fixing-up the libraries, executables and plugins so that they reference each other in a relative way, CMake provides us with the BundleUtilities module.
This module is used in two situations:
- Fixup of Slicer application itself. See SlicerCPack.cmake#L36-68 and SlicerCPackBundleFixup.cmake.in
- Fixup of an extension package. See SlicerExtensionCPack.cmake#L126-143 and SlicerExtensionCPackBundleFixup.cmake.in
What is the difference between Documentation/Nightly/Modules and Documentation/Nightly/Extensions ?
As suggested by the namespace names:
- All module documentation pages should be located under
Documentation/Nightly/Modules
- All extension documentation pages should be located under
Documentation/Nightly/Extensions
For example, if an an extension named DoSomethingGreat
bundles three modules ModuleA
, ModuleB
and ModuleC
. The following pages should be created:
Documentation/Nightly/Extensions/DoSomethingGreat
Documentation/Nightly/Modules/ModuleA
Documentation/Nightly/Modules/ModuleB
Documentation/Nightly/Modules/ModuleC
In case your extension bundles only one module, the extension name is expected to match the module name. For example, if your extension is named DoSomethingAwesome
, the associated module is expected to be named DoSomethingAwesome
. The following pages will then be created:
Documentation/Nightly/Extensions/DoSomethingAwesome
Documentation/Nightly/Modules/DoSomethingAwesome
where page Extensions/DoSomethingAwesome
redirect to page Modules/DoSomethingAwesome
.
To setup a redirection, simply add the following text to page Extensions/DoSomethingAwesome
:
#REDIRECT [[Documentation/Nightly/Modules/DoSomethingAwesome]]
For an example, see here
More details about redirection are available here: http://www.mediawiki.org/wiki/Help:Redirects
Which URL should be associated with EXTENSION_HOMEPAGE metadata ?
Extensions available through the Slicer Extensions Catalog are expected to have a page created under the Nightly
documentation namespace. The corresponding URL should be associated with the EXTENSION_HOMEPAGE
metadata.
For example:
set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DoSomethingGreat")
*set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/DoSomethingAwesome")
Note that this also apply for extension bundling only one module. Indeed, in this case the page will redirect to the appropriate module page. For example: https://www.slicer.org/wiki/Documentation/Nightly/Extensions/SkullStripper == How to rename an extension to add new features ? ==
If you created an extension to perform Task1, but later on, your module is getting more generic and you add some other tasks, the name of your extension might change. In order to rename, your extension, you should:
- Remove your old extension from the ExtensionsIndex
- Then, submit your extension again (including new features) with a new name
- Make also sure to add redirection from the "deprecated" module documentation to the "new" pages. On the Slicer wiki, this could be using the #REDIRECT instruction.
How to check if an extension is built by Slicer Extensions build system ?
Sometimes an extension could be built either as a standalone package or as a Slicer extension.
To differenciate the two cases, the developer could check for the value of:
<ExtensionName>_BUILD_SLICER_EXTENSION
This variable will be set to ON when the extension is built by the Slicer Extensions build system.
How often extensions are uploaded on the extensions server ?
Slicer extensions are built and uploaded on the extensions server every day.
To be more specific, the frequency of extensions build and upload associated with:
- Slicer nightly package occurs every night
and also continuously during the day. - Slicer 4.10 lastest stable release package occurs every night.
All extensions associated can be expected by mid-morning. Checking the dashboard will give a definite answer. Check this page to learn how to easily get the status of any given extension.
Will an extension be uploaded if associated tests are failing ?
Independently of the extension test results, if the extension could be successfully packaged, it will be uploaded on the extensions server.
How do I associate a remote with my local extension git source directory ?
1) Start a terminal (or Git Bash on Windows)
2) Get the associated SSH remote url. Need help ?
3) Associate the remote URL with your local git source tree
git remote add origin git://github.com/<username>/MyExtension
Which remote name is expected for extension git checkout ?
When packaging an extension and generating the associated description file, the system will look for a remote named origin
.
In case you get the error reported below, you will have to either rename or add a remote. Need help ?
CMake Warning at /path/to/Slicer/CMake/FindGit.cmake:144 (message): No remote origin set for git repository: /path/to/MyExtension Call Stack (most recent call first): /path/to/Slicer/CMake/SlicerMacroExtractRepositoryInfo.cmake:99 (GIT_WC_INFO) /path/to/Slicer/CMake/SlicerExtensionCPack.cmake:55 (SlicerMacroExtractRepositoryInfo) CMakeLists.txt:25 (include)
Why ExtensionWizard failed to describe extension: "script does not set 'EXTENSION_HOMEPAGE'" ?
The issue is that the your extension has a "non standard" layout and the wizard was now way of extracting the expected information.
Similar issue has been discussed and reported for the "SPHARM-PDM" or UKF extension.
First half of the solution would be to move the metadata from Common.cmake to CMakeLists.txt as it is done in [1]
Then, you could make sure there is a project() statement by following what is suggested in [2]
If you prefer not to re-organize your extension, you could still contribute extension description file. See here for details.
[1] http://www.nitrc.org/plugins/scmsvn/viewcvs.php?view=rev&root=spharm-pdm&revision=228
[2] http://www.na-mic.org/Bug/view.php?id=3737#c12081
Is project() statement allowed in extension CMakeLists.txt ?
Following Slicer r22038, the project statement is required.
Is call to "if(NOT Slicer_SOURCE_DIR)" required to protect "find_package(Slicer)" in extension CMakeLists.txt ?
Following Slicer r22063, protecting call to find_package(Slicer)
with if(NOT Slicer_SOURCE_DIR)
is optional and should be removed to keep code simpler and easier to maintain.
Before:
cmake_minimum_required(VERSION 2.8.9) if(NOT Slicer_SOURCE_DIR) find_package(Slicer COMPONENTS ConfigurePrerequisites) endif() if(NOT Slicer_SOURCE_DIR) set(EXTENSION_NAME EmptyExtensionTemplate) set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/EmptyExtensionTemplate") set(EXTENSION_CATEGORY "Examples") set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)") set(EXTENSION_DESCRIPTION "This is an example of extension bundling N module(s)") set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/EmptyExtensionTemplate/EmptyExtensionTemplate.png?revision=21746&view=co") set(EXTENSION_SCREENSHOTURLS "http://www.slicer.org/w/img_auth.php/4/42/Slicer-r19441-EmptyExtensionTemplate-screenshot.png") endif() if(NOT Slicer_SOURCE_DIR) find_package(Slicer REQUIRED) include(${Slicer_USE_FILE}) endif() add_subdirectory(ModuleA) if(NOT Slicer_SOURCE_DIR) include(${Slicer_EXTENSION_CPACK}) endif()
After:
cmake_minimum_required(VERSION 2.8.9) find_package(Slicer COMPONENTS ConfigurePrerequisites) project(EmptyExtensionTemplate) set(EXTENSION_HOMEPAGE "https://www.slicer.org/wiki/Documentation/Nightly/Extensions/EmptyExtensionTemplate")set(EXTENSION_CATEGORY "Examples") set(EXTENSION_CONTRIBUTORS "Jean-Christophe Fillion-Robin (Kitware)") set(EXTENSION_DESCRIPTION "This is an example of empty extension") set(EXTENSION_ICONURL "http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Extensions/Testing/EmptyExtensionTemplate/EmptyExtensionTemplate.png?revision=21746&view=co") set(EXTENSION_SCREENSHOTURLS "http://www.slicer.org/w/img_auth.php/4/42/Slicer-r19441-EmptyExtensionTemplate-screenshot.png") find_package(Slicer REQUIRED) include(${Slicer_USE_FILE}) add_subdirectory(ModuleA) include(${Slicer_EXTENSION_CPACK})
Why is the --contribute option is not available with the ExtensionWizard ?
Wizard contribute option is available only (1) if Slicer is built with OpenSSL support or (2) directly from the nightly.
To build Slicer with SSL support, you need to build (or download) Qt with SSL support and configure Slicer with -DSlicer_USE_PYTHONQT_WITH_OPENSSL:BOOL=ON
How dependent extensions are configured and built ?
If an ExtensionB depends on an ExtensionA, ExtensionA should be listed as dependency in the metadata of ExtensionB.
This can be done setting EXTENSION_DEPENDS
in the CMakeLists.txt
or by specifying depends
field in the description file.
Doing so will ensure that:
- (1) the extension build system configure the extensions in the right order
- (2) ExtensionB is configured with option
ExtensionA_DIR
.
How to package third party libraries ?
Extensions integrating third party libraries should follow the SuperBuild extension template.
Each third party libraries will be configured and built using a dedicated External_MyLib.cmake
file, the install location of binaries and libraries should be set to Slicer_INSTALL_BIN_DIR
and Slicer_INSTALL_LIB_DIR
.
Also, starting with r25959, extension can package python modules and packages using PYTHON_SITE_PACKAGES_SUBDIR
CMake variable to specify the install destination.
These relative paths are the one that the extensions manager will consider when generating the launcher and application settings for a given extension.
Can I use C++11/14/17 language features ?
We try to balance between compatibility and using new features. As a result, currently C++11 features are allowed, but usage of C++14/17 language features are discouraged in extensions (relying on C++14/17 features may lead to build errors on some build configurations).
If your extension can be compiled as a standalone project where you would like to use newer feature, you could rely on CMake detecting compile features. See cmake-compile-features for more details.
See the labs topic on upgrading compiler infrastructure for additional information/status.
How do I publish a paper about my extension ?
Consider publishing a paper describing your extension. This link contains a list of journals that publish papers about software:
http://www.software.ac.uk/resources/guides/which-journals-should-i-publish-my-software
How to force a different Slicer revision for downloading different extension ?
Since extensions available from the Extensions Manager are associated with a particular slicer revision, for testing purpose it is practical to override the current revision. This can be done by explicitly setting a revision number.
>>> extensionManagerModel = slicer.app.extensionsManagerModel() >>> extensionManagerModel.slicerRevision = "25742"
On other approach is to re-configure Slicer setting the Slicer_FORCED_WC_REVISION option.
How to address ITK test driver caught an ITK exception "Could not create IO object for reading file" ?
If the following execption is reported when trying to run tests associated with a CLI modules:
ITK test driver caught an ITK exception: itk::ImageFileReaderException (0x1bd8430) Location: "unknown" File: /path/to/Slicer-SuperBuild/ITK/Modules/IO/ImageBase/include/itkImageFileReader.hxx Line: 139 Description: Could not create IO object for reading file /path/to/image.nrrd Tried to create one of the following: MRMLIDImageIO You probably failed to set a file suffix, or set the suffix to an unsupported type.
It most likely means that the test driver is not linking against ITKFactoryRegistration library and/or registrering the ITK factories. To address this, the test driver should be updated:
- (1) to link against ${SlicerExecutionModel_EXTRA_EXECUTABLE_TARGET_LIBRARIES}
- (2) to include itkFactoryRegistration.h
- (3) to call itk::itkFactoryRegistration(); in its main function
For more details, read What is the ITKFactoryRegistration library ?