Commit 0a1cc28c authored by gonciarz's avatar gonciarz

Merge branch 'roiInputInIA' into develop

parents 142d3c35 ed95294f
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="MosaicSuite" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
package mosaic.ia;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
......@@ -8,14 +9,11 @@ import org.apache.log4j.Logger;
import org.scijava.vecmath.Point3d;
import fr.inria.optimization.cmaes.CMAEvolutionStrategy;
import ij.IJ;
import ij.ImagePlus;
import mosaic.ia.HypothesisTesting.TestResult;
import mosaic.ia.Potentials.Potential;
import mosaic.ia.Potentials.PotentialType;
import mosaic.ia.gui.DistributionsPlot;
import mosaic.ia.gui.EstimatedPotentialPlot;
import mosaic.ia.gui.PlotHistogram;
import mosaic.ia.gui.Utils;
import mosaic.utils.Debug;
import mosaic.utils.math.StatisticsUtils;
import mosaic.utils.math.StatisticsUtils.MinMaxMean;
......@@ -25,12 +23,17 @@ public class Analysis {
private Potential iPotential;
private DistanceCalculations iDistanceCalculations;
private double[] iContextQdDistancesGrid;
private double[] iContextQdPdf;
private double[] iNearestNeighborDistancesXtoY;
private double[] iNearestNeighborDistancesXtoYPdf;
private double[] iObservedModelFitPdPdf;
private List<CmaResult> iCmaResults;
private double[][] iBestPointsFound;
private double[] iBestFunctionValue;
private int iBestPointIndex = -1;
public void calcDist(double gridSize, double kernelWeightq, double kernelWeightp, float[][][] genMask, ImagePlus iImageX, ImagePlus iImageY) {
......@@ -51,12 +54,6 @@ public class Analysis {
StatisticsUtils.normalizePdf(iContextQdPdf, iContextQdDistancesGrid, false);
StatisticsUtils.normalizePdf(iNearestNeighborDistancesXtoYPdf, iContextQdDistancesGrid, false);
new DistributionsPlot(iContextQdDistancesGrid, iContextQdPdf, iNearestNeighborDistancesXtoYPdf).show();
PlotHistogram.plot("ObservedDistances", iNearestNeighborDistancesXtoY, getOptimBins(iNearestNeighborDistancesXtoY, 8, iNearestNeighborDistancesXtoY.length / 8));
double suggestedKernel = calcWekaWeights(iNearestNeighborDistancesXtoY);
IJ.showMessage("Suggested Kernel wt(p): " + suggestedKernel);
logger.debug("Suggested kernel wt(p)=" + suggestedKernel);
}
public static class CmaResult {
......@@ -76,10 +73,11 @@ public class Analysis {
}
}
public void cmaOptimization(List<CmaResult> aResultsOutput, int cmaReRunTimes, boolean aRepetitiveResults) {
public void cmaOptimization(int cmaReRunTimes, boolean aRepetitiveResults) {
final FitFunction fitfun = new FitFunction(iContextQdPdf, iContextQdDistancesGrid, iNearestNeighborDistancesXtoYPdf, iNearestNeighborDistancesXtoY, iPotential);
iBestPointsFound = new double[cmaReRunTimes][iPotential.numOfDimensions()];
double[] bestFunctionValue = new double[cmaReRunTimes];
iBestFunctionValue = new double[cmaReRunTimes];
iCmaResults = new ArrayList<CmaResult>();
double bestFitness = Double.MAX_VALUE;
boolean diffFitness = false;
......@@ -108,29 +106,27 @@ public class Analysis {
cma.setFitnessOfMeanX(fitfun.valueOf(cma.getMeanX()));
logCmaResultInfo(cma);
bestFunctionValue[cmaRunNumber] = cma.getBestFunctionValue();
if (bestFunctionValue[cmaRunNumber] < bestFitness) {
if (cmaRunNumber > 0 && bestFitness - bestFunctionValue[cmaRunNumber] > bestFunctionValue[cmaRunNumber] * 0.00001) {
iBestFunctionValue[cmaRunNumber] = cma.getBestFunctionValue();
if (iBestFunctionValue[cmaRunNumber] < bestFitness) {
if (cmaRunNumber > 0 && bestFitness - iBestFunctionValue[cmaRunNumber] > iBestFunctionValue[cmaRunNumber] * 0.00001) {
diffFitness = true;
}
bestFitness = bestFunctionValue[cmaRunNumber];
bestFitness = iBestFunctionValue[cmaRunNumber];
iBestPointIndex = cmaRunNumber;
}
iBestPointsFound[cmaRunNumber] = cma.getBestX();
addNewOutputResult(aResultsOutput, bestFunctionValue[cmaRunNumber], iBestPointsFound[cmaRunNumber]);
addNewOutputResult(iCmaResults, iBestFunctionValue[cmaRunNumber], iBestPointsFound[cmaRunNumber]);
}
logger.debug("Best Parameters Found:" + Debug.getString(iBestPointsFound[iBestPointIndex]) + " fit function value=" + bestFunctionValue[iBestPointIndex]);
logger.debug("Best Parameters Found:" + Debug.getString(iBestPointsFound[iBestPointIndex]) + " fit function value=" + iBestFunctionValue[iBestPointIndex]);
if (diffFitness) {
IJ.showMessage("Warning: Optimization returned different results for reruns. The results may not be accurate. Displaying the parameters and the plots corr. to best fitness.");
Utils.messageDialog("IA - CMA optimization", "Warning: Optimization returned different results for reruns. The results may not be accurate. Displaying the parameters and the plots corr. to best fitness.");
}
fitfun.l2Norm(iBestPointsFound[iBestPointIndex]); // to calc pgrid for best params
new EstimatedPotentialPlot(iContextQdDistancesGrid, iPotential, iBestPointsFound[iBestPointIndex], bestFunctionValue[iBestPointIndex]).show();
double[] observedModelFitPdPdf = fitfun.getObservedModelFitPdPdf() ;
StatisticsUtils.normalizePdf(observedModelFitPdPdf, iContextQdDistancesGrid, false);
new DistributionsPlot(iContextQdDistancesGrid, observedModelFitPdPdf, iContextQdPdf, iNearestNeighborDistancesXtoYPdf, iPotential, iBestPointsFound[iBestPointIndex], bestFunctionValue[iBestPointIndex]).show();
iObservedModelFitPdPdf = fitfun.getObservedModelFitPdPdf() ;
StatisticsUtils.normalizePdf(iObservedModelFitPdPdf, iContextQdDistancesGrid, false);
}
private void addNewOutputResult(List<CmaResult> aResultsOutput, double aBestFunctionValue, double[] aBestPointFound) {
......@@ -210,11 +206,11 @@ public class Analysis {
public TestResult hypothesisTesting(int monteCarloRunsForTest, double alpha) {
if (iBestPointsFound == null) {
IJ.showMessage("Error: Run estimation first");
Utils.messageDialog("IA - hypothesis testing", "Error: Run estimation first");
return null;
}
else if (iPotential.getType() == PotentialType.NONPARAM) {
IJ.showMessage("Hypothesis test is not applicable for Non Parametric potential \n since it does not have 'strength' parameter");
Utils.messageDialog("IA - hypothesis testing", "Hypothesis test is not applicable for Non Parametric potential \n since it does not have 'strength' parameter");
return null;
}
else {
......@@ -279,11 +275,45 @@ public class Analysis {
return iDistanceCalculations.getMaxXtoYdistance();
}
public double[] getDistances() {
public double[] getContextQdDistancesGrid() {
return iContextQdDistancesGrid;
}
public double[] getContextQdPdf() {
return iContextQdPdf;
}
public double[] getNearestNeighborDistancesXtoY() {
return iNearestNeighborDistancesXtoY;
}
public double[] getNearestNeighborDistancesXtoYPdf() {
return iNearestNeighborDistancesXtoYPdf;
}
public double[] getObservedModelFitPdPdf() {
return iObservedModelFitPdPdf;
}
/**
* @return best point coordinates found by CMA optimization
*/
public double[] getBestPointFound() {
return iBestPointsFound[iBestPointIndex];
}
/**
* @return best function value found by CMA optimization
*/
public double getBestFunctionValue() {
return iBestFunctionValue[iBestPointIndex];
}
public List<CmaResult> getCmaResults() {
return iCmaResults;
}
public void setPotentialType(Potential potentialType) {
this.iPotential = potentialType;
iPotential = potentialType;
}
}
......@@ -6,7 +6,7 @@ import java.util.ArrayList;
import org.apache.log4j.Logger;
import org.scijava.vecmath.Point3d;
import ij.IJ;
import mosaic.ia.gui.Utils;
import mosaic.utils.Debug;
import mosaic.utils.math.NearestNeighborTree;
import mosaic.utils.math.StatisticsUtils;
......@@ -84,7 +84,7 @@ public abstract class DistanceCalculations {
logger.debug("Number of points (X/Y): " + iParticlesX.length + " / " + iParticlesY.length);
logger.debug("min/max of x: " + aMinX + "/" + aMaxX + " y: " + aMinY + "/" + aMaxY + " z: " + aMinZ + "/" + aMaxZ);
if (iParticlesX.length == 0 || iParticlesY.length == 0) {
IJ.showMessage("Number discaverd (and filtered) particles cannot be 0 for further calculations.\nNumber of particles (x/y): " + iParticlesX.length + " " + iParticlesY.length);
Utils.messageDialog("IA - state density", "Number discaverd (and filtered) particles cannot be 0 for further calculations.\nNumber of particles (x/y): " + iParticlesX.length + " " + iParticlesY.length);
throw new RuntimeException("Not enough particles to perform calculations!");
}
......
......@@ -5,14 +5,13 @@ import java.io.File;
import java.util.Vector;
import org.scijava.vecmath.Point3d;
import org.supercsv.cellprocessor.ParseDouble;
import org.supercsv.cellprocessor.ift.CellProcessor;
import ij.IJ;
import ij.ImagePlus;
import ij.io.OpenDialog;
import ij.io.Opener;
import mosaic.ia.gui.Utils;
import mosaic.utils.io.csv.CSV;
import mosaic.utils.io.csv.CsvColumnConfig;
......@@ -75,7 +74,7 @@ public class FileUtils {
file = new File(aFileName);
}
if (!file.exists()) {
IJ.showMessage("There is no file [" + file.getName() + "]");
Utils.messageDialog("IA - open CSV file", "There is no file [" + file.getName() + "]");
return null;
}
......@@ -83,7 +82,7 @@ public class FileUtils {
CSV<Point3dCsvReadWrapper>csv = new CSV<Point3dCsvReadWrapper>(Point3dCsvReadWrapper.class);
int numOfCols = csv.setCSVPreferenceFromFile(file.getAbsolutePath());
if (numOfCols <= 1 || numOfCols > 3) {
IJ.showMessage("CSV file should have 2 or 3 columns of data with comma or semicolon delimieters and no header!");
Utils.messageDialog("IA - open CSV file", "CSV file should have 2 or 3 columns of data with comma or semicolon delimieters and no header!");
return null;
}
CsvColumnConfig ccc = numOfCols == 2
......@@ -91,7 +90,7 @@ public class FileUtils {
: Point3dCsvReadWrapper.getConfig3D();
final Vector<Point3dCsvReadWrapper> outdst = csv.Read(file.getAbsolutePath(), ccc, true);
if (outdst.isEmpty()) {
IJ.showMessage("Incorrect CSV file chosen [" + file.getName() + "]\nCSV file should have 2 or 3 columns of data with comma or semicolon delimieters and no header!\n");
Utils.messageDialog("IA - open CSV file", "Incorrect CSV file chosen [" + file.getName() + "]\nCSV file should have 2 or 3 columns of data with comma or semicolon delimieters and no header!\n");
return null;
}
......
......@@ -6,8 +6,8 @@ import java.util.Random;
import org.apache.log4j.Logger;
import ij.IJ;
import mosaic.ia.Potentials.Potential;
import mosaic.ia.gui.Utils;
class HypothesisTesting {
......@@ -58,7 +58,7 @@ class HypothesisTesting {
}
logger.debug(s);
IJ.showMessage(s);
Utils.messageDialog("IA - hypothesis testing result", s);
return new TestResult (
i,
......
package mosaic.ia.gui;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import org.apache.log4j.Logger;
import org.scijava.vecmath.Point3d;
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.WindowManager;
import ij.gui.Overlay;
import ij.gui.Roi;
import ij.macro.Interpreter;
import ij.measure.Calibration;
import ij.measure.ResultsTable;
import ij.plugin.Duplicator;
import ij.plugin.Macro_Runner;
import ij.plugin.frame.RoiManager;
import ij.process.ImageProcessor;
import mosaic.ia.Analysis;
import mosaic.ia.Analysis.CmaResult;
......@@ -28,7 +37,17 @@ import mosaic.ia.Potentials.PotentialType;
public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
private static final Logger logger = Logger.getLogger(InteractionAnalysisGui.class);
public static void main(String[] args) {
// new ImageJ();
ImagePlus image = IJ.openImage("/Users/gonciarz/4rois.tif");
image.show();
// OverlayCommands oc = new OverlayCommands();
// oc.run("to");
new InteractionAnalysisGui();
}
private Analysis iAnalysis;
private ImagePlus iImgX;
private ImagePlus iImgY;
......@@ -36,11 +55,13 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
private Point3d[] iCsvY;
private ImagePlus iMaskImg;
private List<Roi> iRoiData;
// Order must be same as declared in PotentialType enum
private static final String[] PotentialList = { "Step", "Hernquist", "Linear type 1", "Linear type 2", "Plummer", "Non-parametric" };
public InteractionAnalysisGui() {
super(PotentialList);
super(PotentialList);
}
@Override
......@@ -84,10 +105,10 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
resetMask();
}
}
private void testHypothesis() {
if (iAnalysis == null) {
IJ.showMessage("Error: Calculate distances first!");
Utils.messageDialog("IA - test hypothesis", "Error: Calculate distances first!");
return;
}
int monteCarloRunsForTest = Integer.parseInt(monteCarloRuns.getText());
......@@ -98,7 +119,7 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
private void estimatePotential() {
if (iAnalysis == null) {
IJ.showMessage("Error: Calculate distances first!");
Utils.messageDialog("IA - estimate potential", "Error: Calculate distances first!");
return;
}
int numOfSupportPointsValue = Integer.parseInt(numOfSupportPoints.getText());
......@@ -109,8 +130,8 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
int numReRuns = Integer.parseInt(reRuns.getText());
Potential potential = Potentials.createPotential(getPotential(), iAnalysis.getMinDistance(), iAnalysis.getMaxDistance(), numOfSupportPointsValue, smoothnessValue);
iAnalysis.setPotentialType(potential); // for the first time
List<CmaResult> results = new ArrayList<CmaResult>();
iAnalysis.cmaOptimization(results, numReRuns, false);
iAnalysis.cmaOptimization(numReRuns, false);
List<CmaResult> results = iAnalysis.getCmaResults();
mosaic.utils.Debug.print(results);
if (!Interpreter.batchMode) {
final ResultsTable rt = new ResultsTable();
......@@ -124,16 +145,21 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
}
rt.updateResults();
rt.show("Results");
new EstimatedPotentialPlot(iAnalysis.getContextQdDistancesGrid(), potential, iAnalysis.getBestPointFound(), iAnalysis.getBestFunctionValue()).show();
new DistributionsPlot(iAnalysis.getContextQdDistancesGrid(), iAnalysis.getObservedModelFitPdPdf(), iAnalysis.getContextQdPdf(), iAnalysis.getNearestNeighborDistancesXtoYPdf(), potential, iAnalysis.getBestPointFound(), iAnalysis.getBestFunctionValue()).show();
}
}
enum Tabs {IMG, COORD, ROI}
private void calculateDistances() {
double gridDelta = Double.parseDouble(gridSize.getText());
double qkernelWeight = Double.parseDouble(kernelWeightQ.getText());
double pkernelWeight = Double.parseDouble(kernelWeightP.getText());
float[][][] mask3d = iMaskImg != null ? imageTo3Darray(iMaskImg) : null;
if (isCoordinatesTab()) {
if (getTabType() == Tabs.COORD) {
// coordinates
double xmin = Double.parseDouble(xMin.getText());
double ymin = Double.parseDouble(yMin.getText());
......@@ -142,7 +168,7 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
double ymax = Double.parseDouble(yMax.getText());
double zmax = Double.parseDouble(zMax.getText());
if (xmax < xmin || ymax < ymin || zmax < zmin) {
IJ.showMessage("Error: boundary values are not correct");
Utils.messageDialog("IA - calculate distances", "Error: boundary values are not correct");
return;
}
......@@ -152,14 +178,14 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
iAnalysis.calcDist(gridDelta, qkernelWeight, pkernelWeight, mask3d, iCsvX, iCsvY, xmin, xmax, ymin, ymax, zmin, zmax);
}
else {
IJ.showMessage("Load X and Y coordinates first.");
Utils.messageDialog("IA - calculate distances", "Load X and Y coordinates first.");
}
}
else {
else if (getTabType() == Tabs.IMG) {
// image
if (iImgY != null && iImgX != null) {
if (!checkIfImagesAreSameSize()) {
IJ.showMessage("Error: Image sizes/scale/unit do not match");
Utils.messageDialog("IA - calculate distances", "Error: Image sizes/scale/unit do not match");
}
else {
iAnalysis = new Analysis();
......@@ -167,13 +193,127 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
}
}
else {
IJ.showMessage("Load X and Y images first.");
Utils.messageDialog("IA - calculate distances", "Load X and Y coordinates first.");
}
}
else if (getTabType() == Tabs.ROI) {
System.out.println("ROI:" + xRois.getSelectedValue() + " " + yRois.getSelectedValue());
if (xRois.getSelectedIndex() >= 0 && yRois.getSelectedIndex() >= 0 && !xRois.getSelectedValue().equals(yRois.getSelectedValue())) {
readSelectedRois();
// coordinates
double xmin = Double.parseDouble(xMin.getText());
double ymin = Double.parseDouble(yMin.getText());
double zmin = Double.parseDouble(zMin.getText());
double xmax = Double.parseDouble(xMax.getText());
double ymax = Double.parseDouble(yMax.getText());
double zmax = Double.parseDouble(zMax.getText());
if (xmax < xmin || ymax < ymin || zmax < zmin) {
Utils.messageDialog("IA - calculate distances", "Error: boundary values are not correct");
return;
}
System.out.println("X=" + iCsvX.length + " Y=" + iCsvY.length);
System.out.println("Boundary (x/y/z): " + xmin + " - " + xmax + "; " + ymin + " - " + ymax + "; " + zmin + " - " + zmax);
iAnalysis = new Analysis();
iAnalysis.calcDist(gridDelta, qkernelWeight, pkernelWeight, mask3d, iCsvX, iCsvY, xmin, xmax, ymin, ymax, zmin, zmax);
}
}
else {
throw new RuntimeException("Unknown tab chosen in IA GUI");
}
// Generate plots / info for a user
new DistributionsPlot(iAnalysis.getContextQdDistancesGrid(), iAnalysis.getContextQdPdf(), iAnalysis.getNearestNeighborDistancesXtoYPdf()).show();
Utils.plotHistogram("ObservedDistances", iAnalysis.getNearestNeighborDistancesXtoY(), Analysis.getOptimBins(iAnalysis.getNearestNeighborDistancesXtoY(), 8, iAnalysis.getNearestNeighborDistancesXtoY().length / 8));
double suggestedKernel = Analysis.calcWekaWeights(iAnalysis.getNearestNeighborDistancesXtoY());
Utils.messageDialog("IA - kernel", "Suggested Kernel wt(p): " + suggestedKernel);
logger.debug("Suggested kernel wt(p)=" + suggestedKernel);
}
@Override
public void roiInitChosen() {
ImagePlus imp = WindowManager.getCurrentImage();
if (imp != null) {
xRois.removeAll();
yRois.removeAll();
Set<String> types = new HashSet<>();
// Try get ROIs from overlay
Overlay overlay = imp.getOverlay();
if (overlay != null) {
iRoiData = new ArrayList<>();
for (int i=0; i< overlay.size(); ++i) {
types.add(overlay.get(i).getName());
iRoiData.add(overlay.get(i));
}
xRois.setListData(types.toArray(new String[] {}));
yRois.setListData(types.toArray(new String[] {}));
}
else {
// if overlay is empty then try from RoiManager
RoiManager rm = RoiManager.getInstance2();
if (rm != null) {
iRoiData = new ArrayList<>();
for (int i = 0; i < rm.getCount(); ++i) {
types.add(rm.getRoi(i).getName());
iRoiData.add(rm.getRoi(i));
}
xRois.setListData(types.toArray(new String[] {}));
yRois.setListData(types.toArray(new String[] {}));
}
}
}
}
/**
* Initialiez "LoadROI" tab with data provided by user
* @param rois map names of data sets and arrays of points
*/
public void initRoi(Map<String, Point3d[]> rois) {
ArrayList<String> names = new ArrayList<>();
iRoiData = new ArrayList<>();
for (Map.Entry<String, Point3d[]> e : rois.entrySet()) {
names.add(e.getKey());
for (Point3d p : e.getValue()) {
Roi r = new Roi(p.x, p.y, 1, 1);
r.setName(e.getKey());
iRoiData.add(r);
}
}
xRois.setListData(names.toArray(new String[] {}));
yRois.setListData(names.toArray(new String[] {}));
tabbedPane.setSelectedIndex(2);
}
public void readSelectedRois() {
List<Point3d> x = new ArrayList<Point3d>();
List<Point3d> y = new ArrayList<Point3d>();
for (int i = 0; i<iRoiData.size(); i++) {
Roi roi = iRoiData.get(i);
Rectangle bounds = roi.getBounds();
double xp = bounds.getCenterX();
double yp = bounds.getCenterY();
double zp = roi.getZPosition();
if (roi.getName().equals(xRois.getSelectedValue())) {
x.add(new Point3d(xp, yp, zp));
}
else if (roi.getName().equals(yRois.getSelectedValue())) {
y.add(new Point3d(xp, yp, zp));
}
}
iCsvX = x.toArray(new Point3d[] {});
iCsvY = y.toArray(new Point3d[] {});
setMinMaxCoordinates();
}
private boolean isCoordinatesTab() {
return tabbedPane.getSelectedIndex() == 1;
private Tabs getTabType() {
if (tabbedPane.getSelectedIndex() == 1) return Tabs.COORD;
else if (tabbedPane.getSelectedIndex() == 0) return Tabs.IMG;
else return Tabs.ROI;
}
private void setMinMaxCoordinates() {
......@@ -227,8 +367,8 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
}
private void generateMask() {
if (isCoordinatesTab()) {
IJ.showMessage("Cannot generate mask for coordinates. Load a mask instead.");
if (getTabType() != Tabs.IMG) {
Utils.messageDialog("IA - generate mask", "Cannot generate mask for coordinates. Load a mask instead.");
}
else if (iImgY != null) {
iMaskImg = new Duplicator().run(iImgY);
......@@ -238,18 +378,18 @@ public class InteractionAnalysisGui extends InteractionAnalysisGuiBase {
maskPane.setTitleAt(0, "Mask: <generated>");
}
else {
IJ.showMessage("Image Y is null: Cannot generate mask");
Utils.messageDialog("IA - generate mask", "Image Y is null: Cannot generate mask");
}
}
private boolean loadMask() {
ImagePlus tempMask = FileUtils.openImage();
if (tempMask == null) {
IJ.showMessage("Filetype not recognized");
Utils.messageDialog("IA - load mask", "Filetype not recognized");
return false;
}
else if (tempMask.getType() != ImagePlus.GRAY8) {
IJ.showMessage("ERROR: Loaded mask not 8 bit gray");
Utils.messageDialog("IA - load mask", "ERROR: Loaded mask not 8 bit gray");
return false;
}
...