Input and output

Image volumes and their GPU read path (GPUDirect Storage), the zarr-vectors point-cloud and results stores, and CCPi / iDVC file formats. See Image volumes, Search-point store, Results store and CCPi and iDVC file compatibility.

zvdvc.io.volume

Dense image volumes (reference and deformed), read one brick at a time.

A brick is the box a tile needs: the tile’s points plus the halo (zvdvc.config.RunConfig.halo()). The deformed brick is shifted by the tile’s median seed displacement, so a large rigid offset does not inflate the halo. Bricks land on the device in their native dtype (u8/u16/f32). Kernels convert in registers, which keeps a u16 brick at half the size of a float32 one and halves the host-to-device copy.

Sources

ZarrVolume

OME-Zarr v3 array. Recommended layout: 128^3 chunks inside shards aligned to cluster.tile_shape, so a brick read touches a handful of shards. Device path, in order of preference:

  1. kvikio / GPUDirect Storage for local NVMe ([gpu-io] extra);

  2. zarr-python’s GPU buffer mode (zarr.config.enable_gpu()) where the codec pipeline supports it;

  3. host decode into pinned memory, then one host-to-device copy per brick on the worker’s prefetch stream.

Implemented today: path 3. The brick is decoded on the host (zarr-python reads the shards’ chunks concurrently) into a pinned buffer and copied up in one transfer on the caller’s stream. Paths 1 and 2 are optimisations to measure against it (docs/MVP_PLAN.md, risk “GPU zstd decode”).

RawVolume

CCPi/iDVC flat inputs (.raw with header/endianness, .mhd, .npy) through numpy.memmap. Used for development and the parity case. Large inputs should be converted once with convert_to_ome_zarr().

Boxes that extend past the volume are edge-padded. Brick records the valid part, so the solver flags points whose samples leave it as RANGE_FAIL instead of correlating them against padding.

Every source reads bricks in the host’s byte order, so a big-endian file reaches the engines as native data, and .dtype is that native type. Float bricks are checked for NaN/inf as they are read (a brick with any is an error): at open time the check would read the whole volume, which for 100 GB+ inputs costs as much as the run’s own reads, while per brick it is one pass over data already in memory. A NaN would otherwise spread through the interpolation to every point whose subvolume touches it.

class zvdvc.io.volume.Brick(data: 'Any', box: 'Box', valid: 'Box', io: 'str' = 'host')[source]

Bases: object

Parameters:
data: Any
box: Box
valid: Box
io: str = 'host'
property origin_xyz: tuple[float, float, float]

Point-space coordinate of data[0, 0, 0].

property valid_lo_hi_xyz: tuple[tuple[int, int, int], tuple[int, int, int]]

valid as a half-open voxel range in point order, for zvdvc.kernels.interpolate.sample().

class zvdvc.io.volume.VolumeSource(*args, **kwargs)[source]

Bases: Protocol

shape: tuple[int, int, int]
dtype: dtype
read_brick(box, *, device='cuda', stream=None)[source]
Parameters:
Return type:

Brick

zvdvc.io.volume.native(dtype)[source]

dtype in the host’s byte order.

Parameters:

dtype (Any)

Return type:

dtype

zvdvc.io.volume.padded_empty(shape, dtype, xp=<module 'numpy' from '/home/docs/checkouts/zvdvc/envs/latest/lib/python3.11/site-packages/numpy/__init__.py'>, pad_bytes=16)[source]

An uninitialised C-contiguous array at the start of a fresh allocation, with pad_bytes after it.

Fresh allocations are at least 16-byte aligned (cupy: 256), as the u8 kernel’s word loads need.

Parameters:
Return type:

Any

zvdvc.io.volume.is_padded(a, pad_bytes=16)[source]

True for a C-contiguous cupy array, 16-byte aligned, with pad_bytes of its allocation after it.

Parameters:
Return type:

bool

zvdvc.io.volume.to_device(data, *, stream=None)[source]

