How to open a file as a LabelMap from command line?

Operating system: Linux
Slicer version: 4.5.0
Expected behavior: LabelMap file will open as a Volume with “LabelMap” checked in Volume Information, and will appear as Current LabelMapVolume in the display
Actual behavior: LabelMap file opens as a regular volume


Is there a way to specify that a given image/file is a LabelMap when opening the image/file with Slicer from the command line? Currently,

It should work well. What command did you use?

Have you tried this?

Indeed, it does not load as a label map even if I rename the file to include -label prefix.

@lassoan @Fernando the user is asking how to load as label map from the command line (passing the file name as an argument to the Slicer application from command line, I assume), not programmatically.

1 Like

This works for me on a recent nightly version:


Could you test if it works for you, too?

Or to use that from the command line:

~/Desktop/ --python-code "slicer.util.loadLabelVolume('/Users/pieper/data/shere.nrrd')"

Yes I was looking to load a label map from the command line, passing the file.nrrd as an argument to Slicer as @fedorov indicated.
@pieper’s solution is just what I was looking for! Thanks to all.

1 Like