Merge and split stores¶
zvtools merge TARGET SOURCES... appends the objects of files and stores to an
existing store without rewriting what is there. zvtools split STORE OUTDIR
writes one new store per group, attribute value or merged source. The
CLI reference lists every flag.
Merge¶
zvtools merge tracts.zv subject_b.trk --dry-run # plan only: ids, fit
zvtools merge tracts.zv subject_b.trk --on-out-of-bounds expand
Incoming objects get new ids after the target’s last one. Merge carries:
What |
How |
|---|---|
Object attributes |
Appended. A missing column is filled with NaN (float), or the type’s minimum (signed int) or maximum (unsigned int). |
Vertex attributes |
The target’s set, filled the same way. A name new to a non-empty target is skipped. |
Groups |
Renumbered. A name the target has is extended; |
Headers |
Copied. A second header of one format is kept as |
Provenance |
Recorded, for |
Streamlines, lines and point clouds with object ids can be merged; meshes,
skeletons, graphs and mixed geometries cannot. TRK, TCK and TRX files are read
directly. Other files are converted on the target’s chunk shape first. A point
cloud without object ids, or a format that needs options such as table, is
refused: convert it first, then merge the store.
Option |
Meaning |
|---|---|
|
For a source outside the target’s chunks: |
|
Move every source by a 4 × 4 affine ( |
|
Read TRK sources in RAS, for a target converted with |
|
Store each new object’s source index as an object attribute. |
|
Make a missing target with these chunks. |
|
Turn a per-streamline label into named groups, using a JSON |
zvtools merge atlas.zv atlas.trk --create --cell-size 10,10,10 \
--group-by label_id --lut atlas_lut.json
Pyramid after a merge¶
--pyramid rebuild (default) rebuilds each coarser level with its recorded
settings. Pass the --sparsity-strategy the levels were built with, because
it is not recorded. drop removes the levels; keep leaves them out of date and marks each one
with "compose_stale": true in the zarr_vectors_tools block of its level
attributes.
For a different pyramid, merge with --pyramid drop and run zvtools pyramid
(Pyramids).
Split¶
zvtools split atlas.zv bundles/ --dry-run # part names and object counts
zvtools split atlas.zv bundles/ # bundles/atlas_cst.zv, ...
zvtools split tracts.zv parts/ --by provenance
Each part, OUTDIR/<store>_<part>.zv, keeps attributes, groups and headers.
Option |
Meaning |
|---|---|
|
One part per named group (default). |
|
One part per value of an object attribute; |
|
One part per merged source, plus |
|
Split level N instead of level 0. |
|
Rebuild the parent’s coarser levels for each part (level 0 splits only). Default |
Python¶
from zarr_vectors_tools.compose import FileSource, merge_stores, split_store
merge_stores("tracts.zv", [FileSource("subject_b.trk")],
on_out_of_bounds="expand", pyramid="drop")
split_store("atlas.zv", "bundles", by="groups")
Most keywords are the CLI options with _ for - (create, cell_size,
group_prefix, on_out_of_bounds, pyramid; for split_store also by,
attribute, level, bounds, min_objects, overwrite). These differ:
CLI |
Python |
|---|---|
|
|
|
|
|
|
|
|
|
per source: |
|
per source: |
|
|