Skip to content

Commit

Permalink
Improves ask for help command: allows for python to sneak in
Browse files Browse the repository at this point in the history
Allows to set DeepSlice supported atlases from Python
Updates bigdataviewer image loader to support unsigned int 32 bits
  • Loading branch information
NicoKiaru committed Sep 5, 2024
1 parent b6c8af8 commit 912b62d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 34 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

<!-- bdv playground related dependencies -->
<bigdataviewer-playground.version>0.10.4</bigdataviewer-playground.version>
<bigdataviewer-image-loaders.version>0.8.1</bigdataviewer-image-loaders.version>
<bigdataviewer-image-loaders.version>0.8.2</bigdataviewer-image-loaders.version>
<bigdataviewer-biop-tools.version>0.10.5</bigdataviewer-biop-tools.version>
<bigdataviewer-selector.version>0.2.7</bigdataviewer-selector.version>

Expand Down
41 changes: 15 additions & 26 deletions src/main/java/ch/epfl/biop/atlas/aligner/DeepSliceHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> atlasNameMouseCompatible = new ArrayList<>();
final private static List<String> 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);
}

/**
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -33,18 +39,29 @@ public class ABBAForumHelpCommand implements Command {
@Parameter
UpdateService us;

public static String pythonInformation = "";

@Override
public void run() {
try {
Map<String, UpdateSite> sites = AvailableSites.getAvailableSites();

StringBuilder sites_string = new StringBuilder();
if (pythonInformation.isEmpty()) {
Map<String, UpdateSite> 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;
Expand All @@ -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;
Expand All @@ -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";

Expand All @@ -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 "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 912b62d

Please sign in to comment.