Load volume and segmentation issue

Operating system: Window 7
Slicer version: 4.8.1
Expected behavior:Load files and display successfully
Actual behavior: False

Hi again,

I am new to using Python Interactor in 3D Slicer. I am trying to load DCOM/NRRD file for CT Scan Images, load 2 separate segmentations of the same part of carotid. I want to smooth the segmentations and compare the two, and then save the views.

However, when I tried to load the volume. It keeps showing something like below:

slicer.util.loadVolume(slicer.app.slicerHome + “D:\projects\From_CAD\carotid_annotations\subject9\4 CarotidAngio 1.0 B30f.nrrd”)
False

Can I know what I did wrong here? Moreover, is there anyway to download slicer module to use it in SPyder/Anaconda?

Thank you so much for your help.

If you do this:

path = slicer.app.slicerHome + “D:\projects\From_CAD\carotid_annotations\subject9_1.3.12.2.1107.5.1.4.54143.30000006102300243942100012919\4 CarotidAngio 1.0 B30f.nrrd”
path

then you’ll see that the string contains an invalid path. It is not a surprise, as you concatenate a(n almost) valid path to the Slicer home directory. I say almost valid, because backslases are not handled properly unless you add an ‘r’ character before the first quote.

That said, if you want a python script that you can re-use, then using full paths is not a good practice. Your original idea to use the home folder is a good one, but then you need to complete it with a relative path, and not an absolute one.

1 Like

how to do the relative path setting?

Please ask the question in a new thread and make it specific so that it can be answered. Thanks!