From 0bb8c1cbfdc201d8c629ff7228bbbe03d0f3f44f Mon Sep 17 00:00:00 2001 From: Pete Date: Wed, 4 Sep 2024 19:22:41 +0100 Subject: [PATCH] Fix pixel size/downsample inconsistency Introduced in https://github.com/qupath/qupath-extension-instanseg/pull/59 I forgot to rename the variable in the builder. --- .../ext/instanseg/core/DetectionMeasurer.java | 16 ++++++++++------ .../qupath/ext/instanseg/core/InstanSeg.java | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/qupath/ext/instanseg/core/DetectionMeasurer.java b/src/main/java/qupath/ext/instanseg/core/DetectionMeasurer.java index 55979f9..cfa0184 100644 --- a/src/main/java/qupath/ext/instanseg/core/DetectionMeasurer.java +++ b/src/main/java/qupath/ext/instanseg/core/DetectionMeasurer.java @@ -93,15 +93,19 @@ public static class Builder { .filter(m -> m != ObjectMeasurements.Measurements.VARIANCE) // Skip variance - we have standard deviation .toList(); private Collection shapeFeatures = Arrays.asList(ObjectMeasurements.ShapeFeatures.values()); - private double pixelSize; + private double downsample; /** - * Set the pixel size that measurements should be made at. - * @param pixelSize The pixel size that detections/annotations/etc were made at. + * Set the downsample that the measurer should use. + * The measurer is assumed to be short-lived and used for a single image, and so doesn't need to maintain a + * value related to pixel size. Therefore, it takes an explicit downsample to avoid any risk that the + * pixel-size-to-downsample calculation here wouldn't match that done during detection. + * + * @param downsample The downsample that detections/annotations/etc should be made at. * @return A modified builder. */ - public Builder pixelSize(double pixelSize) { - this.pixelSize = pixelSize; + public Builder downsample(double downsample) { + this.downsample = downsample; return this; } @@ -140,7 +144,7 @@ public Builder shapeFeatures(Collection shapeF * @return An immutable detection measurer. */ public DetectionMeasurer build() { - return new DetectionMeasurer(compartments, measurements, shapeFeatures, pixelSize); + return new DetectionMeasurer(compartments, measurements, shapeFeatures, downsample); } } } diff --git a/src/main/java/qupath/ext/instanseg/core/InstanSeg.java b/src/main/java/qupath/ext/instanseg/core/InstanSeg.java index 74d2945..360e089 100644 --- a/src/main/java/qupath/ext/instanseg/core/InstanSeg.java +++ b/src/main/java/qupath/ext/instanseg/core/InstanSeg.java @@ -126,7 +126,7 @@ public static Builder builder() { public void makeMeasurements(ImageData imageData, Collection detections) { double downsample = model.getPreferredDownsample(imageData.getServer().getPixelCalibration()); DetectionMeasurer.builder() - .pixelSize(downsample) + .downsample(downsample) .build() .makeMeasurements(imageData, detections); }