# "Volume Information" in "Volumes" module not updated for modified volumes

**URL:** <https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856>\
**Category:** Support\
**Created:** [August 4, 2020, 6:03pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856 "2020-08-04T18:03:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [August 4, 2020, 6:03pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/1 "2020-08-04T18:03:55Z")

</div>

When I clone a volume node and then modify the array values, the “Volume Information” section shows outdated information and I can’t find a way to get it to update.

```
volNode = getNode('vtkMRMLScalarVolume1')
newVolNode = slicer.modules.volumes.logic().CloneVolume(slicer.mrmlScene, volNode, 'copiedVolume')
newVolArray = slicer.util.arrayFromVolume(newVolNode)
newVolArray[newVolArray>0] = 0
newVolNode.Modified()

```

After this code, the newVolumeNode() has a maximum value of 0, but “Volume Information” still shows it to have a “Scalar Range” up to whatever value the original volNode had. The actual display of the volume in the slice views shows the modified voxel values, and in all other relevant ways the volume is updated, but there seems to be nothing which updates the “Volume Information”.

---

<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 4, 2020, 6:19pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/2 "2020-08-04T18:19:06Z")

</div>

You need to call `slicer.util.arrayFromVolumeModified(newVolNode)` to indicate that you have finished with your modifications. See [documentation](https://slicer.readthedocs.io/en/latest/developer_guide/slicer.html#slicer.util.arrayFromVolume) for details.

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [August 5, 2020, 12:29am UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/3 "2020-08-05T00:29:07Z")

</div>

Thanks, I saw the call to volNode.Modified() somewhere, and thought that was all I needed to do to trigger updates. My mistake! Thanks for your help!

---

<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 5, 2020, 1:07am UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/4 "2020-08-05T01:07:46Z")

</div>

`volNode.Modified()` only indicates that metadata stored in the volume node’s attributes are changed (but not that pixels are changed).

---

<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:** [January 11, 2021, 7:11pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/5 "2021-01-11T19:11:17Z")

</div>

Hello, i kind of have a similar problem but i use C++ and after a long search in the documentation I failed to find the C++ counterpart of `slicer.util.arrayFromVolumeModified(newVolNode)`

Does it really exist ? Or have a different name ?

---

<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:** [January 11, 2021, 7:14pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/6 "2021-01-11T19:14:31Z")

</div>

No, it doesn’t exist. You can just look at the corresponding python implementation and make the same calls. Usually it’s just one or two `Modified()` calls. Note you only need this if you change the array directly. If you work with VTK pipelines it’s typically automatic.

---

<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:** [January 11, 2021, 7:24pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/7 "2021-01-11T19:24:20Z")

</div>

A great side-effect of Slicer (and libraries it uses) being open, along with all documentation, discussion, etc. is that all information is indexed by search engines. So, if you need documentation or source code then you can simply do a web search. For example if you google for `arrayFromVolumeModified` then for me the second hit in the search result is the [source code](https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py).

---

<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:** [January 12, 2021, 3:25pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/8 "2021-01-12T15:25:44Z")

</div>

I though that was what i needed, but in fact it is not.

So, i received data via webSocket, created a node, updated his data, displayed it using something like :

selectionNode-\>SetActiveVolumeID(node.GetID());  
appLogic-\>PropagateVolumeSelection();

And i would like that the volume information section update with his data.

So the node is selected (the eye icon is on) but it seems that the update of the volume information section is triggered by highlighting a node in the hierarchy tree. After some research on the vtkMRMLSelectionNode or vtkMRMLSubjectHierarchyNode i couldn’t find what i was looking for.

I also tried something like :

```
    QString errorMsg;
    qSlicerAbstractCoreModule* volumeModule = qSlicerCoreApplication::application()->moduleManager()->module("Volumes");
    if (!volumeModule)
    {
        errorMsg += "VolumesModule module is not found. ";
        qCritical() << "VolumesModule module is not found";
        return;
    }
    vtkSlicerVolumesLogic* volumeLogic = vtkSlicerVolumesLogic::SafeDownCast(volumeModule->logic());
    if (!volumeLogic)
    {
        errorMsg += "VolumesModule logic is not found. ";
        qCritical() << "VolumesModule logic is not found";
        return;
    }
    volumeLogic->SetActiveVolumeNode(node);

```

But it did’nt have any effect, i miss an update or something ? Any hint ?

---

<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:** [January 12, 2021, 4:51pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/9 "2021-01-12T16:51:15Z")

</div>

You can change the currently selected node in Volumes module GUI by calling:

```
slicer.modules.volumes.widgetRepresentation().setEditedNode(volumeNode)

```

This feature is used when you right-click on a node and choose “Edit node…”. This API should not be necessary for implementing a custom workflow. Instead, **the recommended way to implement workflows is not to switch between modules at all, just put all the widgets that you need into your own module GUI**.

For example, if you want to show volume information in your module, just add a qMRMLVolumeInfoWidget to your module GUI. You can try this easily from the Python console:

```python
w=slicer.qMRMLVolumeInfoWidget()
w.setMRMLScene(slicer.mrmlScene)
w.setVolumeNode(volumeNode)
w.show()

```

All the other parts of the Volumes module are widgets that you can reuse (and customize) in your module. For example, you can show/edit volume display options by adding a `slicer.qSlicerScalarVolumeDisplayWidget()` to your module GUI. Similarly, all other Slicer core module GUI is assembled from widgets that you can reuse in your own module. There could be some exceptions, where some shortcuts were taken and some parts of a module GUI is not a reusable widget. If you encounter anything like that then you can file a bug report.

---

<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:** [January 13, 2021, 6:35pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/10 "2021-01-13T18:35:36Z")

</div>

```auto
slicer.modules.volumes.widgetRepresentation().setEditedNode(volumeNode)

```

Did not have any effect, i would like to try the solution you advised :

```auto
w=slicer.qMRMLVolumeInfoWidget()
w.setMRMLScene(slicer.mrmlScene)
w.setVolumeNode(volumeNode)
w.show()

```

But i did not manage to get the qMRMLVolumeInfoWidget as i work in C++, i could not find any example of use in the source. How should i access it ?

---

<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:** [January 13, 2021, 6:55pm UTC](https://discourse.slicer.org/t/volume-information-in-volumes-module-not-updated-for-modified-volumes/12856/11 "2021-01-13T18:55:37Z")

</div>

> [@rbahegne](#):
>
> ```auto
> slicer.modules.volumes.widgetRepresentation().setEditedNode(volumeNode)
> 
> ```
> 
> Did not have any effect

It does what I described above: changes the currently selected node in Volumes module GUI.

> [@rbahegne](#):
>
> i could not find any example of use in the source

You can use the Volumes module as an example. It displays this widget in its module GUI. The module GUI is designed in [Qt Designer](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/QtDesigner), so the best is to view/edit the GUI there.

Developing modules in C++ is for advanced users. It is recommended to first get to know Slicer using Python scripting.
