H&E Histology Color Normalization Instructions

Training a color classifier using train_classifier.m

Process

colorassign_manual.m   train_classifier.m   color_classify.m   color_normalize.m

Overview

This function uses machine learning algorithms to create a matrix used for classifying tissue structures based on color. A small image sample is used to train the machine learning algorithm. The result can then be used to classify the tissue structures of a larger image. The algorithm uses a decision tree in combination with an SVM algorithm to produce the results.

Inputs

rgb - A multidimensional array of size [MxNx3] where M and N represent the height and width of the image respectively. The third dimension of the data represents each color value (RGB).

idx - The indexed image as returned by colorassign_manual.m. A multidimensional array of size MxN. Each value of the array represents one of a set number of values as defined by the NCLUST constant in colorassign_manual.m.

The mapping of these values to structures is provided by the following input parameters:

lumen, nuclei, stroma, and cytoplasm - The mapping of values to structures as returned by colorassign_manual.m.
Each of these parameters is an array of values used to map the indexed values to the appropriate structures. For example:

lumen = [1, 2]
stroma = [3, 4]
cytoplasm = [5, 6]
nuclei = [9, 10]

Outputs

A multidimensional array of size 3x4 where each row represents the values for a hyperplane defined by the equation.

ax + by + cz = d

This series of hyperplanes acts as the classifier for future data, separating image pixels into one of the four classification groups.

Example output:

classifier = [
    -0.0001     0.0002     0.0001     0.0000
    -0.0010    -0.0035    -0.0020    -0.0001
     0.0028     0.0023     0.0023     0.0018
]

Explanation

As input parameters, the functions takes the same sample image that was given as input to colorassign_manual.m along with the indexed structure map returned by colorassign_manual.m. It also takes a mappings of the indexed values to the respective tissue structures, also returned by colorassign_manual.m.

The function works by splitting the lumen pixels from non-lumen pixels. These two groups are then passed to a SVM algorithm to determine an approximate hyperplane to separate the two sets.

The process is repeated separating nuclei from non-nuclei and then stroma from cytoplasm. The order of this particular decision tree was determined based on research published in the 2015 paper "An optimized color transformation for the analysis of digital images of hematoxylin & eosin stained slides" (jpathinformatics.org).

Free Parameters

TREE = {0, [1 2 3]; ...   % lumen
        1, [2 3]; ...     % nuclei
        2, 3};            % stroma vs cytoplasm

 
The decision tree used for initial data separation. The first branch separates lumen from non-lumen, the second branch separates nuclei from non-nuclei, the third separates stroma from cytoplasm.

The following constants are used as input arguments to the SVM classifier:

KSVM, FCN, ORDER, SIGMA, BOXC, MAXITER

KSVM = 1e4; % number of points per class for training

This value is used as a maximum number of points sent to the SVM classifier. If the image sent has more than 10,000 pixels worth of data in any of the categories, a random sampling will be used to select only 10,000.

BOXC = 0; % box constraint exponent (10^BOXC)

This is used to set value of the box constraint for the soft margin. In the default state this is set to 1 since this is the exponent for the value 10^BOXC.

MAXITER = 10^6;

This is the number of iterations to allow the training algorithm to run before returning an error. If the algorithm does not converge on a solution before this number of iterations, the program will throw an error.

Example Usage

>> loadedImage = imread('/path/to/histology/image.tif')
>> [structureMap, lumen, nuclei, stroma, cytoplasm] = colorassign_manual(loadedImage)
>> classifier = train_classifier(loadedImage,structureMap,lumen,nuclei,stroma,cytoplasm)

Timing

When processing a 1mm2 sample image of 2000x2000 pixels on a 2Ghz Intel i7 processor running with 8GB RAM, this function took 22 seconds to complete.

« Previous Step | Next Step »

 
 Back to Top