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

Add pixel size warning and minor linting #76

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/qupath/ext/instanseg/core/InstanSeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,16 @@ private InstanSegResults runInstanSeg(ImageData<BufferedImage> imageData, Collec
String layoutOutput = "CHW";

// Get the downsample - this may be specified by the user, or determined from the model spec
if (!imageData.getServerMetadata().pixelSizeCalibrated()) {
logger.warn("Running InstanSeg without pixel calibration --- results may not be as expected!");
}
double downsample;
if (this.downsample > 0) {
downsample = this.downsample;
logger.debug("Calling InstanSeg with user-specified downsample {}", downsample);
} else if (!imageData.getServerMetadata().pixelSizeCalibrated()) {
downsample = 1.0;
logger.debug("No pixel calibration - defaulting to a downsample of 1.0");
} else {
downsample = this.model.getPreferredDownsample(imageData.getServer().getPixelCalibration());
logger.debug("Calling InstanSeg with calculated downsample {}", downsample);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class InstanSegController extends BorderPane {
private List<InstanSegModel> remoteModels;

// Listener for property changes in the current ImageData; these can be required to update the input channels
private PropertyChangeListener imageDataPropertyChangeListener = this::handleImageDataPropertyChange;
private final PropertyChangeListener imageDataPropertyChangeListener = this::handleImageDataPropertyChange;

/**
* Create an instance of the InstanSeg GUI pane.
Expand Down Expand Up @@ -715,6 +715,9 @@ private void runInstanSeg(InstanSegModel model) {
Dialogs.showErrorNotification(resources.getString("title"), resources.getString("error.no-imagedata"));
return;
}
if (!imageData.getServerMetadata().pixelSizeCalibrated()) {
Dialogs.showWarningNotification(resources.getString("title"), resources.getString("error.no-pixel-size"));
}

if (!PytorchManager.hasPyTorchEngine()) {
if (!Dialogs.showConfirmDialog(resources.getString("title"), resources.getString("ui.pytorch"))) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/qupath/ext/instanseg/ui/InstanSegUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
class InstanSegUtils {

private InstanSegUtils() {
// Prevent instantiation
throw new UnsupportedOperationException("This class should not be instantiated.");
}

private static ObjectBinding<Path> modelDirectoryBinding = Bindings.createObjectBinding(
private static final ObjectBinding<Path> modelDirectoryBinding = Bindings.createObjectBinding(
() -> tryToGetPath(InstanSegPreferences.modelDirectoryProperty().get()),
InstanSegPreferences.modelDirectoryProperty()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ ui.prefs.permit-online.description = Allow QuPath to check for new InstanSeg mod
## Errors
error.window = Error initializing InstanSeg window.\nAn internet connection is required when running for the first time.
error.no-imagedata = Cannot run InstanSeg without an image available.
error.no-pixel-size = Pixel size is not set in this image! Results may be inaccurate.
error.downloading = Error downloading files
error.querying-local = Error querying local files
error.localModel = Can't find file in user model directory
Expand Down
Loading