Skip to content

Python Scripting

ThomasMr99 edited this page May 8, 2025 · 7 revisions

Voreen enables its users to run Python scripts for automating and customizing workflows.
On this page, we introduce how to use Python scripting within Voreen.

Basics

Python Script Editor

In each workspace, a Python script editor can be enabled to run custom code:

In each workspace, a Python script editor can be enabled to run custom code:

  • Open any workspace (e.g., Raycasting).
  • In the menu bar, go to ToolsPython Scripting.
  • The Python Script Editor will appear on the right side of your Voreen window.

💡 Note: By default, the editor runs voreen.info() and voreenqt.info(), which list all available commands in the voreen and voreenqt modules. A detailed reference can be found here.

ps-1

Accessing Processors & Properties

Python scripts allow you to interact with processors in Network Mode and modify their Properties.
Many scripting functions require the name of a processor and a property-specific ID, which is displayed when you hover over a property.

ps-3

Example: Adjusting a Property in a Loop

This example changes the Angle of the Background processor in a loop to find the best setting.

Steps:

  • Open the workspace Raycasting and the Python Script Editor.
  • Copy paste the following code.
# Voreen Python script
import voreen
import voreenqt

for i in range(voreen.getPropertyMaxValue("Background", "angle") +1):
 voreen.setPropertyValue("Background", "angle", i)
 voreen.render()
 voreenqt.processEvents()
  • Run the script with Ctrl + R.
    You should see the canvas update as the angle increases. ps-2

Advanced: The DynamicPythonProcessor

While the Python Script Editor provides global scripting functionality, Voreen also includes the DynamicPythonProcessor, which offers more advanced integration. It allows you to embed Python scripts directly into the data flow of a workspace.

A good example of its usage is shown in the project:
Volume Processing with Dual Thresholds ps-4

Headless execution

If a script needs to be executed without the visual front-end or just no graphical front-end is available, voreentool can be used to execute a python script from the command line. Execute voreentool, e.g., by using

./voreentool -platform minimal -w someworkspace.vws --script somescript.py
Clone this wiki locally