Reading Progress
0%
Introduction
Gaussian Blur
Segmentation
Tkinter Interface
Counting Cells
Transfection Rate
Improvements
🖱️

Programs

This notebook contains a Python programme capable of counting cells in two images taken under a microscope (one under white light and the other under fluorescence), in order to then calculate the DNA transfection rate in HEK cells. However, this code can be used for other cells for the same purpose.

1 Program
1 Aim
Counting cells
Download the code

Contrast image enhancement with a Gaussian blur

  • The goal of the function GaussianBlur is to reduce noise to facilitate contour detection by adding a gaussian blur. This softens the transitions between pixels before performing segmentation. Here, the size of the blur kernel is (5,5). The larger the kernel, the stronger the blur.

Segmentation with an adaptive threshold

  • This step is necessary to obtain a clean binary image from a grayscale image. Adaptive thresholding makes the method less sensitive to variations in lighting or contrast in the image, often present in microscopic images. Thus it allows the computer to separate, i.e. segment, objects of interest from the rest of the image (background).

Tkinter - Python toolkit interface

  • The principle is based on a Tkinter interface that allows the user to choose the parameters that best identify the contours of the cells in the image. The three parameters are the size of the block for adaptive thresholding, the value of the threshold correction factor and the minimum area of a contour to be counted as a cell.

Counting the cells

  • After segmentation is complete, the function findContours counts the cells in the image based on the contours drawn previously. Regarding the minimum area chosen before, it is able to filter the image and count the number of remaining contours. This is the final step to quantify the number of cells.

Calculation of transfection rate

  • This step is a simple ratio between the number of fluorescent cells and the total number of cells. The user can enter two images of their choice, one in white light (showing all cells) and one in fluorescence (showing only transfected cells), choose the best parameters for each, and then the program simply calculates the ratio of fluorescent cells over total cells to return the transfection rate.

Potential improvements

  • As we neared the end of the project, we took some classes on machine learning, which showed us how we could improve the program even more. Indeed, this program, initially designed to automate the calculation of transfection rates, has great potential for improvement through machine learning, using, for example, a U-Net model, which is particularly suited to biomedical image segmentation tasks such as cell detection.
  • The problem is that we don't have a large number of images, which would limit our dataset and make model training inefficient, with a risk of overfitting. This problem can be solved by training artificial data by augmenting existing data (with rotation, random brightness, etc.).
  • The second option is to use an existing pre-trained model and adapt it to our microscopic images.