TEM Architecture

Image Processing Pipeline

Table of Contents

Introduction

The image processing pipeline is primarily written in C++ with some Python bindings and nodes. It utilizes the Intel Thread Building Blocks library for parallelism, and OpenCV for image processing. The overall data-flow is shown in the diagram below.

%3 cluster_Intel TBB Intel TBB ea7e685ddb7b4c4392848211f424d88c Receive Tile File-path 6e430c3785dd4bdb87361bee69425b08 Load Tile ea7e685ddb7b4c4392848211f424d88c->6e430c3785dd4bdb87361bee69425b08 de718f52653644138c45b2dd1c67eed6 ea7e685ddb7b4c4392848211f424d88c->de718f52653644138c45b2dd1c67eed6 tile.raw 7005026a7b47493d9dd6a2184aeae884 Transfer to GPU 6e430c3785dd4bdb87361bee69425b08->7005026a7b47493d9dd6a2184aeae884 e42cf46016384d5c8e57fe8cbbb80349 Horizontal Flip 7005026a7b47493d9dd6a2184aeae884->e42cf46016384d5c8e57fe8cbbb80349 0584302ae3df4ca794613c45691fccde Flat-Field Correction e42cf46016384d5c8e57fe8cbbb80349->0584302ae3df4ca794613c45691fccde f0d4f2e67fba41758033ad91b20d0c97 CLAHE 0584302ae3df4ca794613c45691fccde->f0d4f2e67fba41758033ad91b20d0c97 d40ca9110cdc43649f2c1bb251dfb232 Min, Max, Mean f0d4f2e67fba41758033ad91b20d0c97->d40ca9110cdc43649f2c1bb251dfb232 ae8eb7f3ca6a4ba195b06df4a5ffc2db FFT f0d4f2e67fba41758033ad91b20d0c97->ae8eb7f3ca6a4ba195b06df4a5ffc2db e5446622fe8343248b51c6709a96c0bf Transfer to CPU Memory f0d4f2e67fba41758033ad91b20d0c97->e5446622fe8343248b51c6709a96c0bf 4da6107dd4f44b329ee4cec57a6c5da6 Clone f0d4f2e67fba41758033ad91b20d0c97->4da6107dd4f44b329ee4cec57a6c5da6 aa43632e3f824d1cb0da3b7abd17e5f1 Lens Correction f0d4f2e67fba41758033ad91b20d0c97->aa43632e3f824d1cb0da3b7abd17e5f1 340898da3d1840918383c534b3f55433 Send Min, Max, Mean d40ca9110cdc43649f2c1bb251dfb232->340898da3d1840918383c534b3f55433 52efd627000c48daab4afa23dc7104cf 340898da3d1840918383c534b3f55433->52efd627000c48daab4afa23dc7104cf tile.statistics.min_max_mean a785bae0d12e4abca0a7a2cf0ef0b881 Compute Focus Score ae8eb7f3ca6a4ba195b06df4a5ffc2db->a785bae0d12e4abca0a7a2cf0ef0b881 a21c29c910a14496b11098c5bf1263f0 Send Focus Score a785bae0d12e4abca0a7a2cf0ef0b881->a21c29c910a14496b11098c5bf1263f0 4a0628c389d745c499d84a2c42bb3452 a21c29c910a14496b11098c5bf1263f0->4a0628c389d745c499d84a2c42bb3452 tile.statistics.focus e37c4925f19641318cc47b25b1c60770 Calculate Histogram e5446622fe8343248b51c6709a96c0bf->e37c4925f19641318cc47b25b1c60770 59d5f692e7be4025b3d58bd2ab66d8cf Save Histogram e37c4925f19641318cc47b25b1c60770->59d5f692e7be4025b3d58bd2ab66d8cf 28cc5f5e4320438d93dad37c3d1b06c5 Send Histogram File-path 59d5f692e7be4025b3d58bd2ab66d8cf->28cc5f5e4320438d93dad37c3d1b06c5 9d6ed83d54044354b21e66953ddbe957 28cc5f5e4320438d93dad37c3d1b06c5->9d6ed83d54044354b21e66953ddbe957 tile.statistics.histogram e8eecf0a3d324de2b8e881738d24946e Down-sample 4da6107dd4f44b329ee4cec57a6c5da6->e8eecf0a3d324de2b8e881738d24946e 074f3c443a954a29a5b2d548fb7bae9a Transfer to CPU Memory e8eecf0a3d324de2b8e881738d24946e->074f3c443a954a29a5b2d548fb7bae9a 186e8487e4af4d809044e9f918ba7b9c Save JPEG 074f3c443a954a29a5b2d548fb7bae9a->186e8487e4af4d809044e9f918ba7b9c 69a324e9bb8744688c13e2b093043667 Send JPEG 186e8487e4af4d809044e9f918ba7b9c->69a324e9bb8744688c13e2b093043667 297d897b689c4931857bd6dc487f5a71 69a324e9bb8744688c13e2b093043667->297d897b689c4931857bd6dc487f5a71 tile.jpeg e5deff2de60440e9be56151be1b64717 Transfer to CPU Memory aa43632e3f824d1cb0da3b7abd17e5f1->e5deff2de60440e9be56151be1b64717 9c7a5cf3f8f64c9286a322dc2c8e73a0 Tile Matcher aa43632e3f824d1cb0da3b7abd17e5f1->9c7a5cf3f8f64c9286a322dc2c8e73a0 42e14a96415c4921949bc14a2d5278b3 Save Tile e5deff2de60440e9be56151be1b64717->42e14a96415c4921949bc14a2d5278b3 e3c37c4adb9d43da839c521b8d92d40d Send Processed Tile Filepath 42e14a96415c4921949bc14a2d5278b3->e3c37c4adb9d43da839c521b8d92d40d d279d12dcbb54c9eab9fd72a7f6fdbc1 e3c37c4adb9d43da839c521b8d92d40d->d279d12dcbb54c9eab9fd72a7f6fdbc1 tile.processed 69adda3ca15247ac8be82bd98d341f89 Transfer to CPU Memory 9c7a5cf3f8f64c9286a322dc2c8e73a0->69adda3ca15247ac8be82bd98d341f89 43632971f9924d6ebeba79f044f8e499 Send Transform 9c7a5cf3f8f64c9286a322dc2c8e73a0->43632971f9924d6ebeba79f044f8e499 528f96b854df4e8c8944ecd8d61c49b2 Save Mini-Map 69adda3ca15247ac8be82bd98d341f89->528f96b854df4e8c8944ecd8d61c49b2 812d04bde22c4c1193cd3ed659323f00 Send Mini-Map 528f96b854df4e8c8944ecd8d61c49b2->812d04bde22c4c1193cd3ed659323f00 bf1741d25c2c48e680956801b2de8c7e 812d04bde22c4c1193cd3ed659323f00->bf1741d25c2c48e680956801b2de8c7e tile.minimap 2b991f8d47c24ac2af3baa9f5f2a15c8 43632971f9924d6ebeba79f044f8e499->2b991f8d47c24ac2af3baa9f5f2a15c8 tile.transform

