Skip to content

osint/fma: hydrate the bake from the real FMA heart subtree, not a fixture#51

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/fma-real-owl-extract
Jun 24, 2026
Merged

osint/fma: hydrate the bake from the real FMA heart subtree, not a fixture#51
AdaWorldAPI merged 1 commit into
mainfrom
claude/fma-real-owl-extract

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

The /fma cockpit view was hydrated from a hand-authored fixture (data/fma-heart.fixture.ttl — 4 chambers × 3 wall layers, with an invented shared tissue type). This replaces it with a real subtree extracted from fma.owl (FMA v5.0.0, the 266 MB UW Structural Informatics Group FMA, CC BY 3.0, now mirrored on the q2 fma-ontology-5.0.0 release; SHA-256 59465eb5…79979e44).

The generic hydrate_fma walk is unchanged — the partonomy is still derived into the 8:8 [container:identity] HHTL cascade, never hardcoded to "heart". Only the data source and the proof changed.

The extractor — tools/extract_fma_heart.py

Streams the OWL (ET.iterparse, memory-bounded — only label / part / superclass maps are retained, not the ~1.5M-triple graph) and walks the regional_part / constitutional_part partonomy from FMA:Heart. The key tuning is a per-parent fan-out cap (root exempt): without it, FMA's ~40-branch coronary arterial tree drained the whole node budget and left the left side of the heart a leaf stub. With it, the slice is a balanced cross-section — all 22 major heart subdivisions (the four chamber cavities, the four valves, the three cardiac septa, both coronary arteries, the wall's endo/epi/myocardium, the fibrous skeleton, …) each with their real sub-parts. It emits the line-Turtle subset fma_ttl::parse already hydrates.

The proof had to change (the fixture lied)

The fixture's "four myocardia all share one Cardiac muscle tissue type" was an invention — real FMA gives region-specific myocardium classes (Myocardium of region of ventricle, …). The hardcoded position(|x| x.label == "Myocardium of left ventricle") no longer exists in the slice.

The proof is now adaptive: it picks the strongest real cross-cutter (the ceiling type that is the is-a target of the most structures) and its deepest member. On the real data:

node: Cavity proper of inflow part of right atrium
  part-of address — HHTL 8:8 [mixin:identity]: HEEL [01:01] HIP [02:06] TWIG [03:01] LEAF [04:01] family [00:00]
  is-a global type (ceiling): Subdivision of cavity of cardiac chamber  HEEL=0xffff HIP=0xffff TWIG=0xffff LEAF=16
  'Subdivision of cavity of cardiac chamber' is the is-a target of 7 structures in different parts of the heart (cross-cutting)
    shared by: Cavity of inflow part of left atrium, Cavity of inflow part of left ventricle, Cavity of inflow part of right atrium, Cavity of inflow part of right ventricle, Cavity of outflow part of left ventricle, Cavity proper of inflow part of right atrium, Cavity proper of left atrium

A genuine 4-tier-deep part-of address and a global type shared by 7 cavity structures across all four chambers — dual membership proven on real anatomy.

Verification

  • Byte-deterministic bake (re-run → identical fma.soa; 6603 bytes, 125 nodes = 80 part-of + 45 ceiling types, 156 edges)
  • End-to-end: ran the actual cargo run -p osint-bake --bin fma binary and inspected the proof output (above)
  • fma_ttl unit tests pass; clippy clean on the bake (the 3 -D warnings are the pre-existing aiwar-ingest lib dep, not these files)
  • cockpit FmaGraph.tsx doc updated to the real cross-cutting example; tsc clean. The decoder is generic over node count, so no decoder change was needed — browser render not exercised here.
  • Isolated to the osint-bake leaf crate + the cockpit vite app; nothing in the quarto-core / pampa / wasm chain is touched.

Not in this PR

The 266 MB fma.owl is not committed; the production hydrator remains the spine's lance_graph_ontology::hydrate_fma over the full file. This light bake exists so /fma renders without the lance/datafusion closure.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TzqvDqbFRzyx17EkLKBoZF


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added a curated heart-related ontology subset for richer heart data coverage.
    • Introduced a new extraction workflow to generate that subset from the source ontology.
  • Bug Fixes

    • Updated the heart proof example to use the new ontology subset and produce clearer, more representative cross-cutting output.
    • Replaced outdated sample comments with more accurate examples.

…xture

The /fma render surface was hydrated from a hand-authored fixture
(data/fma-heart.fixture.ttl, 4 chambers x 3 wall layers). Replace it with a
real subtree extracted from fma.owl (FMA v5.0.0, the 266 MB UW Structural
Informatics Group FMA, CC BY 3.0, now mirrored on the q2 fma-ontology-5.0.0
release; SHA-256 59465eb5...79979e44).

