From 4aea00b3dcee3390260e94957c229b2896c9bc4e Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Tue, 6 Aug 2024 11:45:53 +0100 Subject: [PATCH] Set current image data (#41) --- .../java/qupath/ext/instanseg/core/InstanSeg.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/qupath/ext/instanseg/core/InstanSeg.java b/src/main/java/qupath/ext/instanseg/core/InstanSeg.java index a38f261..16af52e 100644 --- a/src/main/java/qupath/ext/instanseg/core/InstanSeg.java +++ b/src/main/java/qupath/ext/instanseg/core/InstanSeg.java @@ -11,6 +11,7 @@ import qupath.lib.objects.PathObject; import qupath.lib.plugins.TaskRunner; import qupath.lib.plugins.TaskRunnerUtils; +import qupath.lib.scripting.QP; import java.awt.image.BufferedImage; import java.io.IOException; @@ -158,6 +159,16 @@ public Builder imageData(ImageData imageData) { return this; } + /** + * Set the imageData to be used as the current image data. + * @return A modified builder + */ + public Builder currentImageData() { + this.imageData = QP.getCurrentImageData(); + return this; + } + + /** * Set the channels to be used in inference * @param channels A collection of channels to be used in inference @@ -369,10 +380,10 @@ public Builder outputAnnotations() { */ public InstanSeg build() { if (imageData == null) { - throw new IllegalStateException("imageData cannot be null!"); + // assignment is just to suppress IDE suggestion for void return + var tmp = currentImageData(); } if (channels == null) { - // assignment is just to suppress IDE suggestion for void return var tmp = allChannels(); } if (outputClasses == null) {