Host array -> device (padded, see PAD_BYTES), staged through pinned memory as one DMA on stream.

Parameters:
Return type:

Any

class zvdvc.io.volume.ZarrVolume(uri, array_path='0', *, check_chunks=True, gpu_io='auto')[source]

Bases: object

An OME-Zarr level (or bare Zarr array). Opening checks that every chunk is stored (check_chunks).

Parameters:
read_brick(box, *, device='cuda', stream=None)[source]
Parameters:
Return type:

Brick

class zvdvc.io.volume.RawVolume(path, *, shape_xyz=None, dtype=None, header_bytes=0, gpu_io='auto')[source]

Bases: object

Parameters:
read_brick(box, *, device='cuda', stream=None)[source]
Parameters:
Return type:

Brick

zvdvc.io.volume.is_zarr_uri(uri)[source]
Parameters:

uri (str | Path)

Return type:

bool

zvdvc.io.volume.open_volume(spec, which)[source]

Pick ZarrVolume or RawVolume from the URI; wrapped in FilteredVolume if prefilter_sigma.

Parameters:
Return type:

VolumeSource

class zvdvc.io.volume.FilteredVolume(inner, sigma)[source]

Bases: object

A volume seen through a Gaussian low-pass of sigma voxels.

Each brick is read with a margin of the kernel’s radius, filtered and cropped, so a brick equals the same box of the filtered whole volume: tiles meet without seams, and the in-memory and tiled runs see the same data. Outside the volume, voxels are edge-padded before filtering, as read_brick pads. Filtering runs on the GPU when cupy has a device (in z-slabs, so a host brick of any size fits), else on the host. The result keeps the volume’s dtype (rounded to the nearest level), so bricks cost the same memory and u8 volumes keep the kernels’ packed loads.

Parameters:
  • inner (Any)

  • sigma (float)

SLAB = 64
read_brick(box, *, device='cuda', stream=None)[source]
Parameters:
Return type:

Brick

zvdvc.io.volume.gaussian_filtered(data, sigma, dtype, slab=64)[source]

data filtered with a Gaussian of sigma voxels (radius 4 sigma), as dtype, on data’s device.

Host data is filtered slab by slab on the GPU when one is available.

Parameters:
Return type:

Any

zvdvc.io.volume.iter_blocks(shape_zyx, block)[source]

Boxes of at most block tiling shape_zyx in C order.

Parameters:
Return type:

Iterator[Box]

zvdvc.io.volume.create_ome_zarr(path, shape_zyx, dtype, *, chunk=128, shard=1024, codec='zstd', level=3, name=None, overwrite=False)[source]

Create an OME-Zarr v0.5 (Zarr v3) image with one sharded level "0"; returns that array.

Shards are rounded up to a multiple of the chunk and never exceed what the volume needs, so small test volumes get one shard. Every chunk is stored, even an empty one, so a missing chunk means an incomplete array (ZarrVolume warns about those). An existing path is an error unless overwrite, and even then only an existing Zarr store is replaced.

Parameters:
Return type:

Any

zvdvc.io.volume.write_raw(source, path, *, slab=64)[source]

Stream a volume to a headerless little-endian .raw file (x fastest), as CCPi reads it.

Parameters:
Return type:

None

zvdvc.io.volume.convert_to_ome_zarr(src, dst, *, chunk=128, shard=1024, codec='zstd', level=3, shape_xyz=None, dtype=None, header_bytes=0, overwrite=False)[source]

One-off conversion of raw/mhd/npy/tiff input to sharded OME-Zarr v3.

Streams slabs of shard slices so memory stays bounded for 100 GB+ inputs (each slab is written as whole shards). .raw needs shape_xyz and dtype; .tif/.tiff stacks need tifffile (zvdvc[tiff]). The output is written next to dst and renamed into place at the end, so an interrupted conversion leaves no partial dst. An existing dst is an error unless overwrite; dst may not be src or contain it, or lie inside it.

