neu_vol.ops.write¶
Write one subvolume into an existing volume, at a voxel offset and one level.
The companion to neu_vol.ops.create: the frame exists, and each piece (an image
stack, an HDF5 dataset, a region of another volume) is placed into it. Single-scale:
only the named level is written, since a piece’s coarse representation is a separate
decision (averaging a label map invents ids); run neu-vol downsample afterwards.
Serial, in this process; no dask, no manifest.
Partial-chunk writes race. A region off the destination’s chunk grid makes tensorstore read-modify-write its boundary chunks, and two such writes into a shared chunk at once lose one update. The plan reports alignment and the CLI says so.
Tiles are cut on the global destination chunk grid (sized to the source’s read unit, as
in convert), so no two tiles share a destination chunk.
Attributes¶
Functions¶
|
Every volumetric dataset of an HDF5 container, as one source spec each. |
|
Everything |
|
The offset to write at, as |
|
A backend spec for |
|
Write |
|
Write several subvolumes into one volume. Returns one result per source. |
Module Contents¶
- neu_vol.ops.write.container_sources(src: str | Mapping[str, Any], pattern: str = '*', *, src_format: str | None = None) list[dict[str, Any]]¶
Every volumetric dataset of an HDF5 container, as one source spec each.
For a file of several pieces, each with its own
voxel_offset:write_subvolumes(volume, container_sources("gt_v1_eval_cleaned.h5"))
patternis an fnmatch glob, tried against the full path (/edge_z07801) and against the basename (edge_z07801). Datasets come back sorted. A pattern that matches nothing raises, listing what is there, rather than writing nothing.
- neu_vol.ops.write.plan_subvolume_write(volume: str, src: str | Mapping[str, Any], offset: Sequence[int] | None = None, *, level: int = 0, offset_level: int | None = None, offset_field: str = 'voxel_offset', voxel_size_field: str = 'voxel_size', offset_order: str | None = None, background: Sequence[int] | None = None, src_format: str | None = None, dataset: str | None = None, cast: bool = False, max_bytes: int = DEFAULT_TASK_BYTES) dict¶
Everything
write_subvolume()would do, resolved and checked. Writes nothing.offsetmay beNone, in which case it is read from the source — seeresolve_offset().
- neu_vol.ops.write.resolve_offset(backend, offset, *, field: str, order: str | None, ndim: int)¶
The offset to write at, as
(offset, provenance), taking it from the source if none was given.Any backend may expose
stored_offset(name)(HDF5 does), used when no offset is given.orderis the axis order of the numbers,"zyx"or"xyz":voxel_offsetis precomputed’s field name, where it means xyz, and a wrong guess mirrors the piece through the z=x diagonal.order=Nonereadsstored_axes()if the source has it (neu-vol to-hdf5records it), else assumes zyx. The provenance string says which.
- neu_vol.ops.write.source_spec(src: str | Mapping[str, Any], src_format: str | None = None, dataset: str | None = None) dict[str, Any]¶
A backend spec for
src, detecting the format when it is not given.detect_backend()thenlocation_spec(), with thedatasetof an HDF5 container threaded through. Advid://URL resolves here at level 0 with the node as given;pack_hdf5()takes its levels and read options.
- neu_vol.ops.write.write_subvolume(volume: str, src: str | Mapping[str, Any], offset: Sequence[int] | None = None, *, dry_run: bool = False, **kw: Any) dict¶
Write
srcintovolumeat voxeloffsetof one level.offset=Nonetakes it from the source when the source records one. Seeplan_subvolume_write()for the arguments and the checks. Returns the plan plus what happened.
- neu_vol.ops.write.write_subvolumes(volume: str, srcs: Sequence[Any], offsets: Sequence[Sequence[int] | None] | None = None, *, dry_run: bool = False, **kw: Any) list[dict]¶
Write several subvolumes into one volume. Returns one result per source.
Every source is planned before any is written, so a bad offset in the last file is caught while the volume is untouched. Writing then fails fast.
offsetsisNone(every source supplies its own) or one entry per source.
- neu_vol.ops.write.logger¶