© 2018 The Authors. This work is licensed under a Creative Commons Attribution License CC-BY 4.0. All code contained herein is licensed under an MIT license.
import sys
import glob
import numpy as np
import pandas as pd
import skimage.io
import skimage.morphology
import skimage.measure
import scipy.ndimage
import bokeh.io
import bokeh.plotting
import xmltodict
sys.path.insert(0, '../../')
import mscl.image
import mscl.plotting
import mscl.stats
bokeh.io.output_notebook()
In this notebook, we summarize the image processing pipeline used in this work and walk through the implementation for a truncated data set.
As is described in the main text and supplemental information, the crux of this work lies in the reliable and unbiased communication between automated and manual image processing. We desigened the project such that all segmentation and fluorescence quantification was done automatically. However, the dynamics of the experimental set up made time-resolved identification of surviving cells intractable. Therefore, all survivors were marked manually using the CellProfiler plugin for ImageJ and subsequently connected to the programmatically generated segmentation masks.
In the following sections, we will go through each of these steps in detail for a representative dataset. We will cover the loading and preprocessing of images, segmentation, linking manual markers to the segmentation mask, and fluorescence quantification.
The image processing is separated into three major processes -- automated segmentation of single cells, manual identification of survivors, and fluorescence quantification. In the following text, we will use an example image set and walk through each of these steps with line-by-line descriptions. If you are interested in playing around yourself, you can download the dataset directly and change the parameters in this notebook.
We'll begin by loading in all fluorescence and phase contrast images and displaying an example image. All phase contrast images are labeled as 'Brightfield' for convenience in file renaming.
# Load the files
bf_files = np.sort(glob.glob('../../data/20170517*/Pos*/img*Brightfield*.tif'))
gfp_files = np.sort(glob.glob('../../data/20170517*/Pos*/img*GFP*.tif'))
# Load the images as Image Collections.
bf_ims = skimage.io.ImageCollection(bf_files)
gfp_ims = skimage.io.ImageCollection(gfp_files)
# Select an example image for detailing the steps
bf = bf_ims[6]
gfp = gfp_ims[6]
# Define the interpixel distance.
ip_dist = 0.16 # µm per pixel
With all images loaded, we can take a look at the example phase contrast and fluorescence image. For this notebook, we will use the interactive plotting library Bokeh which allows panning and zooming to check out specific cells.
# Show the two example images
p1 = mscl.plotting.imshow(bf, interpixel_distance=0.160, length_units='µm',
color_mapper='Greys_r', plot_height=325)
p2 = mscl.plotting.imshow(gfp, interpixel_distance=0.160, length_units='µm',
color_mapper='viridis', plot_height=325)
# Link the axes for simultaneous zooming
p2.x_range = p1.x_range
p2.y_range = p1.y_range
# Format the axes.
p1.title.text = 'phase contrast'
p2.title.text = 'GFP fluorescence'
# Arrange and show the plots
row = bokeh.layouts.gridplot([[p1, p2]])
bokeh.io.show(row)