Create a preset in volume rendering module

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

See instructions here:

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.

Thank you verry mutch

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

greatly appreciated

slicer is great

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 )


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

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

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

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

You can remove a volume rendering preset like this:

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

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