Applet Library

Example Applets

These applets aren’t very useful, but they have simple, clean implementations. Their source files are the right place to look if you’re just getting started.

Threshold Masking

Threshold Masking Top-Level Operator
class ilastik.applets.thresholdMasking.thresholdMaskingApplet.ThresholdMaskingApplet(workflow, guiName, projectFileGroupName)[source]

This is a simple thresholding applet

Deviation From Mean

Deviation-From-Mean Top-Level Operator
class ilastik.applets.deviationFromMean.deviationFromMeanApplet.DeviationFromMeanApplet(workflow, projectFileGroupName)[source]

This applet serves as an example multi-image-lane applet. The GUI is not aware of multiple image lanes (it is written as if the applet were single-image only). The top-level operator is explicitly multi-image (it is not wrapped in an operatorwrapper).

Useful Base Classes

Many applets or applet GUIs are based on these classes.

Layer Viewer

LayerViewer Top-Level Operator
class ilastik.applets.layerViewer.layerViewerApplet.LayerViewerApplet(workflow)[source]

This applet can be used as a simple viewer of raw image data. Its main purpose is to provide a simple example of how to use the LayerViewerGui, which is intended to be used as a base class for most other applet GUIs.

class ilastik.applets.layerViewer.opLayerViewer.OpLayerViewer(*args, **kwargs)[source]

This is the default top-level operator for the layer-viewer class. Note that applets based on the LayerViewer applet (and the LayerViewerGui) do NOT need to use this operator. Any operator will work with the LayerViewerGui base class.


Example of how to check input data constraints.

class ilastik.applets.layerViewer.layerViewerGui.LayerViewerGui(parentApplet, topLevelOperatorView, additionalMonitoredSlots=[], centralWidgetOnly=False, crosshair=True)[source]

Implements an applet GUI whose central widget is a VolumeEditor and whose layer controls simply contains a layer list widget. Intended to be used as a subclass for applet GUI objects.

Provides: Central widget (viewer), View Menu, and Layer controls Provides an EMPTY applet drawer widget. Subclasses should replace it with their own applet drawer.

__init__(parentApplet, topLevelOperatorView, additionalMonitoredSlots=[], centralWidgetOnly=False, crosshair=True)[source]

Constructor. All slots of the provided topLevelOperatorView will be monitored for changes. Changes include slot resize events, and slot ready/unready status changes. When a change is detected, the setupLayers() function is called, and the result is used to update the list of layers shown in the central widget.

  • topLevelOperatorView – The top-level operator for the applet this GUI belongs to.
  • additionalMonitoredSlots – Optional. Can be used to add additional slots to the set of viewable layers (all slots from the top-level operator are already monitored).
  • centralWidgetOnly – If True, provide only a central widget without drawer or viewer controls.

Create a list of layers to be displayed in the central widget. Subclasses should override this method to create the list of layers that can be displayed. For debug and development purposes, the base class implementation simply generates layers for all topLevelOperatorView slots.

classmethod createStandardLayerFromSlot(slot, lastChannelIsAlpha=False)[source]

Convenience function. Generates a volumina layer using the given slot. Will be either a GrayscaleLayer or RGBALayer, depending on the channel metadata.

  • slot – The slot to generate a layer from
  • lastChannelIsAlpha – If True, the last channel in the slot is assumed to be an alpha channel.

Load the viewer controls GUI, which appears below the applet bar. In our case, the viewer control GUI consists mainly of a layer list. Subclasses should override this if they provide their own viewer control widget.


By default, this base class provides a blank applet drawer. Override this in a subclass to get a real applet drawer.


Labeling Top-Level Operator
class ilastik.applets.labeling.labelingApplet.LabelingApplet(workflow, projectFileGroupName, blockDims=None)[source]

This applet demonstrates how to use the LabelingGui base class, which serves as a reusable base class for other applet GUIs that need a labeling UI.

