diff --git a/pom.xml b/pom.xml index 4135e2a..f6f5b04 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ 0.10.4 - 0.8.1 + 0.8.2 0.10.5 0.2.7 diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/DeepSliceHelper.java b/src/main/java/ch/epfl/biop/atlas/aligner/DeepSliceHelper.java index 18fcb7b..aeaac36 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/DeepSliceHelper.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/DeepSliceHelper.java @@ -8,36 +8,31 @@ import java.io.File; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; public class DeepSliceHelper { + final private static List atlasNameMouseCompatible = new ArrayList<>(); + final private static List atlasNameRatCompatible = new ArrayList<>(); + + public synchronized static void addMouseCompatibleAtlas(String name) { + if(!atlasNameMouseCompatible.contains(name)) atlasNameMouseCompatible.add(name); + } + + public synchronized static void addRatCompatibleAtlas(String name) { + if(!atlasNameRatCompatible.contains(name)) atlasNameRatCompatible.add(name); + } + /** * @param atlasName either the BrainGlobe API name or the specific Java packaged Atlases * @return true if the DeepSlice mouse model will be compatible with this atlas */ public static boolean isDeepSliceMouseCompatible(String atlasName) { - switch (atlasName) { - case "example_mouse_100um": - case "allen_mouse_100um": - case "allen_mouse_50um": - case "allen_mouse_25um": - case "allen_mouse_10um": - case "kim_mouse_100um": - case "kim_mouse_50um": - case "kim_mouse_25um": - case "kim_mouse_10um": - case "osten_mouse_100um": - case "osten_mouse_50um": - case "osten_mouse_25um": - case "osten_mouse_10um": - case "Adult Mouse Brain - Allen Brain Atlas V3": - case "Adult Mouse Brain - Allen Brain Atlas V3p1": - return true; - } - return false; + return atlasNameMouseCompatible.contains(atlasName); } /** @@ -46,13 +41,7 @@ public static boolean isDeepSliceMouseCompatible(String atlasName) { * @return true if the DeepSlice mouse model will be compatible with this atlas */ public static boolean isDeepSliceRatCompatible(String atlasName) { - switch (atlasName) { - case "Rat - Waxholm Sprague Dawley V4": - case "Rat - Waxholm Sprague Dawley V4p2": - case "whs_sd_rat_39um": - return true; - } - return false; + return atlasNameRatCompatible.contains(atlasName); } public static File deepSliceLocalRunner(DeepSliceTaskSettings settings, File input_folder) { diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/command/ABBAForumHelpCommand.java b/src/main/java/ch/epfl/biop/atlas/aligner/command/ABBAForumHelpCommand.java index aaba5cd..24c70f4 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/command/ABBAForumHelpCommand.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/command/ABBAForumHelpCommand.java @@ -6,7 +6,10 @@ import ch.epfl.biop.atlas.aligner.ABBAHelper; import ch.epfl.biop.bdv.img.bioformats.BioFormatsHelper; import ch.epfl.biop.sourceandconverter.register.Elastix2DSplineRegister; +import ch.epfl.biop.wrappers.deepslice.DeepSlice; +import ch.epfl.biop.wrappers.elastix.Elastix; import ch.epfl.biop.wrappers.elastix.ElastixTask; +import ch.epfl.biop.wrappers.transformix.Transformix; import ij.IJ; import net.imagej.ImageJ; import net.imagej.updater.UpdateService; @@ -19,7 +22,10 @@ import org.scijava.util.VersionUtils; import sc.fiji.bdvpg.services.SourceAndConverterServices; +import java.io.File; import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Map; @SuppressWarnings("unused") @Plugin(type = Command.class, @@ -33,18 +39,29 @@ public class ABBAForumHelpCommand implements Command { @Parameter UpdateService us; + public static String pythonInformation = ""; + @Override public void run() { try { - Map sites = AvailableSites.getAvailableSites(); StringBuilder sites_string = new StringBuilder(); + if (pythonInformation.isEmpty()) { + Map sites = AvailableSites.getAvailableSites(); + try { + for (UpdateSite site : sites.values()) { + if (us.getUpdateSite(site.getName()).isActive()) { + sites_string.append(site.getName()).append("+"); + } + } + } catch (Exception e) { + sites_string.append("Could not get installed update sites."); + } + } else { + sites_string.append("Can't collect update sites with ABBA run from Python"); + } - sites.values().stream() - .filter(site -> us.getUpdateSite(site.getName()).isActive()) - .forEach(site -> sites_string.append(site.getName()+"+")); - - String nl = "%0D%0A"; // new line in url get + String nl = "\n"; String imageScForumUrl = "https://forum.image.sc/"; String title = "Help for ABBA in Fiji: [your question here]"; String body = "[Detail your issue here]"+nl; @@ -54,6 +71,11 @@ public void run() { body += "OS and Dependencies Info"+nl; body +="```"+nl; body +="OS "+ System.getProperty("os.name")+nl; + if (!pythonInformation.isEmpty()) { + body += pythonInformation+nl; + } else { + body += "Not run from PyImageJ"+nl; + } body +="ImageJ "+ VersionUtils.getVersion(ImageJ.class)+nl; body +="IJ "+ VersionUtils.getVersion(IJ.class)+nl; body +="ABBA "+ VersionUtils.getVersion(ABBAHelper.class)+nl; @@ -64,13 +86,29 @@ public void run() { body +="Bdv Playground "+VersionUtils.getVersion(SourceAndConverterServices.class)+nl; body +="Biop Image Loader "+VersionUtils.getVersion(BioFormatsHelper.class)+nl; body +="Biop Wrappers "+VersionUtils.getVersion(ElastixTask.class)+nl; + if (Elastix.exePath!=null) { + body += "Elastix Path: " + Elastix.exePath + " exists ?"+new File(Elastix.exePath).exists()+nl; + } else { + body += "Elastix path not set"+nl; + } + if (Transformix.exePath!=null) { + body += "Transformix Path: " + Transformix.exePath + " exists ?"+new File(Transformix.exePath).exists()+nl; + } else { + body += "Transformix path not set"+nl; + } + if (DeepSlice.envDirPath!=null) { + body += "Deepslice env dir: " + DeepSlice.envDirPath + " exists ?"+new File(DeepSlice.envDirPath).exists()+nl; + } else { + body += "Deepslice env dir not set"+nl; + } + //noinspection deprecation body +="Updates sites: "+sites_string+nl; body +="```"; String fullUrl = imageScForumUrl+"new-topic?" +"title="+title+"&" - +"body="+body+"&" + +"body="+formatStringForUrl(body)+"&" +"category=usage-issues&" +"tags=fiji,abba"; @@ -81,4 +119,14 @@ public void run() { e.printStackTrace(); } } + + public static String formatStringForUrl(String input) { + try { + // Encode the input string using UTF-8 + return URLEncoder.encode(input, StandardCharsets.UTF_8.toString()); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } } diff --git a/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java b/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java index 946b932..eaabf20 100644 --- a/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java +++ b/src/main/java/ch/epfl/biop/atlas/aligner/gui/bdv/BdvMultislicePositionerView.java @@ -390,6 +390,11 @@ private void installBdvMenu(int hierarchyLevelsSkipped) { if (this.mode == POSITIONING_MODE_INT) msp.equalSpacingSelectedSlices(); }); + DeepSliceHelper.addMouseCompatibleAtlas("Adult Mouse Brain - Allen Brain Atlas V3"); + DeepSliceHelper.addMouseCompatibleAtlas("Adult Mouse Brain - Allen Brain Atlas V3p1"); + DeepSliceHelper.addRatCompatibleAtlas("Rat - Waxholm Sprague Dawley V4"); + DeepSliceHelper.addRatCompatibleAtlas("Rat - Waxholm Sprague Dawley V4p2"); + if (DeepSliceHelper.isDeepSliceMouseCompatible(msp.getReslicedAtlas().ba.getName())) { logger.debug("Installing DeepSlice Command for Mouse");