Functionality

Receive Tile Filepath

Uses
SubscribeRawTileNode

This node receives the metadata and the path to a raw tile to process from the message broker on the tile.raw topic, and passes the filename to the load tile node.

Load Tile

Uses
IMReadNode

This node receives the metadata and filename, and uses OpenCV to load a tile into CPU memory from SSD based storage.

Transfer to GPU

Uses
ToGPUNode

After the tile is loaded into CPU memory, it is transferred into GPU memory for more efficient processing.

Flip

Uses
FlipNodeGPU

On the GPU, the tile is horizontally flipped.

Flat-Field Correction

Uses:
FlatFieldNodeGPU

The flat-field correction is applied to the tile using brightfield and darkfield images stored on the SSD. The brightfield and darkfield file modification times are checked during each execution to check if they need to be reloaded.

CLAHE

Uses
CLAHENodeGPU

The Contrast Limited Adaptive Histogram Equalization algorithm is applied to the tile. The resulting image is sent to multiple functions for further analysis, including an FFT for calculating the focus score, calculating the minimum, maximum, and mean pixel values, histogram, clone for UI display, and further processing, starting with the lens correction.

Lens Correction

Uses
LensCorrectionNodeGPU

To remove distortion, a lens correction is applied. This is performed using two images stored on the SSD and reloaded whenever the file modification times are newer than the images stored in memory. The output is send to the tile matcher and a to cpu node for saving to disk.

