Headers¶
Format-specific header preservation for zarr vectors stores.
Headers are stored in the attributes of /headers/<format>/ as raw
JSON-compatible dicts. The registry provides opaque round-trip
storage; typed (de)serialisation of header dicts lives in the
format package.
Source-format headers (for example from .trk, .swc or Neuroglancer
precomputed files) kept with a store. Each is stored whole, uninterpreted,
as the attributes of /headers/<format>/.
- class zarr_vectors.headers.registry.HeaderRegistry(store_path_or_root)[source]¶
Bases:
objectManages format-specific headers within a zarr vectors store.
- Parameters:
store_path_or_root (str | Path | Group) – Either a filesystem path (str/Path) to the store, or an already-open
Grouproot handle.
The handle check is against
Group, notFsGroup.FsGroupis returned only when the backing store happens to be aLocalStore, so testing for it meant a cloud-backed root fell through toopen_store(str(root))– which stringifies a Group and then tries to open the result as a path.- add(format_name, header)[source]¶
Store a format header as a dict.
If a header for this format already exists, it is overwritten.
Reached from a dataset as headers:
import zarr_vectors as zv
ds = zv.open("tracts.zarrvectors", mode="r+")
ds.headers.add("trk", {"voxel_to_rasmm": [[1, 0, 0, 0], [0, 1, 0, 0],
[0, 0, 1, 0], [0, 0, 0, 1]]})
ds.headers.available_formats # ['trk']
ds.headers.get("trk") # the dict back, unchanged