# How to unset default 'compress' option during save

**URL:** <https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488>\
**Category:** Support\
**Tags:** file-export\
**Created:** [October 22, 2018, 3:37pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488 "2018-10-22T15:37:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 22, 2018, 3:37pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/1 "2018-10-22T15:37:10Z")

</div>

Hi,

Is there a way to default compress option to NO for save dialog? Compress option is not visible immediately to new Slicer users, and compressing single threaded such large dataset (2000^3) is extremely slow. We are talking about 15 sec for uncomressed data and dozens of minutes with compress enabled on an ssd. Again for a new user, it is not immediately clear to the user whether Slicer stalled/crashed or doing something.

In case someone wants to see, here is a test dataset:  
[https://ndownloader.figshare.com/files/12808130](https://ndownloader.figshare.com/files/12808130)

---

<div class="post-metadata">

**Author:** ![Andinet\_Enquobahrie](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/andinet_enquobahrie/32/75_2.png) [@Andinet\_Enquobahrie](https://discourse.slicer.org/u/Andinet_Enquobahrie)\
**Post date:** [October 22, 2018, 4:27pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/2 "2018-10-22T16:27:45Z")

</div>

In the Save Dialog box, click on “Show options”, then you can toggle off “Compress” option in the options column.

-Andinet

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 22, 2018, 5:55pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/3 "2018-10-22T17:55:03Z")

</div>

For some users it makes more sense to enable compression by default, for some others, disabling compression by default is preferable.

You can set default file type and saving options by specifying a default storage node by adding 3 lines to your application startup script as shown in the [script repository](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Change_default_file_type_for_nodes_.28that_have_never_been_saved_yet.29).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 22, 2018, 6:59pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/4 "2018-10-22T18:59:25Z")

</div>

To me it’s easier to learn to set the save option than it is to add a .slicerrc.py option.

But rather than making this either compression or fast save, maybe we can try to get the benefits of both with something like this: [https://zlib.net/pigz/](https://zlib.net/pigz/) (I haven’t tried this).

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 22, 2018, 7:03pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/5 "2018-10-22T19:03:08Z")

</div>

From a user point of view, this would make sense to be a setting under preferences option.

I use pigz from command line, and it works really well on multi core systems. It would be good to have it in slicer.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 22, 2018, 7:41pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/6 "2018-10-22T19:41:38Z")

</div>

> [@muratmaga](#):
>
> From a user point of view, this would make sense to be a setting under preferences option.

Yes, I can see how this would be a convenience for people who always want one thing or the other. My concern is that this is pretty hidden away and is pretty obscure. With nrrd files it’s not easy for users to know if it’s compressed (need to look in the header or guess based on file size). So sticking with compressed all the time is the best thing if we can make it fast enough.

Just to confirm @muratmaga would you really want lots of 2000^3 files on your disk that were mostly zeros?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 22, 2018, 8:48pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/7 "2018-10-22T20:48:41Z")

</div>

Follow up on pigz, there’s a [github repo](https://github.com/madler/pigz) and the author seems [quite legit](https://en.wikipedia.org/wiki/Mark_Adler). But there’s no obvious windows support so probably a cmakeification effort would be needed.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 22, 2018, 10:04pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/8 "2018-10-22T22:04:06Z")

</div>

Even SSD storage is so cheap now that the time consumption waiting for lots of zeros to be compressed into fewer zeros is hardly justifiable, IMO. People working with large volumes are very likely to be working with fewer datasets than people working on medical analyses, and more likely to use the software interactively doing bunch of one of things that will require them to save repeatedly derivative datasets.

I say +1 for the pigz implementation. Or some indication of progress of saving/compression process. Otherwise Slicer simply looks stalled.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 22, 2018, 10:10pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/9 "2018-10-22T22:10:58Z")

</div>

Another suggestion I have is to make compress visible field visible next to the format in the default save dialog box (as oppose to requiring user to click on options to expand the options). That can be good compromise.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 22, 2018, 10:14pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/10 "2018-10-22T22:14:28Z")

</div>

@lassoan I am not finding a compress example. What would be option to specify for compress?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 22, 2018, 10:38pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/11 "2018-10-22T22:38:09Z")

</div>

> [@muratmaga](#):
>
> Another suggestion I have is to make compress visible field visible next to the format in the default save dialog box (as oppose to requiring user to click on options to expand the options). That can be good compromise.

Yes, if we think that’s a commonly used option it could make a lot of sense to make it visible by default.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 22, 2018, 10:47pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/12 "2018-10-22T22:47:10Z")

</div>