Transfer to CPU Memory

Uses
FromGPUNode

In order to save the tile, it must first be transferred to CPU memory.

Save Tile

Uses
IMWriteNode

The processed tile can now be saved to disk.

Send Tile Filepath

Uses
PublishFileNode

The filepath of the processed tile can now be sent via the broker to other services on the tile.processed topic.

Tile Matcher

Uses
MatcherNodeGPU

This node performs template matching of each tile with its neighbors. It outputs both a minimap image (a down-sampled overview of the entire montage) and the metadata from the matching itself.

Send Transform

Uses
PublishTransformNode

This node sends the transform of the matched tile along with other metadata to the tile.transform topic via the broker.

Minimap to CPU Memory

Uses
FromGPUNode

Before it can be saved, the minimap must be moved to CPU memory.

Save Minimap

Uses
IMWriteNode

The minimap can is saved to disk.

Send Minimap

Uses
PublishFileNode

The path to the minimap can now be sent via the broker on the tile.minimap topic.

Min, Max, Mean

Uses
MinMaxMeanNodeGPU

This node calculates the minimum, maximum, and mean pixel values.

Send Min, Max, Mean

Uses
PublishMinMaxMeanNode

This node sends the minimum, maximum, and mean pixel values to other services via the broker on the tile.statistics.min_max_mean topic.

FFT

Uses
FFTNodeGPU

This node crops out the center of the tile and computes the Fast Fourier Transform.

Focus Score

Uses
FocusNodeGPU

This node uses the FFT data to create a metric for the quality of the focus.

Send Focus Score

Uses
PublishFocusNode

This node sends the focus score to other services via the broker on the tile.statistics.focus topic.

Clone

Uses
CloneNodeGPU

This node copies the image data, since the following node modifies it in-place.

Down-sample

Uses
ResizeNodeGPU

This node down-samples the partially processed tile for UI display.

Down-sampled Image to CPU Memory

Uses
FromGPUNode

The down-sampled image must be moved to CPU memory before it can be saved to disk.

Save JPEG

Uses
IMWriteNode

The down-sampled image should be saved using JPEG compression for the UI.

Send JPEG Filepath

Uses
PublishFileNode

The path to the JPEG compressed image can be published via the broker on the tile.jpeg topic.

Histogram Transfer to CPU Memory

Uses
FromGPUNode

Transfer the image to CPU memory before computing the histogram.

Calculate Histogram

Uses
HistogramNode

A small histogram image is created using this node.

Save Histogram

Uses
IMWriteNode

This node saves the histogram to SSD storage.

Send Histogram

Uses
PublishFileNode

This node sends the filepath to the histogram to other services using the broker on the tile.statistics.histogram topic.

Nodes

Each node can be provided keyword arguments as described below. Many non-input nodes accept a concurrency argument controlling how many copies of that node may be crated. Two predefined values are available in the TEM_graph.consts module, serial, and unlimited. All nodes should also allow their name to be set using the name keyword argument.

IMReadNode

Language
C++
Input
str_message
Output
mat_message
Arguments
name (string) = IMReadNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
flags (int) = IMREAD_GRAYSCALE: OpenCV flags for configuring the underlying OpenCV IMRead function.

This node uses OpenCV to read an image from disk. The path to the image must be provided in the input message and the output message contains the image data. Two flags are provided in the TEM_graph.consts module, IMREAD_GRAYSCALE, and IMREAD_ANYDEPTH.

IMWriteNode

Language
C++
Input
mat_message
Output
str_message
Arguments
name (string) = IMWriteNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
output_dir (string) = .: The directory to save images to.
extension (string) = .tiff: The file extension to use when saving images.
params (int vector) = [IMWRITE_TIFF_COMPRESSION, 1]: The parameters to pass to the underlying OpenCV IMWrite function.

This node uses OpenCV to write an image to disk. The input message contains the image data, and the output message will contain the path where the image was written. The image will be saved in the output_dir directory with the tile ID from the metadata as the filename and with the extension supplied in the arguments. The params are passed to the underlying OpenCV IMWrite() function to control different options, with the defaults here saving an uncompressed TIFF image. One parameter is defined in TEM_graph.consts, which is IMWRITE_TIFF_COMPRESSION.

