phenotypic.GridImage.grid#

property GridImage.grid: GridAccessor#

Returns the GridAccessor object for grid-related operations.

Returns:

Provides access to Grid-related operations.

Return type:

GridAccessor

See Also GridAccessor

GridAccessor API#

class phenotypic.core._image_parts.accessors.GridAccessor(root_image: GridImage)[source]

Bases: ImageAccessorBase

Provides grid-based access and analysis for microbial colony arrays on agar plates.

This class facilitates operations on grid structures within a GridImage, enabling analysis of robotically-pinned microbial colonies arranged in a regular rectangular array pattern. It provides methods for determining grid properties, retrieving colony information by grid location, and visualizing grid overlays with row and column assignments.

The grid divides an agar plate image into a regular matrix of sections, each potentially containing one or more detected colonies. The grid is ordered left-to-right, top-to-bottom when using flattened indexing.

Parameters:

root_image (GridImage)

nrows

Number of rows in the grid (read/write property). Corresponds to the number of row pins in a colony pinning robot. Must be >= 1.

Type:

int

ncols

Number of columns in the grid (read/write property). Corresponds to the number of column pins in a colony pinning robot. Must be >= 1.

Type:

int

Examples

Access grid information for a 96-well colony plate
from phenotypic import GridImage

# Load image and create grid accessor
grid_image = GridImage('agar_plate.png', nrows=8, ncols=12)

# Get grid information as a DataFrame
grid_info = grid_image.grid.info()
print(f"Found {len(grid_info)} colonies across {grid_image.grid.nrows} rows "
      f"and {grid_image.grid.ncols} columns")

# Extract a single grid section (colony at row 2, column 3)
section_idx = 2 * grid_image.grid.ncols + 3  # Flattened index
colony_image = grid_image.grid[section_idx]

# Visualize grid columns with color-coded labels
fig, ax = grid_image.grid.show_column_overlay(show_gridlines=True)
Get colony counts by grid section
# Count colonies in each grid section
section_counts = grid_image.grid.get_section_counts(ascending=False)
print("Colonies per section (sorted):")
print(section_counts)

# Get all colony information for row 0
row_info = grid_image.grid.get_info_by_section((0, slice(None)))
__array__(dtype=None, copy=None)

Implements the array interface for numpy compatibility.

This allows numpy functions to operate directly on accessor objects. For example: np.sum(accessor), np.mean(accessor), etc.

Parameters:
  • dtype – Optional dtype to cast the array to

  • copy – Optional copy parameter for NumPy 2.0+ compatibility

Returns:

The underlying array data

Return type:

np.ndarray

__getitem__(idx: int | tuple[int, int]) Image[source]

Extract a grid section as a subimage.

Returns a cropped image corresponding to a specific grid section based on either its flattened index or a (row, column) grid coordinate. The grid is indexed left-to-right, top-to-bottom (row-major order). Only objects belonging to the specified grid section are included in the subimage. The subimage’s pixel coordinates are adjusted relative to the section origin (top-left corner).

Parameters:

idx (int | tuple[int, int]) –

Grid section identifier. - If int: flattened grid section index, ranging from 0 to

nrows * ncols - 1. For an 8x12 grid: section 0 is top-left, section 11 is top-right, section 84 is bottom-left, section 95 is bottom-right.

  • If tuple[int, int]: (row_index, col_index) pair specifying the grid location, with both indices 0-based (0 <= row_index < nrows, 0 <= col_index < ncols).

Returns:

A subimage containing the grid section. Includes only

pixels and objects belonging to this section. Pixel coordinates in the returned image are relative to the section’s top-left corner. Object labels are preserved for objects in this section; objects from other sections have their labels removed (set to 0). The subimage is marked with IMAGE_TYPE=GRID_SECTION metadata. If no objects are present in the parent image, returns a copy of the entire parent image.

Return type:

phenotypic.Image

Raises:

IndexError – If idx is out of bounds for the grid dimensions, or if idx is a tuple with length != 2.

Examples

