Exercise: machine learning for segmentation#
Duration ~40 min · Session Day 2, Python notebooks
Cell segmentation with a pixel classifier and Cellpose.
Data: data/bbbc020/ field 15min_1, and the Weka export in
data/bbbc020/weka/15min_1_cells_probability_2.tif. If you exported your own in E4, use those
instead: point WEKA at results/weka/ and the rest will work unchanged.
import tifffile
import os; os.environ["DISPLAY"] = ":1"
from course import DATA, show
Task 1: Load the pixel classifier output and perform a watershed segmentation.#
Use a nuclei segmentation to seed the watershed segmentation.
Hint 1: First threshold the Weka output appropriately.
Hint 2: In case the nuclei are not well separated, you could perform a distance transform based watershed segmentation on the nuclei, to then serve as seed for the watershed segmentation of the pixel classifier output.
# --- your turn ---
...
Task 2: Segment the same image with Cellpose, once using only the cell channel, and once using both the cell and nuclei channels.#
Try varying the diameter parameter of Cellpose to see whether it improves the segmentation. It should be set to the approximate diameter of the cells in pixels.
# --- your turn ---
...
Task 3: Segment the cell cytoplasm#
Hint: Use the result of applying different Cellpose models on different channel combinations for this.
# --- your turn ---
...