HistomicsTK
raw JSON → 1.4.0 verified Fri May 01 auth: no python
HistomicsTK is a Python toolkit for histopathology image analysis, providing algorithms for segmentation, feature extraction, and classification of whole-slide images. Current version is 1.4.0, with a release cadence of approximately 2-3 months.
pip install histomicstk Common errors
error ModuleNotFoundError: No module named 'histomicstk' ↓
cause Package not installed or incorrect environment.
fix
Run: pip install histomicstk
error ModuleNotFoundError: No module named 'large_image' ↓
cause Optional dependency not installed for whole-slide image support.
fix
Run: pip install large-image or pip install histomicstk[all]
error ValueError: Haralick features require a 2-D image ↓
cause Input image has more than 2 dimensions (e.g., RGB).
fix
Convert to grayscale: from skimage.color import rgb2gray; gray = rgb2gray(image)
error AttributeError: module 'histomicstk.features' has no attribute 'compute_haralick_features' ↓
cause Old import path used or wrong version.
fix
Ensure you have v1.4.0+ and use correct import: from histomicstk.features import compute_haralick_features
Warnings
breaking In v1.4.0, Python 3.8 support was dropped. You must use Python >=3.9. ↓
fix Upgrade Python to 3.9+ or pin histomicstk to <1.4.0.
deprecated Direct import of submodules like histomicstk.features.haralick is deprecated. Use histomicstk.features instead. ↓
fix Update imports to use top-level module: from histomicstk.features import compute_haralick_features
gotcha compute_haralick_features expects float32 image in [0,1] range. Passing integer or unnormalized images yields incorrect results. ↓
fix Normalize image: image = image.astype(np.float32) / 255.0
gotcha Nuclear segmentation functions require stain normalization (e.g., Reinhard) before use. Skipping this step leads to poor segmentation. ↓
fix Use histomicstk.preprocessing.color_normalization.reinhard first.
Install
pip install histomicstk[all] Imports
- histomicstk wrong
import HistomicsTKcorrectimport histomicstk as htk - segmentation.nuclear_segmentation wrong
from histomicstk.segmentation.nuclei import nuclear_segmentationcorrectfrom histomicstk.segmentation import nuclear_segmentation - features.compute_haralick_features wrong
from histomicstk.features.haralick import compute_haralick_featurescorrectfrom histomicstk.features import compute_haralick_features
Quickstart
import histomicstk as htk
import numpy as np
# Load a sample image (replace with your own)
# For whole-slide images, use large_image
# Here we simulate a 2D grayscale image
image = np.random.rand(100, 100).astype(np.float32)
# Compute Haralick texture features
from histomicstk.features import compute_haralick_features
haralick = compute_haralick_features(image, return_labels=True)
print(haralick['Harmonic mean'])
# Nuclear segmentation (requires stain normalization first)
from histomicstk.segmentation import nuclear_segmentation
# nuclei_df, nuclei_im = nuclear_segmentation.nuclei_segmentation(image) # requires proper staining