ToGPUNode

Language
C++
Input
mat_message
Output
gpu_mat_message
Arguments
name (string) = ToGPUNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node transfers OpenCV image data from CPU memory to GPU memory for further processing.

FromGPUNode

Language
C++
Input
gpu_mat_message
Output
mat_message
Arguments
name (string) = ToGPUNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node transfers OpenCV image data from GPU memory to CPU memory for saving etc.

CloneNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = CloneNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node copies the image data to a new location, so that nodes that modify it in-place do not accidentally cause other nodes to receive the modified data.

CloneNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = CloneNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node has identical functionality to the CloneNode, but uses GPU processing.

FlipNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = FlipNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
axis (int) = horizontal: The axis to flip the image along.

This node flips an image in-place along a provided axis. The TEM_graph.consts module contains three values, horizontal, vertical, and both.

FlipNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = FlipNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
axis (int) = horizontal: The axis to flip the image along.

This node has identical functionality to the FlipNode, but uses GPU processing.

ResizeNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = FlipNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
scale (double) = 0.5: The scaling to apply to the image.
interpolation (int) = INTER_AREA: The interpolation method to use.

This node resizes the incoming image in-place. The TEM_graph.consts module contains interpolation constants, INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_AREA, INTER_LANCZOS4, INTER_LINEAR_EXACT, and INTER_NEAREST_EXACT.

ResizeNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = FlipNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
scale (double) = 0.5: The scaling to apply to the image.
interpolation (int) = INTER_LINEAR: The interpolation method to use.

This node has identical functionality to the DownsampleNode, but uses GPU processing.

FlatFieldNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = FlatFieldNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
brightfield_path (string) = brightfield.tiff: The path to a brightfield image.
darkfield_path (string) = darkfield.tiff: The path to a darkfield image.

This node performs flatfield corrections using the supplied brightfield and darkfield images. The incoming image is modified in-place. If the brightfield or darkfield images have a modification date newer then when they were loaded, they are automatically reloaded.

FlatFieldNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = FlatFieldNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
brightfield_path (string) = brightfield.tiff: The path to a brightfield image.
darkfield_path (string) = darkfield.tiff: The path to a darkfield image.

This node has identical functionality to the FlatFieldNode, but uses the GPU for processing.

CLAHENode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = CLAHENode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
clipLimit (double) = 2: The threshold for contrast limiting.
tileGridSize (int) = 16: The number of rows and columns the image will be split into.

This node performs Contrast Limited Adaptive Histogram Equalization in-place on incoming tiles.

CLAHENodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = CLAHENode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
clipLimit (double) = 2: The threshold for contrast limiting.
tileGridSize (int) = 16: The number of rows and columns the image will be split into.

This node has identical functionality to the CLAHENode, but uses the GPU for processing.

MatcherNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = MatcherNode: The name for the node.

This node must be run single threaded. It receives incoming image tiles and fits them to the montage matching the montage_id in the metadata. It outputs a minimap (a down-sampled) image of the entire montage, along with the fit metadata. If the montage_id is a zero length string, the tile is a preview tile and no matching should be performed. In this case, a zero size image should be output.

MatcherNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = MatcherNode: The name for the node.

This node has identical functionality to the MatcherNode, but uses the GPU for processing.

MinMaxMeanNode

Language
C++
Input
mat_message
Output
int_vec_message
Arguments
name (string) = MinMaxMeanNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node outputs a vector of the minimum, maximum, and mean pixel values of the input image.

MinMaxMeanNodeGPU

Language
C++
Input
gpu_mat_message
Output
int_vec_message
Arguments
name (string) = MinMaxMeanNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node has identical functionality to the MinMaxMeanNode, but uses the GPU for processing.

FFTNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = FFTNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
dftSize (int) = 256: The pixel width and height of a square to crop out of the center of the image.

The FFT node calculates the magnitude spectrum of a square section of the incoming tile image that is dftSize wide and tall.

FFTNodeGPU

Language
C++
Input
gpu_mat_message
Output
gpu_mat_message
Arguments
name (string) = FFTNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
dftSize (int) = 256: The pixel width and height of a square to crop out of the center of the image.

This node has identical functionality to the FFTNode, but uses the GPU for processing.

FocusNode