class ilastik.applets.labeling.opLabeling.OpLabelingSingleLane(blockDims=None, *args, **kwargs)[source]

This is a single-lane operator that can be used with the labeling applet gui. It is basically a wrapper around the OpCompressedUserLabelArray (lazyflow), with the ‘shape’ and ‘blockshape’ input slots taken care of for you.

InputImage = InputSlot()

Original input data.

LabelInput = InputSlot(optional=True)

Input for providing label data from an external source

LabelEraserValue = InputSlot()

The label value that signifies the ‘eraser’, i.e. voxels to clear labels from

LabelDelete = InputSlot()

When this input is set to a value, all labels of that value are deleted from the operator’s data.

LabelImage = OutputSlot()

Stored labels from the user

NonzeroLabelBlocks = OutputSlot()

A list if slices that contain non-zero label values

class ilastik.applets.labeling.opLabeling.OpLabelingTopLevel(blockDims=None, *args, **kwargs)[source]

Top-level operator for the labelingApplet base class. Provides all the slots needed by the labeling GUI, but any operator that provides the necessary slots can also be used with the LabelingGui.

InputImages = InputSlot(level=1)

Original input data.

LabelInputs = InputSlot(level=1)

Input for providing label data from an external source

LabelEraserValue = InputSlot()

The label value that signifies the ‘eraser’, i.e. voxels to clear labels from

LabelDelete = InputSlot()

When this input is set to a value, all labels of that value are deleted from the operator’s data.

LabelImages = OutputSlot(level=1)

Stored labels from the user

NonzeroLabelBlocks = OutputSlot(level=1)

A list if slices that contain non-zero label values


Add an image lane.

removeLane(laneIndex, finalLength)[source]

Remove an image lane.

class ilastik.applets.labeling.labelingGui.LabelingGui(parentApplet, labelingSlots, topLevelOperatorView, drawerUiPath=None, rawInputSlot=None, crosshair=True)[source]

Provides all the functionality of a simple layerviewer applet with the added functionality of labeling.

__init__(parentApplet, labelingSlots, topLevelOperatorView, drawerUiPath=None, rawInputSlot=None, crosshair=True)[source]


  • labelingSlots – Provides the slots needed for sourcing/sinking label data. See LabelingGui.LabelingSlots class source for details.
  • topLevelOperatorView – is provided to the LayerViewerGui (the base class)
  • drawerUiPath – can be given if you provide an extended drawer UI file. Otherwise a default one is used.
  • rawInputSlot – Data from the rawInputSlot parameter will be displayed directly underneath the elements (if provided).

Programmatically select the given labelIndex, which start from 0. Equivalent to clicking on the (labelIndex+1)’th position in the label widget.

class LabelingSlots[source]

This class serves as the parameter for the LabelingGui constructor. It provides the slots that the labeling GUI uses to source labels to the display and sink labels from the user’s mouse clicks.

LabelingGui.onLabelListDataChanged(topLeft, bottomRight)[source]

Handle changes to the label list selections.


QT event handler. The user has selected another applet or is closing the whole app. Save all preferences.


Return a suitable name for the next label added by the user. Subclasses may override this.


Return a QColor to use for the next label.


Return a QColor to use for the next label.


Subclasses can override this to respond to changes in the label names.


Subclasses can override this to respond to changes in the label colors.


Subclasses can override this to respond to changes in a label associated probability color.


find a layer by name


Return a colortable layer that displays the label slot data, along with its associated label source. direct: whether this layer is drawn synchronously by volumina


Sets up the label layer for display by our base class (LayerViewerGui). If our subclass overrides this function to add his own layers, he must call this function explicitly.


In the TrackingWorkflow when labeling 0/1/2/.../N mergers we do not allow to remove another label but the first, as the following processing steps assume that all previous cell counts are given.

Standard Applets

These applets are likely to be re-used in many, if not most, worklows.

Project Metadata

