Beginner Tutorial Macro Macro modules Local Macro

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.

Starting off, we will add the module ImageLoad to our network to load our data. The module can be found by typing its name into the search bar on the top-right corner and is added to your network by clicking it.

Search for ImageLoad

Search for ImageLoad

Next, we select and load the data we’d like to process. Double-click the module ImageLoad to open its panel. You can browse through your folders to select the data you’d like to open. Example data can be found in the MeVisLab DemoData directory $(InstallDir)/Packages/MeVisLab/Resources/DemoData located in the MeVisLab installation path. Select a file, for example an MRI scan of a shoulder Shoulder_Fracture.tif. The image is loaded immediately and basic information of the loaded image can be seen in the Panel.

The Output-Inspector and the Module Inspector

To inspect and visualize the loaded data, we can use the Output Inspector located in the Views area. You can already interact with the image using the mouse wheel Middle Mouse Button / Mouse Wheel and mouse buttons Left Mouse Button / Right Mouse Button . To preview the image, click on the triangle on the top side of the module ImageLoad, which offers the module’s output. All module outputs can be found at the top side of the respective module.

You can now inspect your image in 2D:

Output Inspector

Output Inspector

Your image does not look like this? One reason might be that the slice of the image you are looking at has no information. Click on the Output Inspector and scroll through the slices (This process is called “Slicing”) by using the mouse wheel Middle Mouse Button / Mouse Wheel . Still not seeing anything? Then try to adjust the contrast of the given image by keeping the right mouse button Right Mouse Button pressed while moving the mouse.

You are not restricted to 2D. The Output Inspector offers a 3D View of most loaded images. Try to click on the 3D-tab located in the Output Inspector. The 3D display of the image can be rotated by left-clicking on the image and moving the courser around. The little cube in the lower right corner of the viewer shows the orientation of the image.

Below the Output Inspector, you’ll find the Module Inspector. The Module Inspector displays properties and parameters of the selected module. Parameters are stored in so called Fields. Using the Module Inspector you can examine different fields of your ImageLoad module. The module has, for example, the fields filename (the path, the loaded image is stored in), as well as sizeX, sizeY and sizeZ (the size of the loaded image).

Module Inspector

Module Inspector

Viewer

Instead of using the Output Inspector to inspect images, we’d suggest to add another viewer to the network. Search for the module View2D and add it to your workspace. Most modules have different connector options. Data is generally transmitted from the top side of a module to another modules bottom side.

The module View2D has one input connector for voxel images (triangle-shaped) and three other possible input connectors (Shaped like half-circles) on the bottom. The half-circle-shaped input connectors will be explained later on. Generally, module outputs can be connected to module inputs with the same symbol and thus transmit information and data between those modules.

2D Viewer

2D Viewer

You can now display the loaded image in the newly added viewer module by connecting the output of the module ImageLoad to the input connector of the module View2D. Follow these steps to do so:

  1. Click the output connector of ImageLoad.

  2. Keep the left mouse button Left Mouse Button pressed while dragging the connection to the input connector of View2D (white line).

  3. Check if the connection is well-defined (green line).

  4. Release the mouse button on the input connector of your View2D-module to establish the connection.

Establish connection

Establish connection

Although the connection is established, no image rendering has started yet. To initialize rendering, open the View2D panel by double-clicking on the module. Similar to the Output Inspector, you can scroll through the slices and set different levels of contrast. The amount of displayed annotations is altered by pressing A on the keyboard (annotation-mode).

View2D Panel

View2D Panel

By dragging the connection away from either the input or the output connector, the connection is interrupted.

Connections between compatible outputs and inputs are established automatically if two modules get close enough to each other.

Image Processing

An average kernel will be used to smooth the image out as our next step will be to actually process our image. Add the Convolutionmodule to your workspace and disconnect the View2Dmodule from the ImageLoadmodule by clicking on the connection and pressing DEL . Now, you can build new connections from the module ImageLoad to the module Convolution and the Convolutionmodule to View2D.

Convolution Module

Convolution Module

Open the panel of the Convolution module by double-clicking it. The panel allows configuration of the module. You can adjust parameters or select a kernel. We will be using the 3x3 Average Kernel for now.

Select a Kernel

Select a Kernel

The module View2D is now displaying the smoothed image.

To compare the processed and unprocessed image, click on the output connector of the module ImageLoad to display the original image in the Output Inspector. The Output Inspectors greatest advantage is, that it’s able to display the output of any connector in the process chain (as long as an interpretable format is used). Simply click the connector or connection to find out more about the module output.

You can also inspect changes between processed (output connector) and unprocessed (input connector) images by adding a second or even third viewer to your network.“Layers” of applied changes can be inspected next to each other using more than one viewer and placing as well as connecting them accordingly. We will be using a second View2D-module. Notice how the second Viewer is numbered for you to be able to distinguish them better. It might be important to know at this point, that numerous connections can be established from one output-connector but an input-connector can only receive one stream of data. Please connect the module ImageLoad to the second viewer to display the images twice. You can now scroll through the slices of both viewers and inspect the images.

Multiple Viewers

Multiple Viewers