Language
C++
Input
mat_message
Output
float_message
Arguments
name (string) = FFTNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
dftSize (int) = 256: The width and height of the incoming FFT magnitude spectrum.
frequencyStart (int) = 50: The lower bound of spatial frequencies to evaluate for focus.
frequencyEnd (int) = 251: The upper bound of spatial frequencies to evaluate for focus.

This node calculates a focus score based using a FFT magnitude spectrum.

FocusNodeGPU

Language
C++
Input
gpu_mat_message
Output
float_message
Arguments
name (string) = FFTNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
dftSize (int) = 256: The width and height of the incoming FFT magnitude spectrum.
frequencyStart (int) = 50: The lower bound of spatial frequencies to evaluate for focus.
frequencyEnd (int) = 251: The upper bound of spatial frequencies to evaluate for focus.

This node has identical functionality to the FocusNode, but uses the GPU for processing.

HistogramNode

Language
C++
Input
mat_message
Output
mat_message
Arguments
name (string) = HistogramNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
bins (int) = 256: The number of bins to use when calculating the histogram.
width (int) = 512: The width of the resulting histogram image.
height (int) = 200: The height of the resulting histogram image.

This node creates a histogram plot as an image.

SubscribeRawTileNode

Language
Python
Output
str_message
Arguments
host (string) = 127.0.0.1: The host of the message broker.
port (int) = 61616: The port to use to connect to the message broker.
username (string) = None: The username to use when connecting to the message broker.
password (string) = None: The password to use when connecting to the message broker.
wait_interval (float) = 0.1: The amount of time to wait in seconds when a new file is not availble to process.

PublishFileNode

Language
Python
Input
str_message
Output
str_message
Arguments
service (string) = None: The service name to provide to the broker. Must not be None.
host (string) = 127.0.0.1: The host of the message broker.
port (int) = 61616: The port to use to connect to the message broker.
username (string) = None: The username to use when connecting to the message broker.
password (string) = None: The password to use when connecting to the message broker.
name (string) = PublishFileNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.
topic (string) = None: The topic to publish the file path on. Must not be None.

This node publishes the path to a file (usually the output of am IMWriteNode) using the TEM_comms library. The node outputs the input data without modification.

PublishFocusNode

Language
Python
Input
float_message
Output
float_message
Arguments
service (string) = None: The service name to provide to the broker. Must not be None.
host (string) = 127.0.0.1: The host of the message broker.
port (int) = 61616: The port to use to connect to the message broker.
username (string) = None: The username to use when connecting to the message broker.
password (string) = None: The password to use when connecting to the message broker.
name (string) = PublishFocusNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node publishes the focus score on the tile.statistics.focus topic using the TEM_comms library. The node outputs the input data without modification.

PublishMinMaxMeanNode

Language
Python
Input
int_vec_message
Output
int_vec_message
Arguments
service (string) = None: The service name to provide to the broker. Must not be None.
host (string) = 127.0.0.1: The host of the message broker.
port (int) = 61616: The port to use to connect to the message broker.
username (string) = None: The username to use when connecting to the message broker.
password (string) = None: The password to use when connecting to the message broker.
name (string) = PublishMinMaxMeanNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node publishes the minimum, maximum, and mean pixel values on the tile.statistics.min_max_mean topic using the TEM_comms library. The node outputs the input data without modification.

PublishTransformNode

Language
Python
Input
mat_message
Output
mat_message
Arguments
service (string) = None: The service name to provide to the broker. Must not be None.
host (string) = 127.0.0.1: The host of the message broker.
port (int) = 61616: The port to use to connect to the message broker.
username (string) = None: The username to use when connecting to the message broker.
password (string) = None: The password to use when connecting to the message broker.
name (string) = PublishTransformNode: The name for the node.
concurrency (int) = unlimited: The maximum number of copies of the node to run.

This node publishes the transform and other matching data from the message metadata on the tile.transform topic using the TEM_comms library. The node outputs the input data without modification.

Message Types

All data types are defined as having some metadata, along with data. The common metadata includes the following keys:

tile_id (string)
The unique ID of the tile
montage_id (string)
The unique ID of the montage
row (int)
The row in the montage where the tile is located
column (int)
The column in the montage where the tile if located
overlap (int)
The number of pixels of overlap between tiles

str_message

