Loading [MathJax]/jax/output/HTML-CSS/jax.js
+/- Message
## Loading required package: knitr
+/- r Code
+/- r Code
+/- r Code

Quantitative Big Imaging

author: Kevin Mader date: 26 March 2015 width: 1440 height: 900 css: ../common/template.css transition: rotate

ETHZ: 227-0966-00L

Analysis of Single Objects

Course Outline

+/- r Code
  • 19th February - Introduction and Workflows
  • 26th February - Image Enhancement (A. Kaestner)
  • 5th March - Basic Segmentation, Discrete Binary Structures
  • 12th March - Advanced Segmentation
  • 19th March - Applying Graphical Models and Machine Learning (A. Lucchi)
  • 26th March - Analyzing Single Objects
  • 2nd April - Analyzing Complex Objects
  • 16th April - Groups and Spatial Distribution
  • 23rd April - Statistics and Reproducibility
  • 30th April - Dynamic Experiments
  • 7th May - Scaling Up / Big Data
  • 21th May - Guest Lecture, Applications in High-content Screening and Wood
  • 28th May - Project Presentations

Literature / Useful References

  • Jean Claude, Morphometry with R
  • Online through ETHZ
  • Buy it
  • John C. Russ, “The Image Processing Handbook”,(Boca Raton, CRC Press)
  • Available online within domain ethz.ch (or proxy.ethz.ch / public VPN)
  • Principal Component Analysis
    • Venables, W. N. and B. D. Ripley (2002). Modern Applied Statistics with S, Springer-Verlag
  • Shape Tensors
    • http://www.cs.utah.edu/~gk/papers/vissym04/
    • Doube, M.,et al. (2010). BoneJ: Free and extensible bone image analysis in ImageJ. Bone, 47, 1076–9. doi:10.1016/j.bone.2010.08.023
    • Mader, K. , et al. (2013). A quantitative framework for the 3D characterization of the osteocyte lacunar system. Bone, 57(1), 142–154. doi:10.1016/j.bone.2013.06.026

Previously on QBI ...

  • Image Enhancment
    • Highlighting the contrast of interest in images
    • Minimizing Noise
  • Segmentation
    • Understanding value histograms
    • Dealing with multi-valued data
  • Automatic Methods
    • Hysteresis Method, K-Means Analysis
  • Regions of Interest
    • Contouring
  • Machine Learning

A Machine Learning Approach to Image Processing

Segmentation and all the steps leading up to it are really a specialized type of learning problem.

+/- r Code

Returning to the ring image we had before, we start with our knowledge or ground-truth of the ring

plot of chunk unnamed-chunk-2
+/- r Code

Which we want to identify the from the following image by using image processing tools

plot of chunk unnamed-chunk-3
+/- r Code

What does identify mean?

  • Classify the pixels in the ring as Foreground
  • Classify the pixels outside of the ring as Background

How do we quantify this?

  • True Positive values in the ring that are classified as Foreground
  • True Negative values outside the ring that are classified as Background
  • False Positive values outside the ring that are classified as Foreground
  • False Negative values in the ring that are classified as Background
plot of chunk unnamed-chunk-4
+/- r Code

We can then apply a threshold to the image to determine the number of points in each category

plot of chunk unnamed-chunk-5
+/- r Code

Ring Threshold Example

Try a number of different threshold values on the image and compare them to the original classification

+/- r Code
plot of chunk unnamed-chunk-7
+/- r Code

+/- r Code
Thresh TP TN FP FN
0.0 224 0 217 0
0.2 224 22 195 0
0.4 211 92 125 13
0.6 146 181 36 78
0.8 49 215 2 175
1.0 0 217 0 224
plot of chunk unnamed-chunk-9
+/- r Code

Apply Precision and Recall

  • Recall (sensitivity)= TP/(TP+FN)
  • Precision = TP/(TP+FP)
+/- r Code
Thresh TP TN FP FN Recall Precision
0.30 222 48 169 2 99 57
0.38 214 83 134 10 96 61
0.46 203 119 98 21 91 67
0.54 171 153 64 53 76 73
0.62 132 186 31 92 59 81
0.70 93 198 19 131 42 83

ROC Curve

Reciever Operating Characteristic (first developed for WW2 soldiers detecting objects in battlefields using radar). The ideal is the top-right (identify everything and miss nothing)

plot of chunk unnamed-chunk-11
+/- r Code

Comparing Different Filters

We can then use this ROC curve to compare different filters (or even entire workflows), if the area is higher the approach is better.