Parameters:
Return type:

None

zvdvc.io.gds

Volume bricks read from local files straight into GPU memory (GPUDirect Storage).

Read paths, chosen by volumes.gpu_io ($ZVDVC_GPU_IO overrides auto):

host

Decode on the host into pinned memory, then one copy to the device (zvdvc.io.volume.to_device()). What every earlier measurement used.

kvikio

kvikio reads the stored bytes into device memory, and zstd chunks are decompressed on the GPU by nvCOMP. kvikio goes through cuFile, which uses GPUDirect Storage (NVMe to GPU, no host copy) where the system supports it and a POSIX bounce buffer otherwise, so this path works, and gives the same bytes, on any machine with kvikio installed.

auto

kvikio when GPUDirect Storage is actually available, host otherwise.

“Available” is cuFile’s own verdict, kvikio.cufile_driver.properties.is_gds_available: it needs the nvidia-fs driver and a supported filesystem. kvikio’s defaults.is_compat_mode_preferred() is False whenever libcufile loads, even when cuFile itself then falls back to POSIX reads because nvidia-fs is missing, so it cannot tell. status() reports both.

Layouts read on the device; anything else falls back to the host path (the source records why, DeviceReader.why_not):

  • flat files (.raw, .mhd, C-ordered .npy), any byte order and header;

  • Zarr v3 arrays on a local store, sharded with the index at the end (bytes + optional crc32c index codecs), inner codecs bytes and optionally zstd, the default chunk key encoding: what zvdvc convert and zvdvc synth write.

nvCOMP trusts its input: a malformed zstd chunk can hang its kernel or fail the CUDA context where the host decoder raises. So each shard index’s crc32c is checked, reads must return every byte asked for, and frames go through zarr-vectors’ checked decode_zstd when it is available (otherwise each frame header must declare the chunk’s size). Damage inside a zstd block passes all of these; use the device path on stores you trust.

zvdvc.io.gds.status()[source]

What this machine offers: kvikio and nvCOMP versions, and whether cuFile has GPUDirect Storage.

Return type:

dict[str, Any]

zvdvc.io.gds.resolve(mode='auto')[source]

The read path to use: "kvikio" or "host". auto defers to $ZVDVC_GPU_IO first.

Parameters:

mode (str)

Return type:

str

class zvdvc.io.gds.DeviceReader[source]

Bases: object

Reads the part of a volume inside a box into a device array (native byte order).

why_not: str | None = None
read_into(out, valid, at, stream=None)[source]

Write valid (volume coordinates) into out at offset at (z, y, x).

Parameters:
Return type:

None

class zvdvc.io.gds.RawDeviceReader(path, *, header_bytes, dtype, shape_zyx)[source]

Bases: DeviceReader

A flat (z, y, x) C-ordered file: whole rows of each plane are read, then cropped on the device.

A brick spanning whole planes is one contiguous read; otherwise each plane’s rows are one read. Reading whole rows costs X / (x1 - x0) in bytes, which is small for bricks and keeps the number of requests at one per plane.

Parameters:
read_into(out, valid, at, stream=None)[source]

Write valid (volume coordinates) into out at offset at (z, y, x).

Parameters:
Return type:

None

class zvdvc.io.gds.ShardedZarrReader(array)[source]

Bases: DeviceReader

A sharded Zarr v3 array on a local store: the needed inner chunks’ stored bytes are read with kvikio and decompressed by nvCOMP in batches, then copied into place on the device.

Parameters:

array (Any)

MISSING = np.uint64(18446744073709551615)
read_into(out, valid, at, stream=None)[source]

Write valid (volume coordinates) into out at offset at (z, y, x).

Parameters:
Return type:

None

zvdvc.io.gds.zstd_content_size(header)[source]

The decompressed size a zstd frame header declares, or None when it declares none.

Raises ValueError when header does not start a zstd frame.

Parameters:

