Tutorial

Introduction to MeVisLab

Tutorial Introduction

Welcome to MeVisLab!

More than 20 years of experience and the continuous implementation of adaptations made MeVisLab one of the most powerful development platforms for medical image processing. Several applications and their prototypes are based on and could be realized because of MeVisLab, including software assistants for neuro-imaging, dynamic image analysis, surgery planning, and cardiovascular analysis.

MeVisLab is a development environment for rapid prototyping and product development of medical and industrial imaging applications. It includes a Software Development Kit (SDK) and an ApplicationBuilder for deploying your applications to end customers.

Chapter I: Basic Mechanisms of MeVisLab

Basic Mechanisms of MeVisLab (Example: Building a Contour Filter)

In this chapter, you will learn the basic mechanisms of the MeVisLab IDE. You will learn how to reuse existing modules to load and view data, and you will build your first processing pipeline.

Loading Data

First, we need to load the data we would like to work on, e.g., a CT scan. In MeVisLab, modules are used to perform their associated specific task: they are the basic entities you will be working with. Each module has a different functionality for processing, visualization, and interaction. Connecting modules enables the development of complex processing pipelines. You will get to know different types of modules throughout the course of this tutorial.

Example 1: Data Import in MeVisLab

Example 1: Data Import in MeVisLab

MeVisLab provides several predefined modules to import data for processing in your networks.

These chapters explain the data formats and modules related to this example:

Example 1.1: MeVisLab Coordinate Systems

Example 1.1: MeVisLab Coordinate Systems

Three coordinate systems exist side by side:

  • World coordinates
  • Voxel coordinates
  • Device coordinates

World coordinate systems in MeVisLab are always right handed.

The blue rectangle shows the same region in the three coordinate systems.

Coordinate systems in MeVisLab

Coordinate systems in MeVisLab

World Coordinates

World coordinates are:

  • Global: Combine several objects in a view
  • Isotropic: All directions are equivalent
  • Orthogonal: Coordinate axes are orthogonal to each other

The origin of the world coordinate system can be anywhere and is not clearly defined. Origins of the other coordinate systems can always be mapped to the world coordinate system. In the case of DICOM images, this mapping is defined by DICOM tags.

Example 1.2: DICOM Coordinate Systems

Example 1.2: DICOM Coordinate Systems

General

Coordinate systems in DICOM are basically the same as world coordinates in MeVisLab (except for the 0.5 voxel offset). World coordinates also refer to the patient axes. They are:

  • Based on the patient’s main body axes (transverse, coronal, sagittal)
  • Measured as 1 coordinate unit = 1 millimeter
  • Right-handed
  • Not standardized regarding their origin

World coordinates in context of the human body

World coordinates in context of the human body

Example 2: Macro Modules and Module Interaction

Example 2: Macro Modules

What is a Macro Module?

A macro module can be used to develop your own functionality in MeVisLab.

Like all other standard MeVisLab modules, macro modules have a defined interface with inputs, outputs, and parameters (fields). This interface allows it to interact with other modules in a larger network. They hide the complexity of the internal network or Python code, presenting a more simplified and manageable unit to the user.

Example 2.1: Package Creation

Example 2.1: Package Creation

Introduction

Packages are the way MeVisLab organizes different development projects.

Macro modules and projects are stored in packages. If you like to create a global macro module, you need a package in which this macro module can be stored in. In this chapter, we will create our own package. We start our package creation by creating a package group, because every package needs to be stored in a package group. You can find detailed information about packages and package groups here and in the package documentation .

Example 2.2: Creation of Global Macro Modules

Example 2.2: Global Macro Modules

Introduction

In this chapter, you will learn how to create global macro modules. There are many ways to do this. You can convert local macros into global macro modules or you can directly create global macro modules using the Project Wizard. In contrast to local macro modules, global macro modules are commonly available throughout projects and can be found via module search and under [ Modules ].

Example 2.3: Creation of Module Help

Example 2.3: Creation of Module Help

Generating help of a macro module is part of the video about macro modules from Example 2: Creation of Global Macro Modules

Introduction

In this chapter, you will learn how to create a help page and an example network. For hands-on training, we will use the macro module Filter, which was created in the previous chapter.

Example 2.4: GUI Development

Example 2.4: Building a Panel Layout: Interactions with Macro Modules

Introduction

This chapter gives you an introduction into the creation of module panels and user interfaces. For the implementation, you will need to use the MeVisLab Definition Language (MDL) .

Creating a Panel for the Macro Module Filter

Creation of a Module Panel

In Example 2.2 we created the global macro module Filter. By now, this module does not have a proper panel. When double-clicking Left Mouse Button the module, the Automatic Panel is shown.

Example 2.5: Interactions via Python Scripting

Example 2.5: Module Interactions Using Python Scripting

Introduction

This chapter will give you an overview over Python scripting in MeVisLab. Here, no introduction into Python will be given. However, basic knowledge in Python is helpful. Instead, we will show how to integrate and use Python in the MeVisLab SDK.

In fact, nearly everything in MeVisLab can be done via Python scripting: You can add modules to your network, or remove modules, you can dynamically establish and remove connections, and so on. But, much more important: You can access module inputs and outputs, as well as module fields to process their parameters and data. You can equip user interfaces and panel with custom functionalities. Python can be used to implement module interactions. When you open a panel or you press a button in a panel, the executed actions are implemented via Python scripting.

Example 2.5.1: The Module RunPythonScript

Example 2.5.1: The Module RunPythonScript

Introduction

The module RunPythonScript allows to execute Python scripts from within a MeVisLab network. You can establish parameter connection from modules to RunPythonScript and back to process parameter fields using Python scripting.

Steps to Do

Develop Your Network

