Currently, not without some programming.
If you have checked the “save new masks” and “save loaded masks”, case iterator should at least save your segmentation, though your model will be discarded.
In the github repository, I also have a dev branch, which has multiple additional features, both for the user interface and “under-the-hood” stuff. This includes a more easy way of defining a customized iterator, and auto-updating the layout to accomodate the loaded volumes, aligned on the slices (instead of reformatted volumes to truly transversal/sagittal/coronal).
So if you want to use caseIterator to include saving your models, you’ll have to customize the version you have. You can either update the current master (this would involve adding a function for saving models, and calling that function when the case closes). Alternatively, if you also want to use the newer features, I can help you write a customized iterator which also stores models as part of the workflow.
For updating the current version in the Slicer Extensions index, do the following:
Add this piece of code to
CsvTableIterator.py, just after
saveMask() function (i.e. make it part of the
def saveModel(self, node, reader, overwrite_existing=False):
storage_node = node.GetStorageNode()
if storage_node is not None and storage_node.GetFileName() is not None:
# mask was loaded, save the updated mask in the same directory
target_dir = os.path.dirname(storage_node.GetFileName())
target_dir = self.currentCaseFolder
if not os.path.isdir(target_dir):
self.logger.debug('Creating output directory at %s', target_dir)
nodename = node.GetName()
# Add the readername if set
if reader is not None:
nodename += '_' + reader
filename = os.path.join(target_dir, nodename)
# Prevent overwriting existing files
if os.path.exists(filename + '.vtk') and not overwrite_existing:
self.logger.debug('Filename exists! Generating unique name...')
idx = 1
filename += '(%d).vtk'
while os.path.exists(filename % idx):
idx += 1
filename = filename % idx
filename += '.vtk'
# Save the node
self.logger.info('Saved node %s in %s', nodename, filename)
Add the call to this function in
SlicerCaseIterator.py, in function
_closeCase() (L423-L446). You can do this by inserting this piece of code in L435 (just after the
if self.saveNew: block:
for n in slicer.util.getNodesByClass('vtkMRMLModelNode'):