Extract grid sections by flattened or (row, col) indexing
# Extract top-left grid section (row 0, col 0)
top_left = grid_image.grid[0]
print(f"Section size: {top_left.shape}")

# Extract center section for an 8x12 grid (row 4, col 6)
# Using flattened index
center_idx = 4 * 12 + 6  # = 54
center_section = grid_image.grid[center_idx]

# The same section accessed using (row, col) indexing
center_section_2 = grid_image.grid[4, 6]

# Process colonies in top row (row 0, columns 0-11)
for col in range(grid_image.grid.ncols):
    # Access by (row, col) index
    section = grid_image.grid[0, col]
    analyze_colony(section)
__len__() int

Returns the length of the subject array.

This method calculates and returns the total number of elements contained in the underlying array.

Returns:

The number of elements in the underlying array attribute.

Return type:

int

copy() numpy.ndarray
Return type:

numpy.ndarray

foreground()

Extracts and returns the foreground of the image by masking out the background.

This method generates a foreground image by applying the object mask stored in the Image to the current array representation. Pixels outside the object mask are set to zero in the resulting foreground image. This is useful in image processing tasks to isolate the region of interest in the image, such as microbe colonies on an agar plate.

Returns:

A numpy array containing only the foreground portion of the image, with all non-foreground pixels set to zero.

Return type:

numpy.ndarray

get_centroid_alignment_info(axis: int) tuple[numpy.ndarray, numpy.ndarray][source]

Calculate linear regression fit for colony centroids along a grid axis.

Computes the slope and intercept of a best-fit line through the centroids of colonies arranged along a specified axis (rows or columns). This quantifies alignment quality and any systematic drift in the pinned colony array. Uses standard least-squares linear regression to fit the line: y = m*x + b.

For row-wise analysis (axis=0), the function groups colonies by their row index and fits a line to the relationship between column position and column coordinate. For column-wise analysis (axis=1), it groups by column index and fits a line to the relationship between row position and row coordinate.

Parameters:

axis (int) –

Axis along which to compute alignment: - 0: Row-wise alignment. For each row, measures how colony centers

vary along the column (CC) axis as a function of their grid column position. Slope indicates pixels of drift per grid column.

  • 1: Column-wise alignment. For each column, measures how colony centers vary along the row (RR) axis as a function of their grid row position. Slope indicates pixels of drift per grid row.

Returns:

A tuple containing:
  • m_slope (np.ndarray[float]): Slopes for each row or column. Length is nrows if axis=0, ncols if axis=1. Values represent pixels of drift per grid position unit. NaN indicates no colonies in that row/column, 0 indicates single colony with no drift measurable.

  • b_intercept (np.ndarray): Y-intercepts for each row/column, rounded to nearest integer. NaN indicates no colonies in that row/column.

Return type:

tuple[np.ndarray, np.ndarray]

Raises:
  • NoObjectsError – If the parent image contains no detected objects (colonies).

  • ValueError – If axis is neither 0 nor 1.

Examples

Analyze colony alignment across grid axes
# Check row alignment (horizontal drift of colonies across each row)
row_slopes, row_intercepts = grid_image.grid.get_centroid_alignment_info(axis=0)
print(f"Row alignment slopes (pixels/column): {row_slopes}")

# Check column alignment (vertical drift of colonies across each column)
col_slopes, col_intercepts = grid_image.grid.get_centroid_alignment_info(axis=1)
print(f"Column alignment slopes (pixels/row): {col_slopes}")

# Identify rows with significant drift indicating pinning issues
drift_threshold = 0.05  # pixels per grid position
problematic_rows = np.where(np.abs(row_slopes) > drift_threshold)[0]
print(f"Rows with significant drift: {problematic_rows}")
get_col_edges() numpy.ndarray[source]

Get the column boundary positions in pixel coordinates.

Returns the x-coordinates (column indices) that define the vertical boundaries of each grid column in the image. For an ncols-column grid, returns ncols+1 boundary values: the left edge of column 0, internal boundaries between adjacent columns, and the right edge of column ncols-1.

