Slicer is now fully portable

Slicer can now be run from a portable drive (external drive, USB stick), along with all extensions, Python packages, settings, DICOM database, etc. - without installation. This can be used for easy distribution of Slicer to users, for example to be used as a free DICOM viewer for a folder full of DICOM files, or handing out preconfigured Slicer instance for a training course (see this related request). Since cache directory can be made local, too, the cache can be prepopulated with sample data sets, therefore the application does not need to access the internet for downloading them.

The feature is available in latest Slicer Preview Release. Updated documentation describes the exact rules how the application finds local and common settings. Implementation details are available here.

Example: How to set up Slicer as a portable viewer for a folder of DICOM files

By default, common settings (such as view settings, DICOM database folder location, various module preferences) are still taken from the user profile folder by default:

x:\myfolder\Slicer 4.13.0-2021-01-05>Slicer.exe --settings-path | more
c:/Users/andra/AppData/Roaming/NA-MIC/Slicer.ini

But if Slicer.ini file is copied to the Slicer home folder (including the organization subfolder NA-MIC) then Slicer will use this local settings file instead:

x:\myfolder\Slicer 4.13.0-2021-01-05>copy C:\Users\andra\AppData\Roaming\NA-MIC\Slicer.ini NA-MIC\Slicer.ini
1 file(s) copied.
x:\myfolder\Slicer 4.13.0-2021-01-05>Slicer.exe --settings-path | more
x:\myfolder\Slicer 4.13.0-2021-01-05/NA-MIC/Slicer.ini

After this local settings file is created, all changes in settings are recorded in this file. All paths that are specified relative to the application home folder will be kept as relative folders.

To change DICOM database to a local folder (that is portable along with the application), go to DICOM module, click “Database location”, a choose a folder that you created within the application home folder (for example, x:\myfolder\Slicer 4.13.0-2021-01-05/dicomdb). This change will be stored in the local Slicer.ini file, with a relative path:

[General]
DatabaseDirectory_0.6.3=dicomdb

Similarly, other absolute paths in Slicer.ini and Slicer-NNN.ini can be changed to relative paths (they will be resolved using the current application home folder as a basis).

After this, add DICOM images to the local DICOM database using DICOM module -> “Import DICOM files” button. Make sure to set “Import Directory Mode” -> Copy.

6 Likes

This awesome. Thank you to all folks involved in making it happen.

I do have a small suggestion: Would it be possible to incorporate his into the installer mechanism? For example, installer may ask the user if they intended this is as portable installation and copy all the necessary files and paths automatically? It will be fairly useful in windows envirornment where most users are not even aware of AppData folder (as it is hidden by default)

I would not complicate the installation process with any questions or decisions. It would complicate the installation process and would make user support harder for us (when we help a user we don’t know what installation options he chose). Also, there are dozens of settings to customize when you create a portable Slicer, so it would not be practical to implement all these as part of the installer.

Instead, you can create an extension that creates a portable version of the current Slicer instance. You could choose what directories you want to make portable, if you want to move or clone images in the DICOM database, etc. It could recreate the same setup for all operating systems (the extension could download Slicer core and extensions for all other operating systems and set up everything consistently).

I agree doing this after install time is better, then you could easily change it again later.

But wouldn’t this be better as part of the core instead of an extension? Seems like a pretty broadly applicable functionality.

It would be probably better to develop in a sandbox and then move it to the Slicer core if it is mature enough and we find that many users are interested in it.

I’ve seen applications where their download page allows picking to download an installer or the portable version (packaged in a ZIP).

Here’s Visual Studio Code’s download page https://code.visualstudio.com/download:
image

Oh, that’s right - this relocatable version won’t even need an installer. Sweet.

Yes, every installed Slicer is relocatable now (there is no specific “portable” version of Slicer).

It could be nice to provide download link for zip packages in addition to installer/dmg (CMake can create it already), because users often think that they need to install Slicer or that they need to have admin rights, while in fact they don’t.

Yeah I think it would be nice to set up download links just like Visual Studio Code there.

User Installer first for the majority use case. User’s don’t need admin rights which is helpful in an academic setting.

System Installer second for those wanting to install it for all their users of said computer. Instead of right-click run as admin, manually change path to Program Files, etc.

ZIP/Portable listed last for those lesser used cases, but still nice to have to move it anywhere such as on to a USB drive to shared.

2 Likes

This is very very good news for a hospital setting, where users often do not have the admin privileges necessary to run Slicer and administrators do not like the idea of downloaded data sets and extensions. Thanks for the realization! I would also support the idea of a zip download, as most portable applications come zipped …

4 Likes

The current installer does not require administrative privileges. It is essentially a self-extracting zip file, with a few additional steps (creates start menu shortcuts, sets up file associations, and writes uninstall information). Have you run into troubles running the installer on locked-down hospital computers?

2 Likes

A post was split to a new topic: Application failed to start on Windows 7

I’ve followed the directions -

  • moving silicer.ini from %APPDATA%/roaming/slicer/slicer.ini to %APPDATA/local/slicer5.6.2/slicer.ini

then

./slicer.exe --settings-path | more

And it still returns the original path (it also recreates the slicer.ini in the original folder it was moved from.

Any advice? Is the slicer home folder not the same folder that slicer.exe lives in?

I’d like to be able to keep all the extensions and data in one place and relocate it to another HDD.

Thanks!

Slicer.ini file was placed in the wrong folder, therefore it was not found and a new default one was created. The application home folder and location of the Slicer.ini file within it is described on the documentation page referred to in the first post.

Probably the easiest way to get the correct location is to run this command in Slicer’s Python console:

slicer.app.revisionUserSettings().fileName()

It will print the filename of the revision-specific settings file, such as this:

C:/Users/andra/AppData/Local/slicer.org/Slicer 5.7.0-2024-05-09/slicer.org/Slicer-32842.ini

You need to copy the Slicer.ini file into this same folder:

C:/Users/andra/AppData/Local/slicer.org/Slicer 5.7.0-2024-05-09/slicer.org/Slicer.ini