header (bytes)

Return type:

int | None

zvdvc.io.pointcloud

Search points: import, zarr-vectors store, and per-tile reads.

Search points are stored as a zarr-vectors point cloud. Its chunk grid is zvDVC’s work partition. Tiles are unions of whole chunks, so the cells a worker reads are exactly the cells it later writes in the results store.

Store layout (level 0):

vertices/                   (x, y, z) float32, voxel units
vertex_fragments/           one fragment per bin (zarr-vectors guidance, keeps pyramids useful)
vertex_attributes/point_id  int64: CCPi label (``n`` column of .roi/.disp)
  • chunk_shape is chosen so cluster.tile_shape is an integer multiple of it.

  • Tile reads use zarr_vectors.building.read_cells(level, cells, ["vertices", "vertex_attributes/point_id"]), one pooled read on the host whose offsets are CSR over cells. Each cell’s bins are worked out on the host from those rows, and a tile’s points are a few MB against gigabytes of bricks, so they stay on the host read path; device="cuda" copies them up afterwards. zarr-vectors’ own device read (kvikio, nvCOMP) is not used here.

  • Large clouds are written with zarr-vectors’ three-phase HPC pattern: create_store + defer_presence, then workers write disjoint cells with write_chunk_vertices(..., record_presence=False), then rebuild_presence.

  • Only zarr_vectors.api / zarr_vectors.building are used. Bin assignment (zarr_vectors.spatial.chunking.assign_bins) is internal upstream, so zvDVC assigns bins itself (bin_index()).

Cells and bins follow zarr-vectors: cell floor(x / chunk_shape) (store bounds start at 0), and within a cell, fragment (bx * nby + by) * nbz + bz for the bin b = floor((x - cell_origin) / bin_shape). A cell’s rows are its fragments in order, each in input order. Bins are recomputed from the stored float32 positions whenever they are needed, which reproduces them exactly, so the results store can reuse the input’s fragments without reading fragment metadata.

class zvdvc.io.pointcloud.TilePoints(xyz: 'Any', point_id: 'Any', cells: 'list[CellCoord]', cell_offsets: 'Any', bin_offsets: 'Any', io: 'tuple[str, ...]' = ())[source]

Bases: object

Parameters:
xyz: Any
point_id: Any
cells: list[tuple[int, int, int]]
cell_offsets: Any
bin_offsets: Any
io: tuple[str, ...] = ()
zvdvc.io.pointcloud.bin_index(xyz, cell, chunk_shape, bin_shape)[source]

Fragment index of each point of cell (C order over (x, y, z) bins, as zarr-vectors numbers them).

Parameters:
Return type:

ndarray

zvdvc.io.pointcloud.group_cells(xyz, chunk_shape)[source]

Row indices per cell, in input order.

Parameters:
Return type:

dict[tuple[int, int, int], ndarray]

zvdvc.io.pointcloud.cell_fragments(xyz, cell, chunk_shape, bin_shape)[source]

Row permutation putting a cell’s points in fragment order, and the (n_bins + 1,) fragment offsets.

Parameters:
Return type:

tuple[ndarray, ndarray]

zvdvc.io.pointcloud.read_roi(path)[source]

Read a CCPi .roi or iDVC .txt/.csv point cloud.

Returns (point_id (N,) int64, xyz (N, 3) float64). The first point is CCPi’s default start point. Lines are n x y z separated by tabs, spaces or commas; blank lines, # comments and non-numeric header lines are skipped.

Parameters:

path (str | Path)

Return type:

tuple[ndarray, ndarray]

zvdvc.io.pointcloud.check_points(point_id, xyz, *, where)[source]

Refuse an empty cloud, repeated point ids (results are matched by id) and non-finite coordinates.

Parameters:
Return type:

None

zvdvc.io.pointcloud.default_bin_shape(chunk_shape)[source]

Two bins per axis (8 fragments per cell), zarr-vectors’ guidance for useful pyramids.

