Repository navigation
feat(registration): recover registration geometry without the reference volumes - #28
Merged
Merged
Conversation
…ce volumes The transform needs the geometry of the two volumes the CCF registration worked from. Those are published under ccf_alignment/registration_metadata/ at 1.4-1.8 GB each, but only for some samples: of 60 processed exaSPIM assets with a fused zarr, 40 have them. The rest cannot be transformed at all today. Nothing in the transform reads their voxels -- check_orientation needs input_img.shape and apply_transforms_to_points needs the resampled image's spacing, origin and direction. The only pixel consumer is the QC overlay, which this pipeline does not produce. Two paths, because the samples split cleanly and disjointly. Older samples publish the volumes but carry a v1 processing record with empty parameters; newer ones carry a full v2 record but no volumes. Where the volumes exist their headers are read from a 200 KB byte range rather than the whole file -- exact on all 40. Where the record exists the geometry is derived from the zarr level it names and the sample_scale it recorded. Where both exist, reconcile() checks one against the other and fails rather than mis-registering. Three details are load-bearing, each verified across the 40 and each silently wrong if missed: - the source is fused_ccf_ch.zarr, not fused.zarr; rules from the signal pyramid match 11-27 of 40, the CCF channel matches 40/40 - resampled shapes need exact rationals: 0.0135/0.01 is 1.3499999999999999 in binary float, so a 1270-voxel axis rounds to 1714 where the registration produced 1715 - the direction matrix is ANTs/ITK LPS, which negates the first two rows of the NIfTI RAS srow The written spacing is sample_scale reversed, which does not correspond to the array's physical axes -- the coarse value lands on axis 2 while the coarse axis is z at index 1. Reproducing it is required: the transforms were fit in that space. Also recovers the template-to-CCF version the registration used, so a sample registered against v1.4 is not silently composed with v1.5.
The resample stage no longer writes them, so the role has no source.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #27. Adds
registration.py.The transform needs the geometry of the two volumes the CCF registration worked from, published at 1.4-1.8 GB each under
ccf_alignment/registration_metadata/— but only for some samples. Of 60 processed exaSPIM assets with a fused zarr, 40 have them; the rest cannot be transformed at all today.Nothing reads their voxels:
check_orientationneedsinput_img.shape,apply_transforms_to_pointsneeds the resampled image's spacing/origin/direction. The only pixel consumer is the QC overlay, which this pipeline does not produce.Two paths, because the samples split disjointly. Older samples publish the volumes but carry a v1 record with empty
parameters; newer ones carry a full v2 record but no volumes.sample_scaleit namesreconcile()Three load-bearing details, each verified across the 40 and each silently wrong if missed:
fused_ccf_ch.zarr, notfused.zarr— rules from the signal pyramid match 11-27 of 40, the CCF channel matches 40/400.0135/0.01is1.3499999999999999in binary float, so a 1270-voxel axis rounds to 1714 where the registration produced 1715srowAlso recovers the template-to-CCF version the registration used, so a sample registered against v1.4 is not silently composed with v1.5 (826509 is such a case).
Honest gap: the derivation path cannot be cross-validated against the published volumes, because no sample currently has both.
reconcile()exists to close that the moment one does.Tests: 138 passed, 100% coverage, ruff and interrogate clean.