In this example, we like to dynamically change the color of a cube in an Open Inventor scene. For that, add and connect the following modules as shown.

Example 2.5.2: Module Interactions via Python Scripting

Example 2.5.2: Module Interactions via Python Scripting

Introduction

In this example, you will learn how to add Python scripting to your user interface. The network used in Chapter V will be used for creating the macro module.

Steps to Do

Creating the Macro Module

First, we condense the example network into a macro module and then we create a panel for that module. To create a macro module, use the Project Wizard, which you find under [ File → Run Project Wizard ]. Select Macro module and press Run.

Example 3: Creating a Simple Application

Example 3: Creating a Simple Application

Introduction

In the previous examples, you already learned how to create macro modules, user interfaces, and how to interact with your UI via Python scripting.

In this example, you will learn how to create a simple prototype application in MeVisLab including a user interface with 2D and 3D viewer. You will learn how to implement field listeners and react on events.

Steps to Do

Create Your Network

Start with an empty network and add the module ImageLoad to your workspace. Then, add the modules View2D and View3D to your workspace and connect them as seen below.

Example 4: Installing Additional Python Packages Using the PythonPip Module

Example 4: Installing Additional Python Packages Using the PythonPip Module

Introduction

MeVisLab already comes with a lot of integrated third-party software tools ready to use. Nevertheless, it might be necessary to install additional Python packages for your specific needs. This example will walk you through the process of adding packages by using the PythonPip module.

The PythonPip module allows to work with the Python package manager pip. It can be used to install Python packages into the site-packages of the MeVisLab Python installation.

Example 5: Debugging Python in MATE

Example 5: Debugging Python Files in MATE

Introduction

MeVisLab provides the powerful integrated text editor MATE. By default, MATE is used to create/edit files like Python scripts. In this tutorial, we want to show you how to debug Python scripts in MeVisLab.

Prepare Your Network

We are using a very simple network of predefined modules but you can also debug your self-written Python scripts. Add a LocalImage module to your workspace and connect it to a DicomTagBrowser module. The DicomTagBrowser module shows a table containing the DICOM tags of your currently opened file.

Example 6: Creating Multi View Layouts Using SoViewportRegion

Example 6: Creating Multi-View Layouts Using SoViewportRegion

Introduction

In this guide, we will show how to use the SoViewportRegion module to create custom layouts within the SoRenderArea module. This allows you to display multiple views or slices in a single window.

We will demonstrate how to:

  • Divide the render area into multiple regions.
  • Assign different content to each region.
  • Use alternative methods, such as SoView2D, when applicable.

Prepare Your Network

Displaying Three Images in One Panel

Add an ImageLoad module to your workspace and select a 3D image like ./MeVisLab/Resources/DemoData/MRI_Head.tif from the MeVisLab demo data directory. Connect an OrthoReformat3 module and add three View2D modules.

Example 7: Creating Your Own ItemModel by Using the ItemModelView

Example 7: Creating Your Own ItemModel by Using the ItemModelView

Introduction

In this example, we will show how to use the ItemModelView MDL control to represent an abstract hierarchical item model with generically named attributes. You will see how to select the displayed attributes in the resulting table and how to interact with this table.

We create a macro module that receives an input image and then shows some selected DICOM attributes of this patient in our own ItemModelView.

Chapter II: Open Inventor

Open Inventor Modules

Introduction

In total, there are three types of modules:

  • blue ML modules
  • brown macro modules
  • green Open Inventor modules

The names of Open Inventor modules start with the prefix So\* (for Scene Objects). Open Inventor modules process and render 3D scene objects and enable image interactions. Scene objects are transmitted using the semicircle-shaped input and output connectors. With the help of these modules, Open Inventor scenes can be implemented.

Example 1: Open Inventor Objects

Example 1: Open Inventor Objects

Introduction

In this example we like to construct an Open Inventor scene in which we display three 3D objects of different color and shape.

Steps to Do

Generating Open Inventor Objects

First, add the modules SoExaminerViewer and SoCone to the workspace and connect both modules as shown. The module SoCone creates a cone shaped object, which can be displayed in the viewer SoExaminerViewer.

Example 2: Mouse Interactions in Open Inventor

Example 2: Mouse Interactions in Open Inventor

Introduction

In this example, we implement some image or object interactions. We will create a 3D scene in which we display a cube and change its size using the mouse. We also get to know another viewer, the module SoExaminerViewer. This viewer is important: It enables the rendering of Open Inventor scenes and allows interactions with the Open Inventor scenes.

Example 3: Camera Interactions in Open Inventor

Example 3: Camera Interactions in Open Inventor

Introduction

In this example, we are learning the basic principles of camera interactions in Open Inventor. We will show the difference between a SoRenderArea and a SoExaminerViewer and use different modules of the SoCamera* group.

The SoRenderArea Module

The module SoRenderArea is a simple renderer for Open Inventor scenes. It offers functionality to record movies and to create snapshots, but does not include an own camera or light.

Example 4: Post Effects in Open Inventor

Example 4: Post Effects in Open Inventor

Introduction

Up to this point, we practiced constructing Open Inventor scenes and placed three-dimensional Open Inventor objects of different colors and shapes within them.

In this tutorial, we will go over the steps to add shadows to our 3D objects, make them glow, and vary their opacity to make them transparent. We will also incorporate WEMs from multi-frame DICOMs and render them as scene objects to see how different post effects can be used on them.

Chapter III: Visualization

Visualization in MeVisLab

Introduction

Images and data objects can be rendered in 2D and 3D and interacted with in several ways using a set of tools available through MeVisLab. In this chapter in particular, we will focus on simple image interaction with two- and three-dimensional visualizations.

View2D and View3D