class ilastik.applets.projectMetadata.projectMetadataApplet.ProjectMetadataApplet[source]

This applet allows the user to enter project metadata (e.g. Project name, labeler name, etc.).

Note that this applet does not affect the processing pipeline and has no top-level operator.

Data Selection

DataSelection Top-Level Operator
class ilastik.applets.dataSelection.dataSelectionApplet.DataSelectionApplet(workflow, title, projectFileGroupName, supportIlastik05Import=False, batchDataGui=False, forceAxisOrder=None, instructionText='Use the controls shown to the right to add image files to this workflow.', max_lanes=None, show_axis_details=False)[source]

This applet allows the user to select sets of input data, which are provided as outputs in the corresponding top-level applet operator.

classmethod parse_known_cmdline_args(cmdline_args, role_names)[source]

Helper function for headless workflows. Parses command-line args that can be used to configure the DataSelectionApplet top-level operator and returns (parsed_args, unused_args), similar to argparse.ArgumentParser.parse_known_args()

Relative paths are converted to absolute paths according to ``os.getcwd()``, not according to the project file location, since this more likely to be what headless users expect.

See also: configure_operator_with_parsed_args().


Helper function for headless workflows. Configures this applet’s top-level operator according to the settings provided in parsed_args.

Parameters:parsed_args – Must be an argparse.Namespace as returned by parse_known_cmdline_args().
classmethod convertStacksToH5(filePaths, stackVolumeCacheDir)[source]

If any of the files in filePaths appear to be globstrings for a stack, convert the given stack to hdf5 format.

Return the filePaths list with globstrings replaced by the paths to the new hdf5 volumes.

class ilastik.applets.dataSelection.opDataSelection.OpDataSelection(forceAxisOrder=False, *args, **kwargs)[source]

The top-level operator for the data selection applet, implemented as a single-image operator. The applet uses an OperatorWrapper to make it suitable for use in a workflow.

ProjectFile = InputSlot(optional=True)

The project hdf5 File object (already opened)

ProjectDataGroup = InputSlot(optional=True)

The internal path to the hdf5 group where project-local datasets are stored within the project file

WorkingDirectory = InputSlot()

The filesystem directory where the project file is located

Dataset = InputSlot()

A DatasetInfo object

Image = OutputSlot()

The output image

AllowLabels = OutputSlot()

A bool indicating whether or not this image can be used for training

ImageName = OutputSlot()

The name of the output image

exception InvalidDimensionalityError(message)[source]

Raised if the user tries to replace the dataset with a new one of differing dimensionality.

Batch Output

Batch Output Top-Level Operator

Workflow-specific Applets

These applets were designed with particular workflows in mind, but they could be used with future workflows, too.

Feature Selection

Feature Selection Top-Level Operator
class ilastik.applets.featureSelection.featureSelectionApplet.FeatureSelectionApplet(workflow, guiName, projectFileGroupName, filter_implementation='Original')[source]

This applet allows the user to select sets of input data, which are provided as outputs in the corresponding top-level applet operator.

Pixel Classification

Pixel Classification Top-Level Operator
Pixel Classification Top-Level Operator
class ilastik.applets.pixelClassification.pixelClassificationApplet.PixelClassificationApplet(workflow, projectFileGroupName)[source]

Implements the pixel classification “applet”, which allows the ilastik shell to use it.

Watershed Viewer

Watershed Viewer Top-Level Operator
class ilastik.applets.vigraWatershedViewer.vigraWatershedViewerApplet.VigraWatershedViewerApplet(workflow, guiName, projectFileGroupName)[source]

Viewer for watershed results, with minimal configuration controls.

Object Extraction

The object extraction applet takes as input a data image and an object mask. It then computes object features on the objects and makes them available to downstream applets.

