cellmap_flow.finetune.session.manifest

The files a session is trained from, besides the volume itself.

_virtual_sources.json in corrections/ points the trainer at the annotation volume and carries the patch geometry and normalization; good_regions.json, one level up, lists the regions the user marked as already right. has_painted_annotations says whether a volume holds scribbles as well as imported crops; read_chunk reads one chunk of the volume’s annotation/s0 for it, for the sampler and for the ranking.

Attributes

logger

VIRTUAL_MANIFEST_FILENAME

GOOD_REGIONS_FILENAME

Functions

write_manifest(corrections_dir, manifest) → str

Persist a manifest sentinel that create_dataloader looks for.

read_manifest(corrections_dir) → Optional[dict]

Return the manifest if present, else None.

remove_manifest(corrections_dir) → bool

Remove the session's manifest from corrections_dir; whether there was one.

trained_volume_name(corrections_dir) → Optional[str]

The directory name (<id>.zarr) of the volume the session in

good_regions_path(corrections_dir) → Optional[str]

Where the good regions of the session owning corrections_dir live:

load_good_regions(path) → list

The regions stored at path; [] when there are none or they can't be read.

save_good_regions(path, regions) → bool

Replace the regions at path atomically; False if it could not be written.

load_good_regions_for(corrections_dir) → list

Read the session's good regions, if any were marked.

voxels_inside_any_bbox(voxels, bbox_offsets, bbox_ends) → numpy.ndarray

Return a boolean mask: True where voxels[i] lies inside any

read_chunk(array, index) → numpy.ndarray

Chunk index of array, cut short at the array's end as the

has_painted_annotations(volume_zarr_path) → bool

Whether the volume holds annotations outside its imported crops.

Module Contents

cellmap_flow.finetune.session.manifest.logger
cellmap_flow.finetune.session.manifest.VIRTUAL_MANIFEST_FILENAME = '_virtual_sources.json'
cellmap_flow.finetune.session.manifest.GOOD_REGIONS_FILENAME = 'good_regions.json'
cellmap_flow.finetune.session.manifest.write_manifest(corrections_dir: str, manifest: dict) → str

Persist a manifest sentinel that create_dataloader looks for.

cellmap_flow.finetune.session.manifest.read_manifest(corrections_dir: str) → dict | None

Return the manifest if present, else None.

cellmap_flow.finetune.session.manifest.remove_manifest(corrections_dir: str) → bool

Remove the session’s manifest from corrections_dir; whether there was one.

For a session whose volume is now one no manifest can name (a volume painted before any model): a manifest left naming the volume before it would keep that one the session’s (trained_volume_name), and Rank, Seed and Use this model would read the old paint while the user paints the new volume. The manifest is derived (write_volume_manifest builds it again from a volume record), and the volume it named stays where it is.

cellmap_flow.finetune.session.manifest.trained_volume_name(corrections_dir) → str | None

The directory name (<id>.zarr) of the volume the session in corrections_dir trains on, its manifest’s volume_zarr_path: the session’s current volume, which every route and both modes mean by “the session’s volume”. None without a manifest, or one that names none or cannot be read.

By name, not by path: a resumed session’s manifest names its own copy, and the corrections dir may be spelled another way (a symlink, a trailing slash) by whoever asks.

cellmap_flow.finetune.session.manifest.good_regions_path(corrections_dir: str | None) → str | None

Where the good regions of the session owning corrections_dir live: beside it, in the session directory. None without a corrections dir.

cellmap_flow.finetune.session.manifest.load_good_regions(path: str | None) → list

The regions stored at path; [] when there are none or they can’t be read.

cellmap_flow.finetune.session.manifest.save_good_regions(path: str, regions: list) → bool

Replace the regions at path atomically; False if it could not be written.

cellmap_flow.finetune.session.manifest.load_good_regions_for(corrections_dir: str | None) → list

Read the session’s good regions, if any were marked.

Deliberately read here rather than snapshotted into the manifest: the manifest is written when crops are imported, and regions get marked afterwards, for as long as the user keeps browsing. Reading at training time means the run uses every region marked up to the moment it started.

cellmap_flow.finetune.session.manifest.voxels_inside_any_bbox(voxels: numpy.ndarray, bbox_offsets: numpy.ndarray, bbox_ends: numpy.ndarray) → numpy.ndarray

Return a boolean mask: True where voxels[i] lies inside any [bbox_offsets[j], bbox_ends[j]) half-open box.

voxels: (N, 3) int. bbox_offsets, bbox_ends: (M, 3) int. Vectorized over both: builds an (N, M) inside-test matrix and reduces along M. For typical M ~ 1-10 the temporary stays small.

cellmap_flow.finetune.session.manifest.read_chunk(array: worldarray.WorldArray, index) → numpy.ndarray

Chunk index of array, cut short at the array’s end as the stored chunk is.

cellmap_flow.finetune.session.manifest.has_painted_annotations(volume_zarr_path: str) → bool

Whether the volume holds annotations outside its imported crops.

Those are painted: scribbles, sparse by construction, with unannotated voxels all around them. Chunks entirely inside a crop are not read.