An easy way to display data and images in 2D and 3D is by using them modules View2D and View3D. What can be done with these viewers?

Example 1: Synchronous View of Two Images

Example 1: Synchronous View of Two Images

Introduction

In this example we like to use the module SynchroView2D to be able to inspect two different images simultaneously.

The module SynchroView2D provides two 2D viewers that are synchronized.

As in the tutorial Chapter 1 - Basic Mechanics of MeVisLab, the processed and the unprocessed image can be displayed simultaneously. Scrolling through one image automatically changes the slices of both viewers, so slices with the same slice number are shown in both images.

Example 2: Creating a Magnifier

Example 2: Creating a Magnifier

Introduction

Medical images are typically displayed in three different viewing directions (see image): coronal, axial, and sagittal.

Using the viewer OrthoView2D, you are able to decide which viewing direction you like to use. In addition to that, you have the opportunity to display all three orthogonal viewing directions simultaneously. Here, we like to display an image of the head in all three viewing directions and mark positions in the image.

Example 3: Image Overlays

Example 3: How to Blend Images Over Each Other

Introduction

In this example we will show you how to blend a 2D image over another one. With the help of the module SoView2DOverlay we will create an overlay, which allows us to highlight all bones in the scan.

Steps to Do

Develop Your Network

Start this example by adding the shown modules, connecting the modules to form a network, and loading the example image Bone.tiff.

Example 4: Display 2D Images in Open Inventor SoRenderArea

Example 4: Display Images Converted to Open Inventor Scene Objects

Introduction

In the previous example you learned how to use the module SoView2DOverlay together with a View2D. MeVisLab provides a whole family of SoView2D modules (SoView2DOverlay, SoView2DRectangle, SoView2DGrid, …). These modules are derived from SoView2DExtension, which extends the SoView2D with specialized interaction and rendering. SoView2D itself renders a slice or a slab of a voxel image as a 2D image on the screen.

Example 5: Volume Rendering and Interactions

Example 5: Volume Rendering and Interactions

Introduction

In this example we like to convert a scan of a head into a 3D scene object. The scene object allows to add some textures, interactions, and animations.

Steps to Do

Develop Your Network

Implement the following network and open the image $(DemoDataPath)/BrainMultiModal/ProbandT1.tif.

SoGVRVolumeRenderer

SoGVRVolumeRenderer

The module SoGVRVolumeRenderer allows volume rendering of 3D and 4D images.

Example 6: MeVis Path Tracer

Example 6: MeVis Path Tracer

Introduction

The MeVis Path Tracer offers a Monte Carlo Path Tracing framework running on CUDA GPUs. It offers photorealistic rendering of volumes and meshes, physically based lighting with area lights and soft shadows and fully integrates into MeVisLab Open Inventor (camera, depth buffer, clipping planes, etc.).

Example 6.1: Volume Rendering vs. Path Tracer

Example 6.1: Volume Rendering vs. Path Tracer

Introduction

In this example, you develop a network to show some differences between volume rendering and the MeVis Path Tracer. You will visualize the same scene using both 3D rendering techniques and some of the modules for path tracing.

Example 6.2: Visualization Using Path Tracer

Example 6.2: Visualization Using SoPathTracer

Introduction

In this tutorial, we will explain the basics of using the SoPathTracer module in MeVisLab. You will learn how to create a scene, assign materials, add light sources, and configure the MeVis Path Tracer to generate enhanced renderings.

Example 7: Add 3D Viewer to OrthoView2D

Example 7: Add 3D Viewer to OrthoView2D

Introduction

In this example we will use the OrthoView2D module and add a 3D viewer to the layout Cube.

Steps to Do

Develop Your Network

Add the modules LocalImage and OrthoView2D to your workspace and connect them.

Network

Network

The OrthoView2D module allows you to select multiple layouts. Select layout Cube Equal. The layout shows your image in three orthogonal viewing directions. The top left segment remains empty.

Example 8: Vessel Segmentation Using SoVascularSystem

Example 8: Vessel Segmentation using SoVascularSystem

Introduction

In this tutorial, we are using an input mask to create a vessel centerline using the DtfSkeletonization module and visualize the vascular structures in 3D using the SoVascularSystem module. The second part uses the distance between centerline and surface of the vessel structures to color thin vessels red and thick vessels green.

Steps to Do

Develop Your Network

Load the example tree mask by using the LocalImage module. Connect the output to a DtfSkeletonization module as seen below. The initial output of the DtfSkeletonization module is empty. Press the Update button to calculate the skeleton and the erosion distances.

Example 9: Creating Dynamic 3D Animations Using AnimationRecorder

Example 9: Creating Dynamic 3D Animations using AnimationRecorder

Introduction

In this tutorial, we are using the AnimationRecorder module to generate dynamic and visually appealing animations of our 3D scenes. We will record a video of the results of our previous project, particularly the detailed visualizations of the muscles, bones, and blood vessels created using PathTracer.

Steps to Do

Open the network and files of Example 6.2, add a SoSeparator module and an AnimationRecorder module to your workspace and connect them as shown below.

Chapter IV: Image Processing

Image Processing in MeVisLab

Digital image processing is the use of a digital computer to process digital images through an algorithm (see Wikipedia).

MeVisLab provides multiple modules for image processing tasks, such as:

  • Filters
  • Masks
  • Transformations
  • Arithmetics
  • Statistics

In this chapter, you will find some examples for different types of image processing in MeVisLab.

Developing Your Own C++ Modules

C++ Module Development

Introduction

The development of your own C++ modules can be done by implementing ML modules or Open Inventor modules.

ML Modules on the C++ Level

  • Image processing modules are objects derived from class Module defined in the ML library and therefore are also called ML modules.
  • Image inputs and outputs are connectors to objects of class PagedImage , which are defined in the ML library.
  • Inputs and outputs for abstract data structures are connectors to pointers of objects derived from class Base and are called Base objects.