This message type consists of metadata and a string. This is often used for storing file paths. It has the following keys:

metadata (Metadata)
The message metadata
data (string)
The string data

mat_message

This message type consists of metadata and OpenCV image data. It has the following keys:

metadata (Metadata)
The message metadata
data (cv::Mat)
Image data

gpu_mat_message

This message type consists of metadata and OpenCV image data residing on the GPU. It has the following keys:

metadata (Metadata)
The message metadata
data (cv::cuda::GpuMat)
Image data on the GPU

float_message

This message type consists of metadata and a single floating point value. It has the following keys:

metadata (Metadata)
The message metadata
data (float)
A floating point value

int_vec_message

This message type consists of metadata and a vector of integers. It has the following keys:

metadata (Metadata)
The message metadata
data (int vector)
A vector of integers

Python API

Pipelines can be defined and run using a simple Python API. The library for doing so can be imported using,

import TEM_graph

A graph can then be created using,

graph = TEM_graph.graph()

Nodes are acessible in the TEM_graph.nodes submodule. For example, a CLAHE node could be created using,

CLAHE_node = TEM_graph.nodes.CLAHENode(
    clipLimit=3,
)

Alternatively, if this operation should be performed on a GPU, the GPU version of the node could be crated,

CLAHE_node = TEM_graph.nodes.CLAHENodeGPU(
    clipLimit=3,
)

Please note:

before this node could be used, the image data would have to be moved to GPU memory using the ToGPUNode.

Once the desired nodes are created, they can be connected together using the TEM_graph.make_edge() function. For example,

TEM_graph.make_edge(to_GPU_node, CLAHE_node)

would connect the output of the to_GPU_node to the input of the CLAHE_node. Once the graph is assembled, input nodes must be actived using the .activate() method of the input node.

After the graph is running, the graph.wait_for_all() function will wait for processing to be complete. Alternatively, the graph.cancel() function can be used to immediately halt data processing.

Config File

To further streamline pipeline creation, a YAML configuration file format was created. An example the following pipeline could be crated using a configuration file.

%3 cluster_Intel TBB Intel TBB fa05adbbec5746f6bc35e6833db5cf8b SubscribeRawTileNode db8f3728a1a6464aa24b1455aac3ad79 IMReadNode fa05adbbec5746f6bc35e6833db5cf8b->db8f3728a1a6464aa24b1455aac3ad79 e3717766a39b402389769fea4ecd2904 MinMaxMeanNode db8f3728a1a6464aa24b1455aac3ad79->e3717766a39b402389769fea4ecd2904 783f7f30d59740ed8059a384afaa446d HistogramNode db8f3728a1a6464aa24b1455aac3ad79->783f7f30d59740ed8059a384afaa446d 4eaaaee6c78b486580c5ae9cf2faf491 PublishMinMaxMeanNode e3717766a39b402389769fea4ecd2904->4eaaaee6c78b486580c5ae9cf2faf491 8cf551cf605b441883ef3e0c508120ad IMWriteNode 783f7f30d59740ed8059a384afaa446d->8cf551cf605b441883ef3e0c508120ad 2c0a4a372fe8480798784f576e479886 PublishFileNode 8cf551cf605b441883ef3e0c508120ad->2c0a4a372fe8480798784f576e479886

The configuration file to create this pipeline is:

nodes: # All nodes must be defined under this key
  input: # This is the name of the first node
    type: SubscribeRawTileNode # This is the name of the class that instantiates the node
    to: read # The name of the node which should recieve the output of this node
  read:
    type: IMReadNode
    to: # Multiple node names can also be specified
      - histogram
      - min_max_mean
  histogram:
    type: HistogramNode
    to: save
  save:
    type: IMWriteNode
    args: # Keyword arguments can be defined that will be provided to the node when it is initialized
      output_dir: /tmp/
    to: send_histogram
  send_histogram:
    type: PublishFileNode
    args:
      service: publish_histogram
      topic: tile.statistics.histogram
    # The 'to' key is not required
  min_max_mean:
    type: MinMaxMeanNode
    to: send_min_max_mean
  send_min_max_mean:
    type: PublishMinMaxMeanNode
    args:
      service: publish_min_max_mean

Once a pipeline configuration file has been written, a command line utility can be used to run the pipeline:

TEM_graph pipeline.yaml