Beginner

Chapter I: Basic Mechanisms of MeVisLab

Basic Mechanics 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 re-use 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 pre-defined 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 next to each other:

  • 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 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

Macro modules and Module Interactions via User Interface and Python Scripting

MeVisLab provides different types of modules, which can be distinguished by their color. The brown modules are called Macro modules. Macro modules condense a whole network into one module. You can open the internal network by pressing the middle mouse button Middle Mouse Button / Mouse Wheel or via right mouse click Right Mouse Button and select [ Help → Show Internal Network ]. Macro modules provide the possibility to create customized user interfaces and Python interactions.

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 will give 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 flilter

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 draw 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.

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 semi-circle 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.

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 the 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 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, …). All these modules create or interact with scene objects and are based on the module SoView2D, which can convert a voxel-image into a scene object. In this example, you will get to know some members of the SoView2D-family.

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 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.

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

For details about Image Processing in MeVisLab, see the MeVisLab Documentation

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

Example 1: Arithmetic operations on 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 2 inputs for images and 1 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 case an image is inverted or window/level values are adapted, these black pixels outside clinical relevant pixels 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.

Image masking is a very good way to select a defined region where image processing shall be applied. A mask allows to define a region (the masked region) to allow image modifications whereas pixels outside the mask remain unchanged.

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.

Chapter V: Data Objects

Data Objects in MeVisLab

MeVisLab provides pre-defined data objects, e. g.

  • Contour Segmented Objects (CSOs)
    which are three-dimensional objects encapsulating formerly defined contours within images.
  • Surface Objects (Winged Edge Meshes or WEMs)
    represent the surface of geometrical figures and allow the user to manipulate them.
  • Markers
    are used to mark specific locations or aspects of an image and allow to process those later on.
  • Curves
    can print the results of a function as two-dimensional mathematical graphs into a diagram.

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

Contour Objects (CSO)

Contour Segmented Objects (CSOs) in MeVisLab

Introduction

Structure of CSOs

MeVisLab provides modules to create contours in images. 3D objects which encapsulate these contours are called Contour Segmented 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 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, which 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 semi-automatic 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 image.

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 voxel images.

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 module 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 iso value.

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 iso value

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 every slide, when opening the module View2D. In addition to that the number of CSOs is displayed in the CSOManager. The module CSOIsoGenerator generates iso-contours for each slice at a fixed iso value. 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.

Steps to do

Develop your network

Add a LocalImage and a View2D module 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.

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 on creating WEMs, a few of them are shown in this example. Instead of 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 box Use image max. value. The module WEMIsoSurface creates surface objects out of all voxels with an Iso value equal or above 1200 (and smaller than the image max 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 Modification 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 2 different possibilities to interact with a WEM:

  • Scale, rotate and move a WEM 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 on 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 insight a viewer.

Develop your network

Interactively translating objects in 3D using SoDragger modules

Add and connect the following modules as shown. In 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 on the presented Octaspehere and move it alongside one axis. The following modules are involved in the interactions:

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, 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 ] to open the user interface of the TestCaseManager.

Marker Objects

Markers in MeVisLab

In MeVisLab you can equip images and other data objects with markers. 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 chose 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. Afterwards, you will be able to write test cases for any other module and network yourself.

Steps to do

Creating the network to be used for testing

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

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 ].

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

In the given example, only modules available in commercial MeVisLab Professional SDK have been used. The non-commercial MeVisLab Standard SDK provides more modules for curves.

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.

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 into any of the output formats listed below.

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.

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 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 with 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 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.

  • The module we are adapting has been set up in the Example 1: Module Setup tutorial.
  • The panel and two-dimensional plotting functionality has been added in [Example 2: 2D Plotting] (/tutorials/thirdparty/matplotlib/2dplotting).

Steps to do

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