Parameters:

chunk_shape (tuple[float, float, float])

Return type:

tuple[float, float, float]

zvdvc.io.pointcloud.write_pointcloud_store(path, xyz, point_id, *, bounds, chunk_shape, bin_shape=None)[source]

Write a zarr-vectors point cloud, one fragment per bin.

Uses the three-phase pattern (allocate + defer_presence, write disjoint cells, rebuild_presence) in one process, so the same functions scale to a cluster by running phase 2 per partition.

Parameters:
Return type:

None

zvdvc.io.pointcloud.allocate_store(path, *, bounds, chunk_shape, bin_shape, attributes)[source]

Phase 1: create the store, level 0, the vertex and attribute arrays; defer presence. Returns the level.

Parameters:
Return type:

Any

zvdvc.io.pointcloud.write_cell(level, cell, xyz, attributes, offsets)[source]

Phase 2: one cell’s vertices and attributes, split into fragments at offsets; presence not recorded.

Parameters:
Return type:

None

zvdvc.io.pointcloud.finalize_store(path, *, n_points, pyramid=False)[source]

Phase 3: rebuild presence, record what is present, write level and multiscale metadata.

Parameters:
Return type:

None

class zvdvc.io.pointcloud.PointCloud(path)[source]

Bases: object

Read side of a search-point store.

Parameters:

path (str | Path)

property chunk_shape: tuple[float, float, float]
property bin_shape: tuple[float, float, float]
property n_points: int
cells()[source]

Occupied chunk coordinates, from metadata only.

Return type:

list[tuple[int, int, int]]

cell_counts()[source]

Points per cell, used by the tile cost model.

Return type:

dict[tuple[int, int, int], int]

read_tile(cells, *, device='cuda')[source]
Parameters:
Return type:

TilePoints

read_all(*, device='cpu')[source]

Every point, as (xyz, point_id), in cell order. Used for kNN and seeding on the coordinator.

Parameters:

device (Literal['cpu', 'cuda'])

Return type:

tuple[Any, Any]

cell_extents()[source]

Per cell, the (min, max) point coordinates: tight brick boxes for tile planning.

Return type:

dict[tuple[int, int, int], tuple[ndarray, ndarray]]

zvdvc.io.pointcloud.import_points(roi_path, store_path, *, volume_shape_zyx, chunk_shape)[source]

Convert a CCPi .roi into a point-cloud store bounded by the volume.

Parameters:
Return type:

PointCloud

zvdvc.io.pointcloud.is_store(path)[source]
Parameters:

path (str | Path)

Return type:

bool

zvdvc.io.pointcloud.chunk_shape_for(tile_shape_zyx, per_tile=4)[source]

Default cell size: per_tile cells per tile edge (e.g. 256 for 1024^3 tiles).

Divided exactly, so the tile is a whole number of cells even when its edge is not a multiple of per_tile (cells are in voxel units and may be fractional).

Parameters:
Return type:

tuple[float, float, float]

zvdvc.io.results

DVC results as a zarr-vectors point cloud on the input’s chunk grid.

The results store mirrors the search-point store cell for cell and fragment for fragment. Row r of cell c in the input is row r of cell c here, so no index table is needed and a tile’s writes touch only that tile’s cells.

Vertex attributes (level 0):

name

dtype

cols

meaning

point_id

int64

1

CCPi label

status

int8

1

zvdvc.status.PointStatus

objmin

float32

1

objective at the solution (CCPi objmin)

displacement

float32

3

u, v, w (voxels)

params

float32

dof

full parameter vector (CCPi order)

n_iter

uint8

1

Gauss-Newton iterations used

seed

float32

3

starting displacement (for audit / repair)

strain

float32

6

exx, eyy, ezz, exy, eyz, exz (M5, post)

