Advanced

Example 2.5.2: Module interactions via Python scripting

Example 2.5.2: Module interactions via Python scripting      This example is also available on YouTube. 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 ].

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.

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 through usage of/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 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.

Example 6: MeVis Path Tracer

Example 6: MeVis Path Tracer      We have a Short video showing the possibilities of the MeVis Path Tracer on YouTube. 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 lightning with area lights and soft shadows and fully integrates into MeVisLab Open Inventor (camera, depth buffer, clipping planes, etc.). Extra Infos:  CUDA is a parallel computing platform and programming model created by NVIDIA.

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 MeVisLab Path Tracer. You will visualize the same scene using both 3D rendering techniques and some of the modules for path tracing. Attention:  The MeVis Path Tracer requires an NVIDIA graphics card with CUDA support. In order to check your hardware, open MeVisLab and add a SoPathTracer module to your workspace.

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 PathTracer to generate enhanced renderings. Attention:  The MeVis Path Tracer requires an NVIDIA graphics card with CUDA support. In order to check your hardware, open MeVisLab and add a SoPathTracer module to your workspace.

Example 8: Vessel Segmentation using SoVascularSystem

Example 8: Vessel Segmentation using SoVascularSystem      This example is also available on YouTube. 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.

Example 9: Creating Dynamic 3D Animations using AnimationRecorder

Example 9: Creating Dynamic 3D Animations using AnimationRecorder      This example is also available on YouTube. Introduction In this tutorial, we are using the AnimationRecorder module to generate dynamic and visually appealing animations of our 3D scenes. We will be recording 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.

Example 4: Subtract 3D objects

Example 4: Subtract 3D objects      This example is also available on YouTube. Introduction In this example, we load an image and render it as WEMIsoSurface. Then we create a 3-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.

Example 5: Clip Planes

Example 5: Clip Planes      This example is also available on YouTube. 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.

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 heavy weight, UI driven module. You can use it to see all of your CSOs, CSOLists and CSOGroups in the module panel. The CSOListContainer is a light weight 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 Example 5: WEM - Primitive Value Lists

Surface Example 5: WEM - Primitive Value Lists      This example is also available on YouTube. Introduction WEMs do not only contain the coordinates of nodes and surfaces, they can also contain additional information. These information are stored in so called Primitive Value Lists (PVLs). Every node, every surface and every edge can contains such a list. In these lists, you can for example store the color of the node or specific patient information.

Example 3: Iterative tests in MeVisLab with Screenshots

Example 3: Iterative tests in MeVisLab      This example is also available on YouTube. 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 function object called and the inputs iterated over. 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.

Chapter VII: Application Development

MeVisLab Tutorial Chapter VII Summary This chapter will summarize all previous chapters and you will develop a whole 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 Licensing:  Some of the features described here will require a separate license. Building an installable executable requires the MeVisLab ApplicationBuilder license. It extends the MeVisLab SDK so that you can generate an installer of your developed macro module.

Step 1: Prototyping - Develop your Network

Step 1: Prototyping - Develop your Network      This example is also available on YouTube. Introduction In this example, we will develop a network which fulfills the requirements mentioned on the overview page. The network will be developed by re-using 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 into the image to trigger a RegionGrowing algorithm to segment parts of the loaded image based on a threshold.

Step 2: Prototyping - Create a macro module

Step 2: Prototyping - Create a macro module      This example is also available on YouTube. 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      This example is also available on YouTube. 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.

Step 4: Review - Automated Tests

Step 4: Review - Automated Tests      This example is also available on YouTube. Introduction In the previous chapters you developed a macro module with 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 *.

Step 5: Review - Installer creation

Step 5: Review - Installer creation      This example is also available on YouTube. 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. Licensing:  This step requires a valid MeVisLab ApplicationBuilder license. It extends the MeVisLab SDK so that you can generate an installer of your developed macro module. Free evaluation licenses of the MeVisLab ApplicationBuilder, time-limited to 3 months, can be requested at sales(at)mevislab.

Step 6: Refine - Update Application

Step 6: Refine - Update Application      This example is also available on YouTube. Introduction In previous step you developed an application which can be installed on your customers systems for usage. In this step we are going to integrate simple feedback into our executable and re-create 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 - Re-Build Installer

Step 7: Refine - Re-Build Installer      This example is also available on YouTube. Introduction In this step you are re-creating 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.

Extra: Run your application in Browser

Extra: Run your application in Browser      This example is also available on YouTube. 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. Licensing:  This step requires a valid MeVisLab Webtoolkit license. It extends the MeVisLab SDK so that you can develop web macro modules. Free evaluation licenses of the MeVisLab Webtoolkit, time-limited to 3 months, can be requested at sales(at)mevislab.

Chapter VIII: ThirdParty components

MeVisLab Tutorial Chapter VIII Using ThirdParty 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 works as a guide on how to use some of the third party components integrated in MeVisLab for your projects via Python scripting. Additional Information:  You will also find instructions to install and use any Python package (e.

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 The viewer is empty because the image needs to be set via Python scripting. Info:  More information about the PythonImage module can be found here Create a macro module Now you need to create a macro module from your network.

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. Info:  The Python code used in this example has been taken from Towards Data Science. Steps to do Open Example 1 Add the macro module developed in Example 1 to your workspace. Download trained classifier XML file Initially you need to download the trained classifier XML file. It is available in the OpenCV GitHub repository.

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 currently 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. Warning:  You should not use the general Python pip command from a locally installed Python, because MeVisLab will not know these packages and they cannot be used in MeVisLab directly. The module either allows to install packages into the global MeVisLab installation directory, or into your defined user package.

Example 2: Brain Parcellation using PyTorch

Example 2: Brain Parcellation using PyTorch Introduction In this example, you are using a pre-trained 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.

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 re-use 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 Open the internal network of the module via middle mouse button and right click on the tab of the workspace showing the internal network.

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 among the scientific world as it is easy to grasp for beginners and provides high quality plots and images, that are widely customizable. Info:  The documentation on Matplotlib along with general examples, cheat sheets and a starting guide can be found here. As MeVisLab supports the integration of Python scripts e.

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: Drag the small Preview window to the bottom right corner of your window where it does not bother you.

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 .