> [@muratmaga](#):
>
> I am not finding a compress example. What would be option to specify for compress?

You can enable/disable compression using storage node’s [SetUseCompression](http://apidocs.slicer.org/master/classvtkMRMLStorageNode.html#a279187e9687b417aa391de0078698e33) method.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 23, 2018, 5:18pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/13 "2018-10-23T17:18:44Z")

</div>

Thank you. Based on the example, this works:

#set the default 3D model format to PLY (instead of VTK)  
defaultModelStorageNode = slicer.vtkMRMLModelStorageNode()  
defaultModelStorageNode.SetDefaultWriteFileExtension(‘ply’)  
#to turn off compression for the models  
defaultModelStorageNode.SetUseCompression(0)  
slicer.mrmlScene.AddDefaultNode(defaultModelStorageNode)

But I couldn’t figure out how to use the provided **[Change file type for saving for all volumes (with already existing storage nodes](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Change_file_type_for_saving_for_all_volumes_.28with_already_existing_storage_nodes.29))** example to work with fresh scenes with no volume loaded.

defaultVolumeNode = slicer.vtkMRMLScalarVolumeNode()  
defaultVolumeNode.SetDefaultWriteFileExtension(‘mha’)

fails with AttributeError: ‘vtkCommonCorePython.vtkMRMLScalarVolumeNode’ object has no attribute ‘SetDefaultWriteFileExtension’

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 23, 2018, 5:28pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/14 "2018-10-23T17:28:39Z")

</div>

You need to change the default volume storage node (not the default volume node).

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [October 23, 2018, 5:58pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/15 "2018-10-23T17:58:06Z")

</div>

Thanks, but looks like I need more guidance…

defaultStorageNode = slicer.vtkMRMLStorageNode()

fails with TypeError: this is an abstract class and cannot be instantiated

and I can’t locate a vtkMRMLVolumeStorageNode() (or rather how/where to find it).

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 26, 2018, 2:51pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/16 "2018-10-26T14:51:51Z")

</div>

Here’s an example:

```auto
#set the default volume storage to not compress by default
defaultVolumeStorageNode = slicer.vtkMRMLSegmentationStorageNode()
defaultVolumeStorageNode.SetUseCompression(0)
slicer.mrmlScene.AddDefaultNode(defaultVolumeStorageNode)
logging.info("Segmentation nodes will be stored uncompressed 

```

This is also in the[Script Repository now.](https://www.slicer.org/w/index.php?title=Documentation%2FNightly%2FScriptRepository&type=revision&diff=60488&oldid=60480)

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [October 29, 2018, 1:43pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/17 "2018-10-29T13:43:28Z")

</div>

This came up in another thread recently:

> [@Can Slicer load/save to archives instead of folders, on Mac/Windows?](https://discourse.slicer.org/t/can-slicer-load-save-to-archives-instead-of-folders-on-mac-windows/3785/4):
>
> Also note that volumes get compressed on save by default and for large volumes that can be big. Then the zip (mrb) process re-runs compression of those which is also wasteful. If performance is a big issue for you it’s possible to bypass that.

We could potentially get a big performance boost at minimal file size cost by changing the default gz compression level to 1. In some small-scale tests I did a few months ago, there was a major time cost between high and low settings, for only a tiny compression improvement (e.g. 90-\> 26 MB at level 9 in 34s, vs 90-\>27 MB at level 1 in \<1s). This was only a small test on a few brain MR datasets, but it seems reasonable.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 29, 2018, 2:32pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/18 "2018-10-29T14:32:36Z")

</div>

Using a low compression level would make a lot of sense, as one of the main reasons I would keep compression enabled is to deflate blank voxels around images that have a non-rectangular shape.

Is there an API to change compression level in ITK IO classes?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [October 29, 2018, 3:13pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/19 "2018-10-29T15:13:08Z")

</div>

> [@lassoan](#):
>
> Is there an API to change compression level in ITK IO classes?

Looks like only for a few specific formats (MINC, PNG). For NRRD we can set it in teem directly.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 31, 2018, 8:36pm UTC](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488/20 "2018-10-31T20:36:56Z")

</div>

@muratmaga tomorrow’s nightly build will have this commit which changes the default nrrd compression to ‘low’ so it should be faster and still pretty good compression. Let us know how it works in your use cases.

[https://github.com/Slicer/Slicer/commit/d87fdfd3eeca502c97cf611c92e443571e569292](https://github.com/Slicer/Slicer/commit/d87fdfd3eeca502c97cf611c92e443571e569292)

[Next page](https://discourse.slicer.org/t/how-to-unset-default-compress-option-during-save/4488.md?page=2)
