Matplotlib

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.

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

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.

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 to make them usable. Integrate the following code into your .py file and import numpy.