Skip to content

Commit 129d6cc

Browse files
galenlynchclaude
andcommitted
feat: deprecate auto-metadata helpers, bump to 0.15.0 (C8)
Final commit of the asset-centric API redesign branch. Marks the four auto-discovery convenience helpers as deprecated (they have clean ``Asset``-based replacements with no internal use), bumps the version, and documents the redesign in the CHANGELOG. Deprecated (DeprecationWarning, will be removed in a future release): - ``neuroglancer_to_ccf_auto_metadata`` - ``swc_data_to_ccf_auto_metadata`` - ``indices_to_ccf_auto_metadata`` - ``ccf_to_indices_auto_metadata`` Each warning message names the precise ``Asset.from_*().transform(...)`` replacement. The lower-level free functions (``zarr_to_sitk`` / ``zarr_to_ants`` / ``zarr_to_sitk_stub`` / ``mimic_pipeline_zarr_to_anatomical_stub`` / ``neuroglancer_to_ccf`` / ``ccf_to_indices``) are NOT deprecated this release: they are still called internally by the new ``Asset`` façade and the transform-graph edges. Deprecating them would generate spurious warnings from internal use. They will be deprecated once ``Asset`` calls are routed away from them in a future commit. A pyproject ``filterwarnings`` entry suppresses the new DeprecationWarnings inside our own test suite — the legacy paths are still exercised as regression coverage for the deprecation cycle. Version: 0.14.0 → 0.15.0. Stays on 0.x per the agreed BC plan. All 173 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 89afa9a commit 129d6cc

3 files changed

Lines changed: 155 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
## v0.15.0 (2026-04-28)
2+
3+
### Feat
4+
5+
- New asset-centric API. The package's recommended entry point is now
6+
`Asset` (with `Asset.from_zarr`, `Asset.from_root`,
7+
`Asset.from_neuroglancer`, plus a no-I/O `Asset(zarr_uri, metadata,
8+
processing)` constructor). A single `Asset` instance opens its Zarr
9+
exactly once and resolves transform-chain paths exactly once,
10+
regardless of how many methods participate in a workflow.
11+
- `Points` + `Space` make coordinate spaces first-class. Five spaces
12+
are recognised: `ZARR_INDICES`, `LS_SCALED_MM`, `LS_ANATOMICAL_MM`,
13+
`LS_PIPELINE_ANATOMICAL_MM`, `CCF_MM`. `Asset.transform(points,
14+
to=Space.X)` walks a small graph of named edges to project them.
15+
Every previous combination of `*_to_ccf` / `ccf_to_*` /
16+
`*_to_indices` is now expressible as one `transform` call.
17+
- `Origin` value type replaces the legacy
18+
`(set_origin, set_corner, set_corner_lps)` triple on the image
19+
builders: `Origin.default()`, `Origin.at(point)`,
20+
`Origin.at_corner(code, lps_point)`.
21+
- `Points.from_neuroglancer` and `Points.from_swc` provide one-line
22+
conversion from NG state and raw SWC arrays into the package's
23+
canonical representation.
24+
25+
### Refactor
26+
27+
- The package source is reorganised into focused subpackages:
28+
`io/` (Zarr opening, metadata parsing, processing-JSON parsing,
29+
transform-chain resolution, URI helpers), `domain/` (overlay
30+
protocol, selector, concrete overlays), `formats/` (Neuroglancer
31+
and SWC readers), and the new top-level modules `asset.py`,
32+
`points.py`, `image.py`, `origin.py`. The legacy modules
33+
(`zarr.py`, `neuroglancer.py`, `pipeline_domain_selector.py`,
34+
`pipeline_transformed.py`) keep working as re-export shims and
35+
continue to pass all existing tests.
36+
- The SimpleITK and ANTs pipeline-overlay paths (~320 LOC of
37+
duplication) collapse into a single type-dispatching
38+
`apply_pipeline_overlays` plus a small pure helper
39+
(`_to_ants_convention`) that encodes the level > 0 spacing-reverse
40+
+ opposite-corner origin recompute. The level > 0 ANTs math is now
41+
pinned by dedicated regression tests.
42+
43+
### Deprecations
44+
45+
The following auto-discovery convenience helpers emit
46+
`DeprecationWarning` and will be removed in a future release. Each
47+
points to its `Asset`-based replacement:
48+
49+
- `mimic_pipeline_zarr_to_anatomical_stub` (still callable but
50+
superseded by `Asset(...).stub(pipeline=True)`; not warned this
51+
release because of internal use).
52+
- `neuroglancer_to_ccf_auto_metadata`
53+
`Asset.from_neuroglancer(ng).transform(Points.from_neuroglancer(ng), to=Space.CCF_MM)`
54+
- `swc_data_to_ccf_auto_metadata`
55+
`Asset.from_root(uri).transform(Points.from_swc(...), to=Space.CCF_MM)`
56+
- `indices_to_ccf_auto_metadata`
57+
`Asset.from_zarr(uri).transform(Points(idx, Space.ZARR_INDICES), to=Space.CCF_MM)`
58+
- `ccf_to_indices_auto_metadata`
59+
`Asset.from_zarr(uri).transform(Points(ccf, Space.CCF_MM), to=Space.ZARR_INDICES)`
60+
61+
The lower-level free functions in `pipeline_transformed` and `zarr`
62+
(e.g. `neuroglancer_to_ccf`, `ccf_to_indices`, `zarr_to_sitk`,
63+
`zarr_to_sitk_stub`, `mimic_pipeline_zarr_to_anatomical_stub`) are
64+
unchanged for now and remain part of the package surface.
65+
166
## v0.14.0 (2026-02-11)
267