Writes follow zarr-vectors’ three-phase HPC pattern:

  1. ResultStore.allocate() (coordinator, once): create_store, create_resolution_level, create_vertices_array, one create_attribute_array per row above, then defer_presence. Workers never create arrays, because re-creating one inside a write session drops cells siblings have already written.

  2. ResultStore.write_tile() (workers, in parallel): write_chunk_vertices / write_chunk_attributes with record_presence=False on the tile’s own cells only. Written cells are visible to readers straight away on a deferred level, which is what zvdvc repair and resume rely on.

  3. ResultStore.finalize() (coordinator, once): rebuild_presence, refresh_arrays_present, update_level_metadata, write_multiscale_metadata, and optionally build_pyramid for Neuroglancer overviews.

class zvdvc.io.results.ResultStore(path, mode='r')[source]

Bases: object

Parameters:
  • path (str | Path)

  • mode (str)

classmethod allocate(path, *, points, dof, template_digest=None, prefilter_sigma=0.0, fingerprint=None)[source]

Phase 1 (coordinator): create every array, declare presence deferred.

template_digest (zvdvc.geometry.templates.Template.digest()) is recorded so that a resumed or repaired run refuses to mix subvolume templates (check_template()). fingerprint (JSON data identifying the volumes, points and result-affecting settings) is recorded likewise for check_fingerprint().

Parameters:
Return type:

ResultStore

check_template(digest)[source]

Refuse to add results computed with another subvolume template than the ones already here.

Parameters:

digest (str)

Return type:

None

check_prefilter(sigma)[source]

Refuse to add results computed from differently filtered volumes (volumes.prefilter_sigma).

Parameters:

sigma (float)

Return type:

None

check_fingerprint(fingerprint)[source]

Refuse to add results for other volumes, points or settings than those this store was allocated for.

A store written before fingerprints were recorded is accepted with a warning.

Parameters:

fingerprint (dict[str, Any])

Return type:

None

write_tile(tile, results)[source]

Phase 2 (worker): write one tile’s cells. results maps attribute name to (N, cols) arrays in tile row order.

Parameters:
Return type:

None

written_cells()[source]

Cells already on disk, used to resume after a crash or pre-emption.

A cell counts only if every result array holds it. write_tile writes status last, so a worker killed half-way through a cell leaves a cell that does not count, and the resubmitted job rewrites it.

Return type:

set[tuple[int, int, int]]

read_neighbourhood(cell, *, halo=1, device='cuda')[source]

A cell and its neighbours, in one zarr_vectors.building.read_neighbourhood prefetch.

Parameters:
Return type:

dict[str, Any]

read_all()[source]

Every written point: xyz and each result attribute, in cell order.

Return type:

dict[str, ndarray]

reopen_for_writes()[source]

Phase 1 again (coordinator), for a store finalized before every cell was written.

finalize() ends the deferred-presence declaration, after which record_presence=False writes would stay invisible to written_cells() and read_all(). Call before workers open the store.

Return type:

None

finalize(*, n_points, pyramid=False)[source]

Phase 3 (coordinator): rebuild presence and write metadata. Never run while workers are writing.

Parameters:
Return type:

None

zvdvc.io.results.fingerprint_diff(a, b, prefix='')[source]

Dotted keys at which two fingerprints (nested JSON data) differ.

Parameters:
Return type:

list[str]

zvdvc.io.ccpi

CCPi DVC / iDVC file formats.

Used to (a) run zvDVC as a drop-in for the dvc executable that iDVC launches (zvdvc ccpi dvc_config.txt), (b) run the CCPi baseline on zvDVC’s test cases (M0), and (c) compare results point by point.

dvc_in

key<ws>value  ### comment lines; # lines ignored. Keys as in iDVC’s dvc_config_template.txt and CCPi InputRead.

.disp

Tab-separated, header n x y z status objmin u v w. Current CCPi writes displacements only; older files also carry phi the psi and strain columns, and read_disp() accepts both. Rows are in point-cloud order. One policy for every writer (write_disp()): a point that is not GOOD gets u v w = 0 and a finite objmin (0 when it has none), as CCPi writes failed points; the raw values stay in the results store.

