TileProcessing Overview

Introduction

TileProcessing is the somewhat clumsy name for a concept to allow the processing of images tile-by-tile in such way that the actual processing component is a C++ or python plug-in that is basically independent from MeVisLab. It describes its own interface (at least to some degree) and can work on the input data in-process or send it to a remote service and provide the received output data back to MeVisLab.

Its primary design goal was to simplify deep learning inference in MeVisLab, so at least initially, most of the implemented TileProcessors wrap one CNN (convolutional neural network) inference engine or another. Still, since the framework is not restricted to this purpose, the more general name TileProcessing was chosen.

TileProcessor Providers

Thankfully, MeVisLab’s page-based processing approach fits very well to the way convolutional neural networks are applied to arbitrary-sized images (cf. “overlapping tile strategy” in Olaf Ronnerberger’s original U-net paper, for instance) for voxel classification. There are a number of modules to choose from, depending on whether one wants to classify voxels (segmentation) or images (image classification), whether ensembles of models trained on orthogonal orientations should be used, or whether you want to work in-process or via RPC.

Note that, while each of the items listed above refers to a MeVisLab module, each module is but a parameterization wrapper for a C++ or python TileProcessor class of the same name that does the actual work.

TileProcessor Application Modules

To apply a TileProcessor to an image, an additional module is required.

Straight-forward (i.e. not patch-based) Application

The module ApplyTileProcessor just provides all input images as inputs (each in a single memory block) to the connected TileProcessor and outputs all outputs the same way. Only input/output names and data types are required knowledge in advance. The user has to make sure in the surrounding MeVisLab network that input images have the right memory layout, extent and geometry and that outputs are post-processed correctly.

Patch-based Application

Medical images can be large and not fit (easily) into GPU memory. Also, sometimes only parts of an image are requested. Thus, we can use of MeVisLab paging support and use paging (or patch-based application) also for the TileProcessors. The following modules can be used:

Recommended method for production, has fewest parameters because it relies on correct TileProcessingProperties already being provided with the input. If you append a SetTileProcessorProperties or SetTileProcessorPropertiesFromJson module, incorrect/missing properties can be conveniently/flexibly modified.

Combines ProcessTiles and SetTileProcessorProperties, allowing to modify some parameter ‘on the fly’. Maybe best suited for prototyping, when parameters are not yet fixed.

Combines three instances of ApplyTileProcessorPageWise to work on three orthogonal reformattings of a 3D input volume.

Describing a TileProcessor interface: TileProcessingProperties

TileProcessingProperties are a collection of input/output properties that allow a module such as ProcessTiles to provide input patches in exactly the format required by the TileProcessor instance, and compose its output patches back to output images in exactly the format expected by the MeVisLab user.

If you are looking for details on individual properties, check out the TileProcessorProperties Schema Documentation.

Each TileProcessor will “guess” a few properties (typically input/output names and data types) from the model/algorithm, but especially for page-based application, you will have to extend or modify these. The following modules can be used:

To give you a rough idea, find below a typical TileProcessingProperties object describing a TileProcessor that wraps a CNN model with a single input and single output for patch-wise application:

{
    "VERSION": 2,
    "inputs": {
        "input0": {
            "dataType": "float32",
            "dimensions": "X, Y, Z, CHANNEL1, BATCH",
            "externalDimensionForBatch": null,
            "externalDimensionForChannel1": "C",
            "externalDimensionForChannel2": null,
            "fillMode": "Reflect",
            "fillValue": null,
            "padding": [20, 20, 20, 0, 0, 0]
        }
    },
    "outputs": {
        "output0": {
            "dataType": "float32",
            "referenceInput": "input",
            "stride": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            "tileSize": [52, 52, 52, 3, 1, 1],
            "tileSizeMinimum": [4, 4, 4, 3, 1, 1],
            "tileSizeOffset": [4, 4, 4, 0, 1, 0],
            "valueMaximum": 0.0,
            "valueMinimum": 1.0
        }
    }
}

Implementation

You can think of TileProcessorProperties as simple data objects that do not come with any functionality. Unlike a TileProcessor, a TileProcessorProperties object can be freely copied or modified.

While the application of TileProcessors always happens in C++, bot TileProcessors and TileProcessorProperties can also be created in python and than wrapped by C++ objects through a helper module (PythonToCppTileProcessorBridge, but users don’t need to know/do this themselves).

Model/Schema Details for TileProcessorProperties, InputProperties and OutputProperties

To get the JSON schema file for usage in your favorite editor, open a SetTileProcessorPropertiesFromJson module, it exposes the schema file path in a field. You can also get the path via the tile_processing.properties python API.

The detailed description was auto-generated from the JSON schema, it applies to both C++ and python data models which are (hopefully) 100% equivalent. For technical reasons, it is available externally at