Skip to content

TMA Alignment Pipeline#248

Open
jeffquinn-msk wants to merge 34 commits into
MathOnco:mainfrom
jeffquinn-msk:jq_tma_alignment_pipeline
Open

TMA Alignment Pipeline#248
jeffquinn-msk wants to merge 34 commits into
MathOnco:mainfrom
jeffquinn-msk:jq_tma_alignment_pipeline

Conversation

@jeffquinn-msk
Copy link
Copy Markdown

No description provided.

jeffquinn-msk and others added 30 commits October 13, 2025 12:25
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant