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