From 1d90cc09611ae3bb935e0deb3cb6f44474381217 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Sun, 26 Feb 2023 21:51:56 +0100 Subject: [PATCH] Add "IMAGE_ID" property to ImagePlus, and checks for ImageJ version (#51) --- src/main/java/fr/igred/omero/repository/ImageWrapper.java | 3 +++ src/main/java/fr/igred/omero/roi/ROIWrapper.java | 3 ++- src/test/java/fr/igred/omero/repository/ImageTest.java | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/igred/omero/repository/ImageWrapper.java b/src/main/java/fr/igred/omero/repository/ImageWrapper.java index d7f9a57b..7fa6400f 100644 --- a/src/main/java/fr/igred/omero/repository/ImageWrapper.java +++ b/src/main/java/fr/igred/omero/repository/ImageWrapper.java @@ -719,6 +719,9 @@ public ImagePlus toImagePlus(Client client, pixels.destroyRawDataFacility(); } imp.setPosition(1); + if (IJ.getVersion().compareTo("1.53a") >= 0) { + imp.setProp("IMAGE_ID", getId()); + } return imp; } diff --git a/src/main/java/fr/igred/omero/roi/ROIWrapper.java b/src/main/java/fr/igred/omero/roi/ROIWrapper.java index e253a57d..12aec473 100644 --- a/src/main/java/fr/igred/omero/roi/ROIWrapper.java +++ b/src/main/java/fr/igred/omero/roi/ROIWrapper.java @@ -28,6 +28,7 @@ import fr.igred.omero.repository.ImageWrapper; import fr.igred.omero.repository.PixelsWrapper.Bounds; import fr.igred.omero.repository.PixelsWrapper.Coordinates; +import ij.IJ; import ij.gui.ShapeRoi; import omero.RString; import omero.gateway.model.AnnotationData; @@ -249,7 +250,7 @@ public static List toImageJ(List rois, String public static List toImageJ(Collection rois, String property, boolean groupRois) { property = checkProperty(property); final int maxGroups = 255; - groupRois = groupRois && rois.size() < maxGroups; + groupRois = groupRois && rois.size() < maxGroups && IJ.getVersion().compareTo("1.52t") >= 0; int nShapes = rois.stream().map(GenericObjectWrapper::asDataObject).mapToInt(ROIData::getShapeCount).sum(); diff --git a/src/test/java/fr/igred/omero/repository/ImageTest.java b/src/test/java/fr/igred/omero/repository/ImageTest.java index 10bcd94a..4a950e46 100644 --- a/src/test/java/fr/igred/omero/repository/ImageTest.java +++ b/src/test/java/fr/igred/omero/repository/ImageTest.java @@ -358,6 +358,7 @@ void testToImagePlus() throws Exception { ImageStatistics stats = difference.getStatistics(); assertEquals(0, (int) stats.max); + assertEquals(String.valueOf(IMAGE2.id), imp.getProp("IMAGE_ID")); }