cellmap_flow.ai_annotate.pipeline

From a planned plane to labels: read the raw, ask the model, label the box.

read_plane reads the plane geometry.plan_plane planned, on the image grid it planned and laid out as on screen; build_request makes it the request a backend sends; mask_to_write_shape cuts the mask the backend returns into its connected objects and puts them onto the write box’s voxels, and labels_for_box (accept_labels for Accept) turns those into the labels fill.paint_box writes: one id per object, background elsewhere, as a seed from a model’s prediction is labelled.

The maths is cellmap_flow.portable.ai_annotate’s, which the browser runs too (its resampling is Pillow’s, in both modes); what is the server’s alone is reading the raw, through worldarray (cellmap_flow.io.raw).

Functions

raw_extent_nm(volume)

(lo, hi), world nm z, y, x: where the volume's raw data is, read at

read_plane(volume, plan) → numpy.ndarray

The raw plane plan reads, as a 2D array of plan.image_shape,

build_request(plane, plan, profile[, prompt_override])

The SegmentRequest for plane: its RGB image, the prompt and the colour.

Module Contents

cellmap_flow.ai_annotate.pipeline.raw_extent_nm(volume: dict)

(lo, hi), world nm z, y, x: where the volume’s raw data is, read at its input voxel size (plan_plane’s data_box_nm).

cellmap_flow.ai_annotate.pipeline.read_plane(volume: dict, plan: cellmap_flow.ai_annotate.geometry.PlanePlan) → numpy.ndarray

The raw plane plan reads, as a 2D array of plan.image_shape, laid out as on screen (portable.ai_annotate.plane_image).

Read as stored (no input normalization: the image is scaled to 8 bits for the model on its own) at the plan’s input voxel size, from the level of the volume’s raw dataset for it, resampled when the volume was made with Resample on, as its trainer reads it. Outside the raw the read is padded with 0. The raw’s dtype is kept unless the plane had to be resized to the image’s grid, when it is float32.

cellmap_flow.ai_annotate.pipeline.build_request(plane: numpy.ndarray, plan: cellmap_flow.ai_annotate.geometry.PlanePlan, profile, prompt_override=None)

The SegmentRequest for plane: its RGB image, the prompt and the colour.

The prompt states plan.resolution_nm, the pixel size of the image actually sent. prompt_override replaces the catalog’s description (prompts.build_recolor_prompt).