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.
Your finished network should look like this:
Excursion on the Concept Behind Modules
To be able to build on the foundation we just set, it can be useful to understand how modules are conceptualized:
You will have noticed how for every module, a panel will pop up if you double-click
it. The module panel contains all of its functional parameters and enables you, as the user, to change them within a graphical user interface (GUI). We will do something similar later on.
But where and how is a module panel created? To answer this question, please close the module panel and right-click
the module.
A context menu will open, select Related Files.

As you can see, each module has a .script and a .py file named like the module itself:
- The .script file is where the appearance and structure of the module panel as well as their commands are declared.
- The .py file contains Python functions and methods, which are triggered by their referenced commands within the .script file.
Some modules also reference an .mlab file, which usually contains their internal network as the module is a macro.
Let’s continue with our module setup now:
If your network is ready, group it by selecting all module and right-clicking
and selecting “Grouping”, then “Add To New Group”.
Afterward, convert your grouped network into a macro module.

We’d recommend to do so.
Now open the .script file of your newly created macro through the context menu. The file will be opened within MATE (MeVisLab Advanced Text Editor). Add this short piece of code into your .script file and make sure that the .script and the .py are named exactly the same as the module they are created for.
BaseNetwork.script
Commands{
source = $(LOCAL)/BaseNetwork.py
}
Click the Reload button, which is located above the script for the .py file to be added into the module definition folder, then open it using the “Files” button on the same bar as demonstrated below:
You have now created your own module and enabled the .script file (where the GUI or panel can be described later on) to access functions and methods written in the .py file.
Summary
- Modules are defined by the contents within their definition folder.
- A module consists of of a .script file containing the panel configuration and a .py file containing functions that are accessed via the panel and provide functionalities (interacting with the parameters of modules in the macros internal network).
- A macro module’s panel can access parameters of its internal modules.
- The panel is layouted using MDL.



