# Loading an MRB file

**URL:** <https://discourse.slicer.org/t/loading-an-mrb-file/5116>\
**Category:** Development\
**Created:** [December 17, 2018, 9:53pm UTC](https://discourse.slicer.org/t/loading-an-mrb-file/5116 "2018-12-17T21:53:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [December 17, 2018, 9:53pm UTC](https://discourse.slicer.org/t/loading-an-mrb-file/5116/1 "2018-12-17T21:53:45Z")

</div>

Hello,  
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](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?

Thanks,  
Sara

---

<div class="post-metadata">

**Author:** ![Sam\_Horvath](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sam_horvath/32/3092_2.png) [@Sam\_Horvath](https://discourse.slicer.org/u/Sam_Horvath)\
**Post date:** [December 18, 2018, 1:34pm UTC](https://discourse.slicer.org/t/loading-an-mrb-file/5116/2 "2018-12-18T13:34:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 18, 2018, 1:53pm UTC](https://discourse.slicer.org/t/loading-an-mrb-file/5116/3 "2018-12-18T13:53:21Z")

</div>

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:

```auto
loadedNodes = []

@vtk.calldata_type(vtk.VTK_OBJECT)
def onNodeAdded(caller, event, calldata):
    loadedNodes.append(calldata)

sceneObservationId = slicer.mrmlScene.AddObserver(slicer.vtkMRMLScene.NodeAddedEvent, onNodeAdded)
slicer.util.loadScene('c:/tmp/MyScene.mrb')
slicer.mrmlScene.RemoveObserver(sceneObservationId)

print(loadedNodes)

```

---

<div class="post-metadata">

**Author:** ![smrolfe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/smrolfe/32/3659_2.png) [@smrolfe](https://discourse.slicer.org/u/smrolfe)\
**Post date:** [December 19, 2018, 11:15pm UTC](https://discourse.slicer.org/t/loading-an-mrb-file/5116/4 "2018-12-19T23:15:11Z")

</div>

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.