Returns:

1D array of strictly increasing column edge positions (pixel

column indices). Length is ncols+1. First value is 0 or the left edge of the first column, last value is the image width or right boundary.

Return type:

np.ndarray

Examples

Retrieve and use column edge positions
col_edges = grid_image.grid.get_col_edges()
print(f"Column edges: {col_edges}")
# Output: [0.0, 106.5, 213.0, 319.5, ...]  for a 12-column grid

# Calculate column width
col_width = col_edges[1] - col_edges[0]
print(f"Column width: {col_width} pixels")

# Extract pixels for column 3
col_3_min, col_3_max = int(col_edges[3]), int(col_edges[4])
column_3_data = grid_image.gray[:, col_3_min:col_3_max]

# Visualize grid column positions
fig, ax = plt.subplots()
ax.imshow(grid_image.gray)
ax.vlines(x=col_edges, ymin=0, ymax=grid_image.shape[0], colors='cyan')
get_col_map() numpy.ndarray[source]

Get an object map with objects labeled by their grid column number.

Creates a copy of the object map where each detected colony is relabeled according to its grid column assignment. All pixels belonging to colonies in the same grid column receive the same label. This is useful for visualizing or analyzing all colonies in a particular column together.

Returns:

2D integer array with same shape as the parent image. Each

pixel belonging to a colony is set to that colony’s grid column number (1-indexed, ranging from 1 to ncols). Pixels not belonging to any colony are 0. Can be passed directly to label2rgb for visualization.

Return type:

np.ndarray

Examples

Get and visualize column-labeled colony map
col_map = grid_image.grid.get_col_map()

# All colonies in column 0 have value 1, column 1 have value 2, etc.
print(f"Unique values in col_map: {np.unique(col_map)}")
# Output: [0, 1, 2, 3, ..., 12]  for a 12-column grid

# Count total pixels belonging to each column
for col_num in range(1, grid_image.grid.ncols + 1):
    col_pixels = np.sum(col_map == col_num)
    print(f"Column {col_num}: {col_pixels} pixels")

# Visualize columns with distinct colors
from skimage.color import label2rgb
colored_columns = label2rgb(label=col_map, image=grid_image.gray[:])
plt.imshow(colored_columns)
get_info_by_section(section_number: int | tuple[int, int]) pandas.DataFrame[source]

Get grid information for colonies in a specific grid section.

Retrieves detailed colony information (bounding box coordinates, centroid, area, etc.) for all objects within a given grid section. The section can be specified either by flattened index or by (row, column) tuple. Returns an empty DataFrame if no colonies are present in the requested section.

Parameters:

section_number (int | tuple[int, int]) –

Grid section identifier: - If int: flattened section index (0 to nrows*ncols-1) - If tuple[int, int]: (row_index, col_index) pair specifying grid

position, with both indices 0-based

Returns:

DataFrame with one row per colony in the specified section.

Contains the same columns as the info() method, including ObjectLabel, CenterRR, CenterCC, bounding box coordinates, grid position columns (RowNum, ColNum, SectionNum), and optionally metadata columns. Returns empty DataFrame if section contains no colonies.

Return type:

pd.DataFrame

Raises:

ValueError – If section_number is neither an int nor a 2-tuple.

Examples

Retrieve colony information for specific grid sections
# Get colonies using flattened index (section 25)
section_info = grid_image.grid.get_info_by_section(25)
print(f"Colonies in section 25: {len(section_info)}")

# Get colonies using (row, column) notation
# Get colonies in grid position (row=2, col=5)
section_info = grid_image.grid.get_info_by_section((2, 5))

if len(section_info) > 0:
    # Analyze properties of colonies in this section
    colony = section_info.iloc[0]
    print(f"Colony area: {colony['Area']} pixels")
    print(f"Colony center: ({colony['CenterRR']}, {colony['CenterCC']})")
else:
    print("No colony detected in this section")