Open Inventor Modules on the C++ Level

  • Most Open Inventor modules are objects derived from class SoNode , defined in the Open Inventor library.
  • Open Inventor inputs and outputs are connectors to objects derived from class SoNode, defined in the Open Inventor library. Many Open Inventor modules will return themselves as outputs (“self”). On inputs, they may have connectors to child Open Inventor modules.
  • Some Open Inventor modules are objects derived from class SoEngine . They are used for calculations and return their output not via output connectors but via parameter fields.
  • Open Inventor modules may also have input and output connectors to Base objects and image objects.
  • All standard Open Inventor nodes defined in the Open Inventor library are available in MeVisLab as Open Inventor modules.

This chapter describes some examples for developing your own ML and Open Inventor modules.

Example 1: Creating a New ML Module for Adding a Value to Each Voxel

Example 1: Creating a New ML Module for Adding a Value to Each Voxel

Precondition

Make sure to have CMake installed. This example has been created using CMake Legacy Release (3.31.11).

Introduction

In this example, we develop our own C++ ML module, which adds a constant value to each voxel of the given input image.

Steps to Do

Create a New ML Module

Before creating the module, make sure to have your own user package available. See Package creation for details about Packages.

Example 1: Applying Scalar Functions to Two Images

Example 1: Arithmetic Operations on Two Images

Introduction

We are using the Arithmetic2 module to apply basic scalar functions on two images. The module provides two inputs for images and one output image for the result.

Steps to Do

Develop Your Network

Add two LocalImage modules to your workspace for the input images. Select $(DemoDataPath)/BrainMultiModal/ProbandT1.dcm and $(DemoDataPath)/BrainMultiModal/ProbandT2.dcm from MeVisLab demo data and add a SynchroView2D to your network.

Example 2: Masking Images

Example 2: Masking Images

Introduction

The background of medical images is black for most cases. In the case an image is inverted or window/level values are adapted, these black voxels outside clinical relevant voxels might become very bright or even white.

Being in a dark room using a large screen, the user might be blended by these large white regions.

Example 3: Region Growing

Example 3: Region Growing

Introduction

A very simple approach to segment parts of an image is the region growing method. A general explanation can be found here.

In this example, you will segment the brain of an image and show the segmentation results as an overlay on the original image.

Steps to Do

Develop Your Network

Add a LocalImage module to your workspace and select load $(DemoDataPath)/BrainMultiModal/ProbandT1.dcm. Add a View2D module and connect both as seen below.

Example 4: Subtracting 3D Surface Objects

Example 4: Subtracting 3D Objects

Introduction

In this example, we load an image and render it as WEMIsoSurface. Then, we create a three-dimensional SoSphere and subtract the sphere from the initial WEM.

Steps to Do

Develop Your Network

Add a LocalImage module to your workspace and select load $(DemoDataPath)/BrainMultiModal/ProbandT1.dcm. Add a WEMIsoSurface, a SoWEMRenderer, a SoBackground, and a SoExaminerViewer module and connect them as seen below. Make sure to configure the WEMIsoSurface to use a Iso Min. Value of 420 and a Voxel Sampling of 1.

Example 5: Clip Planes

Example 5: Clip Planes

Introduction

In this example, we are using the SoGVRDrawOnPlane module to define the currently visible slice from a 2D view as a clip plane in 3D.

Steps to Do

Develop Your Network

First, we need to develop the network to scroll through the slices. Add a LocalImage module to your workspace and select the file ProbandT1 from MeVisLab demo data.

Example 6: DICOM RT Visualization in MeVisLab – RTSTRUCT and RTDOSE Workflow

Example 6: DICOM RT Visualization in MeVisLab – RTSTRUCT and RTDOSE Workflow

Introduction

This tutorial explains how to load and visualize DICOM RT (Radiotherapy) data in MeVisLab. You will learn how to:

  • Load CT and related RTSTRUCT data.
  • Visualize RTSTRUCTs as colored CSOs.
  • Show labels next to each RTSTRUCT contour.
  • Visualize RTDOSE as a semitransparent colored overlay.

DICOM RT files are essential in radiotherapy treatment planning.

They include:

  • RT Structure Set: containing information related to patient anatomy, for example, structures, markers, and isocenters. These entities are typically identified on devices such as CT scanners, physical or virtual simulation workstations, or treatment planning systems.
  • RT Plan: containing geometric and dosimetric data specifying a course of external beam and/or brachytherapy treatment, for example, beam angles, collimator openings, beam modifiers, and brachytherapy channel and source specifications. The RT Plan entity may be created by a simulation workstation, and subsequently enriched by a treatment planning system before being passed on to a record and verify system or treatment device. An instance of the RT Plan object usually references an RT Structure Set instance to define a coordinate system and set of patient structures.
  • RT Dose: containing dose data generated by a treatment planning system in one or more of several formats: three-dimensional dose data, isodose curves, DVHs, or dose points.

Additional objects not used in this tutorial are:

Chapter V: Data Objects

Data Objects in MeVisLab

MeVisLab provides predefined data objects, for example:

Usage, advantages, and disadvantages of each above-mentioned data object type will be covered in the following chapters, where you will build example networks for some of the most common use cases.

Contour Objects (CSO)

Contour Segmentation Objects (CSOs) in MeVisLab

Introduction

Structure of CSOs

MeVisLab provides modules to create contours in images. 3D objects that encapsulate these contours are called Contour Segmentation Objects (CSOs).

In the next image, you can see a rectangular shaped CSO. The pink circles you can see are called Seed Points.

