一、分析 H&E 图像的细胞数目
步骤概览
-
新建 QuPath 项目,导入 H&E 图像(
.svs,.qptiff,.tif等)。 -
设置 Color Deconvolution Stains(默认 H&E)。
-
Analyze → Preprocessing → Estimate stain vectors或手动选择预设 “H&E”。
-
-
安装 StarDist 扩展,准备好模型(如
he_heavy_augment.pb)。 -
运行检测脚本(下面给出模板)。
-
查看细胞数目:左侧 Hierarchy → Detections 标签,右下角会显示计数;或通过测量表导出。
可直接运行的脚本(H&E)
import qupath.ext.stardist.StarDist2D
// Specify the model file (you will need to change this!)
def pathModel = 'D:/QuPath-0.7.0/model/he_heavy_augment.pb' //下载地址:https://github.com/qupath/models/tree/main/stardist
def stardist = StarDist2D.builder(pathModel)
.threshold(0.5) // Prediction threshold
.normalizePercentiles(1, 99) // Percentile normalization
.pixelSize(0.5) // Resolution for detection
.build()
// Run detection for the selected objects
def imageData = getCurrentImageData()
def pathObjects = getSelectedObjects()
if (pathObjects.isEmpty()) {
Dialogs.showErrorMessage("StarDist", "Please select a parent object!")
return
}
stardist.detectObjects(imageData, pathObjects)
println 'Done!'
二、分析荧光图像的细胞数目
步骤概览
-
新建 QuPath 项目,导入荧光图像(
.czi,.nd2,.tif等)。 -
确认通道名:在 Image → Channels 里看到
DAPI,FITC等。 -
准备单通道模型(如
dsb2018_heavy_augment.pb)。 -
运行检测脚本(下面给出模板)。
-
统计并导出细胞数目。
可直接运行的脚本(荧光)
import qupath.ext.stardist.StarDist2D
import qupath.opencv.ops.ImageOps
def pathModel = 'D:/QuPath-0.7.0/model/dsb2018_heavy_augment.pb' //下载地址:https://github.com/qupath/models/tree/main/stardist
// 自动提取第一个通道(假设是核染色)
def stardist = StarDist2D.builder(pathModel)
.preprocess(
ImageOps.Channels.extract(0) // 取第一个通道
)
.threshold(0.5)
.normalizePercentiles(1, 99)
.pixelSize(0.5)
.build()
def imageData = getCurrentImageData()
def pathObjects = getSelectedObjects()
if (pathObjects.isEmpty()) {
Dialogs.showErrorMessage("StarDist", "Please select a parent object!")
return
}
stardist.detectObjects(imageData, pathObjects)
println 'Done!'