.stat

Input echo, run start/finish, points per second, and counts per status.

Observed behaviour of dvc 25.0.0 (conda ccpi-dvc, reports v22.0.0-19), found by running it, not from its source:

  • A value keeps its line ending unless a ### comment follows it on the line (so reference_filename  ref.raw fails with “cannot find file”); write_dvc_input() ends every line with a comment.

  • num_points_to_process and starting_point are required although the manual lists them as optional.

  • dvc exits 0 after input errors; the missing .disp is the signal. iDVC checks the QProcess exit status (normal exit or crash), not the exit code, so it too can only tell a failed run by the missing .disp.

  • The .disp holds n x y z status objmin u v w only, with no rotation or strain columns, even for 6/12-DOF runs.

class zvdvc.io.ccpi.RunSummary(n_points: 'int', seconds: 'float', counts: 'dict[int, int]')[source]

Bases: object

Parameters:
n_points: int
seconds: float
counts: dict[int, int]
zvdvc.io.ccpi.read_dvc_input(path)[source]

key value pairs of a CCPi input file. Values keep inner spaces.

Lines starting with # are ignored, and a comment starts at ### or at a # that follows whitespace. Unknown keys warn (CCPi ignores them silently).

Parameters:

path (str | Path)

Return type:

dict[str, str]

zvdvc.io.ccpi.run_config_from_dvc_input(params, *, base_dir='.')[source]

The RunConfig equivalent to a CCPi dvc_in (settings as read_dvc_input() returns them).

Relative paths are resolved against base_dir (the input file’s folder, as dvc resolves them against its working directory). The output store and work directory are <output_filename>.zarrvectors and <output_filename>_zvdvc. Search settings follow CCPi’s behaviour: wavefront (CCPi-order) seeding and no CONVG_FAIL reporting. The result is validated as a YAML config is (RunConfig.validate()); errors name the dvc_in key.

Parameters:
Return type:

RunConfig

zvdvc.io.ccpi.ccpi_volume_layout(cfg)[source]

(shape_xyz, dtype, header_bytes) of the reference volume as CCPi must read it.

CCPi reads a flat file of unsigned 8/16-bit voxels with a fixed header. .npy qualifies (its header is the fixed header) when C-ordered; OME-Zarr must first be exported with zvdvc.io.volume.write_raw().

Parameters:

cfg (RunConfig)

Return type:

tuple[tuple[int, int, int], dtype, int]

zvdvc.io.ccpi.write_dvc_input(cfg, path, *, roi_path, output_base)[source]

Write a CCPi input file equivalent to cfg, to run the CPU baseline on the same case (M0).

Parameters:
Return type:

None

zvdvc.io.ccpi.write_roi(path, point_id, xyz)[source]

CCPi point cloud: one n<TAB>x<TAB>y<TAB>z line per point, no header.

Parameters:
Return type:

None

zvdvc.io.ccpi.read_disp(path)[source]

Structured array with fields n, x, y, z, status, objmin, u, v, w (+ optional extra columns).

Parameters:

path (str | Path)

Return type:

ndarray

zvdvc.io.ccpi.g(v)[source]

A number as C++ operator<< prints it by default (6 significant digits, like %g).

Parameters:

v (Any)

Return type:

str

zvdvc.io.ccpi.disp_row(n, xyz, status, objmin, uvw)[source]

One CCPi append_result line: default-format coordinates and objective, 6-decimal displacements.

Parameters:
Return type:

str

zvdvc.io.ccpi.write_disp(path, point_id, xyz, status, objmin, displacement, *, ccpi_precision=False)[source]

CCPi .disp, with the one policy for points that are not GOOD: zero displacement and a finite objmin.

zvDVC-only status codes are written as CCPi’s NOT_SEARCHED. Numbers are written to 9 significant digits, or with ccpi_precision exactly as CCPi prints them (disp_row()), as the drop-in does.

