Hi,
I have a script that automatically crops (and resamples) my volumes in Slicer. It works fine, but every time it runs, it leaves a copy of the original volume in the temp folder. In my case, here:
c:\Users\tamas\AppData\Local\Temp\Slicer\
I just realized that this folder was over 100 GB today. I’m not sure if this would be cleaned up automatically after a while. But I would prefer a way to clean it up from my python script immediately after resampling my volumes.
Does anybody know how to clean up the temp folder of Slicer?
Or prevent the crop volume logic to create these large temp files? (I have lots of RAM.)
Here is a minimal script to reproduce the issue. You will need the MRHead image and a ROI in the scene to run this:
inputVolume = slicer.util.getNode('MRHead')
roi = slicer.util.getNode('R')
cropVolumeNode = slicer.vtkMRMLCropVolumeParametersNode()
cropVolumeNode.SetScene(slicer.mrmlScene)
slicer.mrmlScene.AddNode(cropVolumeNode)
cropVolumeNode.SetInputVolumeNodeID(inputVolume.GetID())
cropVolumeNode.SetROINodeID(roi.GetID())
# cropVolumeNode.SetOutputVolumeNodeID(outputVolume.GetID()) # This is optional
cropVolumeLogic = slicer.modules.cropvolume.logic()
cropVolumeLogic.Apply(cropVolumeNode)
Thanks,
Tamas