Tutorial 8: Using Prefab Pipelines#
Building a pipeline from scratch gives you full control, but PhenoTypic also ships prefab pipelines — pre-configured ImagePipeline subclasses tuned for common organisms and plate types. In this tutorial you will survey the available prefabs, apply one, and compare results.
What you will learn:
What prefab pipelines are and when to use them
Survey the available prefabs
Apply a prefab pipeline
Compare results from different prefabs
Imports#
[1]:
from phenotypic.data import load_synth_yeast_plate
Available Prefab Pipelines#
Each prefab is an ImagePipeline subclass with operations and measurements already configured. Choose based on your organism and plate conditions.
Prefab |
Best for |
Strategy |
|---|---|---|
|
General-purpose yeast, clean plates |
Multi-stage Otsu with refinement |
|
Touching or clustered colonies |
Watershed segmentation |
|
Round colonies, lightweight |
Peak detection |
|
Round colonies needing refinement |
Extended peak detection |
|
Filamentous fungi (Neurospora, etc.) |
BM3D denoise + specialized detector |
|
Pre-tiled grid sections |
Section-level processing |
Apply HeavyOtsuPipeline#
Let’s start with the most general-purpose option — HeavyOtsuPipeline. It chains Gaussian blur, CLAHE, median filtering, Sobel edge enhancement, Otsu detection, and several refinement steps (morphological opening, border removal, small-object removal, mask fill).
[2]:
from phenotypic.prefab import HeavyOtsuPipeline
plate = load_synth_yeast_plate()
heavy_otsu = HeavyOtsuPipeline()
result_otsu = heavy_otsu.apply(plate)
result_otsu.dash(overlay=True)
PNG file does not have exif data.
[3]:
print(f"HeavyOtsuPipeline detected {result_otsu.num_objects} colonies")
HeavyOtsuPipeline detected 88 colonies
Apply RoundPeaksPipeline#
Now let’s try RoundPeaksPipeline — a lighter approach that uses peak detection to find circular colonies. It is faster but may miss irregular or faint colonies.
[4]:
from phenotypic.prefab import RoundPeaksPipeline
plate2 = load_synth_yeast_plate()
round_peaks = RoundPeaksPipeline()
result_rp = round_peaks.apply(plate2)
result_rp.dash(overlay=True)
PNG file does not have exif data.
[5]:
print(f"RoundPeaksPipeline detected {result_rp.num_objects} colonies")
RoundPeaksPipeline detected 88 colonies
Compare#
Different prefabs produce different results on the same plate. The best choice depends on your colonies, your imaging conditions, and what you need to measure. A quick visual comparison and colony count helps you decide.
[6]:
print(f"HeavyOtsuPipeline: {result_otsu.num_objects} colonies")
print(f"RoundPeaksPipeline: {result_rp.num_objects} colonies")
HeavyOtsuPipeline: 88 colonies
RoundPeaksPipeline: 88 colonies
Prefabs Include Measurements#
Prefab pipelines come with measurements pre-configured, so you can call .apply_and_measure() directly — no need to add your own meas list.
[7]:
plate3 = load_synth_yeast_plate()
df = heavy_otsu.apply_and_measure(plate3)
print(f"{len(df)} colonies measured across {df.shape[1]} features")
df.head()
PNG file does not have exif data.
88 colonies measured across 128 features
[7]:
| Shape_Area | Shape_Perimeter | Shape_Circularity | Shape_ConvexArea | Shape_MedianRadius | Shape_MeanRadius | Shape_MaxRadius | Shape_MinFeretDiameter | Shape_MaxFeretDiameter | Shape_Eccentricity | ... | Bbox_MaxRR | Bbox_MaxCC | Bbox_IntensityWeightedCenterRR | Bbox_IntensityWeightedCenterCC | Bbox_DistWeightedCenterRR | Bbox_DistWeightedCenterCC | Grid_RowNum | Grid_ColNum | Grid_RowMajorIdx | Grid_ColMajorIdx | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2746.0 | 192.752309 | 0.928777 | 184.931454 | 8.944272 | 10.073936 | 28.861739 | 57.000000 | 59.908263 | 0.197044 | ... | 96 | 705 | 65.577126 | 675.117063 | 65.687209 | 675.177970 | 0 | 9 | 9 | 72 |
| 1 | 2804.0 | 194.994949 | 0.926704 | 186.843865 | 8.944272 | 10.152089 | 29.274562 | 58.689863 | 60.539243 | 0.140064 | ... | 98 | 153 | 67.158223 | 122.557819 | 67.191776 | 122.542560 | 0 | 1 | 1 | 8 |
| 2 | 2181.0 | 172.267027 | 0.923552 | 164.531689 | 8.000000 | 9.026047 | 25.632011 | 51.000000 | 53.009433 | 0.183600 | ... | 91 | 275 | 63.812682 | 248.465178 | 63.866256 | 248.428227 | 0 | 3 | 3 | 24 |
| 3 | 2313.0 | 177.681241 | 0.920666 | 169.588697 | 8.062258 | 9.262891 | 26.627054 | 53.000000 | 54.644304 | 0.184090 | ... | 92 | 583 | 64.928982 | 554.744857 | 64.973582 | 554.700651 | 0 | 7 | 7 | 56 |
| 4 | 2675.0 | 191.338095 | 0.918186 | 182.718280 | 8.944272 | 9.929177 | 28.284271 | 57.000000 | 58.830264 | 0.108238 | ... | 97 | 90 | 66.665330 | 60.434904 | 66.841375 | 60.565583 | 0 | 0 | 0 | 0 |
5 rows × 128 columns
Summary#
Prefab pipelines are the fastest path from plate image to results:
``HeavyOtsuPipeline`` — robust general-purpose detection with refinement
``RoundPeaksPipeline`` — lightweight peak-based detection for round colonies
``HeavyWatershedPipeline`` — for touching or clustered colonies
``FilamentousFungiPipeline`` — specialized for branching fungal morphology
All prefabs support
.apply(),.apply_and_measure(),.to_json(), etc.
Choose based on your organism, plate conditions, and desired accuracy. When a prefab is close but not quite right, use it as a starting point and customize the parameters.
Next up: Tutorial 9: Diagnosing Image Quality — assess plate quality before choosing a pipeline.