TMA Alignment Pipeline#248
Open
jeffquinn-msk wants to merge 34 commits into
Open
Conversation
This part of the project is making it impossible for me to install the project on my HPC, and something about libvips does not play nice with Apptainer, so removing the java aspect so I can try installing in conda.
This evaluates to 0 when running in a single core worker, which is not valid
- Add CropMode StrEnum (issue 4); old CROP_* constants kept as aliases - Add eager Valis construction validation for src_dir (issue 13) - Add import-order segfault guard in __init__.py (issue 9) - Annotate public API with type hints; add rc_to_wh/wh_to_rc utilities (issues 2, 5) - Add 17 unit tests covering enums, validation, coord utils, alignment indices (issue 8) - Update IMPROVEMENTS.md with completed status Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Issue 3: Add RegistrationConfig dataclass with typed fields, factory defaults, and two presets (for_ihc, for_cycif). Valis.__init__ accepts an optional config= kwarg; explicit kwargs still take precedence. Issue 6: Add DisplacementField class encapsulating the three-way (memory/pyvips/disk) backing-store logic previously spread across Slide._bk_dxdy_np, _bk_dxdy_f, and stored_dxdy flag. Issue 7: Narrow bare except: to except Exception: in feature_detectors.py. Issues 10/11: Add warp-method and crop-mode decision tables to the Valis class docstring. Issue 12: Add four runnable example scripts (basic_registration, non_rigid_registration, resume_from_saved_state, extract_transforms). Issue 14: Move torch/torchvision/kornia/einops to optional [dl] extras in pyproject.toml. Add ImportError guards with install hints to all torch-dependent classes. DEFAULT_MATCHER falls back to VggFD when torch is absent. Import-order guard in __init__.py updated accordingly. Issue 8: Expand unit tests from 17 to 26 covering RegistrationConfig presets, config-kwarg precedence, and DisplacementField state management. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Convert the 6,649-line monolithic registration.py into a structured package at src/valis/registration/: __init__.py Re-exports every public name; zero breaking changes _constants.py Module-level constants, defaults, shared imports state.py CropMode, DisplacementField, RegistrationConfig, load_registrar slide.py Slide class (~1,500 lines) pipeline.py Valis class (~4,800 lines) slide.py uses TYPE_CHECKING to reference Valis, avoiding the circular import that previously coupled the two classes. All 26 unit tests pass. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The package split omitted the module-level logger definition from the original registration.py. Add import logging + logger = logging.getLogger(__name__) to pipeline.py, slide.py, and state.py. Smoketest now passes again. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
With from __future__ import annotations already present, all annotations are lazy strings at runtime — there is no actual circular import. The Valis import in the TYPE_CHECKING block was solving a non-problem. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Not needed on modern Python. Also drop duplicate dataclass import left over in state.py from the extraction. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…gs (#6) ## Summary - Wire ruff into CI with bug-catching checks only (F821 undefined name, F811 redefinition, F823 use-before-assign, E9 syntax) — exactly the class of bug that produced the recent \`slide_tools\` NameError. Avoids noisy stylistic checks (F401/F841) so it doesn't block CI on unrelated cleanup. - Add a parametrized import smoke test in \`tests/test_unit.py\` that walks every submodule under \`valis.*\` and asserts it imports. - Fix the existing F821/F811 violations surfaced by the new check, several of which are real bugs: - \`registration/slide.py\`: missing \`colour\`, \`shapely\`, \`tqdm\`, \`deepcopy\`, \`skimage.transform\`, \`CropMode\`, \`WARP_ANNO_MSG\` imports. - \`registration/pipeline.py\`: restore lost \`missing_mask = warp_tools.resize_img(...)\` step (regression from the registration package split). - \`serial_non_rigid.py\`: \`updated_dxdy\` was referenced before assignment on the first loop iteration; initialized to \`None\`. - \`slide_io.py\`: \`vips2ome_dtype()\` was undefined at two call sites; replaced with the two-step \`VIPS_FORMAT_NUMPY_DTYPE → NUMPY_FORMAT_OME_DTYPE\` lookup used elsewhere in the same file. - \`superglue_models/utils.py\`: add missing \`matplotlib\` / \`plt\` imports. - Assorted duplicate-import removals via \`ruff --fix\`. ## Test plan - [x] \`uvx ruff check src/valis tests examples\` → clean - [x] \`pytest tests/test_unit.py\` → 45 passed (includes 19 new module-import cases) - [x] \`from valis import registration; from valis.registration import slide, pipeline\` succeeds - [ ] CI green on this PR 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
No description provided.