# Create a preset in volume rendering module

**URL:** https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227
**Category:** Support
**Tags:** volume-rendering
**Created:** [December 30, 2018, 2:02pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227 "2018-12-30T14:02:31Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![maxaerosat.co.za](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@maxaerosat.co.za](https://discourse.slicer.org/u/maxaerosat.co.za)
#### Post date: [December 30, 2018, 2:02pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/1 "2018-12-30T14:02:32Z")

</div>

Just started on slicer and manage to do volume rendering of data  
I would like to have an additional preset(s} to be created and available  
with all the colours set to white and shading set “off”  
that will make it easier to color the images in my liking in my next step  
How do i do it / can it be built

---

<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: [December 30, 2018, 2:09pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/2 "2018-12-30T14:09:49Z")

</div>

See instructions here:

[https://www.slicer.org/wiki/Documentation/Nightly/Modules/VolumeRendering#How\_to\_register\_custom\_volume\_rendering\_presets](https://www.slicer.org/wiki/Documentation/Nightly/Modules/VolumeRendering#How_to_register_custom_volume_rendering_presets)

You can add the script to your _.slicerrc_ file or do it in the startup of a scripted module.

---

<div class="post-metadata">

### Author: ![maxaerosat.co.za](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@maxaerosat.co.za](https://discourse.slicer.org/u/maxaerosat.co.za)
#### Post date: [December 30, 2018, 5:37pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/3 "2018-12-30T17:37:50Z")

</div>

Thank you verry mutch

Will try it immediately once i get to my office in the morning

greatly appreciated

slicer is great

---

<div class="post-metadata">

### Author: ![maxaerosat.co.za](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@maxaerosat.co.za](https://discourse.slicer.org/u/maxaerosat.co.za)
#### Post date: [December 30, 2018, 9:58pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/4 "2018-12-30T21:58:39Z")

</div>

Thanks : not as easy as i thought it will be

tried to follow the example to the letter with appropriate modifications

running Linux (Fedora )

strange could not find an .slicerrc file anywhere

so i experimented …

created one in my slicer directory

when that did not work made one in my home directory

… and when that did not work

made one in my / directory

with the code ( modified )

```auto

presetsScenePath = "/home/maxwell/slicer.mypresets/MyPresets.mrml"
# Read presets scene
customPresetsScene = slicer.vtkMRMLScene()
vrPropNode = slicer.vtkMRMLVolumePropertyNode()
customPresetsScene.RegisterNodeClass(vrPropNode)
customPresetsScene.SetURL("/home/maxwell/slicer/mypresets/MyPresets.mrml")

##** slicer is in "/home/maxwell/slicer" directory and the presets are in a /home/maxwell/slicer/mypresets/" directory customPresetsScene.Connect()
# Add presets to volume rendering logic
vrLogic = slicer.modules.volumerendering.logic()
presetsScene = vrLogic.GetPresetsScene()
vrNodes = customPresetsScene.GetNodesByClass("vtkMRMLVolumePropertyNode")
vrNodes.UnRegister(None)
for itemNum in range(vrNodes.GetNumberOfItems()):
node = vrNodes.GetItemAsObject(itemNum)
vrLogic.AddPreset(node)

```

did not have the desired outcome

something is not right

or more simple

how do i run / load the code as per page instructions

hopefully will still have the baseline presets available to use

Greatly appreciated

---

<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: [December 31, 2018, 2:04am UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/5 "2018-12-31T02:04:32Z")

</div>

> [@maxaerosat.co.za](#):
>
> did not have the desired outcome  
> something is not right

We would be happy to help, but we need much better error reports than this.

> [@maxaerosat.co.za](#):
>
> strange could not find an .slicerrc file anywhere  
> so i experimented …

You may also just use Google. Since all Slicer discussions, supports requests, and documentation are indexed, you should be able to find answers to many questions. If you Google slicerrc then this link comes up on the first page:

[https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python\_scripting#How\_to\_systematically\_execute\_custom\_python\_code\_at\_startup\_.3F](https://www.slicer.org/wiki/Documentation/Nightly/Developers/Python_scripting#How_to_systematically_execute_custom_python_code_at_startup_.3F)

---

<div class="post-metadata">

### Author: ![maxaerosat.co.za](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@maxaerosat.co.za](https://discourse.slicer.org/u/maxaerosat.co.za)
#### Post date: [June 17, 2021, 5:36pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/6 "2021-06-17T17:36:14Z")

</div>

Thank you .  
Actully the directions you gave me works perfectly . And can add presets - or more accurately managed to load predefined presets in a session without to restart slicer - thanks .

problem now :i am able to remove the preset in the slicer session ( to edit and reload ) but the icon does not disappear from the drop down menu - so if i reload the preset file it just get added to the icons . need to remove the icons from the list of icons also . can see that the removed icon has functionally been removed , as when i use it - end up with a black screen 3d rendering screen  
code i used  
node = vrNodes.GetItemAsObject(0);print(node);vrLogic.RemovePreset(node)  
=\> need the icon to be removed from the drop down menu also in same session

---

<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: [June 18, 2021, 4:08am UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/7 "2021-06-18T04:08:40Z")

</div>

You can remove a volume rendering preset like this:

```python
vrLogic.RemovePreset(vrLogic.GetPresetByName('MyPreset1'))

```

---

<div class="post-metadata">

### Author: ![Juergen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/juergen/32/66870_2.png) [@Juergen](https://discourse.slicer.org/u/Juergen)
#### Post date: [October 26, 2023, 11:47pm UTC](https://discourse.slicer.org/t/create-a-preset-in-volume-rendering-module/5227/8 "2023-10-26T23:47:35Z")

</div>

Hi Andras,  
How can I remove the default presets. I never use them but they take up a lot of screen space. As an alternative I would like to replace all the presets with my own preset only.  
Thanks, Juergen
