Skip to content

Commit

Permalink
Reflect modifications in OMEROBatchPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed Nov 4, 2023
1 parent 383f64b commit 2f18650
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ An ImageJ plugin to run a script on a batch of images from/to OMERO.

1. Install the [OMERO.insight plugin](https://omero-guides.readthedocs.io/en/latest/fiji/docs/installation.html) (if you
haven't already).
2. Download the JAR file for this [library](https://github.com/GReD-Clermont/simple-omero-client/releases/tag/5.12.1/).
3. Download the JAR file ([for this plugin](https://github.com/GReD-Clermont/omero_batch-plugin/releases/tag/1.0.5/)).
2. Download the JAR file for this [library](https://github.com/GReD-Clermont/simple-omero-client/releases/tag/5.16.0/).
3. Download the JAR file ([for this plugin](https://github.com/GReD-Clermont/omero_batch-plugin/releases/tag/2.0.0/)).
4. Place these JAR files in your "plugins" folder.

## How to use
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/igred/ij/gui/OMEROConnectDialog.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 MICA & GReD
* Copyright (C) 2021-2023 MICA & GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fr/igred/ij/io/OMEROBatchImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public ImagePlus getImagePlus(ROIMode mode) {
imp = imageWrapper.toImagePlus(client);
// Store image "annotate" permissions as a property in the ImagePlus object
imp.setProp("Annotatable", String.valueOf(imageWrapper.canAnnotate()));
loadROIs(imp, mode);
if (imp != null) {
loadROIs(imp, mode);
}
} catch (ExecutionException | ServiceException | AccessException e) {
LOGGER.severe("Could not load image: " + e.getMessage());
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/fr/igred/ij/macro/OMEROBatchRunner.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 MICA & GReD
* Copyright (C) 2021-2023 MICA & GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -97,6 +97,7 @@ public class OMEROBatchRunner extends Thread {

private BatchListener listener;


public OMEROBatchRunner(ScriptRunner script, List<BatchImage> images, Client client) {
this(script, images, client, new ProgressLog(LOGGER));
}
Expand Down Expand Up @@ -139,7 +140,7 @@ private static String removeExtension(String title) {
} else {
String afterExt = TITLE_AFTER_EXT.matcher(title.substring(index + 1)).replaceAll("$1");
String beforeExt = title.substring(0, index);
if(beforeExt.toLowerCase().endsWith(".ome") && beforeExt.lastIndexOf('.') > 0) {
if (beforeExt.toLowerCase().endsWith(".ome") && beforeExt.lastIndexOf('.') > 0) {
beforeExt = beforeExt.substring(0, beforeExt.lastIndexOf('.'));
}
return afterExt.isEmpty() ? beforeExt : beforeExt + "_" + afterExt;
Expand Down
58 changes: 33 additions & 25 deletions src/main/java/fr/igred/ij/plugin/frame/OMEROBatchPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 MICA & GReD
* Copyright (C) 2021-2023 MICA & GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
Expand All @@ -18,6 +18,7 @@

import fr.igred.ij.gui.OMEROConnectDialog;
import fr.igred.ij.gui.ProgressDialog;
import fr.igred.ij.io.BatchImage;
import fr.igred.ij.macro.BatchListener;
import fr.igred.ij.macro.OMEROBatchRunner;
import fr.igred.ij.macro.ScriptRunner;
Expand Down Expand Up @@ -58,6 +59,8 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static fr.igred.ij.io.LocalBatchImage.listImages;
import static fr.igred.ij.io.OMEROBatchImage.listImages;
import static javax.swing.JOptionPane.showMessageDialog;

/**
Expand Down Expand Up @@ -920,43 +923,48 @@ private void previewDataset() {
*/
public void start(ActionEvent e) {
ProgressDialog progress = new ProgressDialog();
OMEROBatchRunner runner = new OMEROBatchRunner(script, client, progress);
runner.setListener(this);
OMEROBatchRunner runner;

// initiation of success variables
// initialization of success variables
boolean checkInput;
boolean checkMacro = getMacro();
boolean checkOutput = getOutput();

// input data
if (omero.isSelected()) {
runner.setInputOnOMERO(true);
int index = datasetListIn.getSelectedIndex();
DatasetWrapper dataset = datasets.get(index);
long inputDatasetId = dataset.getId();
runner.setInputDatasetId(inputDatasetId);
List<BatchImage> images;
long inputDatasetId = -1L;
try {
if (omero.isSelected()) {
int index = datasetListIn.getSelectedIndex();
DatasetWrapper dataset = datasets.get(index);
inputDatasetId = dataset.getId();
List<ImageWrapper> imageWrappers = dataset.getImages(client);
images = listImages(client, imageWrappers);
checkInput = true;
} else { // local.isSelected()
checkInput = getLocalInput();
images = listImages(directoryIn, recursive.isSelected());
}
runner = new OMEROBatchRunner(script, images, client, progress);
runner.setOutputDatasetId(inputDatasetId);
checkInput = true;
} else { // local.isSelected()
runner.setInputOnOMERO(false);
checkInput = getLocalInput();
runner.setDirectoryIn(directoryIn);
runner.setRecursive(recursive.isSelected());
runner.setListener(this);

runner.setSuffix(suffix.getText());
runner.setLoadROIS(checkLoadROIs.isSelected());
runner.setClearROIS(checkDelROIs.isSelected());
runner.setSaveImage(checkImage.isSelected());
runner.setSaveResults(checkResults.isSelected());
runner.setSaveROIs(checkROIs.isSelected());
runner.setSaveLog(checkLog.isSelected());
} catch (ServiceException | AccessException | ExecutionException | IOException exception) {
IJ.error(exception.getMessage());
return;
}

if (!checkInput || !checkMacro || !checkOutput) {
return;
}

// suffix
runner.setSuffix(suffix.getText());

runner.setLoadROIS(checkLoadROIs.isSelected());
runner.setClearROIS(checkDelROIs.isSelected());
runner.setSaveImage(checkImage.isSelected());
runner.setSaveResults(checkResults.isSelected());
runner.setSaveROIs(checkROIs.isSelected());
runner.setSaveLog(checkLog.isSelected());
if (onlineOutput.isSelected()) {
runner.setOutputOnOMERO(true);
if (checkResults.isSelected()) {
Expand Down

0 comments on commit 2f18650

Please sign in to comment.