Seed Points define the shape of the CSO. In the case of a rectangle, you need four Seed Points forming the corners to define the whole rectangle.

Contour Example 1: Creation of Contours

Contour Example 1: Creation of Contours

Introduction

We like to start with the creation of CSOs. To create CSOs, you need a SoCSO*Editor. There are several different editors that can be used to create CSOs (see here). Some of them are introduced in this example.

Steps to Do

Develop Your Network

For this example, we need the following modules. Add the modules to your workspace, connect them as shown below, and load the example image $(DemoDataPath)/BrainMultiModal/ProbandT1.tif.

Contour Example 2: Contour Interpolation

Contour Example 2: Creating Contours using Live Wire and Interpolation

Introduction

In this example, we like to create CSOs using the Live Wire Algorithm, which allows semiautomatic CSO creation. The algorithm uses edge detection to support the user creating CSOs.

We also like to interpolate CSOs over slices. That means additional CSOs are generated between manual segmentations based on a linear interpolation.

Contour Example 3: 2D and 3D Visualization of Contours

Contour Example 3: Overlay Creation and 3D Visualization of Contours

Introduction

In this example, we’d like to use the created CSOs to display an overlay. This allows us to mark one of two lungs. In addition to that, we will display the whole segmented lobe of the lung in a 3D viewer.

Steps to Do

Develop Your Network

Use the network from the contour example 2 and add the modules VoxelizeCSO, SoView2DOverlay and View2D to your workspace. Connect the module as shown. The module VoxelizeCSO allows to convert CSOs into a voxel image.

Contour Example 4: Annotation of Images

Contour Example 4: Annotation of Images

Introduction

In this example, we like to calculate the volume of our object, in this case, the part of the lung we have segmented.

Steps to Do

Develop Your Network and Calculate the Lung Volume

Add the modules CalculateVolume and SoView2DAnnotation to your workspace and connect both modules as shown. Update the module CalculateVolume, which directly shows the volume of our object.

Contour Example 5: Contours and Ghosting

Contour Example 5: Visualizing Contours and Images

Introduction

In this example, we like to automatically create CSOs based on a predefined isovalue.

Steps to Do

Develop Your Network

Add the following modules to your workspace and connect them as shown. Load the example image Bone.tiff.

Automatic Creation of CSOs Based on the Isovalue

Now, open the panel of CSOIsoGenerator to set the Iso Value to 1200. If you press Update in the panel, you can see the creation of CSOs on each image slice when opening the module View2D. In addition to that, the number of CSOs is displayed in the CSOManager. The module CSOIsoGenerator generates isocontours for each slice at a fixed isovalue. This means that closed CSOs are formed based on the detection of the voxel value of 1200 on every slice.

Contour Example 6: Adding Labels to Contours

Contour Example 6: Adding Labels to Contours

Introduction

In this example, we are adding a label to a contour. The label provides information about measurements and about the contour itself. The label remains connected to the contour and can be moved via mouse interactions Left Mouse Button .

Steps to Do

Develop Your Network

Add the modules LocalImage and View2D to your workspace and connect them as shown below. Load the file ProbandT1.dcm from MeVisLab demo data. In order to create contours (CSOs), we need a SoView2DCSOExtensibleEditor module. It manages attached CSO editors, renderers, and offers an optional default renderer for all types of CSOs.

Contour Example 7: Using the CSOListContainer

Contour Example 7: Using the CSOListContainer

Introduction

In this example, we are using the module CSOListContainer instead of the CSOManager. The CSOManager is a heavyweight, UI driven module. You can use it to see all of your CSOs and CSOGroups in the module panel. The CSOListContainer is a lightweight module with focus on Python scripting. We recommend to use this module for final application development, because Python provides much more flexibility in handling CSO objects.

Surface Objects (WEM)

Surface Objects (WEMs)

Introduction

In MeVisLab, it is possible to create, visualize, process, and manipulate surface objects, also known as polygon meshes. Here, we call surface objects Winged Edge Mesh, in short WEM. In this chapter you will get an introduction into WEMs. In addition, you will find examples on how to work with WEMs. For more information on WEMs, take a look at the MeVisLab Toolbox Reference . If you like to know which WEM formats can be imported into MeVisLab, take a look at the assimp documentation here.

Surface Example 1: Creation of WEMs

Surface Example 1: Create Winged Edge Mesh out of Voxel Images and CSOs

Introduction

In this example, you will learn how to create a Winged Edge Mesh (WEM). There are several approaches of creating WEMs, a few of them are shown in this example.Additionally to creating WEMs, they can also be imported, see chapter Surface Objects (WEM).

Steps to Do

From Image to Surface: Generating WEMs out of Voxel Images

At first, we will create a WEM out of a voxel image using the module WEMIsoSurface. Add and connect the shown modules. Load the image $(DemoDataPath)/Bone.tiff and set the Iso Min. Value in the panel of WEMIsoSurface to 1200. Tick the checkbox Use image max. value. The module WEMIsoSurface creates surface objects out of all voxels with an isovalue equal or above 1200 (and smaller than the image’s maximum value). The module SoWEMRenderer can now be used to generate an Open Inventor scene, which can be displayed by the module SoExaminerViewer.

Surface Example 2: Processing and Modification of WEM

Surface Example 2: Processing and Modifying of WEM

Introduction

In this example, you will learn how to modify and process WEMs.

Steps to Do

Develop Your Network

Modification of WEMs

Use the module WEMLoad to load the file venus.off. Then, add and connect the shown modules. We like to display the WEM venus two times, one time this WEM is modified. You can use the module WEMModify to apply modifications. In its panel, change the scale and the size of the WEM. Now, you see two times the venus next to each other.

Surface Example 3: Interactions With WEM

