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
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.
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)
- nbdev_export
- nbdev_test
- nbdev_clean
- nbdev_readme
- nbdev_preview