mangia3/foveate

0

stars

16

commits

Python

primary language

Sep 8, 2026

updated

README

foveate

Research question: can saccadic/foveated sampling improve whole-slide pathology accuracy per unit compute compared with uniform patch sampling?

Phase 1 implements lazy WSI access, tissue masking, uniform grid sampling, reproducible patch budgets, JSON manifests, and a PyTorch/MONAI-compatible dataset. Phase 2 adds a uniform slide-classification baseline with configurable encoders, mean pooling, metrics, checkpointing, and compute accounting. Learned saccades are not implemented. Local development is CPU-only; GPU training will run remotely.

Structure

  • src/foveate/data/: readers, coordinates, masks, sampler, manifests, dataset
  • src/foveate/{models,training,evaluation}/: classifier, training, metrics, accounting
  • src/foveate/saccade/: reserved for the future sampling policy
  • scripts/: environment check, slide inspection, metadata, sampling, smoke training
  • tests/: synthetic/mock unittest suite; no pathology dataset required
  • docs/phase1_uniform_baseline.md: coordinate contract and research design
  • data/raw/, data/processed/: local data locations; raw data remains immutable
  • CODEX_PROGRESS.md, CODEX_RUN_SUMMARY.md: recovery log and implementation report

Commands (PowerShell, repository root)

Activate the existing Python 3.11 environment:

conda activate foveate
& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/check_environment.py

Phase 4D plotting uses Matplotlib 3.11.1, already installed locally and pinned in requirements-plotting.txt. When preparing the plotting dependency in another existing project environment, use its Python interpreter to install that file. The local interpreter command is:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' -m pip install -r requirements-plotting.txt

This supplements the existing Conda environment; it is not a complete environment lock. On PACE, use the Python interpreter of the configured remote environment.

Inspect an existing, OpenSlide-supported WSI:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/inspect_slide.py 'data/raw/slide.svs'

Create an unfiltered uniform baseline with an explicit per-slide budget:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/sample_uniform.py 'data/raw/slide.svs' --output outputs/uniform.json --level 0 --patch-size 256 256 --stride 256 256 --max-patches 128 --seed 42

Add --min-tissue-fraction 0.5 to filter candidates before budgeting, or --measure-tissue to record fractions without filtering. Omit --max-patches for all eligible patches. Both scripts support --help. Tissue masking requires a pyramid level fitting --mask-max-size (default 2048); oversized overviews fail explicitly. Existing manifests require --overwrite to replace.

Run all CPU tests, and enable library imports for your own scripts:

$env:PYTHONPATH = 'src'
& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' -m unittest discover -v

See the Phase 1 design for dataset usage, coordinate conventions, reproducibility and fair compute comparisons. Real WSI validation remains necessary before research experiments. See the Phase 2 classifier design for the metadata, model, metrics, budgets, and future policy interface. Phase 3 prepares the frozen Virchow2-compatible encoder contract, physical scale provenance, and embedding cache; see the Phase 3 foundation-encoder design. Phase 4A prepares the complete CAMELYON16 cohort inventory, integrity audit, resumable download workflow, and explicit training-only splits; see the Phase 4A cohort design. Phase 4B defines physical-scale uniform manifests for the primary 0.5 um/pixel experiment; see the Phase 4B manifest design. Phase 4C connects exact physical observations to pinned Virchow2, a resumable observation cache, and one-slide-per-task GPU orchestration; see the Phase 4C extraction workflow. Use scripts/extract_virchow_embeddings.py for Phase 4B manifests; the older extract_embeddings.py and example configs target earlier smoke workflows. Phase 4D freezes the training-only research split and evaluates cached uniform representations with a linear classifier, separate sampling/training seeds, provenance-checked resume, and explicit compute attribution; see the Phase 4D uniform baseline. Its production CLI is scripts/run_uniform_baseline.py; local structural validation uses scripts/validate_phase4d_local.py and the existing tiny caches.

For bounded, one-WSI-at-a-time extraction on Kaggle or Colab, see free-cloud execution and the thin launchers under notebooks/cloud/. They reuse Phase 4B/4C and require NVIDIA acceptance before CUDA streaming; cloud validation remains pending.

Resources

Data

CAMELYON16 is Foveate's current primary dataset. CAMELYON17 is not part of the primary experiment; its page is included as a related challenge/data resource.

Models

  • Virchow2: the frozen pathology foundation encoder used in the current Foveate pipeline.

MONAI / NVIDIA pathology resources

These provide medical-imaging and pathology implementation context; inclusion does not imply that their code was copied directly into Foveate.

Acknowledgments / Built With

Foveate builds on these software projects, listed separately from scientific references:

Contributors

mangia3

16 commits

mangia3/foveate

0

stars

16

commits

Python

primary language