368
### Feat

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ authors = [
1313
]
1414
classifiers = ["Programming Language :: Python :: 3"]
1515
readme = "README.md"
16-
version = "0.14.0"
16+
version = "0.15.0"
1717

1818
dependencies = [
1919
"aind-anatomical-utils>=0.4",
@@ -73,6 +73,14 @@ ignore-words-list = "nd"
7373
[tool.pytest.ini_options]
7474
addopts = "--strict-markers --tb=short --cov=src --cov-report=term-missing --cov-fail-under=0"
7575
testpaths = ["tests"]
76+
# Suppress DeprecationWarnings emitted by our own legacy free functions —
77+
# the test suite still exercises them as regression coverage for the
78+
# 0.15 → 0.16 deprecation cycle. Drop this filter once the legacy paths
79+
# are removed.
80+
filterwarnings = [
81+
"ignore::DeprecationWarning:aind_zarr_utils.pipeline_transformed",
82+
"ignore::DeprecationWarning:aind_zarr_utils.zarr",
83+
]
7684

7785
[tool.interrogate]
7886
ignore-init-method = true

src/aind_zarr_utils/pipeline_transformed.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from __future__ import annotations
1717

1818
import os
19+
import warnings
1920
from typing import TYPE_CHECKING, Any, TypeVar
2021

2122
import numpy as np
@@ -837,7 +838,26 @@ def ccf_to_indices_auto_metadata(
837838
--------
838839
>>> ccf_pts = {"layer1": np.array([[5000, 6000, 7000]])}
839840
>>> indices_pts = ccf_to_indices_auto_metadata(ccf_pts, zarr_uri)
841+
842+
.. deprecated:: 0.15
843+
Use :class:`~aind_zarr_utils.asset.Asset` instead::
844+
845+
asset = Asset.from_zarr(zarr_uri)
846+
indices = asset.transform(
847+
Points(ccf_points, Space.CCF_MM),
848+
to=Space.ZARR_INDICES,
849+
).values
850+
851+
This shim will be removed in a future release.
840852
"""
853+
warnings.warn(
854+
"ccf_to_indices_auto_metadata is deprecated; use "
855+
"Asset.from_zarr(zarr_uri).transform(Points(ccf_points, Space.CCF_MM),"
856+
" to=Space.ZARR_INDICES) instead. This shim will be removed in a "
857+
"future release.",
858+
DeprecationWarning,
859+
stacklevel=2,
860+
)
841861
alignment_zarr_uri, metadata, processing_data = alignment_zarr_uri_and_metadata_from_zarr_or_asset_pathlike(
842862
a_zarr_uri=zarr_uri
843863
)
@@ -895,7 +915,26 @@ def neuroglancer_to_ccf_auto_metadata(
895915
------
896916
ValueError
897917
If no image sources can be found in ``neuroglancer_data``.
918+
919+
.. deprecated:: 0.15
920+
Use :class:`~aind_zarr_utils.asset.Asset` instead::
921+
922+
asset = Asset.from_neuroglancer(neuroglancer_data)
923+
ccf = asset.transform(
924+
Points.from_neuroglancer(neuroglancer_data),
925+
to=Space.CCF_MM,
926+
)
927+
928+
This shim will be removed in a future release.
898929
"""
930+
warnings.warn(
931+
"neuroglancer_to_ccf_auto_metadata is deprecated; use "
932+
"Asset.from_neuroglancer(ng).transform(Points.from_neuroglancer(ng),"
933+
" to=Space.CCF_MM) instead. This shim will be removed in a future "
934+
"release.",
935+
DeprecationWarning,
936+
stacklevel=2,
937+
)
899938
if asset_uri is None:
900939
image_sources = get_image_sources(neuroglancer_data, remove_zarr_protocol=True)
901940
# Get first image source in dict
@@ -1056,7 +1095,30 @@ def swc_data_to_ccf_auto_metadata(
10561095
-------
10571096
dict[str, NDArray]
10581097
Mapping neuron ID → (N, 3) array of anatomical CCF coordinates in LPS.
1098+
1099+
.. deprecated:: 0.15
1100+
Use :class:`~aind_zarr_utils.asset.Asset` instead::
1101+
1102+
asset = Asset.from_root(asset_uri)
1103+
ccf = asset.transform(
1104+
Points.from_swc(
1105+
swc_point_dict,
1106+
axis_order=swc_point_order,
1107+
units=swc_point_units,
1108+
),
1109+
to=Space.CCF_MM,
1110+
)
1111+
1112+
This shim will be removed in a future release.
10591113
"""
1114+
warnings.warn(
1115+
"swc_data_to_ccf_auto_metadata is deprecated; use "
1116+
"Asset.from_root(asset_uri).transform(Points.from_swc(swc_point_dict, "
1117+
"axis_order=..., units=...), to=Space.CCF_MM) instead. This shim "
1118+
"will be removed in a future release.",
1119+
DeprecationWarning,
1120+
stacklevel=2,
1121+
)
10601122
zarr_uri, metadata, processing_data = alignment_zarr_uri_and_metadata_from_zarr_or_asset_pathlike(
10611123
asset_uri=asset_uri
10621124
)
@@ -1126,7 +1188,26 @@ def indices_to_ccf_auto_metadata(
11261188
... indices,
11271189
... zarr_uri="s3://aind-open-data/dataset_123/image.zarr"
11281190
... )
1191+
1192+
.. deprecated:: 0.15
1193+
Use :class:`~aind_zarr_utils.asset.Asset` instead::
1194+
1195+
asset = Asset.from_zarr(zarr_uri)
1196+
ccf = asset.transform(
1197+
Points(annotation_indices, Space.ZARR_INDICES),
1198+
to=Space.CCF_MM,
1199+
)
1200+
1201+
This shim will be removed in a future release.
11291202
"""
1203+
warnings.warn(
1204+
"indices_to_ccf_auto_metadata is deprecated; use "
1205+
"Asset.from_zarr(zarr_uri).transform(Points(annotation_indices, "
1206+
"Space.ZARR_INDICES), to=Space.CCF_MM) instead. This shim will be "
1207+
"removed in a future release.",
1208+
DeprecationWarning,
1209+
stacklevel=2,
1210+
)
11301211
alignment_zarr_uri, metadata, processing_data = alignment_zarr_uri_and_metadata_from_zarr_or_asset_pathlike(
11311212
a_zarr_uri=zarr_uri
11321213
)

0 commit comments

Comments
 (0)