Skip to content

docs: add ADR 0021 on micrograph preview image ingestion and serving#232

Open
vredchenko wants to merge 2 commits into
mainfrom
docs/adr-0021-micrograph-image-serving
Open

docs: add ADR 0021 on micrograph preview image ingestion and serving#232
vredchenko wants to merge 2 commits into
mainfrom
docs/adr-0021-micrograph-image-serving

Conversation

@vredchenko

Copy link
Copy Markdown
Collaborator

Summary

Adds ADR 0021 — Micrograph Motion-Corrected Preview Image Ingestion and Serving (Status: Proposed).

The micrograph (exposure) leaf of the Atlas -> Grid Square -> Foil Hole -> Micrograph hierarchy has no image endpoint, so smartem-frontend's FoilholeDetail.tsx renders the most scientifically meaningful image as a grey placeholder. This is tracked as smartem-decisions #308.

Decision

  • Do not serve the stored high_res_path (the naive reading of #308): it is the raw multi-GB dose-fractionated movie stack — a 3D array PIL.Image.fromarray cannot encode, and loading it reproduces the atlas-page OOM. Unprocessed rows carry high_res_path = '.' (the agent's unset Path("")).
  • Ingest the motion-corrected artefacts cryoem-services already produces — a 2D motion-corrected .mrc and a ready downscaled .jpeg snapshot — carried through SmartEM's existing POST /micrographs/{uuid}/motion_correction/completed contract (additive, backward-compatible). SmartEM does not consume cryoem-services' spa.* Zocalo messages; this reuses a contract SmartEM already owns.
  • Serve via a new GET /micrographs/{uuid}/micrograph_image: JPEG-first (FileResponse, zero-render, structurally OOM-immune) -> MRC-fallback (existing _render_image_png, same x,y,w,h crop as atlas_image) -> 404.

Follow-ups (filed as issues)

This ADR re-scopes smartem-decisions #308 (serving endpoint, gated) and spawns two tracking issues: the schema-migration + contract-extension + consumer-persistence work, and a separate cryoem-services adapter coordination item.

Compatible with any resolution of the deferred frontend image-serving/zoom decision (smartem-frontend #111); no frontend change is required by the ADR.

The micrograph (exposure) leaf of the spatial hierarchy has no image
endpoint, so FoilholeDetail renders the most scientifically meaningful
image as a grey placeholder. Serving the stored high_res_path is wrong:
it is the raw multi-GB movie stack, which fails to encode as a 2D image
and reproduces the atlas-page OOM.

Record the decision to ingest the motion-corrected artefacts
cryoem-services already produces (2D MRC + downscaled JPEG snapshot),
carried through SmartEM's existing motion_correction/completed contract,
and serve them JPEG-first / MRC-fallback / 404 via a new
micrograph_image endpoint. This re-scopes smartem-decisions #308.
@github-actions github-actions Bot added the documentation Improvements or additions to project documentation label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to project documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant