# Visualization bug in subject hierarchy

**URL:** <https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647>\
**Category:** Support\
**Tags:** bug\
**Created:** [October 2, 2019, 7:40am UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647 "2019-10-02T07:40:49Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [October 2, 2019, 7:40am UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/1 "2019-10-02T07:40:49Z")

</div>

OS: MacOS 10.14.6  
Slicer version: r28525

The subject hierarchy folder contains several children that are not displayed:

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

You can see a lot of children but only few displayed, If I show all nodes you can see they are there:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/b/4b572899f207790c844050aae8f1b96363052d96.png)

Even when you save the scene they are there:

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

So this is not a critical bug, but it is very annoying, in the 25/9 release the bug was even worse as no volume were displayed at all, this was corrected but not entirely.

---

<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 2, 2019, 11:27am UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/2 "2019-10-02T11:27:31Z")

</div>

Fixes have been integrated since then. Please try with latest preview version (r28531) and let us know if you still find any issues.

---

<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:** [October 3, 2019, 7:49am UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/3 "2019-10-03T07:49:25Z")

</div>

The problem remains, see

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

I have recreated everything since the beginning and so it is not because of the old configuration.

I can share the scene with you for you to study what is the offending part.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 1:49pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/4 "2019-10-03T13:49:23Z")

</div>

Yes please, the scene would be helpful.

---

<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:** [October 3, 2019, 2:01pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/5 "2019-10-03T14:01:27Z")

</div>

get it here [https://drive.google.com/open?id=1lHh5lHeKBQY9t49J\_kKZIOF0XG1qN-ut](https://drive.google.com/open?id=1lHh5lHeKBQY9t49J_kKZIOF0XG1qN-ut)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:05pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/6 "2019-10-03T14:05:07Z")

</div>

Thanks, got it! Other than the obvious issue with the Results item is there anything else that is not how it’s supposed to be?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:06pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/7 "2019-10-03T14:06:34Z")

</div>

By the way it seems to load fine for me:

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

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:07pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/8 "2019-10-03T14:07:18Z")

</div>

Another screenshot from the bottom:

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

---

<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:** [October 3, 2019, 2:07pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/9 "2019-10-03T14:07:44Z")

</div>

Thats Odd, let me retry with r28532

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:08pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/10 "2019-10-03T14:08:30Z")

</div>

OK sounds good. If you have an issue in r28532 then I’ll check it out on Mac

---

<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:** [October 3, 2019, 2:12pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/11 "2019-10-03T14:12:35Z")

</div>

Ok thats was solved, Thanks

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

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:21pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/12 "2019-10-03T14:21:46Z")

</div>

Results still has the question mark.

What do you get if you paste this in the python window?

```
shn=slicer.mrmlScene.GetSubjectHierarchyNode()
resultsItem = shn.GetItemByName('Results')
shn.GetItemOwnerPluginName(resultsItem)

```

It’s supposed to return ‘Folder’

---

<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:** [October 3, 2019, 2:23pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/13 "2019-10-03T14:23:27Z")

</div>

We need to have it as `Results` Level, since it must be univocally identified from the rest of folders. We are refactoring this part so we don’t need to force this, but for now it is our bug 😉  
The main problem is that there could be more than one Results folder and that would crash the workflow.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:28pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/14 "2019-10-03T14:28:46Z")

</div>

You don’t need to use Level. You can use attribute instead. Like  
`shn.SetItemAttribute(resultsItem, 'Results', 1)`  
then  
`shn.HasItemAttribute(resultsItem, 'Results')`  
will return True

---

<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:** [October 3, 2019, 2:29pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/15 "2019-10-03T14:29:33Z")

</div>

Nice! I will try that asap!

---

<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:** [October 3, 2019, 2:54pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/16 "2019-10-03T14:54:03Z")

</div>

That does not worked out, the attribute is not set! I think it is not working for folders.

Ahh, the value argument must be a string!!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 2:57pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/17 "2019-10-03T14:57:46Z")

</div>

It works on all kinds of items. Yes it needs to be string. Check the error log if anything strange happens. Usually it should tell you what went wrong and why.

---

<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:** [October 3, 2019, 3:28pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/18 "2019-10-03T15:28:36Z")

</div>

It is working for the Results folder thanks!

And I found the cause of the original problem: it is a refresh issue, the scene needs to be refreshed, but currently I have tried the `StartModify - EndModify` things and they don’t refresh the scene.

Basically I create the scene, no items visible  
save the scene to a mrb file, close current scene and load back the mrb and voila, the items magically appear.

Is there a way to force the scene to refresh?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 3, 2019, 5:51pm UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/19 "2019-10-03T17:51:21Z")

</div>

How exactly do you use StartModify / EndModify? We usually use it on individual nodes, in which case it should be OK, because on EndModify the one corresponding SH item updates itself and that’s it.

I recently integrated a change that allows subject hierarchy to be stable with BatchProcessing, maybe you should use that instead.

---

<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:** [October 23, 2019, 8:24am UTC](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647/20 "2019-10-23T08:24:58Z")

</div>

OK  
Most has been fixed in the lasts versions, but still I have some issues, although I am closer to the issue identification.  
I can do

```python
    def createFolder(parentID, name):
        shNode = vtkmrmlutils.getSubjectHierarchyNode()
        folderID = shNode.CreateFolderItem(parentID, name)

        pluginHandler = slicer.qSlicerSubjectHierarchyPluginHandler().instance()
        folderPlugin = pluginHandler.pluginByName('Folder')
        folderPlugin.setDisplayVisibility(folderID, 1)

        return folderID

    def setItemFolder(itemID, folderID):
        shNode = vtkmrmlutils.getSubjectHierarchyNode()
        shNode.SetItemParent(itemID, folderID)

```

And then this happens  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/a/3a5c8ffad7712b0460ae071111adb200f0ec676c.png)

BUT when I press the eye button in one node (the ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/4/342d524a62dcc95b51fb0d099074769a12edc22b.png), then magically

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/e/9ed1d743ba80d5f49695274c3c06e8d01caa32ff.png)

So, whats wrong here? How can I force the shNode to refresh?

[Next page](https://discourse.slicer.org/t/visualization-bug-in-subject-hierarchy/8647.md?page=2)
