Skip to content

docs: more insight from the same compute in eight tutorials - #11

Merged
Mr-Milk merged 11 commits into
mainfrom
docs/tutorial-insights
Oct 6, 2026
Merged

Mr-Milk merged 11 commits into
mainfrom
docs/tutorial-insights

Conversation

@Mr-Milk

@Mr-Milk Mr-Milk commented Oct 6, 2026

Copy link
Copy Markdown
Member

PR D of the tutorial plan: each tutorial shows more of what it already computes, at about the same render cost.

  • zero-shot-learning: prompt templates and the x100 logit scale that CLIP-style models use. The slide call goes from 0.41 / 0.29 / 0.30 to 1.00 / 0.00 / 0.00 for lung carcinoma, in line with Prism further down. The planned per-tile maps and zero-shot tissue typing were dropped: every tile came out at about 1.0, and the tissue typing missed the tumor regions.
  • cell-segmentation: cell counts per type (log scale, since 91% are cancer cells) and a cells-per-tile density map of the region. The region's tile table is renumbered after subset_tiles, the same workaround as in gene_expression_prediction, because lazyslide's tile plot reads values by row label.
  • survival_prediction: 5-fold stratified cross-validation for both models, with scaling fit inside each fold. Coxnet scores 0.42 ± 0.19 and the Cox MLP 0.62 ± 0.17, and the text treats this as a demonstration, not as evidence. Also fixes the SLURM and download snippets.
  • build_tile_model: the validation loop reset its metrics on every batch, so the reported accuracy covered only the last batch (0.7621, against 0.7692 over all tiles). It now reports balanced accuracy and macro F1 over all batches and adds a confusion matrix.
  • virtual_staining: zooms into the 512 px block with the highest predicted CK and shows the H&E next to CK, CD3 and CD8.
  • preprocessing: classic and deep-learning tissue masks side by side, and the four lowest- and four highest-scoring QC tiles.
  • visualization: tiles colored by spatial domains of their ResNet-50 features (7 domains at resolution 1.0; the plan's 0.2 gave a single domain). The GitHub-style tip becomes a MyST tip block.
  • image_generation: conditions CytoSyn on three tiles picked by KMeans on their H0-mini features, and shows each next to the image generated from it.

Checks

  • Each notebook ran end to end locally with no errors. The numbers above come from those runs (image_generation on CPU, as in CI).
  • ruff 0.11.12 format and check pass on all eight, and the notebook JSON is canonical.
  • Rebased onto main's latest render (25093e9). This render should execute only these eight notebooks; the other five come from main's cache.
  • Render time: image_generation's conditional cell now makes 3 images instead of 2, a few minutes more on CI and well under the 30-min cell limit. The other notebooks add seconds.

Found along the way, not fixed here

  • lazyslide zs.pl.tiles: a categorical with unused categories raises KeyError, and a view that lacks some categories can get the wrong legend colors.
  • CytoSyn fails on Apple MPS because its scheduler uses float64. CI runs on CPU and is not affected.

Mr-Milk added 10 commits October 6, 2026 21:09
Softmax over raw cosine similarities made the classes look nearly equal (0.41 / 0.29 / 0.30). CLIP-style models scale the similarity by about 100 first. Also averages a few prompt phrasings per class.
A single 80/20 split left 10 test patients, so 0.64 vs 0.86 was noise. Scaling now happens inside each fold.
…e_model

Metrics were reset on every batch; Overall Accuracy was the balanced accuracy.
The sample slide has no tumor, and the block is the one with the highest predicted CK. Also says each panel has its own color scale and why some areas are black.
Review follow-ups: notes on overlapping tiles, color scales and domain labels; the unscaled feature copy moves to the loading cell; the snapshot_download snippet gets its import, the canonical repo id and a matching local_dir; Adam named correctly; typo fixes.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 19:10
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Mr-Milk
Mr-Milk merged commit ecfbde7 into main Oct 6, 2026
1 check 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