plot of chunk unnamed-chunk-12
+/- r Code

Different approaches can be compared by area under the curve

plot of chunk unnamed-chunk-13
+/- r Code

True Positive Rate and False Positive Rate

Another way of showing the ROC curve (more common for machine learning rather than medical diagnosis) is using the True positive rate and False positive rate

  • True Positive Rate (recall)= TP/(TP+FN)
  • False Positive Rate = FP/(FP+TN)

These show very similar information with the major difference being the goal is to be in the upper left-hand corner. Additionally random guesses can be shown as the slope 1 line. Therefore for a system to be useful it must lie above the random line.

plot of chunk unnamed-chunk-14
+/- r Code

Practical Example: Calcifications in Breast Tissue

While finding a ring might be didactic, it is not really a relevant problem and these terms are much more meaningful when applied to medical images where every False Positives and False Negative can be mean life-threatening surgery or the lack thereof. (Data courtesy of Zhentian Wang)

+/- r Code
plot of chunk unnamed-chunk-15
+/- r Code

From these images, an expert labeled the calcifications by hand, so we have ground truth data on where they are:

plot of chunk unnamed-chunk-16
+/- r Code

Applying a threshold

We can perform the same analysis on an image like this one, again using a simple threshold to evalulate how accurately we identify the calcifications

plot of chunk unnamed-chunk-17
+/- r Code

plot of chunk unnamed-chunk-18
+/- r Code

Examining the ROC Curve

+/- r Code
+/- r Code
Thresh TP TN FP FN Recall Precision
7 2056 13461 74483 0 100 3
23 2030 25806 62138 26 99 3
34 1950 38744 49200 106 95 4
42 1726 51676 36268 330 84 5
48 1435 64161 23783 621 70 6
54 1043 76363 11581 1013 51 8
plot of chunk unnamed-chunk-20
+/- r Code

plot of chunk unnamed-chunk-21
+/- r Code

Comparing Absorption and Scattering Channels

Since our image has two channels we can examine both of them (Recall is not on a linear scale so the differences can more easily be seen). It is clear that scattering provides more useful information than absorption except for very high recall and meaninglessly low precision.

+/- r Code
plot of chunk unnamed-chunk-23
+/- r Code

Combining both channels

+/- r Code

We can get even better results by using a combination of both absorption and scattering to find the calcifications

plot of chunk unnamed-chunk-24
+/- r Code

This can then be represented as a pseudo-ROC curve by showing all of the points and finding the maximum value.

plot of chunk unnamed-chunk-25
+/- r Code

Learning Objectives

Motivation (Why and How?)

  • How do we quantify where and how big our objects are?
  • How can we say something about the shape?
  • How can we compare objects of different sizes?
  • How can we compare two images on the basis of the shape as calculated from the images?
  • How can we put objects into an finite element simulation? or make pretty renderings?

Outline

  • Motivation (Why and How?)
  • Object Characterization
  • Volume
  • Center and Extents
  • Anisotropy

  • Shape Tensor
  • Principal Component Analysis
  • Ellipsoid Representation
  • Scale-free metrics
  • Anisotropy, Oblateness
  • Meshing
    • Marching Cubes
    • Isosurfaces
  • Surface Area

Motivation

We have dramatically simplified our data, but there is still too much.

  • We perform an experiment bone to see how big the cells are inside the tissue Bone Measurement

2560 x 2560 x 2160 x 32 bit

56GB / sample

  • Filtering and Enhancement!
  • 56GB of less noisy data

  • Segmentation

2560 x 2560 x 2160 x 1 bit

(1.75GB / sample)

  • Still an aweful lot of data

What did we want in the first place

Single number:

  • volume fraction,
  • cell count,
  • average cell stretch,
  • cell volume variability

Component Labeling

Once we have a clearly segmented image, it is often helpful to identify the sub-components of this image. The easist method for identifying these subcomponents is called component labeling which again uses the neighborhood N as a criterion for connectivity, resulting in pixels which are touching being part of the same object.

In general, the approach works well since usually when different regions are touching, they are related. It runs into issues when you have multiple regions which agglomerate together, for example a continuous pore network (1 object) or a cluster of touching cells


The more general formulation of the problem is for networks (roads, computers, social). Are the points start and finish connected?

Network connectivity
+/- r Code

Component Labeling: Algorithm

We start out with the network and we grow Begin to its connections. In a brushfire-style algorithm

  • For each point (x,y){Begin,Pixels Grown}
    • For each point (x,y)N(x,y)
    • Set the label to Pixels Grown
  • Repeat until no more labels have been changed

