Project guidance for Claude Code in this repository.
Python launcher: Use py on this Windows system (not python).
# Install in editable mode (preferred)
uv pip install -e .
# Lint and format
ruff check . --fix && ruff format .
# Type checking
mypy src/ tests/
# All pre-commit hooks
pre-commit run --all-files
# Fast tests (recommended for development)
py -m pytest tests/ -m "not slow and not requires_data" -v
# Single test file or test by name
py -m pytest tests/test_contour_tools.py -v
py -m pytest tests/test_contour_tools.py::test_extract_surface -v
# Skip GPU-dependent tests
py -m pytest tests/ --ignore=tests/test_segment_chest_total_segmentator.py \
--ignore=tests/test_register_images_icon.py
# With coverage
py -m pytest tests/ --cov=src/physiomotion4d --cov-report=html
# Experiment notebook tests (very slow, opt-in)
py -m pytest tests/ --run-experiments
# Create missing baselines
py -m pytest tests/ --create-baselinesVersion bumping: bumpver update --patch (or --minor, --major)
Pipeline: 4D CT → Segmentation → Registration → Contour Extraction → USD Export
All classes inherit from PhysioMotion4DBase (physiomotion4d_base.py), which provides
a shared logger. Use self.log_info(), self.log_debug() — never print().
Consult docs/API_MAP.md for the full index of classes, methods, and signatures.
Regenerate it after any public API change: py utils/generate_api_map.py
Key data conventions:
- Images:
itk.Image, axes X, Y, Z [, T] in RAS world space - 4D time series: shape
(X, Y, Z, T)— never silently squeeze or permute axes - Surfaces:
pv.PolyDatain RAS; converted to Y-up only at USD export - Masks: ITK images with integer labels; consistent anatomy group IDs across all segmenters
- Transforms: ITK composite transforms stored in
.hdffiles - State axis order and shape explicitly in every docstring and comment that touches arrays
- Baselines in
tests/baselines/via Git LFS — rungit lfs pullafter cloning tests/conftest.py: session-scoped fixtures chaining download → convert → segment → registersrc/physiomotion4d/test_tools.py: baseline comparison utilities (TestTools, etc.)- Markers:
slow,requires_gpu,requires_data,experiment(skipped by default) - Prefer synthetic
itk.Image/pv.PolyDataover real data; keep volumes ≤64 voxels/side
Before editing any code:
- Read the relevant source file(s) in full.
- Summarize current behavior in 2–4 sentences.
- Propose a numbered plan; confirm before implementing non-trivial changes.
- Implement in small, reviewable diffs.
- Update docstrings and tests for every changed public method.
- Call out breaking changes explicitly.
Breaking changes are acceptable. Backward-compatibility shims are not.
Role-specific subagents live in .claude/agents/; slash-command skills in .claude/skills/.
See AGENTS.md for role-based guidance that applies across all AI tooling.
/plan— inspect files, summarize design, produce a numbered plan (no code changes)/impl— read → summarize → plan → implement in small diffs/test-feature— propose test plan, write synthetic-data pytest tests/doc-feature— update docstrings and regenerate API map
Use git mv / git rm — not mv / rm — to preserve history.
Do not create new .md files unless explicitly requested.
Document via docstrings and inline comments.
- Single quotes for strings; double quotes for docstrings
- Full type hints (
mypystrict;disallow_untyped_defs = true) Optional[X]notX | None(ruffUP007suppressed)- Breaking changes are acceptable — backward compatibility is not a priority
- Max line length: 88 characters