shNode = slicer.modules.subjecthierarchy.logic().GetSubjectHierarchyNode()
# get current SceneID
SceneID = shNode.GetSceneItemID()
# folder create
folderNum = shNode.CreateFolderItem(SceneID, "test")
# dummy item
temp = getNode('F')
# add item to folder
shNode.CreateItem(folderNum, temp)
However, when I run the code that adds data to the folder like this, there is a phenomenon that the slicer turns off when there is a lot of data. Is there an optimization method?
Load all markups (fiducialNode, ClosedcurvedNode, etc) used in slicer.
Create a folder corresponding to each markups
Distribute markups data corresponding to each folder.
#example tree
Scene
|
|
| ㅡㅡㅡ FiducialNode(tentative named)
| |___ node1
| |___ node2
|
|
| ㅡㅡㅡ ClosedCurvedNode
|
|
|ㅡㅡ etc
# Get hierarychyNode
shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
# Get Current SceneID
SceneID = shNode.GetSceneItemID()
# Create folder
folderNum = shNode.CreateFolderItem(SceneID, "test")
# Set dummy data
temp = getNode('F')
# add item to folder
shNode.CreateItem(folderNum, temp)
However, in the case of proceeding as above, if there is a lot of data to put in the folder, the slicer is turned off.
I will refer to this method and try it.
edit :
# Get hierarychyNode
shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
# Get Current SceneID
SceneID = shNode.GetSceneItemID()
# Create folder
folderNum = shNode.CreateFolderItem(SceneID, "test")
# Set dummy data
temp = getNode('F')
# Get the item ID of the node
nodeItemID = shNode.GetItemByDataNode(node)
# Set the parent of the node item to the folder item
shNode.SetItemParent(nodeItemID, folderItemID)
Distribute markups data corresponding to each folder.
Having data nodes under other nodes is possible in SH, but it is not something I’d consider default behavior. If you only have folders as parents of nodes, does it work?
I assume this means it crashes. If you can reproduce this with only using sample or synthetic data, please upload a scene and/or provide instructions and we’ll try to fix the crash.
Unfortunately subject hierarchy is still not bullet-proof. Sticking to the “normal” behavior it tends to work fine, but some errors do pop up. If you have cases that are not that normal (see above), probably mode. This particular warning does not indicate serious issues. If you know how to debug in C++, it would be great if you could find the cause for these.
@dsa934 I’m glad the last comment was helpful enough to set it as solution, but maybe it would help others seeing this topic later if you told us what exactly helped. Was it using folder items? Thanks
The folders have a special folder display node, but it is only created when you show/hide it in the Data module (you’ll notice because the color item will appear in its row). In theory you can create it programmatically, but as I see that function is not python wrapped. This is the code:
I have to admit that I don’t quite get what you are saying.
Here’s what I want to do.
I inspected the Data module and found out that it is using qMRMLSubjectHierarchyTreeView widget for showing the nodes in a tree view. I wanted to customize the Data module by creating my own custom widget. So I created a widget, with a combo box that selects from the list plans. The plans contains lines. I want to show the lines like a list and with all the added functionality of hide/show `eye` button, transformation tracking, color picking, and their IDs like how the Data module shows it. So I created one instance of qMRMLSubjectHierarchyTreeView, and set it like this.
The problem is that it shows all the nodes and folders. I just want to show the line that corresponds to the selected plan. I thought I could do the following
but this shows the folders with the lines. even if it didn’t show the folders, I don’t know how to delete the other line nodes that doesn’t belong to the current selected plan.
Any help will be appreciated. Thank you for replying to me.
OK, it turns out you want to hide them from the tree view, and not their contents from the views. This is why explaining a problem in more than a single line helps preventing misunderstandings I thought this was a very simple question related to the original topic, but it’s quite different. Please open a new topic with your question if you cannot find the solution among the filtering options of the tree view, which is quite comprehensive.