+/- r Code
One Growth Step
+/- r Code

Component Labeling: Algorithm Steps

10 Growth Steps
+/- r Code
10 Growth Steps
+/- r Code

Diagonal Growth Steps
+/- r Code

Component Labeling: Images Algorithm

Same as for networks but the neighborhood is defined with a kernel (circular, full, line, etc) and labels must be generate for the image

  • Assign a unique label to each point in the image L(x,y)=yImwidth+x

  • For each point (x,y)

    • Check each point (x,y)N(x,y)
    • Set L(x,y)=min(L(x,y),L(x,y)) L(x,y)=L(x,y)
  • Repeat until no more L values are changed


Image as Network
+/- r Code

Component Labeling: Image Algorithm

+/- r Code
One Growth Step
+/- r Code
One Growth Step
+/- r Code

The image very quickly converges and after 4 iterations the task is complete. For larger more complicated images with thousands of components this task can take longer, but there exist much more efficient algorithms for labeling components which alleviate this issue.

One Growth Step
+/- r Code

Component Labeling: Image Algorithm

Cell Colony
+/- r Code
Cell Colony
+/- r Code

Cell Colony
+/- r Code

Component Labeling: Beyond

Now all the voxels which are connected have the same label. We can then perform simple metrics like

  • counting the number of voxels in each label to estimate volume.
  • looking at the change in volume during erosion or dilation to estimate surface area

Next week we will cover how more detailed analysis can be performed on these data.

From the labels

Cell Colony
+/- r Code

What we would like to to do

  • Count the cells
  • Say something about the cells
  • Compare the cells in this image to another image
  • But where do we start?

COV: With a single object