# Find largest colony in section 10
section_10 = grid_image.grid.get_info_by_section(10)
if len(section_10) > 0:
    largest = section_10.loc[section_10['Area'].idxmax()]
    print(f"Largest colony: label={largest.name}, area={largest['Area']}")
get_row_edges() numpy.ndarray[source]

Get the row boundary positions in pixel coordinates.

Returns the y-coordinates (row indices) that define the horizontal boundaries of each grid row in the image. For an nrows-row grid, returns nrows+1 boundary values: the top edge of row 0, internal boundaries between adjacent rows, and the bottom edge of row nrows-1.

Returns:

1D array of strictly increasing row edge positions (pixel

row indices). Length is nrows+1. First value is 0 or the top edge of the first row, last value is the image height or bottom boundary.

Return type:

np.ndarray

Examples

Retrieve and use row edge positions
row_edges = grid_image.grid.get_row_edges()
print(f"Row edges: {row_edges}")
# Output: [0.0, 95.2, 190.4, 285.6, ...]  for an 8-row grid

# Calculate row height
row_height = row_edges[1] - row_edges[0]
print(f"Row height: {row_height} pixels")

# Extract pixels for row 4
row_4_min, row_4_max = int(row_edges[4]), int(row_edges[5])
row_4_data = grid_image.gray[row_4_min:row_4_max, :]

# Visualize grid row positions
fig, ax = plt.subplots()
ax.imshow(grid_image.gray)
ax.hlines(y=row_edges, xmin=0, xmax=grid_image.shape[1], colors='cyan')
get_row_map() numpy.ndarray[source]

Get an object map with objects labeled by their grid row number.

Creates a copy of the object map where each detected colony is relabeled according to its grid row assignment. All pixels belonging to colonies in the same grid row receive the same label. This is useful for visualizing or analyzing all colonies in a particular row together.

Returns:

2D integer array with same shape as the parent image. Each

pixel belonging to a colony is set to that colony’s grid row number (1-indexed, ranging from 1 to nrows). Pixels not belonging to any colony are 0. Can be passed directly to label2rgb for visualization.

Return type:

np.ndarray

Examples

Get and visualize row-labeled colony map
row_map = grid_image.grid.get_row_map()

# All colonies in row 0 have value 1, row 1 have value 2, etc.
print(f"Unique values in row_map: {np.unique(row_map)}")
# Output: [0, 1, 2, 3, ..., 8]  for an 8-row grid

# Count total pixels belonging to each row
for row_num in range(1, grid_image.grid.nrows + 1):
    row_pixels = np.sum(row_map == row_num)
    print(f"Row {row_num}: {row_pixels} pixels")

# Visualize rows with distinct colors
from skimage.color import label2rgb
colored_rows = label2rgb(label=row_map, image=grid_image.gray[:])
plt.imshow(colored_rows)
get_section_counts(ascending: bool = False) pandas.Series[source]

Count the number of objects (colonies) in each grid section.

Returns a Series showing how many colonies were detected in each grid section, sorted by count. Useful for quality control to identify problematic sections with unexpected colony counts (e.g., empty sections, multiple colonies in single pinned location, indicating pinning errors or detection artifacts).

Parameters:

ascending (bool, optional) – If False (default), sort counts in descending order (sections with most colonies first). If True, sort ascending (fewest colonies first, useful for identifying empty sections). Defaults to False.

Returns:

A pandas Series where:
  • Index: Grid section number (0 to nrows*ncols-1), unsorted sections (those with no colonies) are not included

  • Values: Count of colonies in that section

  • Index name: GRID.SECTION_NUM constant

Return type:

pd.Series

Examples

Count and analyze colonies per grid section
section_counts = grid_image.grid.get_section_counts()

# Find sections with multiple colonies (potential pinning errors)
problem_sections = section_counts[section_counts > 1]
print(f"Sections with multiple colonies: {problem_sections}")
# Output:
# SectionNum
# 5      2
# 12     3
# dtype: int64

# Find empty sections (no colony detected)
expected_sections = set(range(grid_image.grid.nrows * grid_image.grid.ncols))
detected_sections = set(section_counts.index)
empty_sections = expected_sections - detected_sections
print(f"Empty sections: {empty_sections}")