Sep 8, 2026

updated

README

foveate

Research question: can saccadic/foveated sampling improve whole-slide pathology accuracy per unit compute compared with uniform patch sampling?

Phase 1 implements lazy WSI access, tissue masking, uniform grid sampling, reproducible patch budgets, JSON manifests, and a PyTorch/MONAI-compatible dataset. Phase 2 adds a uniform slide-classification baseline with configurable encoders, mean pooling, metrics, checkpointing, and compute accounting. Learned saccades are not implemented. Local development is CPU-only; GPU training will run remotely.

Structure

  • src/foveate/data/: readers, coordinates, masks, sampler, manifests, dataset
  • src/foveate/{models,training,evaluation}/: classifier, training, metrics, accounting
  • src/foveate/saccade/: reserved for the future sampling policy
  • scripts/: environment check, slide inspection, metadata, sampling, smoke training
  • tests/: synthetic/mock unittest suite; no pathology dataset required
  • docs/phase1_uniform_baseline.md: coordinate contract and research design
  • data/raw/, data/processed/: local data locations; raw data remains immutable
  • CODEX_PROGRESS.md, CODEX_RUN_SUMMARY.md: recovery log and implementation report

Commands (PowerShell, repository root)

Activate the existing Python 3.11 environment:

conda activate foveate
& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/check_environment.py

Phase 4D plotting uses Matplotlib 3.11.1, already installed locally and pinned in requirements-plotting.txt. When preparing the plotting dependency in another existing project environment, use its Python interpreter to install that file. The local interpreter command is:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' -m pip install -r requirements-plotting.txt

This supplements the existing Conda environment; it is not a complete environment lock. On PACE, use the Python interpreter of the configured remote environment.

Inspect an existing, OpenSlide-supported WSI:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/inspect_slide.py 'data/raw/slide.svs'

Create an unfiltered uniform baseline with an explicit per-slide budget:

& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' scripts/sample_uniform.py 'data/raw/slide.svs' --output outputs/uniform.json --level 0 --patch-size 256 256 --stride 256 256 --max-patches 128 --seed 42

Add --min-tissue-fraction 0.5 to filter candidates before budgeting, or --measure-tissue to record fractions without filtering. Omit --max-patches for all eligible patches. Both scripts support --help. Tissue masking requires a pyramid level fitting --mask-max-size (default 2048); oversized overviews fail explicitly. Existing manifests require --overwrite to replace.

Run all CPU tests, and enable library imports for your own scripts:

$env:PYTHONPATH = 'src'
& 'C:\Users\megaa\miniconda3\envs\foveate\python.exe' -m unittest discover -v

See the Phase 1 design for dataset usage, coordinate conventions, reproducibility and fair compute comparisons. Real WSI validation remains necessary before research experiments. See the Phase 2 classifier design for the metadata, model, metrics, budgets, and future policy interface. Phase 3 prepares the frozen Virchow2-compatible encoder contract, physical scale provenance, and embedding cache; see the Phase 3 foundation-encoder design. Phase 4A prepares the complete CAMELYON16 cohort inventory, integrity audit, resumable download workflow, and explicit training-only splits; see the Phase 4A cohort design. Phase 4B defines physical-scale uniform manifests for the primary 0.5 um/pixel experiment; see the Phase 4B manifest design. Phase 4C connects exact physical observations to pinned Virchow2, a resumable observation cache, and one-slide-per-task GPU orchestration; see the Phase 4C extraction workflow. Use scripts/extract_virchow_embeddings.py for Phase 4B manifests; the older extract_embeddings.py and example configs target earlier smoke workflows. Phase 4D freezes the training-only research split and evaluates cached uniform representations with a linear classifier, separate sampling/training seeds, provenance-checked resume, and explicit compute attribution; see the Phase 4D uniform baseline. Its production CLI is scripts/run_uniform_baseline.py; local structural validation uses scripts/validate_phase4d_local.py and the existing tiny caches.

For bounded, one-WSI-at-a-time extraction on Kaggle or Colab, see free-cloud execution and the thin launchers under notebooks/cloud/. They reuse Phase 4B/4C and require NVIDIA acceptance before CUDA streaming; cloud validation remains pending.

Resources

Data

CAMELYON16 is Foveate's current primary dataset. CAMELYON17 is not part of the primary experiment; its page is included as a related challenge/data resource.

Models

  • Virchow2: the frozen pathology foundation encoder used in the current Foveate pipeline.

MONAI / NVIDIA pathology resources

These provide medical-imaging and pathology implementation context; inclusion does not imply that their code was copied directly into Foveate.

Acknowledgments / Built With

Foveate builds on these software projects, listed separately from scientific references:

Contributors

mangia3

16 commits

Languages

Python

96.0%

Jupyter Notebook

3.6%