Ingest workflows

Each ingest function reads one source format and writes a Zarr Vectors store. There are no re-exports — zarr_vectors_tools/convert/ingest/__init__.py is empty, so every import names its module in full.

# Always import from the module, never from the package.
from zarr_vectors_tools.convert.ingest.csv_points import ingest_csv

result = ingest_csv(
    "transcripts.csv",          # source file
    "transcripts.zv",           # path for the new store (must not exist)
    (50.0, 50.0, 50.0),         # chunk_shape — required, positional
    bin_shape=None,             # optional supervoxel bin size
    # ... format-specific options ...
)
result["vertex_count"]          # summary dict from the underlying writer

Two entry points break that shape: ingest_edgelist takes an edge CSV and a node CSV before output_path, and ingest_trk_parallel takes no chunk_shape at all — it derives the grid from num_chunks.

The returned dict is whatever the zarr-vectors writer produced (write_points, write_lines, write_polylines, write_graph, write_mesh), plus enrichment counters such as dropped_by_length, dropped_na, or dropped_duplicates.

Format matrix

Generated from FORMAT_REGISTRY in zarr_vectors_tools/cli/_args.py — the single place that maps a --format key to extensions, module, entry function, and extra.

Format

CLI --format key

Ingest function

Zarr Vectors geometry

Extra required

CSV / XYZ point cloud

csv (.csv, .xyz)

zarr_vectors_tools.convert.ingest.csv_points.ingest_csv

points

none

LAS / LAZ

las (.las, .laz)

zarr_vectors_tools.convert.ingest.las.ingest_las

points

las

PLY (points)

ply (.ply)

zarr_vectors_tools.convert.ingest.ply.ingest_ply

points

ply

AnnData

h5ad (.h5ad)

zarr_vectors_tools.convert.ingest.h5ad.ingest_h5ad

points

h5ad

Keyed table

table (no extension)

zarr_vectors_tools.convert.ingest.cell_table.ingest_table

points

none

CSV line segments

lines (no extension)

zarr_vectors_tools.convert.ingest.lines.ingest_lines_csv

lines

none

TrackVis TRK

trk (.trk)

zarr_vectors_tools.convert.ingest.trk_parallel.ingest_trk_parallel

streamlines

parallel

TRX

trx (.trx)

zarr_vectors_tools.convert.ingest.trx.ingest_trx

streamlines

streamlines

MRtrix TCK

tck (.tck)

zarr_vectors_tools.convert.ingest.tck.ingest_tck

streamlines

streamlines

SWC

swc (.swc)

zarr_vectors_tools.convert.ingest.swc.ingest_swc

skeleton

none

Edge-list CSV pair

edgelist (no extension)

zarr_vectors_tools.convert.ingest.edgelist.ingest_edgelist

graph

graph

GraphML

graphml (.graphml)

zarr_vectors_tools.convert.ingest.graphml.ingest_graphml

graph

graph

Wavefront OBJ

obj (.obj)

zarr_vectors_tools.convert.ingest.obj.ingest_obj

mesh

none

STL

stl (.stl)

zarr_vectors_tools.convert.ingest.stl.ingest_stl

mesh

none

GIFTI surfaces

gifti (.gii, or a directory of them)

zarr_vectors_tools.convert.ingest.gifti.ingest_gifti

mesh (one object per hemisphere)

surfaces

FreeSurfer subject

freesurfer (a subject directory)

zarr_vectors_tools.convert.ingest.freesurfer.ingest_freesurfer

mesh (one object per hemisphere)

surfaces

Neuroglancer precomputed skeletons or meshes

precomputed (a URL, or a directory with an info file)

zarr_vectors_tools.convert.ingest.precomputed.ingest_precomputed

skeleton or mesh (one object per segment ID)

precomputed

Install an extra with pip install "zarr-vectors-tools[las]", or [all] for the lot. Python 3.11 or newer is required.

Warning

lines, edgelist and table register no file extensions, so they can never be auto-detected — the CLI requires an explicit --format. A .csv input with no --format resolves to csv, i.e. a point cloud, silently and successfully. Pass --format lines, --format edgelist or --format table when the CSV is not a numeric point table.

table is the CSV path for rows carrying a stable identifier: it reads through pandas (so string and categorical columns work, where csv’s numpy.loadtxt path needs everything numeric) and hashes the identifier into a join key, so further files can be staged into the store afterwards. See Single-cell and spatial omics.

gifti and freesurfer also accept a directory, because one subject’s cortex is many files. A FreeSurfer subject is recognised by surf/lh.white or surf/rh.white, and any other directory holding .gii files resolves to gifti. CIFTI files carry no geometry, so they are staged onto a surface store with zvtools attach instead. See Cortical surfaces.

precomputed reads a layer, which is a directory or a bucket prefix: any URL resolves to it, since no other ingester reads one, as does a local directory holding an info file. ingest_precomputed reads that info and hands a skeleton layer to precomputed_skeletons.run_ingest when it has a spatial_index, or to precomputed_plain_skeletons.run_ingest_plain when it does not. A mesh layer goes to precomputed_meshes.ingest_precomputed_meshes. See Skeletons in EM and Meshes.

trk and precomputed are the registry entries with inline_pyramid=True: the ingest builds the multiscale pyramid itself rather than leaving it to a follow-up build_pyramid call. A precomputed mesh layer is the exception, and builds its pyramid afterwards like any other mesh. See Tractography at scale.

Ingests not in the CLI registry

One entry point is reachable from Python only:

Function

Source

Extra

zarr_vectors_tools.convert.ingest.trk.ingest_trk

TRK, serial whole-file read via nibabel

streamlines

ingest_trk is the serial sibling of ingest_trk_parallel. --format trk on the CLI always routes to the parallel path; reach for the serial one in Python when the file is small enough to hold in RAM and you want the nibabel reader’s data_per_point / data_per_streamline handling.

Geometry pages

Attribute names produced by the enrichment options are listed in full at Enrichments.

Headers and round-trip

Several formats carry metadata that is not part of the geometry: TRK voxel-to-RAS affines, SWC comment lines, OBJ object names, CSV normalisation offset and scale. These are written to /headers/<format>/ so the matching export_* can recover them. Header preservation is best-effort — a failure there never fails the ingest. See Headers.

See also