Function slicer.util.loadVolume does not accept periods in the filename

If the file has a period in its name, e.g. word1.word2.tif, then the loaded volume using slicer.util.loadVolume function will have its name as just word1.

Is this intended?

Tested on 4.11.20210226 r29738.

When you load a file using the GUI then there is a mechanism that strips known file extensions for the selected reader and allows the user to edit it before loading.

If you load a node programmatically then a simpler mechanism is used that removes the complete file extension.

If you want to remove only the longest known file extension then you can use the storage node’s GetFileNameWithoutExtension() method:

volumeNode = slicer.util.loadVolume(r'c:\tmp\word1.word2.tif')
1 Like