tools/extract_fma_heart.py streams the OWL (ET.iterparse, memory-bounded — only
the label / part / superclass maps are retained, not the ~1.5M-triple graph),
walks the regional_part / constitutional_part partonomy from FMA:Heart with a
per-parent fan-out cap (root exempt). That keeps the slice a balanced
cross-section — all 22 major heart subdivisions (the four chamber cavities, the
four valves, the three cardiac septa, both coronary arteries, the wall's
endo/epi/myocardium, the fibrous skeleton, ...) with their real sub-parts —
instead of draining into FMA's ~40-branch coronary arterial tree. It emits the
line-Turtle subset fma_ttl::parse already hydrates; the generic hydrate_fma walk
is unchanged (the partonomy IS the key, derived, not hardcoded to "heart").

The fixture's "four myocardia all share one Cardiac-muscle-tissue type" was an
invention — real FMA gives region-specific myocardium classes. Rewrite the
dual-membership proof to pick the strongest real cross-cutter in the slice (the
ceiling type that is the is-a target of the most structures) and its deepest
member, instead of a hardcoded label that no longer exists. On the real data it
surfaces "Cavity proper of inflow part of right atrium" at a 4-tier-deep part-of
address (HEEL[01:01] HIP[02:06] TWIG[03:01] LEAF[04:01]), is-a "Subdivision of
cavity of cardiac chamber" — a global type shared by 7 cavity structures across
all four chambers. The dual membership is now proven on real anatomy.

Verified:
- byte-deterministic bake (re-run -> identical fma.soa; 6603 bytes, 125 nodes
  = 80 part-of + 45 ceiling types, 156 edges)
- fma_ttl unit tests pass; clippy clean on the bake (the 3 -D warnings are the
  pre-existing aiwar-ingest lib dep, not these files)
- cockpit FmaGraph.tsx doc updated to the real cross-cutting example; tsc clean
- isolated to the osint-bake leaf crate + cockpit vite app; nothing in the
  quarto-core / pampa / wasm chain is touched

The 266 MB OWL is NOT committed; the production hydrator remains the spine's
lance_graph_ontology::hydrate_fma over the full fma.owl.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TzqvDqbFRzyx17EkLKBoZF
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f875bab1-3b26-4bb1-ae67-ba610ecc6c93

📥 Commits

Reviewing files that changed from the base of the PR and between 1e83f07 and 0851e26.

📒 Files selected for processing (6)
  • cockpit/public/fma.soa
  • cockpit/src/FmaGraph.tsx
  • crates/osint-bake/data/fma-heart.fixture.ttl
  • crates/osint-bake/data/fma-heart.ttl
  • crates/osint-bake/src/bin/fma.rs
  • crates/osint-bake/tools/extract_fma_heart.py

📝 Walkthrough

Walkthrough

Removes the hand-authored fma-heart.fixture.ttl and adds a new Python streaming extraction tool (extract_fma_heart.py) that produces fma-heart.ttl from fma.owl. Updates fma.rs to hydrate from the new TTL and replaces the hard-coded dual-membership proof selection with a dynamic algorithm. Updates a related comment in FmaGraph.tsx.

Changes

FMA Heart Extraction and Dual-Membership Proof Update

Layer / File(s) Summary
FMA heart extraction script
crates/osint-bake/tools/extract_fma_heart.py
New Python tool that streams fma.owl via iterparse, collects class labels, rdfs:subClassOf, and part-of relationships from owl:Restriction nodes, runs a BFS from FMA:Heart with depth/node/children caps, then emits bounded Turtle output with bfo:part_of and rdfs:subClassOf triples plus a stderr summary.
New extracted FMA heart TTL data
crates/osint-bake/data/fma-heart.ttl
Adds the generated fma-heart.ttl (166 lines) with provenance header comments, bfo:part_of assertions for anatomical heart components, and rdfs:subClassOf hierarchy triples for cavities, valves, walls, endocardium/epicardium/myocardium, and septa. The old fma-heart.fixture.ttl (53 lines) is fully removed.
fma.rs: hydration switch and generalized proof selection
crates/osint-bake/src/bin/fma.rs, cockpit/src/FmaGraph.tsx
Updates FMA_TTL to include fma-heart.ttl; replaces the hard-coded LV myocardium label lookup with dynamic tier_depth computation, REL_IS_A grouping by ceiling type, most-sharers selection (deterministic tie-break by label), deepest-anchor selection (tie-break by label), and a sorted "shared by" member list in output. Updates the corresponding inline comment example in FmaGraph.tsx.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AdaWorldAPI/q2#47: Introduces the FMA dual-membership pipeline in fma.rs and FmaGraph.tsx that this PR directly extends by switching the TTL source and generalizing the proof selection.
  • AdaWorldAPI/q2#48: Updates fma.rs dual-membership proof logic to use 8:8 HHTL tier addressing, which the generalized tier-depth selection in this PR builds upon.
  • AdaWorldAPI/q2#50: Also removes fma-heart.fixture.ttl and adds fma-heart.ttl with extracted content, directly overlapping with the data file changes in this PR.

Poem

🐇 A fixture is gone, a real heart takes its place,
BFS through chambers at a bounding pace.
No hard-coded myocardium, the anchor is found
By tier depth and sharers—on firmer ground.
The cross-cutter chosen, its members all sorted,
The FMA truth now properly reported! 🫀

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI AdaWorldAPI merged commit 81a0d3d into main Jun 24, 2026
3 of 4 checks passed
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.

2 participants