I am having the following problems under Windows when programmatically loading a volume. Always the wrong volume is loaded into Slicer. The directory that I shared here has two volumes:
a. MRI Prostate image (two files)
b. ZFrame template (one file)
Please try the following on Windows:
load prostate image
This is supposed to load the prostate volume, but it doesn’t. It loads the template image which is located in the same directory.
prostateVolume = slicer.util.loadVolume(‘a000001.dcm’, returnNode=True)
It works with the setting singleFile to True but that doesn’t solve the problem since the dataset has more than one slice. a000001.dcm and a000002.dcm belong to the same dataset.
And it doesn’t explain why it works as expected on Ubuntu and MacOS without even adding anything else than I am using in the first post.
When I manually selected the file in the “add data”-dialog and set explicitly description to “Volume” then it works even when I uncheck property singleFile
I’ve debugged into this and the problem is caused by using backslash path separator character or drive letter capitalization. I’ve made file comparison mechanism more robust (normalizing filenames before comparison) in r26146, which should fix the problem.
I didn’t realize this is going on. I would definitely switch to the DICOM plugin. Most likely, that util function is just using straight ITK reader, since it is the same call that is used to read non-DICOM data.
Ultimately, scalar images are always read by ITK reader. The difference is how the list of files is determined and how they deal with inconsistencies (varying spacing, non-parallel slices, etc).
ScalarVolume DICOM plugin requires a list of files (files may spread across various folders) and the plugin sorts all the files and provides the file list to the ITK reader.
When you load a DICOM volume using slicer.util.loadVolume then the ITK reader receives only a single filename and the ITK reader determines the file list (it considers filenames in the same folder, checks series UID match, and sorts based on image position patient).