# Ways to load nodes into Slicer scene WITHOUT displaying them immediately

**URL:** https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138
**Category:** Development
**Created:** [September 27, 2017, 8:57pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138 "2017-09-27T20:57:08Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![che85](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/che85/32/636_2.png) [@che85](https://discourse.slicer.org/u/che85)
#### Post date: [September 27, 2017, 8:57pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/1 "2017-09-27T20:57:08Z")

</div>

Hi Developers,

I am wondering, if it’s possible to load nodes (volume, fiducial) into a Slicer scene without having them displayed immediately within the slice views.

I am asking this, because I want to load a bunch of data programmatically but I don’t want the slice views to flicker for each loaded volume.

Are there any properties that can be set on

```
slicer.util.loadVolume(...)
slicer.util.loadLabelVolume(...)
slicer.util.load...(...)
```

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [September 27, 2017, 9:46pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/2 "2017-09-27T21:46:41Z")

</div>

There’s a flag on the SliceCompositeNode to turn this off on a per-slice view basis. It could be good to have some slicer.util or other place to turn them all on or off, but I don’t think that exists yet.

> <https://github.com/Slicer/Slicer/blob/703557e658c976f7d146ff4c8408ef43ec7dea00/Libs/MRML/Logic/vtkMRMLApplicationLogic.cxx#L124>

---

<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: [September 29, 2017, 1:18am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/3 "2017-09-29T01:18:56Z")

</div>

Background volume and FOV reset on volume loading has bothered me a couple of times, too. I’ve now added a new ‘show’ option (enabled by default) to the `Add data` dialog for volumes that can be unchecked if the user does not want the volume to be propagated to slice views. See pull request here: [https://github.com/Slicer/Slicer/pull/800](https://github.com/Slicer/Slicer/pull/800)

---

<div class="post-metadata">

### Author: ![che85](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/che85/32/636_2.png) [@che85](https://discourse.slicer.org/u/che85)
#### Post date: [October 2, 2017, 2:33pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/4 "2017-10-02T14:33:46Z")

</div>

Great! Thanks for adding this option Andras.

---

<div class="post-metadata">

### Author: ![mschumaker](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschumaker/32/1395_2.png) [@mschumaker](https://discourse.slicer.org/u/mschumaker)
#### Post date: [October 13, 2017, 6:15pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/5 "2017-10-13T18:15:16Z")

</div>

Thank you, that’s a great feature. I had asked something very similar to this post a couple of months ago. If I load a volume with ‘show’ set to False, how would I then display it in one (and only one) of the slice views?

> [@Override automatic display of newly-loaded volume?](https://discourse.slicer.org/t/override-automatic-display-of-newly-loaded-volume/846):
>
> Writing my first module. When I use the DICOM widget to load an image set, and use a qMRMLNodeComboBox, the newly-loaded node is automatically displayed in the Red, Yellow, and Green MRML slice views. I’m hoping to override this action, so that the newly-loaded volume is only displayed in either (but only one of) the Red or Yellow view. How would I do that? Thanks. Code is below: def setup(self): ScriptedLoadableModuleWidget.setup(self) #Link to image database for SSFP self.LoadS…

---

<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: [October 13, 2017, 7:40pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/6 "2017-10-13T19:40:14Z")

</div>

You can use slicer.util.setSliceViewerLayers

---

<div class="post-metadata">

### Author: ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)
#### Post date: [August 15, 2019, 11:06am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/7 "2019-08-15T11:06:09Z")

</div>

> [@lassoan](#):
>
> slicer.util.setSliceViewerLayers

Hi Andras,  
I am loading the model node and want it to be displayed automatically using scripting. I am loading it using python scripting. but I need to actually go to models and then click on it to display it but I need an automatic way.= thorugh scripting. how to? please suggest.

Thank you

---

<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: [August 15, 2019, 3:14pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/8 "2019-08-15T15:14:57Z")

</div>

If you want to load a volume without showing it, add `show=False` argument to `slicer.util.loadVolume`. See list of all options [here](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.loadVolume).

---

<div class="post-metadata">

### Author: ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)
#### Post date: [August 16, 2019, 7:49am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/9 "2019-08-16T07:49:01Z")

</div>

loadNodeFromFile `returnNode` argument is deprecated. Loaded node is now returned directly if `returnNode` is not specified.

What does this mean I get this when runing the script for loading a modelnode

outputVolume = slicer.util.loadModel(filepath+"\simplification.ply",True)

Also please tell me how to change the 3d display representation of a modelnode in scripting. Example from surface to surface with edges

---

<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: [August 16, 2019, 11:47am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/10 "2019-08-16T11:47:06Z")

</div>

> [@Saima](#):
>
> loadNodeFromFile `returnNode` argument is deprecated. Loaded node is now returned directly if `returnNode` is not specified.
> 
> What does this mean I get this when runing the script for loading a modelnode

This means you don’t need to specify `returnNode=True` anymore. If you don’t specify it then only one value, the volume node is returned. This is just a small change in the API to make the syntax simpler.

> [@Saima](#):
>
> Also please tell me how to change the 3d display representation of a modelnode in scripting. Example from surface to surface with edges

You can change it in the [display node](http://apidocs.slicer.org/master/classvtkMRMLSegmentationDisplayNode.html#aa3b52c05c86a143c9636bf26c8b2d41b) of the segmentation node.

```
segmentationNode.GetDisplayNode().SetOpacity2DOutline() 

```

By default outline is displayed, so if you don’t see it then it may be because it is occluded by some other content (for example, after you imported the segmentation from labelmap node, you did not hide or delete the labelmap node).

---

<div class="post-metadata">

### Author: ![Saima](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Saima](https://discourse.slicer.org/u/Saima)
#### Post date: [August 22, 2019, 4:47am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/11 "2019-08-22T04:47:02Z")

</div>

Hi Andras,  
I need to do the following with scripting.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/d/0d4da30e9023ce23d3a084e19e002fa3ce1417f1.png)

On the left side in the REpresentation I am selecting surface with edges. I need to do it through scripting on the model surface. Any suggestions?

nn = n.GetModelDisplayNode()  
nn.EdgeVisibilityOn()

I used the above it displays the edges. Is this true for every model either surface or volumetric mesh model.  
is there any page online of scripting available for help?

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/alex_vergara/32/15205_2.png) [@Alex\_Vergara](https://discourse.slicer.org/u/Alex_Vergara)
#### Post date: [August 22, 2019, 7:59am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/12 "2019-08-22T07:59:56Z")

</div>

> [@Saima](#):
>
> is there any page online of scripting available for help?

Use this [Documentation/Nightly/ScriptRepository - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository)

---

<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: [August 22, 2019, 1:44pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/13 "2019-08-22T13:44:40Z")

</div>

C++ API documentation is available here: [https://apidocs.slicer.org/](https://apidocs.slicer.org/)

For example, documentation of model display node: [https://apidocs.slicer.org/master/classvtkMRMLModelDisplayNode.html](https://apidocs.slicer.org/master/classvtkMRMLModelDisplayNode.html)

---

<div class="post-metadata">

### Author: ![ibro45](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ibro45/32/78047_2.png) [@ibro45](https://discourse.slicer.org/u/ibro45)
#### Post date: [September 26, 2024, 2:52am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/14 "2024-09-26T02:52:43Z")

</div>

Thank you!

`show=False` doesn’t seem to exist for `slicer.util.loadSegmentation`, is there any workaround?

---

<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: [September 26, 2024, 4:41am UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/15 "2024-09-26T04:41:51Z")

</div>

You can hide the segmentation immediately after loading. If it still shows up for a moment then you can pause rendering before you start loading and resume rendering after you completed loading and made the segmentation hidden.

Alternatively, you can save the segmentation and its display node into a scene (.mrml or .mrb file) and load that. Display properties that are specified in the display node are applied immediately. If the visibility is turned off in the display node then the segmentation will not be displayed upon loading the scene.

---

<div class="post-metadata">

### Author: ![ibro45](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ibro45/32/78047_2.png) [@ibro45](https://discourse.slicer.org/u/ibro45)
#### Post date: [September 26, 2024, 3:36pm UTC](https://discourse.slicer.org/t/ways-to-load-nodes-into-slicer-scene-without-displaying-them-immediately/1138/16 "2024-09-26T15:36:48Z")

</div>

Thank you so much, `slicer.app.layoutManager().setRenderPaused(True)` was perfect!
