# Update volume node

**URL:** <https://discourse.slicer.org/t/update-volume-node/7590>\
**Category:** Development\
**Created:** [July 15, 2019, 2:12pm UTC](https://discourse.slicer.org/t/update-volume-node/7590 "2019-07-15T14:12:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [July 15, 2019, 2:12pm UTC](https://discourse.slicer.org/t/update-volume-node/7590/1 "2019-07-15T14:12:33Z")

</div>

Hello,

I want to display data as i receive them. So i created a volume node and each time i receive data i do a SetAndObserveImageData with the new data. Like this :

> m\_streamNode-\>StartModify();  
> m\_streamNode-\>SetAndObserveImageData(imageData);  
> m\_streamNode-\>SetOrigin(originToRAS);  
> m\_streamNode-\>SetSpacing(pixelSpacingX,pixelSpacingY,scliceThickness);  
> m\_streamNode-\>SetIToRASDirection(rowToRAS[0],rowToRAS[1],rowToRAS[2]);  
> m\_streamNode-\>SetJToRASDirection(colToRAS[0],colToRAS[1],colToRAS[2]);  
> m\_streamNode-\>SetKToRASDirection(scliceToRAS[0],scliceToRAS[1],scliceToRAS[2]);  
> m\_streamNode-\>Modified();  
> m\_streamNode-\>CreateDefaultDisplayNodes();  
> m\_streamNode-\>CreateDefaultStorageNode();  
> m\_streamNode-\>UpdateScene(this-\>GetMRMLScene());  
> this-\>UpdateFromMRMLScene();

It kind of works but to have the display updated i need to hide and show the node, or to zoom on the window or click anything to have the window updated.

I searched and tried several kind of update command on the scene, node or displayNode. I did not manage to have it auto updated for now.

Is this possible ? Am I doing it the right way ?

---

<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:** [July 15, 2019, 2:32pm UTC](https://discourse.slicer.org/t/update-volume-node/7590/2 "2019-07-15T14:32:17Z")

</div>

Looks like you never call `EndModify` to match up with your `StartModifify` (these are used to make bulk changes to several nodes with only a single event)

---

<div class="post-metadata">

**Author:** ![rbahegne](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbahegne/32/4837_2.png) [@rbahegne](https://discourse.slicer.org/u/rbahegne)\
**Post date:** [July 16, 2019, 1:03pm UTC](https://discourse.slicer.org/t/update-volume-node/7590/3 "2019-07-16T13:03:11Z")

</div>

Ok, in fact my main problem was a thread problem. I receive image data via websocket running in a separate tread and that was this tread tryng to update the node. And the node hierachy is managed i guess by the main thread. The solution in a simple signal/slot and make sure that the operation on the node are made by the main thread.

I had various not predictable behaviours and this kind of error/warning :

> HasItemAttribute: Failed to find subject hierarchy item by ID 94424278946520  
> Input port 0 of algorithm vtkImageMapToWindowLevelColors(0x55914d195a70) has 0 connections but is not optional.  
> Input port 0 of algorithm vtkImageThreshold(0x55914d19d860) has 0 connections but is not optional.  
> QObject::startTimer: Timers cannot be started from another thread  
> QObject::killTimer: Timers cannot be stopped from another thread  
> Cannot make QOpenGLContext current in a different thread

One last question, it work without StartModify and EndModify, so what is the purpose of thoses functions ?

---

<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:** [July 16, 2019, 8:28pm UTC](https://discourse.slicer.org/t/update-volume-node/7590/4 "2019-07-16T20:28:42Z")

</div>

> [@rbahegne](#):
>
> One last question, it work without StartModify and EndModify, so what is the purpose of thoses functions ?

They are only for efficiency - should work the same without them.
