Basically I have a big subject hierarchy (several folders), and inside each I have nodes (volumes, segmentations, transformations). I want to create a table for instance and place it in the same location of the generating data, or clone one of the volumes, make some calculation and save as a new volume in the same hierarchy.
the created volume is outside of the hierarchy so I have to move it manually. Is there a way to tell the new volume to be placed where the father is located??
This feature is already available in Data module. You can convert file folder hierarchy to subject hierarchy by clicking on the empty area of the subject hierarchy tree:
For example, you load a number of images from a folder structure (folder names a, b, c, d, e):
But then when I visualize both images, THEY ARE BOTH CHANGED!!
I need to preserve the hierarchy path, but also to create a new volume and modify it without changing the original. This code preserves the hierarchy, but modifies both volumes:
Cloning a volume using CloneSubjectHierarchyItem creates a shallow copy of the image data. You can either use Volume module’s CloneVolume method or modify your code above to clone the image data by adding clonedNode.SetAndObserveImageData(vtk.vtkImageData()) before slicer.util.updateVolumeFromArray(clonedNode, vox_arr).