The available features are provided by a plugin system. Each plugin reports the names of the features it supports, and handles the actual calculation. The GUI queries all plugins for the features they provide and present them to the user. The user selects some features, and the selection is sent to the operator, which calls the appropriate plugins and aggregates the results. A detailed example of a user-defined plugin with object features can be found in the $ILASTIK/examples directory. To get your plugins discovered by ilastik, you have to add their path to the .ilastikrc file in your home directory. The file should look as follows:


plugin_directories: /path/to/cool_features

The cool_features directory in this case should contain the .py and the .yapsy-plugin files.

class ilastik.applets.objectExtraction.objectExtractionApplet.ObjectExtractionApplet(name='Object Extraction', workflow=None, projectFileGroupName='ObjectExtraction', interactive=True)[source]

Calculates object features for each object in an image.

Features are provided by plugins, which are responsible for performing the actual computation.

class ilastik.plugins.ObjectFeaturesPlugin(*args, **kwargs)[source]

Plugins of this class calculate object features.

availableFeatures(image, labels)[source]

Reports which features this plugin can compute on a particular image and label image.

  • image – numpy.ndarray
  • labels – numpy.ndarray, dtype=int

a nested dictionary, where dict[feature_name] is a dictionary of parameters.

compute_global(image, labels, features, axes)[source]

calculate the requested features.

  • image – np.ndarray
  • labels – np.ndarray, dtype=int
  • features – which features to compute
  • axes – axis tags

a dictionary with one entry per feature. dict[feature_name] is a numpy.ndarray with ndim=2 and shape[0] == number of objects

compute_local(image, binary_bbox, features, axes)[source]

Calculate features on a single object.

  • image – np.ndarray - image[expanded bounding box]
  • binary_bbox – binarize(labels[expanded bounding box])
  • features – which features to compute
  • axes – axis tags

a dictionary with one entry per feature. dict[feature_name] is a numpy.ndarray with ndim=1


For every feature in the feature dictionary, fill in its properties, such as ‘detailtext’, which will be displayed in help, or ‘displaytext’ which will be displayed instead of the feature name Args:

feature_dict: dictionary of features
same dictionary, with additional fields filled for each feature
do_channels(fn, image, axes, **kwargs)[source]

Helper for features that only take one channel.

Parameters:fn – function that computes features
class ilastik.applets.objectExtraction.opObjectExtraction.OpObjectExtraction(*args, **kwargs)[source]

The top-level operator for the object extraction applet.

Computes object features and object center images.

static createExportTable(features)[source]

This function takes the features as produced by the RegionFeatures slot and transforms them into a flat table, which is later used for exporting object-level data to csv and h5 files. The columns of the table are as follows: (t, object index, feature 1, feature 2, ...). Row-wise object index increases faster than time, so first all objects for time 0 are exported, then for time 1, etc

class ilastik.applets.objectExtraction.opObjectExtraction.OpAdaptTimeListRoi(parent=None, graph=None)[source]

Adapts the t array output from OpRegionFeatures to an Output slot that is called with a ‘List’ rtype, where the roi is a list of time slices, and the output is a dictionary of (time, featuredict) pairs.

class ilastik.applets.objectExtraction.opObjectExtraction.OpCachedRegionFeatures(*args, **kwargs)[source]

Caches the region features computed by OpRegionFeatures.

class ilastik.applets.objectExtraction.opObjectExtraction.OpRegionFeatures(parent=None, graph=None)[source]

Produces region features for time-stacked 3d+c volumes

The image’s axes are extended to the full xyzc shape, one t-slice at a time.


  • RawVolume : the raw data on which to compute features
  • LabelVolume : a volume of connected components for each object in the raw data.
  • Features : a nested dictionary of features to compute. Features[plugin name][feature name][parameter name] = parameter value


  • Output : a nested dictionary of features. Output[plugin name][feature name] = numpy.ndarray
compute_extent(i, image, mincoords, maxcoords, axes, margin)[source]

Make a slicing to extract object i from the image.