Surface Example 3: Interactions with WEM

Introduction

In these examples, we are showing two different possibilities to interact with the visualization of the WEM:

  • Scale, rotate, and move a WEM’s visualization in a scene
  • Modify a WEM in a scene

Scale, Rotate, and Move a WEM in a Scene

We are using a SoTransformerDragger module to apply transformations to the visualization of a 3D WEM object via mouse interactions.

Surface Example 4: Interactively Moving WEM

Surface Example 4: Interactively Moving WEM

Introduction

In this example, we like to interactively move WEMs using SoDragger modules inside a viewer.

Develop Your Network

Interactively Translating Objects in 3D Using SoDragger Modules

Add and connect the following modules as shown. On the panel of the module WEMInitialize, select the Model Octasphere. After that, open the viewer SoExaminerViewer and make sure to select the Interaction Mode. Now, you are able to click Left Mouse Button on the presented Octasphere and move it alongside one axis. The following modules are involved in the interactions:

Surface Example 5: WEM - Primitive Value Lists

Surface Example 5: WEM - Primitive Value Lists

Introduction

WEMs do not only contain the coordinates of nodes, they can also contain additional information. That information is stored in so-called Primitive Value Lists (PVLs). Every node, every edge, and every faces can contain such a list. In these lists, you can, for example, store the color of the node or specific patient information. This information can be used for visualization or for further statistical analysis.

Chapter VI: Testing

MeVisLab Tutorial Chapter VI

Testing, Profiling, and Debugging in MeVisLab

The MeVisLab Integrated Development Environment (IDE) provides tools to write automated tests in Python, to profile your network performance, and to debug your Python code. All of these funtionalities will be addressed in this chapter.

Testing

The MeVisLab TestCenter is the starting point of your tests. Select [ File → Run TestCaseManager ] or press Ctrl + Alt + T to open the user interface of the TestCaseManager.

Marker Objects

Markers in MeVisLab

In MeVisLab, you can attach markers to images and other data objects. In this example, you will see how to create, process, and use markers.

Creation and Rendering

To create markers, you can use a marker editor, for example, the SoView2DMarkerEditor. Connect this editor to a viewer as shown below. Now you can interactively create new markers. Connect the module XMarkerListContainer to your marker editor to store markers in a list.

Example 1: Distance Between Markers

Example 1: Calculating the Distance Between Markers

Introduction

In this example, we will measure the distance between one position in an image to a list of markers.

Steps to Do

Develop Your Network

Add the following modules and connect them as shown.

We changed the names of the modules SoView2DMarkerEditor and XMarkerListContainer, to distinguish these modules from two similar modules we will add later on. Open the panel of SoView2DMarkerEditor and select the tab Drawing. Now choose the Color red.

Example 1: Writing a Simple Test Case in MeVisLab

Example 1: Writing a Simple Test Case in MeVisLab

Introduction

In this example, you will learn how to write an automated test for a simple network using the DicomImport, MinMaxScan, and View3D modules. Afterward, you will be able to write test cases for any other module and network yourself.

MeVisLab provides two options to compare a test result with an expected result:

Example 2: Profiling in MeVisLab

Example 2: Profiling in MeVisLab

Introduction

In this example we are using the MeVisLab Profiler to inspect the memory and CPU consumption of the modules in an example network.

Steps to Do

Creating the Network to be Used for Profiling

You can open any network you like, here we are using the example network of the module MinMaxScan for profiling. Add the module MinMaxScan to your workspace, open the example network via right-click Right Mouse Button and select [ Help → Show Example Network ].

Example 3: Iterative Tests in MeVisLab With Screenshots

Example 3: Iterative Tests in MeVisLab

Introduction

In this example, you are writing an iterative test. Iterative test functions run a function for every specified input. They return a tuple consisting of the inputs iterated over and the function object called. The iterative test functions are useful if the same function should be applied to different input data. These could be input values, names of input images, etc.

Curves

Curves in MeVisLab

Introduction

Curves can be used in MeVisLab to print the results of a function as two-dimensional mathematical curves into a diagram.

Curves in MeVisLab

Curves in MeVisLab

Example 1: Drawing Curves

Example 1: Drawing Curves

Introduction

In this example, you will draw one or more curves into a diagram and define different styles for the curves.

Steps to Do

Develop Your Network

A curve requires x- and y-coordinates to be printed. You can use the CurveCreator module as input for these coordinates. The SoDiagram2D draws the curves into a SoRenderArea. You can also define the style of the curves by using the StylePalette module.

Chapter VII: Application Development

MeVisLab Tutorial Chapter VII

Summary

This chapter will summarize all previous chapters and you will develop an entire application in MeVisLab. The complete workflow from developing a prototype to delivering your final application to your customer is explained step-by-step.

Prototype to product

Prototype to product

Step 1: Prototyping - Develop Your Network

Step 1: Prototyping - Develop Your Network

Introduction

In this example, we will develop a network that fulfills the requirements mentioned on the overview page. The network will be developed by reusing existing modules and defining basic field values.

Steps to Do

2D Viewer

The 2D viewer shall visualize the loaded images. In addition to that, it shall be possible to click Left Mouse Button into the image to trigger a region growing algorithm to segment parts of the loaded image based on a position and a threshold.

Step 2: Prototyping - Create a Macro Module

Step 2: Prototyping - Create a Macro Module

Introduction

In this example, we encapsulate the previously developed prototype network into a macro module for future application development and automated testing.

Steps to Do

Make sure to have your .mlab file from the previous tutorial available.

Package Creation

Packages are described in detail in Example 2.1: Package creation. If you already have your own package, you can skip this part and continue creating a macro module.

Step 3: Prototyping - User Interface and Python Scripting

Step 3: Prototyping - User Interface and Python Scripting