Parameter Connection for Synchronization

You’re now able to scroll through the slices of the image in two separate windows. To examine the effect of the filter even better, we will now synchronize both viewers.

We already know data connections between module inputs and outputs. Besides module connections, it is also possible to connect the fields within the panels of the modules via parameter connection. The values of connected fields are synchronized, which means that the changing value of one field will be adapted to all other connected fields.

In order to practise establishing parameter connections, add the SyncFloat module to your workspace.

SyncFloat Module

SyncFloat Module

We will be synchronizing the startSlice fields of our viewers, to be able to directly compare the effect our processing module has on the slices: Right-click the viewer View2D to open its context menu and select [ Show Window → Automatic Panel ].

Automatic Panel View2D

Automatic Panel View2D

Doing so shows all parameter fields of the module View2D.

Search for the field startSlice. The field indicates which slice is currently shown in the viewer. If you scroll through the slices of an image the value of startSlice changes.

Now, double-click the module SyncFloat to open its panel.

Click on the label startSlice in the automatic panel of the module View2D, keep the button pressed and drag the connection to the label Float1 in the panel of the module SyncFloat.

Synchronize StartSlice

Synchronize StartSlice

The connection is drawn as a thin grey arrow between both modules with the arrowhead pointing to the module that receives the field value as input. The value of the field starSlice is now transmitted to the field Float1. Changing StartSlice automatically changes Float1, but not the other way round.

Parameter Connection StartSlice

Parameter Connection StartSlice

We will now establish a connection from the module SyncFloat to the second viewer, Viewer2D1. In order to do that, open the automatic panel View2D1. Draw a connection from the label Float2 of the panel of the module SyncFloat to the label startSlice in the automatic panel of the module View2D1. Lastly, implement a connection between the parameter fields startSlice of both viewers. Draw the connection from View2D1 to View2D.

Synchronize both directions

Synchronize both directions

As a result, scrolling through the slices with the mouse wheel Middle Mouse Button / Mouse Wheel in one of the viewers synchronizes the rendered slice in the second viewer. In this case, you can inspect the differences between smoothed and unsmoothed data on every single slice.

Your final Network

Your final Network

It is also possible to use the pre-defined module SynchroView2D to accomplish a similar result.(SynchroView2D’s usage is futherly described in this chapter ).

Grouping modules

A contour filter can be created based on our previously created network. To finalize the filter, add the modules Arithmetic2 and Morphology to your workspace and connect the modules as shown below. Double-click the module Arithmetic2 to open its panel. Change the field Function of the module Arithmetic2 to use the function subtract in the panel of the module. The contour filter is done now. You can inspect each processing step using the Output Inspector by clicking on the input and output connectors of the respective modules. The final results can be displayed using the viewer modules. If necessary, adjust the contrast by pressing the right arrow key and moving the cursor.

Grouping modules

Grouping modules

If you’d like to know more about specific modules, search for help. You can do this by right-clicking the module and select help, which offers an example network and further information about the selected module in particular.

Module Help

Module Help

To be able to better distinguish the image processing pipeline, you can encapsulate it in a group: Select the three modules, for example by dragging a selection rectangle around them. Then right-click the selection to open the context menu and select [ Add to New Group ].

Add modules to new group

Add to new group

Enter a name for the new group, for example Filter. The new group is created and displayed as a green rectangle. The group allows for quick interactions with all its modules.

Your Filter Group

Your Filter Group

Your network got very complex and you lost track? No problem. Let MeVisLab arrange your modules automatically via [ Mein Menu → Edit → Auto Arrange Selection ] (or via keyboard shortcut CTRL + 1 ).

Now, it is time to save your first network. Open the tab [ File → Save ] to save the network in an .mlab file.

Macro modules

You have probably already noticed how the modules differ in color. Each color represents another type of module:

  • The blue modules are called ML modules, they process voxel images.
  • Green modules are OpenInventor modules, they enable visual 3D scene graphs.
  • The brown modules are called macro modules. Macro modules encapsulate a whole network in a single module.

To condense our filter into one single module, we will now be creating a macro module out of it. To do that, right-click on the group title and select Convert To Local Macro. Name your new macro module and finish. You just created a local macro module. Local macro modules can only be used in the network they were created in.

Convert to local macro

Convert to local macro

Your first local macro

Your first local macro

Right-click the macro module and select Show Internal Network to inspect and change the internal network. You can change the properties of the new macro module by changing the properties in the internal network. You can, for example, right-click the module Convolution and change the kernel. These changes will be preserved.

Internal Network of your local macro

Internal Network of your local macro

Summary

  • MeVisLab provides pre-defined modules you can re-use and connect for building more or less complex networks.
  • Each module’s output can be previewed using the Output Inspector.
  • Each module provides example networks to explain their usage.
  • Parameters of each module can be changed in the Module Inspector or Automatic Panel of the module.
  • Parameter connections can be established to synchronize the values of these parameters.
  • Modules can be clustered. Clustered modules can be encapsulated into local or global macro modules.
  • Macro modules encapsulate networks. Internal networks can be shown and modified. Any changes of the internal network are applied to the macro module.