compute_rawbbox(image, extent, axes)[source]

essentially returns image[extent], preserving all channels.

class ilastik.applets.objectExtraction.opObjectExtraction.OpObjectCenterImage(parent=None, graph=None)[source]

Produceds an image with a cross in the center of each connected component.

Object Classification

The object classification applet provides functionality for labeling objects, training a classifier, and visualizing the prediction results. The top-level operator receives connected component images and object features from upstream operators, and it receives object labels from the object classification GUI. In addition to providing the usual output slots for classification, such as probabilities and predictions for each object, it also provides warnings for bad objects (i.e., those with missing or mangled features).

class ilastik.applets.objectClassification.objectClassificationApplet.ObjectClassificationApplet(name='Object Classification', workflow=None, projectFileGroupName='ObjectClassification', selectedFeatures={})[source]

An applet for labeling and classifying objects.

class ilastik.applets.objectClassification.opObjectClassification.OpObjectClassification(*args, **kwargs)[source]

The top-level operator for object classification.

Most functionality is handled by specialized operators such as OpObjectTrain and OpObjectPredict.

Also transfers existing labels if the upstream object segmentation changes. The transfer is conservative: labels only get transfered from an old object to a new object if they overlap sufficiently, and the label does not overlap with other objects.


Setup the label input and caches to correct dimensions

assignObjectLabel(imageIndex, coordinate, assignedLabel)[source]

Update the assigned label of the object located at the given coordinate. Does nothing if no object resides at the given coordinate.


For all images with labels, export object bounding boxes and label classes as JSON.


Read labels and bounding boxes from a JSON file. For all image lanes in the JSON file, replace all labels in that image. For image lanes NOT listed in the JSON file, keep the existing labels.


Implements ExportOperator.save_export_progress_dialog Without this the progress dialog would be hidden after the export :param dialog: the ProgressDialog to save

do_export(settings, selected_features, progress_slot, lane_index, filename_suffix='')[source]

Implements ExportOperator.do_export(settings, selected_features, progress_slot Most likely called from ExportOperator.export_object_data :param settings: the settings for the exporter, see :param selected_features: :param progress_slot: :return:

class ilastik.applets.objectClassification.opObjectClassification.OpObjectTrain(*args, **kwargs)[source]

Trains a random forest on all labeled objects.

class ilastik.applets.objectClassification.opObjectClassification.OpObjectPredict(parent=None, graph=None)[source]

Predicts object labels in a single image.

Performs prediction on all objects in a time slice at once, and caches the result.

class ilastik.applets.objectClassification.opObjectClassification.OpRelabelSegmentation(parent=None, graph=None)[source]

Takes a segmentation image and a mapping and returns the mapped image.

For instance, map prediction labels onto objects.

class ilastik.applets.objectClassification.opObjectClassification.OpMultiRelabelSegmentation(*args, **kwargs)[source]

Takes a segmentation image and multiple mappings and returns the mapped images.

For instance, map prediction probabilities for different classes onto objects.

class ilastik.applets.objectClassification.opObjectClassification.OpMaxLabel(*args, **kwargs)[source]

Finds the maximum label value in the input labels.

Special operator for object classification labels, expects inputs to be in a dictionary

class ilastik.applets.objectClassification.objectClassificationGui.ObjectClassificationGui(parentApplet, op)[source]

A subclass of LabelingGui for labeling objects.

Handles labeling objects, viewing the predicted results, and displaying warnings from the top level operator. Also provides a dialog for choosing subsets of the precalculated features provided by the object extraction applet.


Load the ui file for the applet drawer, which we own.


Return a colortable layer that displays the label slot data, along with its associated label source.

direct: whether this layer is drawn synchronously by volumina

onClick(layer, pos5d, pos)[source]

Extracts the object index that was clicked on and updates that object’s label.

handleWarnings(*args, **kwargs)[source]

handle incoming warning messages by opening a pop-up window