Introduction

In this step, we will develop a user interface and add Python scripting to the macro module you created in Step 2.

Steps to Do

Develop the User Interface

A mockup of the user interface you are going to develop is available here. The interface provides the possibility to load files and shows a 2D and a 3D viewer. In addition to that, some settings and information for our final application are available.

Step 4: Review - Automated Tests

Step 4: Review - Automated Tests

Introduction

In the previous chapters you developed a macro module with a user interface and Python scripting. In this step you will see how to implement an automated test to verify and validate the requirements defined in Overview.

Steps to Do

Create a Test Network Using Your Macro Module

Create a new and empty network and save it as .mlab file. Remember the location.

Step 5: Review - Installer creation

Step 5: Review - Installer creation

Introduction

Your macro module has been tested manually and/or automatically? Then, you should create your first installable executable and deliver it to your customer(s) for final evaluation.

Step 6: Refine - Update Application

Step 6: Refine - Update Application

Introduction

In the previous step you developed an application that can be installed on your customers systems for usage. In this step we are going to integrate simple feedback into our executable and recreate the installer.

We want to show you how easy it is to update your application using MeVisLab.

Your customer requests an additional requirement to define the transparency of your 2D overlay in addition to defining the color.

Step 7: Refine - Rebuild Installer

Step 7: Refine - Rebuild Installer

Introduction

In this step you are recreating your application installer after changing the UI in previous Step 6: Refine - Update Application.

Steps to Do

Update the .mlinstall File

You do not need to use the Project Wizard now, because you already have a valid .mlinstall file. The location should be in your package under .\Configuration\Installers\TutorialSummary. Open the file in any text editor and search for the $VERSION 0.5. Change the version to something else, in our case, we now have our first major release 1.0.

Extra: Run Your Application in a Browser

Extra: Run Your Application in a Browser

Introduction

This step explains how to run your developed application in a browser. The MeVisLab network remains the same, only some adaptations are necessary for running any macro module in a browser window.

Chapter VIII: Third-party Components

MeVisLab Tutorial Chapter VIII

Using Third-party Software Integrated into MeVisLab

MeVisLab is equipped with a lot of useful software right out of the box, like the Insight Segmentation and Registration Toolkit (ITK) or the Visualization Toolkit (VTK). This chapter is intended as a guide on how to use some of the third-party components integrated in MeVisLab for your projects via Python scripting.

OpenCV

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV includes, among others, algorithms to:

OpenCV

Open Source Computer Vision Library (OpenCV)

Introduction

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.

This chapter provides some examples how to use OpenCV in MeVisLab.

Other Resources

You can find a lot of OpenCV examples and tutorials on their website.

Example 1: Webcam Access with OpenCV

Example 1: Webcam Access with OpenCV

Introduction

In this example, we are using the PythonImage module and access your webcam to show the video in a View2D.

Steps to Do

Creating the Network to be Used for Testing

Add the modules to your workspace and connect them as seen below.

Example network

Example network

The viewer is empty because the image needs to be set via Python scripting.

Example 2: Face Detection with OpenCV

Example 2: Face Detection with OpenCV

Introduction

This example uses the OpenCV webcam Python script and adds a basic face detection.

Steps to Do

Open Example 1

Add the macro module developed in Example 1 to your workspace.

assimp

Asset-Importer-Lib (assimp)

Introduction

Assimp (Asset-Importer-Lib) is a library to load and process geometric scenes from various 3D data formats.

This chapter provides some examples of how 3D formats can be imported into MeVisLab. In general, you always need a SoSceneLoader module. The SoSceneLoader allows to load meshes as Open Inventor points/lines/triangles/faces using the Open Asset Import Library.

SoSceneLoader

SoSceneLoader

You can also use the SoSceneWriter module to export your 3D scenes from MeVisLab in a number of output formats.

Example 1: 3D Printing in MeVisLab

Example 1: 3D Printing in MeVisLab

Introduction

This example uses the assimp library to load a 3D file and save the file as .stl for 3D printing.

Steps to Do

Develop Your Network

Add the modules SoSceneLoader, SoBackground, and SoExaminerViewer to your workspace and connect them as seen below.

Example network

Example network

Open the 3D File

Select the file vtkCow.obj from MeVisLab demo data directory. Open SoExaminerViewer and inspect the scene. You will see a 3D cow.

PyTorch

PyTorch

Introduction

PyTorch is a machine learning framework based on the Torch library, used for applications such as Computer Vision and Natural Language Processing, originally developed by Meta AI and now part of the Linux Foundation umbrella.

A lot of AI frameworks can be used within MeVisLab. We do not provide a preintegrated AI framework though as we try to avoid compatibility issues, and AI frameworks are very fast-moving by nature.

Example 1: Installing PyTorch Using the PythonPip Module

Example 1: Installing PyTorch Using the PythonPip Module

Introduction

The module PythonPip allows you to install additional Python packages to be used in MeVisLab.

The module either allows to install packages into the global MeVisLab installation directory, or into your defined user package. We will use the user package directory, because then the installed packages remain available in your packages even if you uninstall or update MeVisLab. In addition to that, no administrative rights are necessary if you did install MeVisLab for all users.

Example 2: Brain Parcellation Using PyTorch

Example 2: Brain Parcellation Using PyTorch

Introduction

In this example, you are using a pretrained PyTorch deep learning model (HighRes3DNet) to perform a full brain parcellation.

HighRes3DNet is a 3D residual network presented by Li et al. in On the Compactness, Efficiency, and Representation of 3D Convolutional Networks: Brain Parcellation as a Pretext Task.

Steps to Do

