neu_vol.ops.rebuild

Regenerate a multiscale pyramid in place, from a level you trust.

When the coarse end of a pyramid is wrong — blank, aliased, or built from a bad intermediate — the fix is to re-derive it, not to reconvert. Downsampling is cascaded (level N is built from level N-1, not from level 0), so a single bad level poisons everything above it and re-deriving must start at or below the lowest good one.

rebuild_pyramid(“s3://bucket/prefix/volume”, start_level=2, kind=”image”)

Levels at or below start_level are never opened for writing. Everything above is rebuilt with the original factors, since the schedule is recomputed from level 0.

Attributes

Functions

rebuild_pyramid(dst, *, start_level[, kind, profile, ...]) → dict

Rebuild levels start_level+1 … of the volume at dst, in place.

resolve_max_levels(recorded) → tuple[int, str]

The level cap for a rebuild, and why — from the volume where it says anything.

Module Contents

neu_vol.ops.rebuild.rebuild_pyramid(dst: str, *, start_level: int, kind: str | None = None, profile: str | None = None, voxel_size: Sequence[float] | None = None, factors: Sequence[Sequence[int]] | None = None, max_levels: int | None = None, min_dim: int = 128, chunk: Sequence[int] | None = None, shard: Sequence[int] | None = None, encoding: str | None = None, name: str = 'image', client: Any | None = None, npartitions: int | None = None, resume: bool = False, verify: bool = False, sparse: bool = False, progress_path: str | None = None, validate: bool = True) → dict

Rebuild levels start_level+1 … of the volume at dst, in place.

start_level is the level to derive from — it is read, never written. 0 is valid and is the ordinary case: rebuild the whole pyramid from full resolution.

kind picks the reducer: "image" is a mask-weighted mean (anti-aliased), "segmentation" a label-preserving mode. It defaults to whatever the volume already records (precomputed info["type"], OME multiscales type), since averaging label ids invents ids. If the volume records nothing usable, pass it.

Metadata (shape, voxel size, offset, axes) comes from the existing volume. voxel_size overrides it, for a volume whose recorded scale is itself the thing that was wrong.

The progress manifest defaults to a name distinct from a conversion’s, which would mark the levels being rebuilt as already done.

neu_vol.ops.rebuild.resolve_max_levels(recorded: Sequence[Any] | None) → tuple[int, str]

The level cap for a rebuild, and why — from the volume where it says anything.

A pyramid’s depth is the volume’s own, so a rebuild matches it; a conversion’s default would leave the top levels of a deeper pyramid untouched. A volume recording one level or none has no pyramid to match (write and relabel tell you to run downsample to build one), so it gets the conversion default.

neu_vol.ops.rebuild.logger