# Save & load (scalar opacity | Scalar color | gradient opacity) mapping settings from volume rendering?

**URL:** <https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271>\
**Category:** Support\
**Created:** [August 19, 2021, 12:55pm UTC](https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271 "2021-08-19T12:55:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [August 19, 2021, 12:55pm UTC](https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271/1 "2021-08-19T12:55:45Z")

</div>

Hey all,

Is there a way (python or otherwise) to save and load the “transfer curves”, meaning the scalar opacity mapping, scalar color mapping, and gradient opacity mapping settings to a file for reloading later? I do not use any of the presets, and it would be nice to be able to save mappings for later.

Totally fine if this is only doable from python with telling a node (or nodes) to write/read to/from disk.

Thanks!

-Hollister

---

<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:** [August 19, 2021, 2:35pm UTC](https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271/2 "2021-08-19T14:35:31Z")

</div>

These links should help:

> <https://github.com/SlicerMorph/Spr_2021/blob/cbd6e1d269fdb256d2ab0f42933a1422c8c8fff6/Day_2/VolumeRendering/VolumeRendering.md#saving-your-transfer-functions>

> [@I want to boot up with my very own color map and a black background](https://discourse.slicer.org/t/i-want-to-boot-up-with-my-very-own-color-map-and-a-black-background/16383/8):
>
> Ok…I have hit a roadblock. I am following the guidance here: [https://slicer.readthedocs.io/en/latest/developer\_guide/modules/volumerendering.html#how-to-register-custom-volume-rendering-presets](https://slicer.readthedocs.io/en/latest/developer_guide/modules/volumerendering.html#how-to-register-custom-volume-rendering-presets) I have a new file called MyPresets.mrml in my Slicer Scene Location directory along with a PNG thumbnail. Now I come to this instruction… " Use the following code to read all the custom presets from MyPresets.mrml and load it into the scene:" I do not know how to ‘use’ the code. I pasted it in the Py…

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [August 19, 2021, 2:42pm UTC](https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271/3 "2021-08-19T14:42:54Z")

</div>

Most excellent! Thanks much.

-Hollister

---

<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:** [August 19, 2021, 6:57pm UTC](https://discourse.slicer.org/t/save-load-scalar-opacity-scalar-color-gradient-opacity-mapping-settings-from-volume-rendering/19271/4 "2021-08-19T18:57:52Z")

</div>

Here is an example from SlicerMorph. A mrml file that defines the presets, and a short resource script that loads it into the scene (you only care the top couple lines, the rest are other SlicerMorph preferences).

> **[SlicerMorph/MorphPreferences/Resources at master · SlicerMorph/SlicerMorph](https://github.com/SlicerMorph/SlicerMorph/tree/master/MorphPreferences/Resources)**
>
> master/MorphPreferences/Resources
