I was trying to get all the children of a folder in the subject hierarchy node using the convenience method slicer.mrmlScene.GetSubjectHierarchyNode. It didn’t work and I got the error:
I’m relatively new to slicer so I’m not sure if this is correct. If it is, is there something I can do to patch it up? If not, could you please show me how to use this function?
Thank you very much in advance for your answers! Cheers,
I now realized I didn’t write the correct function that is not working for me, which is slicer.util.getSubjectHierarchyItemChildren()
I am using Slicer’s Python interpreter in Slicer 4.11.20210226 r29738 / 7a593c8
To reproduce the error, you just need to write that function in the interpreter, after which I get the error mentioned before.
I also tried importing slicer before running that command, but it keeps throwing the same error. If I copy the function in the GitHub link that I provided in the interpreter, everything works, so I am not sure why it is having trouble finding the slicer module.
Good catch, somehow the import slicer, vtk statement was missed in that function. I’ve added it now and the fix will be available in the Slicer Preview Release from tomorrow. You can fix this now on your computer by updating this file.