Skip to main content

pyhscore

CI PyPI version DOI

Install

First set up a new conda environment with some basic dependencies:

conda create -n pyhscore python pip ipykernel

Then activate the environment and install the package:

conda activate pyhscore
pip install pyhscore

How to use

Always ensure you are using an active environment where the package has been installed to. If you followed the suggested install instructions that can be done by running conda activate pyhscore.

from pyhscore import score

help(score.compute_pxlhscore)
Help on function compute_pxlhscore in module pyhscore.score:

compute_pxlhscore(hed_img, h_threshold=0.05, d_thresholds=[0.12, 0.24, 0.6], verbose=False)
    Computes the pixel H-score for a given HED (Hematoxylin and Eosin-DAB) stained image.

    The H-score is calculated based on the intensity of the DAB stain, which is
    indicative of the presence and quantity of a specific biomarker in IHC images.
    The function allows for automatic thresholding based on the distribution of staining intensities.
    Inspired by the implementation in Ram et al. 2021.

    Parameters:

    - hed_img (numpy.ndarray): The HED-stained image as a NumPy array of shape
        (height, width, channels).

    - h_threshold (str or float): Threshold for Hematoxylin intensity.
        If 'auto', the threshold is set to the mean intensity.

    - d_thresholds (str or list of floats): Thresholds for DAB intensity,
        defining negative, low, medium, and high intensity ranges.
        If 'auto', thresholds are set to the 90th, 94.95th, and 99.9th percentiles.

    - verbose (bool): If True, displays histograms of the distributions of
        Hematoxylin and DAB stain values, and images showing pixels classified
        as high, medium, low, and negative DAB stained.

    Returns:

    - pxlHscore (float): The pixel H-score, a weighted sum of pixels classified
        as having high, medium, or low DAB intensity,
        normalized by the total number of pixels considered.

Development

It is recommended to use the Dev Container provided with the repo (Miniconda with zsh enabled). Once within the container, pip install nbdev and pyhscore ".[dev]".

Ensure also that quarto is installed by doing nbdev_install_quarto.

If working with VS code, note that the nbdev jupyter clean-up hooks might not work properly, so make sure the git commit hooks are setup properly (https://nbdev.fast.ai/tutorials/pre_commit.html) or install the nbdev VS code extension.

Before commiting, ensure the following is run (either manually or via hooks/extensions)

  1. nbdev_export
  2. nbdev_test
  3. nbdev_clean
  4. nbdev_readme
  5. nbdev_preview

Release files for pyhscore 0.0.3

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

Source distribution (sdist)

Source distribution for pyhscore 0.0.3
File Size Uploaded
pyhscore-0.0.3.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyhscore 0.0.3
File Interpreter ABI Platform
pyhscore-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / pyhscore-0.0.3.tar.gz

Download URL pyhscore-0.0.3.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
94759e7230deff60eb34b774b425f8d8533a5cfb38351e58834a6e4b5566f601
BLAKE2b-256 checksum
How to use checksums
40d541c1a015e8997cdfdbe8821962821f314cbdb0daa9f0232a34cb7928c1e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / pyhscore-0.0.3-py3-none-any.whl

Download URL pyhscore-0.0.3-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f8d322fbd8c736988c53f702dda51bbb52f8e9ce47842a848226218fa412cac
BLAKE2b-256 checksum
How to use checksums
5b8ac503d84e414c9fe5b9daace982ad35087c9447aa45fa02c66c0689bd2bbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

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