Skip to main content

Histopathology Models and Workflows

Models on public data

This repository contains a set of models built on and for public datasets (PANDA, TCGA). Detailed instructions to on-board the datasets and run the models are provided on readthedocs.

Getting started

Setting up Python

For working on the histopathology folder, please create a separate Conda environment.

cd hi-ml-cpath
make env

You can then activate the environment via conda activate HimlHisto. Set VSCode to use this Conda environment, by choosing "Python: Select Interpreter" from the command palette.

If the dependencies need to be updated, please modify hi-ml-cpath/primary_deps.yml, and then run the script hi-ml-cpath/create_and_lock_environment.sh. This will create a full "locked" environment specification with pinned versions of all depdencies.

Setting up AzureML

In addition, please download an AzureML workspace configuration file for the workspace that you wish to use:

  • In the browser, navigate to the workspace in question
  • Click on the drop-down menu on upper right of the page, to the left of your account picture.
  • Select "Download config file".
  • Save that file into the the repository root.

Once that config file is in place, all Python runs that you start inside the hi-ml-cpath folder will automatically use this config file.

Running histopathology models

To test your setup, please execute in the hi-ml-cpath folder:

conda activate HimlHisto
python ../hi-ml/src/health_ml/runner.py --model health_cpath.TcgaCrckImageNetMIL  --cluster=training-nd24

This should start an AzureML job in the AzureML workspace that you configured above via config.json. You may need to adjust the name of the compute cluster (training-nd24 in the above example).

Conda environment

If you start your jobs in the hi-ml-cpath folder, they will automatically pick up the Conda environment file that is present in that folder. If you start your jobs in a different folder, you need to add the --conda_env option to point to the file <repo_root>/hi-ml-cpath/environment.yml.

Running histopathology tests

In the hi-ml-cpath folder, run

make call_pytest

Inside of VSCode, all tests in the repository should be picked up automatically. You can exclude the tests for the hi-ml and hi-ml-azure packages by modifying python.testing.pytestArgs in the VSCode .vscode/settings.json file.

Tests that require a GPU

The test pipeline for the histopathology folder contains a run of pytest on a machine with 2 GPUs. Only tests that are marked with the pytest mark gpu are executed on that GPU machine. Note that all tests that bear the gpu mark will also be executed when running on a CPU machine. You need to manually add a skipif flag for tests that are meant to exclusively run on GPU machines. This also helps to ensure that the test suite can pass when executed outside of the build agents.

  • Tests that run only on a CPU machine: Provide no pytest marks
def test_my_code() -> None:
    pass
  • Tests that run on both on a CPU and on a GPU machine: Add @pytest.mark.gpu
@pytest.mark.gpu
def test_my_code() -> None:
    pass
  • Tests that run only on a GPU machine:
from health_ml.utils.common_utils import is_gpu_available
no_gpu = not is_gpu_available()

@pytest.mark.skipif(no_gpu, reason="Test requires GPU")
@pytest.mark.gpu
def test_my_code() -> None:
    pass

Release files for hi-ml-cpath 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hi-ml-cpath 0.4.1
File Size Uploaded
hi-ml-cpath-0.4.1.tar.gz 114.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hi-ml-cpath 0.4.1
File Interpreter ABI Platform
hi_ml_cpath-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 256.6 kB

Release files / hi-ml-cpath-0.4.1.tar.gz

Download URL hi-ml-cpath-0.4.1.tar.gz
Size 114.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f88a0154be9df008e52b56c2cb41262e57c96a0b44ff4160c28e799858b557c0
BLAKE2b-256 checksum
How to use checksums
e5bfee008094e0c6429fc0e40d3577a9151a5866678165cc71fd2113ecac9287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.6

Release files / hi_ml_cpath-0.4.1-py3-none-any.whl

Download URL hi_ml_cpath-0.4.1-py3-none-any.whl
Size 141.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df12987d12a8c18f14c6a3cf09f7537cbf47fec9fb7cd405637b7ad45a2862fc
BLAKE2b-256 checksum
How to use checksums
94a74458a7bb3bb7f44c9b07739baed95ac408a75f25f6c2bc4c27592dd34e52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.6

Release history Release notifications | RSS feed

0.5.2

2 release files

0.4.3

2 release files

0.4.2

2 release files

This release

0.4.1 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.18

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page