Tutorial 1: Your First Plate Image#
Welcome to PhenoTypic! In this tutorial, you will load your first agar plate image, display it interactively, inspect its basic properties, and explore the accessor pattern that gives you different views of the same plate.
What you will learn:
Load a plate image using
load_yeast_plate()Display it interactively with
.dash()Inspect basic properties:
.shape,.bit_depth,.name, and.dtypeExplore the accessor pattern:
.rgb[:],.gray[:],.detect_mat[:]Understand what each accessor provides and when you would use it
Imports#
Start by importing PhenoTypic and the sample data loader. The convention is to import the library as pht.
[1]:
from phenotypic.data import load_yeast_plate
Load a Plate Image#
PhenoTypic ships with several sample plate images so you can start experimenting right away. load_yeast_plate() returns a GridImage of Rhodotorula yeast colonies arranged in a standard 96-well grid (8 rows by 12 columns).
A GridImage is PhenoTypic’s main data structure for arrayed colony plates – it behaves like a regular Image but also knows about the grid layout of wells.
[2]:
plate = load_yeast_plate()
print(type(plate))
<class 'phenotypic._core._grid_image.GridImage'>
You now have a GridImage object stored in plate. Everything you need – pixel data, metadata, accessors, and visualization methods – lives on this single object.
Display the Plate#
The quickest way to see your plate is with .dash(). This renders the full-color image inline. Take a look at the Rhodotorula colonies – you should see a grid of round, pigmented spots on a light agar background.
[3]:
plate.dash();
Nice work – you have just visualized your first plate image!
Inspect Basic Properties#
Before processing a plate, it helps to know what you are working with. Let’s inspect a few key properties.
``.shape`` – the dimensions of the image array (height, width, channels)
``.bit_depth`` – bits per pixel (8 means values 0–255; 16 means 0–65 535)
``.name`` – a human-readable identifier for the image
``.rgb.dtype`` – the NumPy data type of the underlying pixel array
[4]:
print("Shape: ", plate.shape)
print("Bit depth:", plate.bit_depth)
print("Name: ", plate.name)
print("Dtype: ", plate.rgb.dtype)
Shape: (770, 1644, 3)
Bit depth: 8
Name: RhodotorulaYeastCenterCrop
Dtype: uint8
The shape tells you the image height and width in pixels, plus the number of color channels (3 for an RGB image). The bit depth and dtype confirm the precision of the pixel values. These properties are useful for sanity-checking your data before you feed it into a processing pipeline.
The Accessor Pattern#
PhenoTypic uses an accessor pattern to give you different representations of the same plate image. Instead of calling separate functions, you access views through dot-notation attributes on the image object.
The three primary accessors are:
Accessor |
What it provides |
Typical use |
|---|---|---|
|
Full-color pixel data |
Visualization, color analysis |
|
Luminance-weighted grayscale |
Intensity-based measurements |
|
Detection matrix (enhanced grayscale) |
Colony detection and segmentation |
Each accessor supports NumPy-style slicing with [:] to retrieve the underlying array, and has its own .dash() method for quick visualization. Let’s explore each one.
RGB Accessor#
The .rgb accessor holds the full-color image data. Use .rgb[:] to get the raw NumPy array (shape: height x width x 3), or .rgb.dash() to display it. This is the same view you saw with plate.dash() earlier.
[5]:
rgb_array = plate.rgb[:]
print("RGB array shape:", rgb_array.shape)
print("RGB array dtype:", rgb_array.dtype)
RGB array shape: (770, 1644, 3)
RGB array dtype: uint8
[6]:
plate.rgb.dash();
Grayscale Accessor#
The .gray accessor provides a luminance-weighted grayscale version of the plate. The conversion uses perceptual weights so bright colonies appear bright and dark agar appears dark, matching what your eye expects.
The array has shape (height, width) – a single channel – with float32 values.
[7]:
gray_array = plate.gray[:]
print("Grayscale array shape:", gray_array.shape)
print("Grayscale array dtype:", gray_array.dtype)
Grayscale array shape: (770, 1644)
Grayscale array dtype: float64
[8]:
plate.gray.dash();
Detection Matrix Accessor#
The .detect_mat accessor is where the magic happens. The detection matrix is the grayscale representation that PhenoTypic’s detectors actually work on. When you apply enhancers to a plate image, they modify the detection matrix while leaving the RGB and grayscale data untouched.
This separation is a key design decision: you can aggressively preprocess the detection matrix to improve colony segmentation without corrupting the original color data that you need for accurate measurements later.
Right now, before any enhancers have run, the detection matrix looks identical to the grayscale image.
[9]:
detect_array = plate.detect_mat[:]
print("Detection matrix shape:", detect_array.shape)
print("Detection matrix dtype:", detect_array.dtype)
Detection matrix shape: (770, 1644)
Detection matrix dtype: float64
[10]:
plate.detect_mat.dash();
Right now it looks just like the grayscale view – and that is expected. Once you start applying enhancers (contrast stretching, background subtraction, etc.), the detection matrix will diverge from the raw grayscale, making colonies easier for detectors to find.
Summary#
Congratulations – you have loaded your first plate image, explored its properties, and seen the three key image representations that PhenoTypic provides:
``.rgb`` – full-color pixel data for visualization and color analysis
``.gray`` – luminance-weighted grayscale for intensity work
``.detect_mat`` – the detection matrix that enhancers modify and detectors consume
You now have a solid foundation for working with plate images in PhenoTypic.
Next up: In Tutorial 2: Detecting Colonies, you will use this plate to detect and segment individual colonies.