Iid(x,y)={1,L(x,y)=id0,otherwise

Single Cell
+/- r Code

Define a center

ˉx=1NvIidvi ˉy=1NvIidvj ˉz=1NvIidvk

COM: With a single object

If the gray values are kept (or other meaningful ones are used), this can be seen as a weighted center of volume or center of mass (using Igy to distinguish it from the labels)

Single Cell
+/- r Code

Define a center

ΣIgy=1NvIidIgy(v) ˉx=1ΣIgyvIid(vi)Igy(v) ˉy=1ΣIgyvIid(vj)Igy(v) ˉz=1ΣIgyvIid(vk)Igy(v)

Extents: With a single object

Exents or caliper lenghts are the size of the object in a given direction. Since the coordinates of our image our x and y the extents are calculated in these directions

Single Cell
+/- r Code

Define extents as the minimum and maximum values along the projection of the shape in each direction Extx={vIid:max(vi)min(vi)} Exty={vIid:max(vj)min(vj)} Extz={Iid:max(vk)min(vk)}

  • Lots of information about each object now
  • But, I don't think a biologist has ever asked "How long is a cell in the x direction? how about y?"

Anisotropy: What is it?

By definition (New Oxford American): varying in magnitude according to the direction of measurement.

  • It allows us to define metrics in respect to one another and thereby characterize shape.
  • Is it tall and skinny, short and fat, or perfectly round

Due to its very vague definition, it can be mathematically characterized in many different very much unequal ways (in all cases 0 represents a sphere)

Aiso1=Longest SideShortest Side1

Aiso2=Longest SideShortest SideLongest Side

Aiso3=Longest SideAverage Side Length1

Aiso4=Longest SideShortest SideAverage Side Length

 ad nauseum

Anisotropy: Which definition makes sense?

Let's take some sample objects

Sample Objects
+/- r Code

+/- r Code
Y Extent Aiso1 Aiso2 Aiso3 Aiso4
0.00 4999.00 1.00 1.00 2.00
0.01 499.00 1.00 1.00 1.99
0.10 49.00 0.98 0.96 1.92
1.00 4.00 0.80 0.67 1.33
2.00 1.50 0.60 0.43 0.86
3.00 0.67 0.40 0.25 0.50
4.00 0.25 0.20 0.11 0.22
5.00 0.00 0.00 0.00 0.00

Anisotropy: Which definition makes sense?

Sample Objects
+/- r Code

Anisotropy vs x extents

Anisotropy Formulas
+/- r Code

Distributions: Randomly Sized Objects

Objects with uniformally distributed, independent x and y extents

Sample Objects
+/- r Code
Anisotropy Formulas
+/- r Code

Anisotropy Formulas
+/- r Code
Anisotropy Formulas
+/- r Code

Extents: With all objects

All Cells Labeled
+/- r Code

All Cells
+/- r Code

COV and Extents: All Cells

All Cells
+/- r Code

Bounding Box: All Cells

All Cells Bounding Box
+/- r Code

Sorted by Anisotropy

All Cells Bounding Box
+/- r Code

Bounding Box is a Poor Approximation

While easy to calculate, the bounding box / extents approach is a very rough approximation for most of the objects in our image. In particular objects which are not parallel to the XY-axes are misrepresented.

Possible Solutions

  • Orient the boxes so there is the least amount of empty space or it best fits the data
  • Assume the object is an ellipse and do some sort of curve fitting to find the object
  • Don't worry about height and width and focus instead on more general characteristics like curvature, thickness (next lecture)

Useful Statistical Tools: Principal Component Analysis

While many of the topics covered in Linear Algebra and Statistics courses might not seem very applicable to real problems at first glance, at least a few of them come in handy for dealing distributions of pixels (they will only be briefly covered, for more detailed review look at some of the suggested material)

Principal Component Analysis

Similar to K-Means insofar as we start with a series of points in a vector space and want to condense the information. With PCA instead of searching for distinct groups, we try to find a linear combination of components which best explain the variance in the system.


As an example we will use a very simple example of corn and chicken prices vs time

Corn and Chicken
+/- r Code
PCA Example
+/- r Code

Useful Statistical Tools: Principal Component Analysis

The first principal component condenses the correlated information in both the chicken and corn prices (perhaps the underlying cost of fuel) since it explains the most variance in the final table of corn and chicken prices.

PCA Example
+/- r Code

The second principal component is then related to the unique information seperating chicken from corn prices but neither indices directly themselves (maybe the cost of antibiotics)

PCA Example
+/- r Code

Applied PCA: Shape Tensor

How do these statistical analyses help us?

Going back to a single cell, we have the a distribution of x and y values.

  • are not however completely independent
  • greatest variance does not normally lie in either x nor y alone.

A principal component analysis of the voxel positions, will calculate two new principal components (the components themselves are the relationships between the input variables and the scores are the final values.)

  • An optimal rotation of the coordinate system

Single Cell
+/- r Code
plot of chunk unnamed-chunk-60
+/- r Code

How did we calculate that?

We start off by calculating the covariance matrix from the list of x, y, and z points that make up our object of interest.

COV(Iid)=1NvIid[vxvxvxvyvxvzvyvxvyvyvyvzvzvxvzvyvzvz]

We then take the eigentransform of this array to obtain the eigenvectors (principal components, Λ13) and eigenvalues (scores, λ13)

COV(Iid)[Λ1xΛ1yΛ1zΛ2xΛ2yΛ2zΛ3xΛ3yΛ3z]Eigenvectors[λ1000λ2000λ3]Eigenvalues[Λ1xΛ1yΛ1zΛ2xΛ2yΛ2zΛ3xΛ3yΛ3z]TEigenvectors The principal components tell us about the orientation of the object and the scores tell us about the corresponding magnitude (or length) in that direction.

Principal Component Analysis: Take home message

  • We calculate the statistical distribution individually for x, y, and z and the 'correlations' between them.
  • From these values we can estimate the orientation in the direction of largest variance
  • We can also estimate magnitude
  • These functions are implemented as princomp or pca in various languages and scale well to very large datasets.

Principal Component Analysis: Elliptical Model

While the eigenvalues and eigenvectors are in their own right useful

  • Not obvious how to visually represent these tensor objects
  • Ellipsoidal (Ellipse in 2D) representation alleviates this issue

Ellipsoidal Representation

  1. Center of Volume is calculated normally
  2. Eigenvectors represent the unit vectors for the semiaxes of the ellipsoid
  3. Eigenvalues is proportional to the length of the semiaxis (l=5λi), derivation similar to moment of inertia tensor for ellipsoids.

Single Cell
+/- r Code

Elliptical Model vs Bounding Box

Single Cell
+/- r Code

  • The bounding box matches boundaries better
  • The ellipse captures the dimensions and shape better
  • Extents can be calculated from either method
  • Anisotropy can also be calculated from either method

Elliptical Model for All Samples

All Cells Elliptical Model
+/- r Code

Comparison between Anisotropy for both models

All Cells Elliptical Model
+/- r Code

We see that there seems to be a general, albeit weak, correlation between the two measures. The most concerning portion is however the left side where the extents or bounding box method reports 0 anisotropy and the elliptical method reports substancial amounts of it.

All Cells Elliptical Model
+/- r Code

3D Shape Analysis

The models we have done are all applicable to both 2D and 3D images. The primary difference is when looking at 3D images there is an extra dimension to consider.

3D Ellipse
+/- r Code

It can also be shown as a series of 2D slices.

3D Ellipse
+/- r Code

Anisotropy applies to these samples as well but it only gives us information about the shortest and the longest dimensions. Is that enough?

Pancakeness

Each of these images has the exact same anisotropy because the shortest semiaxis length remains

Oblateness
+/- r Code

If we take a slice through the image we can image the final shape looking like a very small thin rod in the case where the second dimension is equal to 3 (short in two directions and long in the other) and a pankcake (short in one direction and long in the other two).

Oblateness Slices
+/- r Code

Oblateness

We can thus introduce a new metric for assessing the second-degree anisotropy in the object and this we shall somewhat more formally call Oblateness.

Ob=2λ2λ1λ3λ11

The value like in anisotropy is bound between -1 and 1.

  • -1 indicates the middle semiaxis is the same length of the shortest semiaxis λ2=λ1 and thus the structure is rod-like prolate
  • +1 indicates the middle axis is the same length as the longest semiaxis λ2=λ3 and thus the structure is pancake-like oblate

Oblateness Slices
+/- r Code
Oblateness Slices
+/- r Code

Interfaces / Surfaces

Many physical and chemical processes occur at surfaces and interfaces and consequently these structures are important in material science and biology. For this lecture surface and interface will be used interchangebly and refers to the boundary between two different materials (calcified bone and soft tissue, magma and water, liquid and gas) Through segmentation we have identified the unique phases in the sample under investigation.

  • Segmentation identifying volumes (3D) or areas (2D)
  • Interfaces are one dimension lower corresponding to surface area (3D) or perimeter (2D)
  • Interfaces are important for
    • connectivity of cell networks, particularly neurons
    • material science processes like coarsening or rheological behavior
    • chemical processes (surface-bound diffusion, catalyst action)

Surface Area / Perimeter

We see that the dilation and erosion affects are strongly related to the surface area of an object: the more surface area the larger the affect of a single dilation or erosion step.

Surface Area Estimation
+/- r Code

Attenuation to Intensity
+/- r Code

Meshing

Constructing a mesh for an image provides very different information than the image data itself. Most crucially this comes when looking at physical processes like deformation.

While the images are helpful for visualizing we rarely have models for quantifying how difficult it is to turn a pixel off

Deformation in Pixels
+/- r Code

If the image is turned into a mesh we now have a list of vertices and edges. For these vertices and edges we can define forces. For example when looking at stress-strain relationships in mechanics using Hooke's Model F=k(x0x) the force needed to stretch one of these edges is proportional to how far it is stretched.

Deformation with Meshes
+/- r Code

Meshing

Since we uses voxels to image and identify the volume we can use the voxels themselves as an approimation for the surface of the structure.

  • Each 'exposed' face of a voxel belongs to the surface

From this we can create a mesh by

  • adding each exposed voxel face to a list of surface squares.
  • adding connectivity information for the different squares (shared edges and vertices)

A wide variety of methods of which we will only graze the surface (http://en.wikipedia.org/wiki/Image-based_meshing)

Marching Cubes

Why

Voxels are very poor approximations for the surface and are very rough (they are either normal to the x, y, or z axis and nothing between). Because of their inherently orthogonal surface normals, any analysis which utilizes the surface normal to calculate another value (growth, curvature, etc) is going to be very inaccurate at best and very wrong at worst.

How

The image is processed one voxel at a time and the neighborhood (not quite the same is the morphological definition) is checked at every voxel. From this configuration of values, faces are added to the mesh to incorporate the most simple surface which would explain the values.

Marching tetrahedra is for some applications a better suited approach

Next Time on QBI

So while bounding box and ellipse-based models are useful for many object and cells, they do a very poor job with the sample below.

Single Cell
+/- r Code

Why

  • We assume an entity consists of connected pixels (wrong)
  • We assume the objects are well modeled by an ellipse (also wrong)

What to do?

  • Is it 3 connected objects which should all be analzed seperately?
  • If we could divide it, we could then analyze each spart as an ellipse
  • Is it one network of objects and we want to know about the constrictions?
  • Is it a cell or organelle with docking sites for cell?
  • Neither extents nor anisotropy are very meaningful, we need a more specific metric which can characterize