Loading an MRB file

I’m trying to load an MRB file into Slicer using the following snippet:

loadedNodes = vtk.vtkCollection()
fileProperties = {}
fileProperties[‘fileName’] = ‘…localData/Slicer/RemoteIO/mCT_mouse.mrb’
success = slicer.app.coreIOManager().loadNodes(‘SceneFile’, fileProperties, loadedNodes)

the MRB file I’m using for testing can be downloaded from: http://slicermorph.fhl.washington.edu/mCT_mouse.mrb

When I try this, the files are loaded into slicer, but the nodes are not returned in ‘loadedNodes’.Trying this code with a .nrrd file returns the correct nodes. Is this expected behavior?


Some thoughts:

What is the value of the success variable after attempting the load? are you specifying the full path when you run the snippet?

Would slicer.util.loadScene work for your application?

1 Like

The scene reader does not provide a list of all nodes that are loaded, only a success/fail flag. However, you can easily get the list of loaded nodes by adding an observer to the scene:

loadedNodes = []

def onNodeAdded(caller, event, calldata):

sceneObservationId = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, onNodeAdded)

1 Like

Thanks @Sam_Horvath. The success variable was ‘True’ and slicer.util.loadScene() does work.

Thanks @lassoan for clarifying how the scene reader works. I now understand that the Sample Data module was checking for a list of loaded nodes after importing my MRB file because the parameters were not set properly when registering the custom data set.