Add a LocalImage module to your workspace and select the file MRI_Head.dcm. For PyTorch, it is necessary to resample the data to a defined size. Add a Resample3D module to the LocalImage and open the panel. Change Keep Constant to Voxel Size and define Image Size as 176, 217, 160.

Example 3: Segment Persons in Webcam Videos

Example 3: Segment Persons in Webcam Videos

Introduction

This tutorial is based on Example 2: Face Detection With OpenCV. You can reuse some of the scripts already developed in the other tutorial.

Steps to Do

Add the macro module developed in the previous example to your workspace.

WebcamTest module

WebcamTest module

Open the internal network of the module via middle mouse button Middle Mouse Button / Mouse Wheel and right-click Right Mouse Button on the tab of the workspace showing the internal network. Select Show Enclosing Folder.

MONAI

MONAI

Introduction

MONAI (Medical Open Network for AI) is an open-source framework built on PyTorch designed for developing and deploying AI models in medical imaging.

Created by NVIDIA and the Linux Foundation, it provides specialized tools for handling medical data formats like DICOM and NIfTI, along with advanced preprocessing, augmentation, and 3D image analysis capabilities.

MONAI includes ready-to-use deep learning models (such as UNet and SegResNet) and utilities for segmentation, classification, and image registration. It supports distributed GPU training and ensures reproducible research workflows.

Example 1: Installing MONAI Using the PythonPip Module

Example 1: Installing MONAI Using the PythonPip Module

Introduction

With the PythonPip module, you can import additional Python libraries into MeVisLab.

Steps to Do

Install PyTorch

As MONAI requires PyTorch, install it by using the PythonPip module as described here.

Install MONAI

After installing torch and torchvision, we install MONAI.

For installing MONAI, enter "monai" into the Command textbox and press Install.

Install MONAI

Install MONAI

Example 2: Applying a Spleen Segmentation Model from MONAI in MeVisLab

Example 2: Applying a Spleen Segmentation Model from MONAI in MeVisLab

Introduction

In the following, we will perform a spleen segmentation using a model from the MONAI Model Zoo. The MONAI Model Zoo is a collection of pretrained models for medical imaging, offering standardized bundles for tasks like segmentation, classification, and detection across MRI, CT, and pathology data, all built for easy use and reproducibility within the MONAI framework. Further information and the required files can be found here.

Matplotlib

Matplotlib

Matplotlib, introduced by John Hunter in 2002 and initially released in 2003, is a comprehensive data visualization library in Python. It is widely used in the scientific world as it is easy to grasp for beginners and provides high quality plots and images that are widely customizable.

As MeVisLab supports the integration of Python scripts, e.g., for test automation, Matplotlib can be used to visualize any data you might want to see. And as it is directly integrated into MeVisLab, you don’t have to install it (via PythonPip module) first.

Example 1: Module Setup

Example 1: Module Setup

Introduction

To be able to access the data needed for our grayscale distribution plots, we need a network consisting of a module that imports DICOM data, a module that differentiates between slices, and another module that ouputs histogram data.

Steps to Do

Open up your MeVisLab workspace and add the modules LocalImage, SubImage, and Histogram to it. Connect the output of LocalImage to the input of SubImage, and the output of SubImage to the input of Histogram. If you feel like using a shortcut, you can also download the base network below and open it in your MeVisLab.

Example 2: 2D Plotting

Example 2: 2D Plotting

Introduction

In this tutorial, we will equip the macro module we created in the previous tutorial with a responsive and interactable panel to plot grayscale distributions of single slices as well as defined sequences of slices in 2D.

Steps to Do

Open the module definition folder of your macro module and the related .script file in MATE. Then, activate the preview as shown below:

MATE’s Preview view

MATE's Preview view

Example 3: Slice Comparison

Example 3: Slice Comparison

Introduction

We will adapt the previously created macro module to be able to overlay two defined slices to compare their grayscale distributions.

Steps to Do

As a first step, we will extend the panel: Open your BaseNetwork macro module within an empty MeVisLab workspace and select the .script file from its related files.

Example 4: 3D Plotting

Example 4: 3D Plotting

Introduction

In this tutorial, we will equip the macro module we created in the Example 1: Module Setup and later on adapted by enabling it to plot grayscale distributions of single slices and sequences in 2D in Example 2: 2D Plotting with a three-dimensional plotting functionality.

Steps to Do

The fields and commands needed have already been prepared in the second tutorial. We will just have to modify our .py file a little bit to make them usable. Integrate the following code into your .py file and import numpy.

Tips and Tricks

MeVisLab Tips and Tricks

This chapter shows some features and functionalities that are helpful but do not provide its own tutorial.

Keyboard Shortcuts

This is a collection of useful keyboard shortcuts in MeVisLab.

ShortcutFunctionality
Ctrl + 1Automatically arrange selection of modules in the current network
Ctrl + 2Open most recent network file
Ctrl + 3Run most recent test case (extremely useful for developers)
Ctrl + A then Ctrl + 1Layout network
Ctrl + A then TABLayout .script file (in MATE)
Ctrl + DDuplicate currently selected module (including all field values)
Ctrl and Left Mouse Button Left Mouse Button or Middle Mouse Button Middle Mouse Button / Mouse WheelShow internal network
SPACEShow hidden outputs of the currently selected module
Ctrl + Alt + TStart TestCaseManager
Ctrl + KRestart MeVisLab with current network(s)
Ctrl + RRun script file with the same name of your network file if available in the same directory
Alt Double-click Left Mouse Button on a moduleOpen automatic panel of the module.

Using Snippets

Sometimes you have to create the same network over and over again — for example, to quickly preview DICOM files. Generally, you will at least add one module to load and another module to display your images. Sometimes you may also want to view the DICOM header data. A network you possibly generate whenever opening DICOM files will be the following: