Skip to content

Add midplane z-slice to TestCase and thread through runner - #2

Closed
trisha-ant wants to merge 1 commit into
trisha/gently-remove-confidencefrom
trisha/gently-zslice-harness
Closed

Add midplane z-slice to TestCase and thread through runner#2
trisha-ant wants to merge 1 commit into
trisha/gently-remove-confidencefrom
trisha/gently-zslice-harness

Conversation

@trisha-ant

Copy link
Copy Markdown
Owner

Stacked on #1.

Why

Max-intensity projections collapse depth: overlapping body segments fuse into one bright band, destroying the discriminative feature for fold stages — how many times the body folds back on itself. The fold-stage accuracy gap (1.5fold 55–65%, 2fold 58–77%) is the primary bottleneck. To let a perception variant count discrete body-segment cross-sections at one plane, the harness needs to expose a non-projected z-slice alongside the projection.

This is the harness half of the z-slice subagent work — no perception logic here, just plumbing.

What

  • benchmark/testset.py
    • New _create_slice_image(volume, z=None, max_dim=800) — renders one XY slice (defaults to z=Z//2), uses the same crop as the three-view projection so framing matches, returns base64 JPEG.
    • TestCase gains a midplane_b64 field; iter_embryo populates it.
    • Collapsed the duplicated load-volumes-or-not branch into one path.
  • run.py
    • _accepted_optional_kwargs(perceive_fn) introspects the perception function's signature once and passes midplane_b64 only if the function declares it (or **kwargs). All 15 existing variants get an empty extra-kwargs set, so they're called exactly as before — zero churn to existing variants.
  • program.md × 2 — document the optional kwarg.

4 files, +69 / −9.

Verification

  • _create_slice_image produces valid JPEG (ffd8ff); default is byte-identical to z=Z//2; negative/over-range z clamps to boundaries; Z=1 volumes and the resize-to-800px path handled.
  • All 15 registered variants → _accepted_optional_kwargs(...) == set() (no breakage).
  • iter_embryo populates midplane_b64 in both load_volumes={True,False} modes (mocked volume loader).
  • End-to-end run_variant delivers the kwarg as JPEG b64 when declared, omits it cleanly (no TypeError) when not.
  • python run.py --help exits 0; all modules import cleanly.
  • Pyright: 22→24, the 2 new warnings are PIL_Image lazy-import instances inside _create_slice_image — same pattern as the 7 pre-existing instances in the file; no other deltas.

…l kwarg

Max-intensity projections collapse depth, so overlapping body segments
fuse into one band — the key discriminative feature for fold stages is
lost. This is the harness half of the z-slice subagent work: expose a
single non-projected XY slice (z=Z//2) so a perception variant can
count discrete body-segment profiles at one plane.

- testset.py: new _create_slice_image() helper (same crop as the
  three-view projection); TestCase gains midplane_b64; iter_embryo
  populates it. Also collapses the duplicated load-volumes-or-not
  branch into one path.
- run.py: introspect perceive_fn signature once and only pass
  midplane_b64 when the function declares it (or **kwargs), so all
  existing variants are called unchanged.
- program.md: document the new optional kwarg.
@trisha-ant

Copy link
Copy Markdown
Owner Author

Subsumed into #5 — all commits are in that branch and the retrospective there covers this variant.

@trisha-ant trisha-ant closed this Apr 28, 2026
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