Parameters:
Return type:

None

zvdvc.io.ccpi.write_stat(path, cfg, summary)[source]

Run summary in the spirit of CCPi’s .stat: settings, time, rate and status counts.

status <NAME> lines count zvDVC’s statuses; the number ... lines below them count CCPi’s codes, mapped as the .disp maps them (THRESH_FAIL and SINGULAR are not searched). This is not the layout iDVC parses; the drop-in (zvdvc.ccpi_dropin) writes that one.

Parameters:
Return type:

None

zvdvc.io.ccpi.read_stat_throughput(path)[source]

Points per second reported in a CCPi .stat file (the M0 baseline number).

Parameters:

path (str | Path)

Return type:

float

zvdvc.ccpi_dropin

A drop-in for CCPi’s dvc executable, so iDVC (or any script that runs dvc) uses zvDVC.

iDVC runs dvc <dvc_in> from PATH in its working directory, follows progress by reading stdout lines that start with <count>/<total>, treats a normal process exit as success, then reads <output_filename>.disp (tab separated, one header line) and <output_filename>.stat, which it parses by line position (iDVC utilities.RunResults). This module reproduces those files byte for byte in the layout of CCPi 22.0.0 (InputRead::echo_input, result_header, append_result and dvc.cpp), with zvDVC’s results in them:

  • the .stat echo of the input, the point-cloud bounding box, run times, rate and counts;

  • the .disp rows in processing order (distance from the starting point, as CCPi), for the num_points_to_process points processed; x y z status objmin in C++’s default (%g) format and u v w fixed to 6 decimals, as CCPi writes them;

  • a progress line per point, i/N label<TAB>x y z <TAB>Point_Good<TAB>obj= ....

As in CCPi, relative paths in dvc_in are relative to the working directory. The run is the in-memory wavefront solve (CCPi’s order and seeding) on the default backend (the GPU when there is one; ZVDVC_BACKEND overrides). One difference is deliberate: a point whose subvolume leaves the image is Range_Fail, where CCPi interpolates wrapped or unset data (docs/benchmarks/2026-09-26-case-A-real.md).

To use it from iDVC, put an executable named dvc that runs zvdvc-dvc "$@" ahead of CCPi’s on PATH (docs/IDVC.md).

zvdvc.ccpi_dropin.write_disp(path, point_id, xyz, status, objmin, disp)[source]

CCPi’s .disp as CCPi prints it; failed points get zero displacement (blank_par_min), as every writer does.

Parameters:
Return type:

None

zvdvc.ccpi_dropin.stat_echo(params, n_points, bbox_min, bbox_max)[source]

InputRead::echo_input: the settings, point-cloud size and bounding box, and version.

Parameters:
Return type:

str

zvdvc.ccpi_dropin.stat_summary(start, finish, count, seconds, codes)[source]

The end of the .stat (dvc.cpp): times, rate and status counts.

Parameters:
Return type:

str

zvdvc.ccpi_dropin.progress_line(i, total, label, xyz, status, objmin, uvw)[source]

dvc.cpp’s per-point console line; iDVC reads the count before the /.

Parameters:
Return type:

str

zvdvc.ccpi_dropin.run(dvc_in, *, backend=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]

Run dvc_in as CCPi would, with zvDVC; 0 on success.

Every input is read and checked first. The .disp and .stat are written to temporary files and renamed into place only when the run succeeds (the .disp last), so a failed run leaves earlier outputs as they were and never a new .disp, the only failure signal iDVC sees (zvdvc.io.ccpi). A failure prints one input file problem: ... or run failed: ... line and returns 1.

Parameters:
Return type:

int

zvdvc.ccpi_dropin.main(argv=None)[source]

zvdvc-dvc: CCPi dvc’s command line (dvc dvc_in, help, version).

Parameters:

argv (list[str] | None)

Return type:

int