Lesson 39: Basic image quantification


[1]:
import numpy as np

# Our image processing tools
import skimage.filters
import skimage.io
import skimage.measure
import skimage.morphology
import skimage.segmentation

import holoviews as hv
hv.extension('bokeh')

import panel as pn
pn.extension()

Now that we have learned how to do basic segmentation, we continue our image processing lessons to learn how to obtain quantitative data from images.

In this lesson, we will expand on what we learned in the first image processing tutorial and develop some further skills to help us with segmentation of images. The images we will use were acquired by Griffin Chure in Rob Phillips’s lab here at Caltech. The bacteria are the HG105 E. coli strain, developed for an earlier paper from the Phillips lab. The strain is wild type, except the LacZYA genes are deleted. It features a YFP gene hooked up to the Lac promoter. Thus, the fluorescent signal is a measure of gene expression governed by the Lac promoter in the absence of several of its repressors.

In the previous lesson, we made strong arguments for performing segmentation on images of bacteria constitutively expressing a fluorescent protein. The main motivation is that the haloing effect from phase contrast images makes segmenting bacteria in large clumps very difficult. However, for the images we are analyzing here, we do not have a constitutive fluorescent protein. It is a bad idea to use the fluorescent signal we are measuring to do the segmentation, since this could introduce bias, especially when we have very low fluorescent signal for some cells. So, in this experiment, we will do the segmentation using the phase image and then use the fluorescent image to get a measure of the fluorescence intensity for each bacterium. It is important to have a dilute field of bacteria so that we do not have clumps of bacteria that make segmentation difficult.

Importantly, we are free to manipulate the brightfield image as we like in order to get good segmentation. After we have identified which pixels below to which cells, we have to be very careful adjusting the fluorescent images as the pixel values in these images are the signal we are measuring. We will only employ a median filter with a very small structuring element to deal with the known camera issue of occasional rogue high intensity pixels.

Inspecting the images

Let’s start by just getting a look at the images to see what we’re dealing with here. A collection of images can be found in data/HG105_images which will be used for this lesson and the following practice section. The specific images we will be looking at here will be noLac_phase_0000.tif and noLac_FITC_0000.tif. Since we are not quantifying the shape of these cells, and for ease, we will not scale the axes and instead leave them in units of pixels.

[2]:
# Load the images
im_phase = skimage.io.imread("data/HG105_images/noLac_phase_0004.tif")
im_fl = skimage.io.imread("data/HG105_images/noLac_FITC_0004.tif")

# Set up display options
height_pixels, width_pixels = im_phase.shape
bounds = [0, 0, *im_phase.shape]
frame_height = 200
frame_width = im_phase.shape[1] * frame_height // im_phase.shape[0]

opts = dict(
    frame_height=frame_height,
    frame_width=frame_width,
    xlabel='',
    ylabel='',
)

# Display side-by-side
plots = [
    hv.Image(data=im_phase, bounds=bounds).opts(cmap="viridis", **opts),
    hv.Image(data=im_fl, bounds=bounds).opts(cmap="viridis", **opts),
]

pn.Row(*plots)
[2]: