cellmap_flow.finetune.session.fill

Labelling a whole box of an annotation volume at once.

The Finetune tab’s “Seed” and “All background” buttons label the box on screen in one click: from the model’s own prediction, for the user to clean up with the brush, or all background (1), for a region of false positives. Either way only unannotated voxels (0) are filled. A stroke the user painted is a decision about that voxel; a seed is a guess. paint_box is the write under both, and can also write over painted voxels, for an AI annotation the user has reviewed and chosen to keep over what is there. “Split objects” relabels the box’s foreground by connected component (relabel_objects), so a background wall painted through a merged object gives it two ids again.

The objects a seed writes come from post.segment, the segmenter that fits the model (seed_labels takes its labels). Split Objects is 6-connected by default (face neighbours, scipy’s default): a one-voxel wall the brush paints cuts an object under it, where under 26-connectivity the voxels across a diagonal wall would still touch.

The decisions (which voxels a box covers, the ids a seed or a split gives, which voxels each write changes and an undo puts back) are cellmap_flow.portable.fill’s, which the browser makes too, over its paint store; they are re-exported here, beside the reads and writes around them.

The write goes to MinIO, as cc3d_relabel’s does, not to the volume on disk: MinIO holds strokes the periodic sync has not pulled yet, which is what “only fill 0s” must see, and it is what neuroglancer reads. The caller then pulls the changed chunks to disk with sync.sync_volume, so disk and MinIO agree and the periodic sync has nothing to revert.

Attributes

logger

Functions

open_served_labels(state, volume_id)

The volume's annotation/s0 as MinIO serves it, open for writing.

paint_box(state, volume_id, lo, hi, labels_for[, ...])

Write labels_for(existing) into the box [lo, hi).

fill_unpainted(state, volume_id, lo, hi, labels_for[, ...])

Write labels_for(existing) into the box [lo, hi) where the volume holds 0.

rewrite_foreground(state, volume_id, lo, hi, relabel)

Write relabel(existing)'s labels over the box's foreground voxels.

restore_box(state, volume_id, lo, hi, before, after)

Put the box back to before where it still holds after: an undo.

Module Contents

cellmap_flow.finetune.session.fill.logger
cellmap_flow.finetune.session.fill.open_served_labels(state, volume_id)

The volume’s annotation/s0 as MinIO serves it, open for writing.

The bucket key is <volume_id>.zarr, as for the sync.

cellmap_flow.finetune.session.fill.paint_box(state, volume_id, lo, hi, labels_for, local_zarr_path=None, undo=None, overwrite=False)

Write labels_for(existing) into the box [lo, hi).

labels_for gets the box as MinIO holds it and returns labels of the same shape (0 for “leave as it is”). Without overwrite only unannotated voxels (0) are written, as for a seed: what the user painted stays. With it every voxel the labels cover is written, painted or not, for a result the user has looked at and prefers to what is there. Returns (n_foreground, n_background, n_overwritten): how many voxels were written with foreground and with background, and how many of those held a label before. Nothing is written when nothing would change. undo, a list, gets (lo, hi, before, after) appended when something was written (restore_box).

cellmap_flow.finetune.session.fill.fill_unpainted(state, volume_id, lo, hi, labels_for, local_zarr_path=None, undo=None)

Write labels_for(existing) into the box [lo, hi) where the volume holds 0.

labels_for gets the box as MinIO holds it and returns labels of the same shape (0 for “leave as it is”). Returns (n_foreground, n_background): how many voxels were filled with each. Nothing is written when nothing would change. undo, a list, gets (lo, hi, before, after) appended when something was written (restore_box).

cellmap_flow.finetune.session.fill.rewrite_foreground(state, volume_id, lo, hi, relabel, local_zarr_path=None, undo=None)

Write relabel(existing)’s labels over the box’s foreground voxels.

relabel gets the box as MinIO holds it and returns (labels, counts) (relabel_objects); only foreground voxels (2 and up) whose label changed are written, so a stroke painted meanwhile elsewhere in the box is kept. Returns (n_changed, counts). undo: as for fill_unpainted.

cellmap_flow.finetune.session.fill.restore_box(state, volume_id, lo, hi, before, after)

Put the box back to before where it still holds after: an undo.

Only voxels the action changed and nobody has touched since go back, so a stroke painted in the box after the action is kept. Returns how many voxels were restored.