Skip to content

RodSizer improvements: calibration & raft-splitting fixes, batch comparison, richer stats, UX (supersedes #2) - #3

Open
aaturk2 wants to merge 10 commits into
Caesiumatic:mainfrom
aaturk2:rodsizer-improvements
Open

RodSizer improvements: calibration & raft-splitting fixes, batch comparison, richer stats, UX (supersedes #2)#3
aaturk2 wants to merge 10 commits into
Caesiumatic:mainfrom
aaturk2:rodsizer-improvements

Conversation

@aaturk2

@aaturk2 aaturk2 commented Aug 7, 2026

Copy link
Copy Markdown

Builds on #2 and supersedes it — this PR contains everything in #2 (the first three commits) plus seven further commits of bug fixes and features. Reviewing this one alone covers all of it; #2 can be closed.

Bug fixes (scientifically important)

  • Calibration upload race — on batch uploads, an image saved before its .dm3 partner never picked up the scale, so ~half of paired uploads silently fell back to an uncalibrated placeholder. Lookup now runs after the whole batch is on disk. (50ff705)
  • Side-by-side rod rafts measured as one particle — parallel rods touching along their length have no binary "neck", so the distance-transform watershed reported whole rafts as single giant particles (widths 3–5× the true rod width). New intensity-seam splitter re-thresholds the clump interior so the lighter contact seams drop out, seeds a watershed per rod core, and recurses on still-wide children; a width/shape guard rejects bogus cuts through single rods. Worst raft image went from 19 particles (9 fused monsters, widths to 175 nm) to 67 correctly separated rods, median width unchanged. (88e953c)

Features

  • Compare Batches page (/compare) — overlay normalized length/width/AR distributions of 2–4 folders with side-by-side extended statistics. (eb1ac43)
  • Richer statistics — median, D10/D90, CV%, and rod yield added to Excel exports, the aggregate API, and the folder analysis page. (eb1ac43)
  • Folder-analysis membership UX — green tick badge on gallery images that are part of the folder analysis; click to remove; inline save feedback instead of a blocked popup. (2869c30)

Fixes & polish

  • Results housekeeping — export temps self-delete after download; deleting a folder removes its cached results; a startup sweep purges orphaned results. (eb1ac43)
  • Two-step inline delete replacing native confirm() popups (blocked in embedded browser panes, which made delete appear to do nothing). (a09c571)
  • Overlay style — thicker detection boxes, dashed outlines for excluded particles, IDs shown by default and colour-coded by decade. (cfb6354)
  • Gallery — ~50% smaller thumbnails and scroll-position restore when returning from an image. (36860f1)

Notes for review

🤖 Generated with Claude Code

aaturk2 and others added 10 commits July 20, 2026 12:16
Nothing in the pipeline imports stardist or tensorflow, and they were the
main cause of slow (~5-10 min, ~1 GB) and failure-prone first-time setup.
Mac launcher no longer forces Python 3.11 (a TensorFlow constraint) and
now accepts any Python 3.10+; Windows launchers auto-detect 3.12/3.13.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-implements the column sorting (click header to toggle asc/desc with
arrow indicator) that existed in Arda's local copy, adapted to the new
XSS-safe textContent row rendering.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Unpinned installs meant each computer resolved different library
versions - a major source of machine-to-machine differences. Versions
pinned from the tested working environment (Python 3.12.5, macOS).
Launchers now target Python 3.10-3.12 to match the pinned numpy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Results housekeeping: Excel export temps now self-delete after
  download, deleting a folder removes its cached results, and a startup
  sweep purges results whose source upload no longer exists (freed
  362 MB / 541 files on first run).
- Statistics: new compute_summary_stats() adds median, D10/D90,
  CV% and rod yield (AR >= 1.5) to Excel exports, the folder aggregate
  API, and a Detailed Statistics table on the folder analysis page.
- New Compare Batches page (/compare): overlay normalized length /
  width / aspect-ratio distributions of 2-4 folders with side-by-side
  extended statistics; linked from the dashboard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Embedded browser panes (e.g. IDE previews) block native confirm()
dialogs, which made image and folder deletion silently do nothing.
First click arms the button ('Delete?' / 'Really delete?'), a second
click within 4s confirms; it disarms automatically otherwise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Calibration lookup ran inside the per-file save loop, so an image saved
before its .dm3 partner in the same batch never found it — the decision
was frozen into the queued background task. Lookup now happens after the
entire batch is on disk.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Parallel rods touching along their full length have no binary 'neck',
so the distance-transform watershed measured whole rafts as one giant
particle (widths 3-5x the true rod width). New split path:

- Estimate single-rod width from the narrowest substantial regions.
- Regions much wider than that (even convex ones that pass the solidity
  test) get split_clump_intensity: re-threshold the clump interior at a
  darker cutoff so the lighter contact seams drop out, leaving one core
  per rod; cores seed a watershed over the smoothed intensity.
- split_raft recurses on still-wide children with LOCAL contrast, which
  resolves rods much lighter than their raft neighbours.
- Accept a split only if most pieces are single-rod-width — rejects
  bogus cuts through single rods with internal diffraction bands.

Worst raft image: 19 particles (9 fused monsters, widths to 175 nm)
-> 67 particles, zero width outliers, median width unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 'Add to Folder Analysis' no longer flickers and no longer relies on a
  popup alert (blocked in embedded browsers, so saves looked like they
  did nothing): the button itself shows 'Added N particles' inline,
  with a stable width and inline error text on failure.
- Gallery cards now show a green tick badge on images whose selection
  is part of the folder analysis (backend reports in_analysis).
- Clicking the tick (twice, two-step confirm) removes that image's
  data from the folder analysis via a new DELETE endpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Box outlines thickened (base line ~2.3x) for visibility on dense rafts;
  excluded particles keep their orange dashed style.
- Particle IDs now show by default; button starts as 'Hide IDs'.
- ID numbers are color-coded by decade (0s yellow, 10s magenta, 20s
  green, 30s cyan, 40s red, 50s orange, 60s pink, 70s spring green,
  cycling) so a given ID is findable at a glance, restoring the scheme
  from the original pre-fork overlay renderer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Thumbnail grid tightened (min column 250->160px, image height
  200->110px, smaller gap and caption) so ~40-image folders show far
  more per screen with less scrolling.
- Returning from an image's analysis view restores the previous scroll
  position (saved to sessionStorage per folder on image open) instead
  of jumping back to the top of the folder.

Co-Authored-By: Claude Fable 5 <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