Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix channel selector when duplicate channels present (resolve #11) #13

Merged
merged 9 commits into from
Apr 25, 2024
26 changes: 26 additions & 0 deletions src/main/java/qupath/ext/instanseg/core/InstanSegUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package qupath.ext.instanseg.core;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import java.nio.file.Files;
import java.nio.file.Path;

public class InstanSegUtils {
private static final Logger logger = LoggerFactory.getLogger(InstanSegUtils.class);

private InstanSegUtils() {
throw new AssertionError("Do not instantiate this class");
}

public static boolean isValidModel(Path path) {
// return path.toString().endsWith(".pt"); // if just looking at pt files
if (Files.isDirectory(path)) {
return Files.exists(path.resolve("instanseg.pt")) && Files.exists(path.resolve("rdf.yaml"));
}
return false;
}

}
34 changes: 34 additions & 0 deletions src/main/java/qupath/ext/instanseg/ui/ChannelSelectItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package qupath.ext.instanseg.ui;

import qupath.lib.images.servers.ColorTransforms;

/**
* Super simple class to deal with channel selection dropdown items that have different display and selection names.
* e.g., the first channel in non-RGB images is shown as "Channel 1 (C1)" but the actual name is "Channel 1".
*/
class ChannelSelectItem {
private final String name;
private final ColorTransforms.ColorTransform transform;
ChannelSelectItem(String name) {
this.name = name;
this.transform = ColorTransforms.createChannelExtractor(name);
}

ChannelSelectItem(String name, ColorTransforms.ColorTransform transform) {
this.name = name;
this.transform = transform;
}

@Override
public String toString() {
return this.name;
}

public String getName() {
return name;
}

public ColorTransforms.ColorTransform getTransform() {
return transform;
}
}
Loading
Loading