This file answers one question: where does new functionality belong?
Owns: Infrastructure that any library or orchestrator needs.
- Label translation (name ↔ integer, groups, cross-standard mapping)
- Model download, caching, and integrity verification
- Output path management
- External command execution (generic and CARPentry-specific)
- Configuration scaffolding (YAML template generation)
- Logging setup
Does NOT own: Anything domain-specific to images, meshes, or simulations.
Rule: If the functionality would be useful to all three downstream libraries, it belongs here.
Owns: Everything that operates on SimpleITK.Image objects in memory.
- Segmentation post-processing (myocardium growth, valve creation, ring creation)
- Label remapping and component cleanup
- Image quality metrics (MSE, PSNR, SSIM, gradient error)
- Anatomy-specific schematics (LV, RV, valve blueprints)
- Recipe sequences (named workflow variants)
- Scaffolding for image analysis configs
Does NOT own: File I/O (orchestrator responsibility), mesh operations, simulation setup.
Rule: If it takes a sitk.Image and returns a sitk.Image, it belongs here.
Owns: Everything from segmentation image → simulation-ready mesh.
- Volumetric meshing (meshtools3d wrapper)
- Mesh refinement and tag relabeling
- Surface extraction for UVC (ventricular and atrial)
- Universal Ventricular Coordinate calculation (mguvc / FEM solver)
- Fibre field generation (GlRuleFibres)
- Path contracts and builders for all of the above
- Thin wrappers: MeshtoolWrapper, CarpWrapper, Meshtools3DWrapper
Does NOT own: Image segmentation logic, label translation (delegates to pycemrg core).
Rule: If it requires a mesh file on disk (.pts/.elem) or produces one, it belongs here.
| New functionality | Where it goes |
|---|---|
| New label translation method | pycemrg.data |
| New external tool wrapper (generic) | pycemrg.system |
| New image mask operation | pycemrg-image-analysis logic or utilities |
| New anatomy schematic | pycemrg-image-analysis schematics |
| New image quality metric | pycemrg-image-analysis.utilities.metrics |
| New mesh I/O function | pycemrg-model-creation.utilities.mesh |
| New meshtool command | pycemrg-model-creation.tools.wrappers.MeshtoolWrapper |
| New surface extraction workflow | pycemrg-model-creation.logic.SurfaceLogic |
| New path contract | pycemrg-model-creation.logic.contracts |
| New builder method | pycemrg-model-creation.logic.builders |
| Orchestration logic | The consuming orchestrator script, not any library |
pycemrg-model-creationimportsLabelManagerandLabelMapperfrompycemrg.datapycemrg-model-creationimportsCarpRunnerandCommandRunnerfrompycemrg.systempycemrg-image-analysisimportsLabelManagerfrompycemrg.datapycemrg-image-analysisandpycemrg-model-creationdo not import from each other
pycemrg-model-creation: FibreLogic not yet implemented (tracked in TASKS.md)pycemrg-model-creation: Atrial UVC not yet implementedpycemrg-model-creation: Open-source FEM Laplace solver planned as alternative to mguvcpycemrg: No CLAUDE.md yet- UVC error in pycemrg: open, unresolved