# Statistics on detection completeness
num_expected = grid_image.grid.nrows * grid_image.grid.ncols
num_detected = len(section_counts)
completeness = 100 * num_detected / num_expected
print(f"Array completeness: {completeness:.1f}%")
get_section_map() numpy.ndarray[source]

Get an object map with objects labeled by their grid section number.

Creates a copy of the object map where each detected colony is relabeled according to its grid section assignment (flattened grid index). Section numbering is 0-indexed, ordered left-to-right, top-to-bottom (row-major).

Returns:

2D integer array with same shape as the parent image. Each

pixel belonging to a colony is set to that colony’s grid section number (0-indexed, ranging from 0 to nrows*ncols-1). Pixels not belonging to any colony are 0. Can be passed directly to label2rgb for visualization.

Return type:

np.ndarray

Examples

Get and visualize section-labeled colony map
section_map = grid_image.grid.get_section_map()

# For an 8x12 grid:
# Section 0: top-left (row 0, col 0)
# Section 11: top-right (row 0, col 11)
# Section 84: bottom-left (row 7, col 0)
# Section 95: bottom-right (row 7, col 11)

# Identify empty sections
empty_sections = []
for section_num in range(grid_image.grid.nrows * grid_image.grid.ncols):
    if np.sum(section_map == section_num) == 0:
        empty_sections.append(section_num)
print(f"Empty sections: {empty_sections}")

# Visualize section distribution
from skimage.color import label2rgb
colored_sections = label2rgb(label=section_map, image=grid_image.gray[:])
plt.imshow(colored_sections)
histogram(figsize: Tuple[int, int] = (10, 5), *, cmap='gray', linewidth=1, channel_names: list | None = None) Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]

Plots the histogram(s) of an image along with the image itself. The behavior depends on the dimensionality of the image array (2D or 3D). In the case of 2D, a single image and its histogram are produced. For 3D (multi-channel images), histograms for each channel are created alongside the image. This method supports customization such as figure size, colormap, line width of histograms, and labeling of channels.

Parameters:
  • figsize (Tuple[int, int]) – The size of the figure to create. Default is (10, 5).

  • cmap (str) – Colormap used to render the image when the data is single channel. Default is ‘gray’.

  • linewidth (int) – Line width of the plotted histograms. Default is 1.

  • channel_names (list | None) – Optional names for the channels in 3D data. These are used as titles for channel-specific histograms. If None, channels are instead labeled numerically.

Returns:

The Matplotlib figure and axes objects representing the plotted image and its histograms.

Return type:

Tuple[plt.Figure, plt.Axes]

Raises:

ValueError – If the dimensionality of the input image array is unsupported.

Notes

This method uses skimage.exposure.histogram for computing the histogram data.

imsave(filepath: str | Path | None = None) None

Save the image array to a file with PhenoTypic metadata embedded.

Metadata is embedded in format-specific locations: - JPEG: EXIF UserComment tag - PNG: tEXt chunk with key ‘phenotypic’ - TIFF: ImageDescription tag (270)

Parameters:

filepath (str | Path | None) – Path to save the image file. Extension determines format.

Raises:

ValueError – If file extension is not supported.

Return type:

None

info(include_metadata=True) pandas.DataFrame[source]

Get grid information for all detected colonies.

Returns a DataFrame with bounding box measurements and grid location (row, column, section) assignments for each detected object (colony). This is the primary method for accessing detailed colony positioning and measurement data.

Parameters:

include_metadata (bool, optional) – Whether to include image metadata columns in the output DataFrame. Defaults to True.

Returns:

DataFrame with one row per detected colony. Columns include:
  • ObjectLabel: Unique identifier for the colony

  • CenterRR, CenterCC: Row and column coordinates of colony center

  • MinRR, MaxRR, MinCC, MaxCC: Bounding box coordinates

  • RowNum: Grid row index (0-indexed)

  • ColNum: Grid column index (0-indexed)

  • SectionNum: Flattened grid section index (0 to nrows*ncols-1)

  • Additional columns if include_metadata=True

Return type:

pd.DataFrame

Examples

Retrieve and analyze grid information
# Get full grid information
grid_info = grid_image.grid.info()

# Count colonies by row
colonies_per_row = grid_info.groupby('RowNum').size()

# Find largest colony in grid section 10
section_10 = grid_info[grid_info['SectionNum'] == 10]
largest = section_10.loc[section_10['Area'].idxmax()]

# Get colonies without metadata
grid_info_minimal = grid_image.grid.info(include_metadata=False)
isempty()
classmethod load(filepath: str | Path) numpy.ndarray

Load an image array from file and verify it was saved from this accessor type.

Checks if the image contains PhenoTypic metadata indicating it was saved from the same accessor type (e.g., Image.gray, Image.rgb). If metadata doesn’t match or is missing, a warning is raised but the array is still loaded.

Parameters:

filepath (str | Path) – Path to the image file to load.

Returns:

The loaded image array.

Return type:

np.ndarray

Warns:

UserWarning – If metadata is missing or indicates the image was saved from a different accessor type.

Examples

Load a grayscale image from file
>>> from phenotypic.core._image_parts.accessors import Grayscale
>>> arr = Grayscale.load("my_gray_image.png")
show_column_overlay(use_enhanced: bool = False, show_gridlines: bool = True, ax: plt.Axes | None = None, figsize: tuple[int, int] = (9, 10)) tuple[plt.Figure, plt.Axes][source]

Visualize colonies with column-based color coding and optional grid overlay.

Displays the image with an overlay where each colony is colored according to its grid column assignment. This helps visualize the column structure of the pinned array and identify any column-wise positioning issues or misalignment.

Parameters:
  • use_enhanced (bool, optional) – If True, use the enhanced grayscale version of the parent image (enh_gray) for better contrast and visibility. If False, use the standard grayscale image (gray). Defaults to False.

  • show_gridlines (bool, optional) – If True, overlay cyan dashed vertical lines marking the column boundaries and horizontal lines for row boundaries. Defaults to True.

  • ax (plt.Axes | None, optional) – Existing Matplotlib Axes object to plot into. If None, a new figure and axes are created with the specified figsize. Defaults to None.

  • figsize (tuple[int, int], optional) – Figure size as (width, height) in inches, only used when ax is None. Defaults to (9, 10).

Returns:

A tuple containing the Matplotlib Figure and

Axes objects. If ax was provided as input, the function returns the created figure and the input ax object (not func_ax). If ax is None, returns the newly created figure and axes.

Return type:

tuple[plt.Figure, plt.Axes]

Examples

Display column overlay visualization with options
# Display column overlay with gridlines
fig, ax = grid_image.grid.show_column_overlay(show_gridlines=True)
plt.title("Colony Array - Column Overlay")
plt.show()

# Use enhanced image for better contrast
fig, ax = grid_image.grid.show_column_overlay(
    use_enhanced=True,
    show_gridlines=True,
    figsize=(12, 14)
)

# Plot on existing axes
fig, axes = plt.subplots(1, 2, figsize=(16, 10))
grid_image.grid.show_column_overlay(ax=axes[0])
grid_image.grid.show_row_overlay(ax=axes[1])
show_overlay(object_label: int | None = None, figsize: tuple[int, int] | None = None, title: str | None = None, show_labels: bool = False, ax: matplotlib.axes.Axes | None = None, *, label_settings: dict | None = None, overlay_settings: dict | None = None, imshow_settings: dict | None = None) tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]

Displays an overlay of the object map on the parent image with optional annotations.

This method enables visualization by overlaying object regions on the parent image. It

provides options for customization, including the ability to show_labels specific objects

and adjust visual styles like figure size, colors, and annotation properties.

Parameters:
  • object_label (None | int) – Specific object label to be highlighted. If None, all objects are displayed.

  • figsize (tuple[int, int]) – Size of the figure in inches (width, height).

  • title (None | str) – Title for the plot. If None, the parent image’s name is used.

  • show_labels (bool) – If True, displays annotations for object labels on the object centroids.

  • label_settings (None | dict) – Additional parameters for customization of the object annotations. Defaults: size=12, color=’white’, facecolor=’red’. Other kwargs are passed to the matplotlib.axes.text () method.

  • ax (plt.Axes) – Optional Matplotlib Axes object. If None, a new Axes is created.

  • overlay_settings (None | dict) – Additional parameters for customization of the overlay.

  • imshow_settings (None|dict) – Additional Matplotlib imshow configuration parameters for customization. If None, default Matplotlib settings will apply.

Returns:

Matplotlib Figure and Axes objects containing the generated plot.

Return type:

tuple[plt.Figure, plt.Axes]

show_row_overlay(use_enhanced: bool = False, show_gridlines: bool = True, ax: plt.Axes | None = None, figsize: tuple[int, int] = (9, 10)) tuple[plt.Figure, plt.Axes][source]

Visualize colonies with row-based color coding and optional grid overlay.

Displays the image with an overlay where each colony is colored according to its grid row assignment. This helps visualize the row structure of the pinned array and identify any row-wise positioning issues or misalignment.

Parameters:
  • use_enhanced (bool, optional) – If True, use the enhanced grayscale version of the parent image (enh_gray) for better contrast and visibility. If False, use the standard grayscale image (gray). Defaults to False.

  • show_gridlines (bool, optional) – If True, overlay cyan dashed horizontal lines marking the row boundaries and vertical lines for column boundaries. Defaults to True.

  • ax (plt.Axes | None, optional) – Existing Matplotlib Axes object to plot into. If None, a new figure and axes are created with the specified figsize. Defaults to None.

  • figsize (tuple[int, int], optional) – Figure size as (width, height) in inches, only used when ax is None. Defaults to (9, 10).

Returns:

A tuple containing the Matplotlib Figure and

Axes objects. If ax is None, returns the created figure and axes. If ax is provided, returns the created figure and the input ax object.

Return type:

tuple[plt.Figure, plt.Axes]

Examples

Display row overlay visualization with options
# Display row overlay with gridlines
fig, ax = grid_image.grid.show_row_overlay(show_gridlines=True)
plt.title("Colony Array - Row Overlay")
plt.show()

# Use enhanced image for better contrast
fig, ax = grid_image.grid.show_row_overlay(
    use_enhanced=True,
    show_gridlines=True,
    figsize=(12, 14)
)

# Create side-by-side comparison
fig, axes = plt.subplots(1, 2, figsize=(16, 10))
grid_image.grid.show_column_overlay(ax=axes[0])
grid_image.grid.show_row_overlay(ax=axes[1])
plt.suptitle("Column vs Row Grid Visualization")
plt.show()
val_range() pd.Interval

Return the closed interval [min, max] of the subject array values.

Returns:

A single closed interval including both endpoints.

Return type:

pd.Interval

property dtype
property ncols: int

Get the number of columns in the grid.

Returns:

Number of columns in the grid array. Must be >= 1.

Return type:

int

property ndim: int

Returns the number of dimensions of the underlying array.

The ndim property provides access to the dimensionality of the array being encapsulated in the object. This value corresponds to the number of axes or dimensions the underlying array possesses. It can be useful for understanding the structure of the contained data.

Returns:

The number of dimensions of the underlying array.

Return type:

int

property nrows: int

Get the number of rows in the grid.

Returns:

Number of rows in the grid array. Must be >= 1.

Return type:

int

property shape: Tuple[int, ...]

Returns the shape of the current image data.

This method retrieves the dimensions of the array stored in the _main_arr attribute as a tuple, which indicates its size along each axis.

Returns:

A tuple representing the dimensions of the _main_arr attribute.

Return type:

Tuple[int, …]

property size: int

Gets the size of the subject array.

This property retrieves the total number of elements in the subject array. It is read-only.

Returns:

The total number of elements in the subject array.

Return type:

int