This is possible without you doing any coding, you just need to follow the instructions here: Script repository — 3D Slicer documentation in the section “Change default output file type for new nodes”.
For the compression option, add the line
defaultModelStorageNode.SetUseCompression(0) # change default to uncompressed
to your .slicerrc.py file right before the last line you just pasted in.
So, the 4 lines total which you will have added to the file will be
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()
defaultModelStorageNode.SetDefaultWriteFileExtension("ply") # change default to .ply
defaultModelStorageNode.SetUseCompression(0) # change default to uncompressed
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)
These settings will take effect next time you open Slicer. So, if you add these lines to your .slicerrc.py file while you have Slicer open, you will still need to change the settings manually in that Slicer session.
It looks like you could use exactly the analogous approach for color tables.
defaultColorTableStorageNode = slicer.vtkMRMLColorTableStorageNode()
defaultModelStorageNode.SetDefaultWriteFileExtension("txt") # looks like txt is the other option for color tables
slicer.mrmlScene.AddDefaultNode(defaultColorTableStorageNode)
For image files, it looks a little different:
defaultImageStorageNode = slicer.vtkMRMLVolumeArchetypeStorageNode()
defaultImageStorageNode.SetDefaultWriteFileExtension( 'nii.gz' ) # insert extension you want here
slicer.mrmlScene.AddDefaultNode(defaultImageStorageNode)
I think this will likely work fine for the color tables. I’m less sure whether this will work for image volumes. If it doesn’t work, I would post a new discourse question on that topic to get suggestions from others. One consideration is that images are very likely to have been loaded from a particular format, and may remember that format rather than have that overridden by a default setting.
Thank you for your answer.
Maybe I was not clear but it was for changing the compression default for color table and image files.
Once again, thanks a lot
For the compression settings on each of these storage nodes, you can use the SetUseCompression() function. You can add the lines
# Insert this line before: slicer.mrmlScene.AddDefaultNode(defaultColorTableStorageNode)
defaultColortTableStorageNode.SetUseCompression(0) # 0 for no compression, 1 for compression
# Insert this line before: slicer.mrmlScene.AddDefaultNode(defaultImageStorageNode)
defaultImageStorageNode.SetUseCompression(0) # 0 for no compression, 1 for compression
I’m not sure which setting wins if the format/extension conflicts with the SetUseCompression() setting, but you can test and see. For example, if you specified the extension as ‘nii.gz’, indicating a compressed Nifti file, but set SetUseCompression(0), indicating not to compress it, I’m not sure whether the output would be compressed or not. Safest would be to make sure the two settings are compatible with each other.