Skip to main content

Compute H-scores in Python, including the canonical cell-based H-score and a pixel-wise implementation inspired by Ram et al. 2021.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhscore-0.0.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

pyhscore-0.0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pyhscore-0.0.2.tar.gz.

File metadata

  • Download URL: pyhscore-0.0.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for pyhscore-0.0.2.tar.gz
Algorithm Hash digest
SHA256 83d4e3c6e1748acbdc76242dc51002024ba7712576cd16db4fb80cde1dd0a2a1
MD5 3da785adb136b56734d969012d4fe4c7
BLAKE2b-256 de5b2ab7e358479220147919c48d1c873ea7adf62ed45bf2288a588072012892

See more details on using hashes here.

File details

Details for the file pyhscore-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyhscore-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for pyhscore-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a753bfc2f840278ca662ff3eed2b2e75519cee66ff80474c625e3603f6c742c1
MD5 d7b2be4f55dc768ac85124a166ac6217
BLAKE2b-256 47d7faf83b72a9ccf5f22782bce0164860d611cb0b1efee50da73953cbe6a98b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page