-
Notifications
You must be signed in to change notification settings - Fork 6
Python Scripting
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.
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 Tools → Python Scripting.
- The Python Script Editor will appear on the right side of your Voreen window.
💡 Note: By default, the editor runs
voreen.info()
andvoreenqt.info()
, which list all available commands in thevoreen
andvoreenqt
modules. A detailed reference can be found here.
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.
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.
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
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