Page MenuHomec4science

No OneTemporary

File Metadata

Created
Wed, Dec 18, 06:21
diff --git a/DeconvolutionLab2.config b/DeconvolutionLab2.config
index ec0766e..7e52e25 100644
--- a/DeconvolutionLab2.config
+++ b/DeconvolutionLab2.config
@@ -1,74 +1,87 @@
#DeconvolutionLab2
#DeconvolutionLab2
-#Fri Apr 21 13:03:50 CEST 2017
+#Mon Apr 24 10:39:24 CEST 2017
Algorithm.BVLS.iterations=10
Algorithm.BVLS.step=1.0
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=0.1
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
Algorithm.algorithm=Regularized Inverse Filter
-Border.apoxy=Uniform
+Border.apoxy=Hamming
Border.apoz=Uniform
-Border.extxy=0
+Border.extxy=4
Border.extz=0
Border.padxy=None
Border.padz=None
Computation.display=yes
Computation.epsilon=1E-6
Computation.fft=Fastest
Computation.multithreading=yes
Computation.normalization=1
Computation.system=yes
Controller.constraint=no
Controller.monitor=console table
Controller.reference.enable=false
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.value=0.01
Controller.stats=no
Controller.time.enable=false
Controller.time.value=3600
Controller.verbose=log
-DeconvolutionLab.MainDialog.location.h=511
-DeconvolutionLab.MainDialog.location.w=593
-DeconvolutionLab.MainDialog.location.x=108
-DeconvolutionLab.MainDialog.location.y=440
-Image.image.row0=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
-Image.image.selected=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
+DeconvolutionLab.DeconvolutionDialog.location.h=1009
+DeconvolutionLab.DeconvolutionDialog.location.w=600
+DeconvolutionLab.DeconvolutionDialog.location.x=0
+DeconvolutionLab.DeconvolutionDialog.location.y=23
+DeconvolutionLab.MainDialog.location.h=812
+DeconvolutionLab.MainDialog.location.w=577
+DeconvolutionLab.MainDialog.location.x=663
+DeconvolutionLab.MainDialog.location.y=66
+Image.image.row0=input-v2.tif;file;/Users/sage/Desktop/Deconvolution/data/microtubules2/input-v2.tif;\u232B
+Image.image.row1=CElegans-FITC.tif;file;/Users/sage/Desktop/Deconvolution/data/c-elegans/CElegans-FITC.tif;\u232B
+Image.image.row2=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
+Image.image.selected=input-v2.tif;file;/Users/sage/Desktop/Deconvolution/data/microtubules2/input-v2.tif;\u232B
Language.headless=Run (Headless)
Language.job=Job
Language.language=Command line
-PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
-PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
-Path.current=Current
-Path.path=/Users/sage/Desktop/worksmlm/deconvolution
+Output.output.row0=mip;MI1;;;;\u2713;\u2713;\u232B
+Output.output.selected=mip;MI1;;;;\u2713;\u2713;\u232B
+PSF.psf.row0=h.tif;file;/Users/sage/Desktop/Deconvolution/data/microtubules2/h.tif;\u232B
+PSF.psf.row1=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+PSF.psf.selected=h.tif;file;/Users/sage/Desktop/Deconvolution/data/microtubules2/h.tif;\u232B
+Path.current=Specify
+Path.path=/Users/sage/Desktop/test
Running.Directory=/Users/dsage/git/deconvolution
Running.Monitor=console table
Running.Path=current
Running.Verbose=log
+System.Frame.location.h=313
+System.Frame.location.w=640
+System.Frame.location.x=4
+System.Frame.location.y=438
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 47445e8..08e1d75 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,101 +1,99 @@
#DeconvolutionLab2
#DeconvolutionLab2
-#Mon Apr 24 13:08:32 CEST 2017
+#Fri Apr 28 15:00:20 CEST 2017
Algorithm.BVLS.iterations=10
Algorithm.BVLS.step=1.0
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.4642
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=1.000E-18
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
Algorithm.algorithm=Landweber
-Border.apoxy=Uniform
-Border.apoz=Uniform
-Border.extxy=0
-Border.extz=0
-Border.padxy=None
-Border.padz=None
-Computation.display=yes
-Computation.epsilon=1E-6
-Computation.fft=Fastest
-Computation.multithreading=yes
-Computation.normalization=1
-Computation.system=no
Controller.constraint=no
Controller.monitor=console table
Controller.reference.enable=true
Controller.reference.value=/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png
Controller.residu.enable=false
Controller.residu.value=0.01
Controller.stats=no
Controller.time.enable=false
Controller.time.value=1
Controller.verbose=log
-DeconvolutionLab.DeconvolutionDialog.location.h=400
-DeconvolutionLab.DeconvolutionDialog.location.w=600
-DeconvolutionLab.DeconvolutionDialog.location.x=0
-DeconvolutionLab.DeconvolutionDialog.location.y=23
DeconvolutionLab.MainDialog.location.h=774
DeconvolutionLab.MainDialog.location.w=507
-DeconvolutionLab.MainDialog.location.x=1248
-DeconvolutionLab.MainDialog.location.y=41
+DeconvolutionLab.MainDialog.location.x=65
+DeconvolutionLab.MainDialog.location.y=63
FFT.epsilon=1E-6
FFT.fft=Academic
+FFT.multithreading=yes
Image.image.row0=Cube;synthetic;Cube 50.0 1.0 size 300 128 300 intensity 255.0 ;\u232B
Image.image.row10=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
Image.image.row11=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row12=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row13=RandomLines;synthetic;RandomLines 100.0 size 128 128 32 intensity 255.0 ;\u232B
Image.image.row14=active;platform;active;\u232B
Image.image.row15=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row16=Applications;directory;/users/dsage/Applications;\u232B
Image.image.row17=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row18=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
Image.image.row1=Cube;synthetic;Cube 10.0 1.0 size 300 128 32 intensity 255.0 ;\u232B
Image.image.row2=workspace;directory;/Users/dsage/Desktop/workspace;\u232B
Image.image.row3=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 10.0 5.0 size 128 128 128 intensity 255.0 ;\u232B
Image.image.row4=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 8.0 16.0 size 128 128 32 intensity 255.0 ;\u232B
Image.image.row5=Cube of Spherical Beads;synthetic;Cube of Spherical Beads 3.0 0.5 8.0 8.0 size 128 128 128 intensity 255.0 ;\u232B
Image.image.row6=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row7=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
Image.image.row8=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row9=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.selected=Cube;synthetic;Cube 50.0 1.0 size 300 128 300 intensity 255.0 ;\u232B
+LabDialog.Algo=true
+LabDialog.Directory=false
+LabDialog.Image=false
+LabDialog.PSF=false
Language.headless=Run (Headless)
Language.job=Job
Language.language=Java
Output.output.row0=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
Output.output.selected=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
PSF.psf.row0=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
PSF.psf.row1=Sinc;synthetic;Sinc 3.0 3.0 3.0 size 100 128 200 intensity 255.0 ;null
PSF.psf.selected=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
Path.current=Current
+Path.display=true
Path.path=/Users/sage/Desktop/worksmlm/deconvolution/DeconvolutionLab2
+Path.system=true
+Preprocessing.apoxy=Uniform
+Preprocessing.apoz=Uniform
+Preprocessing.extxy=0
+Preprocessing.extz=0
+Preprocessing.normalization=1
+Preprocessing.padxy=None
+Preprocessing.padz=None
Running.Directory=/Users/dsage/git/deconvolution/DeconvolutionLab2
Running.Monitor=table
Running.Path=specify
Running.Verbose=quiet
diff --git a/DeconvolutionLab2/src/Test_Airy.java b/DeconvolutionLab2/src/Test_Airy.java
deleted file mode 100644
index eca5c82..0000000
--- a/DeconvolutionLab2/src/Test_Airy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-import ij.plugin.PlugIn;
-import signal.ComplexComponent;
-import signal.ComplexSignal;
-import signal.RealSignal;
-import deconvolutionlab.Lab;
-import deconvolutionlab.monitor.Monitors;
-import fft.AbstractFFT;
-import fft.FFT;
-
-
-public class Test_Airy implements PlugIn {
-
- @Override
- public void run(String arg0) {
- }
-
- public static void main(String arg[]) {
- new Test_Airy();
- }
-
- public Test_Airy() {
- int nx = 128;
- int ny = 128;
- int nz = 128;
- RealSignal otf = new RealSignal("psf", nx, ny, nz);
-
- int cx = nx/2;
- int cy = ny/2;
- int cz = nz/2;
- double p = 1.3;
- for(int i=0; i<nx; i++)
- for(int j=0; j<ny; j++) {
- double d = Math.sqrt((i-cx)*(i-cx) + (j-cy)*(j-cy));
- double v = (p-Math.exp(-d*0.1));
- for(int k=0; k<nx; k++) {
- double dz = ((double)Math.abs(k-cz))/nz;
- double g = Math.exp(-dz*dz*2*nx);
- double vz = g*v*Math.cos(d*Math.PI*2/nx);
- if (vz > 0) {
- double r = Math.sqrt((i-cx)*(i-cx) + (j-cy)*(j-cy) + (k-cz)*(k-cz));
- if (r < cx)
- otf.data[k][i+j*nx] = (float)vz; //(Math.exp(-r*0.1));
-
- }
- }
- }
- Lab.show(otf);
- Lab.showOrthoview(otf, "out", cx, cy, cz);
-
- float[] stats = otf.getStats();
- for(float s : stats)
- System.out.println("" + s);
-
- AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
- fft.init(Monitors.createDefaultMonitor(), nx, ny, nz);
- ComplexSignal psf = fft.transform(otf);
- float[] stats1 = psf.getModule().getStats();
- for(float s : stats1)
- System.out.println("PSF " + s);
- Lab.show(Monitors.createDefaultMonitor(), psf.getModule().circular(), "psf");
-
- }
-
-}
diff --git a/DeconvolutionLab2/src/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index fffa8c0..7262f4e 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,424 +1,424 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
+import ij.IJ;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Constants;
import deconvolutionlab.module.AbstractModule;
import deconvolutionlab.module.CommandModule;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.output.Output;
import deconvolutionlab.output.Output.View;
import fft.FFT;
import signal.Constraint;
import signal.Operations;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
import wavelets.Wavelets;
public class Command {
public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-system", "-stats", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft", "-epsilon" };
private static AbstractModule modules[];
private static CommandModule command;
public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
-
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
-
return cmd;
}
public static Controller decodeController(String command) {
Controller controller = new Controller();
ArrayList<Token> tokens = parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
controller.setPath(token.parameters);
if (token.keyword.equalsIgnoreCase("-monitor"))
controller.setMonitors(decodeMonitors(token.parameters));
if (token.keyword.equalsIgnoreCase("-verbose"))
controller.setVerbose(Verbose.getByName(token.parameters));
if (token.keyword.equalsIgnoreCase("-system"))
controller.setSystem(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-multithreading"))
controller.setMultithreading(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-display"))
controller.setDisplayFinal(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-stats"))
controller.setStats(decodeStats(token));
if (token.keyword.equalsIgnoreCase("-constraint"))
controller.setConstraint(decodeConstraint(token));
if (token.keyword.equalsIgnoreCase("-time"))
controller.setTimeLimit(decodeTimeLimit(token));
if (token.keyword.equalsIgnoreCase("-residu"))
controller.setResiduMin(decodeResidu(token));
if (token.keyword.equalsIgnoreCase("-reference"))
controller.setReference(token.parameters);
if (token.keyword.equalsIgnoreCase("-pad"))
controller.setPadding(decodePadding(token));
if (token.keyword.equalsIgnoreCase("-apo"))
controller.setApodization(decodeApodization(token));
if (token.keyword.equalsIgnoreCase("-norm"))
controller.setNormalizationPSF(decodeNormalization(token));
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equalsIgnoreCase("-fft"))
controller.setFFT(FFT.getLibraryByName(token.parameters).getDefaultFFT());
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equals("-out")) {
Output out = decodeOut(token);
if (out != null)
controller.addOutput(out);
}
}
return controller;
}
public static AbstractAlgorithm decodeAlgorithm(String command) {
AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
ArrayList<Token> tokens = parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-algorithm"))
algo = Command.decodeAlgorithm(token);
}
return algo;
}
/**
* This methods first segments the command line, then create all the tokens
* of the command line
*
* @param command
* Command line
* @return the list of tokens extracted from the command line
*/
public static ArrayList<Token> parse(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
ArrayList<Token> tokens = new ArrayList<Token>();
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
Token token = new Token(keyword, command, begin, end);
tokens.add(token);
}
return tokens;
}
public static Token extract(String command, String keyword) {
ArrayList<Token> tokens = parse(command);
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase(keyword))
return token;
return (Token) null;
}
public static double[] parseNumeric(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static ArrayList<CommandSegment> findSegment(String command, String keyword) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
String regex = "(?<!\\w)" + keyword + "(?!\\w)";
if (command == null)
return segments;
Matcher matcher = Pattern.compile(regex).matcher(command);
while (matcher.find()) {
segments.add(new CommandSegment(keyword, matcher.start()));
}
return segments;
}
public static String extractOptions(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
String options = "";
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
if (keyword != "-image" && keyword != "-psf" && keyword != "-algorithm")
options += keyword + " " + command.substring(begin, end);
}
return options;
}
public static AbstractAlgorithm decodeAlgorithm(Token token) {
String option = token.option;
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
double params[] = parseNumeric(token.parameters);
if (params != null) {
algo.setParameters(params);
}
if (algo.isWaveletsBased()) {
for (String wavelet : Wavelets.getWaveletsAsArray()) {
int pos = token.parameters.toLowerCase().indexOf(wavelet.toLowerCase());
if (pos >= 0)
algo.setWavelets(wavelet);
}
}
return algo;
}
public static Output decodeOut(Token token) {
int freq = 0;
String line = token.parameters;
String parts[] = token.parameters.split(" ");
for (int i = 0; i < Math.min(2, parts.length); i++) {
if (parts[i].startsWith("@"))
freq = (int) NumFormat.parseNumber(parts[i], 0);
}
String p = token.parameters.toLowerCase();
Output out = null;
if (p.startsWith("stack"))
out = new Output(View.STACK, freq, line.substring("stack".length(), line.length()));
if (p.startsWith("series"))
out = new Output(View.SERIES, freq, line.substring("series".length(), line.length()));
if (p.startsWith("mip"))
out = new Output(View.MIP, freq, line.substring("mip".length(), line.length()));
if (p.startsWith("ortho"))
out = new Output(View.ORTHO, freq, line.substring("ortho".length(), line.length()));
if (p.startsWith("figure"))
out = new Output(View.FIGURE, freq, line.substring("figure".length(), line.length()));
if (p.startsWith("planar"))
out = new Output(View.PLANAR, freq, line.substring("planar".length(), line.length()));
return out;
}
public static double decodeNormalization(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return 0;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static Stats decodeStats(Token token) {
String parts[] = token.parameters.toLowerCase().split(" ");
int m = 0;
for (String p : parts) {
if (p.startsWith("no") || p.equals("false") || p.equals("0"))
return new Stats(Stats.Mode.NO);
if (p.equals("1"))
return new Stats(Stats.Mode.SHOW);
if (p.equals("2"))
return new Stats(Stats.Mode.SAVE);
if (p.equals("3"))
return new Stats(Stats.Mode.SHOWSAVE);
if (p.equals("show"))
m += 1;
if (p.equals("save"))
m += 2;
}
if (m==1)
return new Stats(Stats.Mode.SHOW);
if (m==2)
return new Stats(Stats.Mode.SAVE);
if (m==3)
return new Stats(Stats.Mode.SHOWSAVE);
return new Stats(Stats.Mode.NO);
}
public static Constraint.Mode decodeConstraint(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("non"))
return Constraint.Mode.NONNEGATIVE;
if (p.startsWith("no"))
return Constraint.Mode.NO;
if (p.startsWith("clip"))
return Constraint.Mode.CLIPPED;
if (p.equals("0"))
return Constraint.Mode.NO;
return Constraint.Mode.NO;
}
public static double decodeResidu(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return -1;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static double decodeTimeLimit(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return -1;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
String param = token.parameters.trim();
String[] parts = param.split(" ");
if (parts.length > 0)
padXY = Padding.getByShortname(parts[0].trim());
if (parts.length > 1)
padZ = Padding.getByShortname(parts[1].trim());
double[] ext = NumFormat.parseNumbers(param);
int extXY = 0;
if (ext.length > 0)
extXY = (int) Math.round(ext[0]);
int extZ = 0;
if (ext.length > 1)
extZ = (int) Math.round(ext[1]);
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
public static Apodization decodeApodization(Token token) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
String[] parts = token.parameters.trim().split(" ");
if (parts.length >= 1)
apoXY = Apodization.getByShortname(parts[0].trim());
if (parts.length >= 2)
apoZ = Apodization.getByShortname(parts[1].trim());
return new Apodization(apoXY, apoXY, apoZ);
}
public static String getPath() {
command();
ArrayList<Token> tokens = parse(command.getCommand());
String path = System.getProperty("user.dir");
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
path = token.parameters;
return path;
}
public static Monitors decodeMonitors(String cmd) {
String parts[] = cmd.toLowerCase().split(" ");
Monitors monitors = new Monitors();
for (String p : parts) {
if (p.equals("0") || p.startsWith("no"))
monitors.clear();
if (p.equals("1") || p.startsWith("console"))
monitors.add(new ConsoleMonitor());
if (p.equals("2"))
monitors.add(new TableMonitor(Constants.widthGUI, 240));
if (p.equals("3")) {
monitors.add(new ConsoleMonitor());
monitors.add(new TableMonitor(Constants.widthGUI, 240));
}
if (p.equals("console"))
monitors.add(new ConsoleMonitor());
if (p.equals("table"))
monitors.add(new TableMonitor(Constants.widthGUI, 240));
}
return monitors;
}
public static boolean decodeBoolean(String cmd) {
String p = cmd.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
if (p.startsWith("dis"))
return false;
return true;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 5358ec9..08f08da 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,406 +1,420 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
+import ij.IJ;
+
import java.io.File;
import com.esotericsoftware.minlog.Log;
import bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.output.Output;
import signal.RealSignal;
import signal.SignalCollector;
/**
* This class is the main class to run deconvolution with or without user interface.
*
* All the parameters are given in the command line (String variable command).
*
* @author Daniel Sage
*
*/
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
private AbstractAlgorithm algo = null;
private Controller controller = new Controller();
private String command = "";
private Features report = new Features();
private String name = "";
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
private boolean embeddedStats = false;
public Deconvolution(String name, String command) {
this.name = name;
this.finish = Finish.DIE;
+IJ.log("Deconvolution, line 82 " + command);
+
setCommand(command);
+IJ.log("Deconvolution, line 84 " + command);
+
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
}
public void setCommand(String command) {
this.command = command;
controller = Command.decodeController(command);
algo = Command.decodeAlgorithm(command);
algo.setController(controller);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortnames()[0];
}
public RealSignal deconvolve() {
return deconvolve(image, psf);
}
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
Lab.setVisible(((TableMonitor)monitor).getPanel(), "Monitor of " + name, 10, 10);
if (controller.getFFT() == null) {
run();
return deconvolvedImage;
}
if (!controller.getFFT().isMultithreadable()) {
run();
return deconvolvedImage;
}
if (controller.isMultithreading()) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
return deconvolvedImage;
}
/**
* This method runs the deconvolution with a graphical user interface.
*/
public void launch() {
embeddedStats = true;
dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this);
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
Monitors monitors = controller.getMonitors();
report.add("Path", controller.toStringPath());
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
report.add("FFT", controller.getFFT().getName());
report.add("Algorithm", algo.getName());
if (embeddedStats) {
TableMonitor tableMonitor = null;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
tableMonitor = (TableMonitor)monitor;
if (controller.getStats().getMode() == Stats.Mode.SHOW || controller.getStats().getMode() == Stats.Mode.SHOWSAVE) {
controller.getStats().setEmbeddedInFrame(embeddedStats);
dialog.addStats(controller.getStats());
}
if (tableMonitor != null) {
dialog.addMonitor(tableMonitor);
}
}
algo.setController(controller);
deconvolvedImage = algo.run(image, psf);
report.add("End", NumFormat.time(System.nanoTime() - chrono));
if (finish == Finish.KILL) {
System.out.println("End");
System.exit(0);
}
if (finish == Finish.DIE)
die();
}
public void close() {
if (dialog != null)
dialog.dispose();
SignalCollector.free(image);
SignalCollector.free(psf);
SignalCollector.free(deconvolvedImage);
algo = null;
image = null;
psf = null;
deconvolvedImage = null;
System.gc();
}
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
Token image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
double norm = controller.getNormalizationPSF();
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReference());
features.add("Constraint", controller.getConstraintAsString());
features.add("Padding", controller.getPadding().toString());
features.add("Apodization", controller.getApodization().toString());
features.add("FFT", controller.getFFT() == null ? "null" : controller.getFFT().getName());
}
features.add("Path", controller.getPath());
String s = "[" + controller.getVerbose().name() + "] ";
for(AbstractMonitor monitor : controller.getMonitors())
s+= monitor.getName() + " ";
features.add("Monitor", s);
if (controller.getStats() != null)
features.add("Stats", controller.getStats().toStringStats());
features.add("Running", controller.toStringRunning());
for (Output out : controller.getOuts())
features.add("Output " + out.getName(), out.toString());
Log.info("Recap deconvolution parameters");
return features;
}
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
public void abort() {
algo.getController().abort();
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
+
if (token == null)
return null;
+
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
+
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
+
image = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
+IJ.log("Deconvolution, line 312 " + (image==null));
Log.info("Open image " + arg + " " + cmd);
+IJ.log("Deconvolution, line 314 " + (image==null));
return image;
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
psf = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
Log.info("Open PSF " + arg + " " + cmd);
return psf;
}
private static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
+IJ.log("Deconvolution, line 337 " + arg);
if (arg.equalsIgnoreCase("synthetic")) {
+IJ.log("Deconvolution, synthetic 337 " + arg);
signal = Lab.createSynthetic(monitors, cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = Lab.getImage(monitors, cmd);
}
if (arg.equalsIgnoreCase("file")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.openFile(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.openFile(monitors, cmd);
}
}
}
if (arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
}
return signal;
}
public void setAlgorithm(AbstractAlgorithm algo) {
this.algo = algo;
}
public AbstractAlgorithm getAlgorithm() {
return algo;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public RealSignal getOutput() {
return deconvolvedImage;
}
public RealSignal getImage() {
return image;
}
public RealSignal getPSF() {
return psf;
}
public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public String getCommand() {
return command;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index fd001aa..5db0496 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,532 +1,534 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bilib.tools.NumFormat;
import bilib.tools.WebBrowser;
import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
+import ij.IJ;
import imagej.IJImager;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.SignalFactory;
import signal.factory.Sphere;
/**
* This class contains a collection of useful static methods to manage all the
* peripherical aspects of the deconvolution, such as load, display, or save an
* image.
* <p>
* At the construction of the class, the config is loaded. In practice, any
* deconvolution program has to start with Lab.init(Platform).
*
* @author Daniel Sage
*
*/
public class Lab {
private static Imager imaging;
private static ArrayList<JFrame> frames;
private static ArrayList<JDialog> dialogs;
static {
frames = new ArrayList<JFrame>();
dialogs = new ArrayList<JDialog>();
imaging = new IJImager();
Config.init(System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
/**
* Initializes the Lab with a give platform.
*
* @param platform
* The platform is ImageJ, ICY, or Matlab.
*/
public static void init(Imager.Platform platform) {
init(platform, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
/**
* Initializes the Lab with a give platform and a given configuration file
*
* @param platform
* @param configFilename
*/
public static void init(Imager.Platform platform, String configFilename) {
switch (platform) {
case IMAGEJ:
imaging = new IJImager();
break;
case ICY:
imaging = new IcyImager();
break;
default:
imaging = new IJImager();
break;
}
Config.init(configFilename);
}
/**
* Returns the platform.
*
* @return
*/
public static Imager.Platform getPlatform() {
return imaging.getPlatform();
}
/**
* Open a web page on the DeconvolutionLab2.
*/
public static void help() {
WebBrowser.open(Constants.url);
}
/**
* Checks the installed FFT libraries on a small (40, 30, 20) signal.
*
* @param monitors
*/
public static void checkFFT(Monitors monitors) {
ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
for (AbstractFFTLibrary library : libraries) {
RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
double chrono = System.nanoTime();
AbstractFFT fft = library.getDefaultFFT();
fft.init(monitors, y.nx, y.ny, y.nz);
RealSignal x = fft.inverse(fft.transform(y));
chrono = System.nanoTime() - chrono;
double residu = y.getEnergy() - x.getEnergy();
monitors.log("\t residu of reconstruction: " + residu);
monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
}
}
public static ContainerImage createContainer(Monitors monitors, String title) {
monitors.log("Create Live Real Signal " + title);
return imaging.createContainer(title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title) {
imaging.append(container, signal, title, Imager.Type.FLOAT);
monitors.log("Add Live Real Signal " + title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imager.Type type) {
imaging.append(container, signal, title, type);
monitors.log("Add Live Real Signal " + title);
}
/**
* Displays a the module of complex signal.
*
* @param monitors
* @param signal
* @param title
*/
public static void show(Monitors monitors, ComplexSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, ComplexComponent.MODULE);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param signal
*/
public static void show(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param monitors
* @param signal
*/
public static void show(Monitors monitors, RealSignal signal) {
if (signal == null) {
monitors.error("This image does not exist.");
return;
}
monitors.log("Show Real Signal " + signal.name);
imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param monitors
* @param signal
* @param title
*/
public static void show(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images using a given type.
*
* @param monitors
* @param signal
* @param title
* @param type
*/
public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images using a given type and
* shows the slice number z.
*
* @param monitors
* @param signal
* @param title
* @param type
* @param z
*/
public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, z);
}
public static void save(Monitors monitors, RealSignal signal, String path, String name) {
save(monitors, signal, path + File.separator + name + ".tif", Imager.Type.FLOAT);
}
public static void save(Monitors monitors, RealSignal signal, String path, String name, Imager.Type type) {
save(monitors, signal, path + File.separator + name + ".tif", type);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
imaging.save(signal, filename, Imager.Type.FLOAT);
monitors.log("Save Real Signal " + filename);
}
public static void save(Monitors monitors, RealSignal signal, String filename, Imager.Type type) {
imaging.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
public static RealSignal createSynthetic(Monitors monitors, String cmd) {
+IJ.log("Lab, synthetic 337 " + cmd);
RealSignal signal = SignalFactory.createFromCommand(cmd);
if (signal == null)
monitors.error("Unable to create " + cmd);
else
monitors.log("Create " + cmd);
return signal;
}
/**
* Return the active image.
*
* @return
*/
public static RealSignal getImage() {
return getImager().getActiveImage();
}
/**
* Return an image from the platform with a specified name.
*
* @param name
* @return
*/
public static RealSignal getImage(String name) {
return getImager().getImageByName(name);
}
/**
* Return an image from the platform with a specified name.
*
* @param monitors
* @param name
* @return
*/
public static RealSignal getImage(Monitors monitors, String name) {
RealSignal signal = getImager().getImageByName(name);
if (signal == null)
monitors.error("Unable to get " + name);
else
monitors.log("Load " + name);
return signal;
}
/**
* Open an image from the disk.
*
* @param filename
* @return
*/
public static RealSignal openFile(String filename) {
return imaging.open(filename);
}
/**
* Open an image from the disk.
*
* @param monitors
* @param filename
* @return
*/
public static RealSignal openFile(Monitors monitors, String filename) {
RealSignal signal = imaging.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
/**
* Open a series of image from a directory.
*
* @param path
* @return
*/
public static RealSignal openDir(String path) {
return openDir(Monitors.createDefaultMonitor(), path);
}
/**
* Open a series of image from a directory.
*
* @param monitors
* @param path
* @return
*/
public static RealSignal openDir(Monitors monitors, String path) {
String parts[] = path.split(" pattern ");
String dirname = path;
String regex = "";
if (parts.length == 2) {
dirname = parts[0].trim();
regex = parts[1].trim();
}
File file = new File(dirname + File.separator);
if (!file.isDirectory()) {
monitors.error("Dir " + dirname + " is not a directory.");
return null;
}
String[] list = file.list();
ArrayList<RealSignal> slices = new ArrayList<RealSignal>();
int nx = 0;
int ny = 0;
Pattern pattern = Pattern.compile(regex);
for (String filename : list) {
if (pattern.matcher(filename).find()) {
RealSignal slice = imaging.open(dirname + File.separator + filename);
if (slice != null) {
slices.add(slice);
nx = Math.max(nx, slice.nx);
ny = Math.max(ny, slice.ny);
monitors.log("Image " + path + File.separator + filename + " is loaded.");
}
}
else {
monitors.error("Error in loading image " + path + File.separator + filename);
}
}
int nz = slices.size();
if (nz <= 0) {
monitors.error("Dir " + path + " do no contain valid images.");
return null;
}
RealSignal signal = new RealSignal(file.getName(), nx, ny, nz);
for (int z = 0; z < slices.size(); z++)
signal.setSlice(z, slices.get(z));
return signal;
}
public static void showOrthoview(RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
return;
}
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(RealSignal signal) {
if (signal == null) {
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
imaging.show(signal.createOrthoview(hx, hy, hz), signal.name, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showMIP(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal.createMIP(), signal.name, Imager.Type.FLOAT, 0);
}
public static void showMIP(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show MIP " + title + " this image does not exist.");
return;
}
imaging.show(signal.createMIP(), title, Imager.Type.FLOAT, 0);
}
public static void showPlanar(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal.createPlanar(), signal.name, Imager.Type.FLOAT, 0);
}
public static void showPlanar(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Planar " + title + " this image does not exist.");
return;
}
imaging.show(signal.createPlanar(), title, Imager.Type.FLOAT, 0);
}
/*
public static RealSignal create(Monitors monitors, String name) {
RealSignal signal = imaging.create(name);
if (signal != null)
monitors.log("Created the real signal " + name + " " + signal.toString());
else
monitors.error("Impossible to create the real signal " + name);
return signal;
}
public static RealSignal create(Monitors monitors) {
RealSignal signal = imaging.create();
if (signal != null)
monitors.log("Created the real signal from the active window " + signal.toString());
else
monitors.error("Impossible to create the real signal from the active window");
return signal;
}
*/
public static Imager getImager() {
return imaging;
}
public static String getActiveImage() {
if (imaging.isSelectable())
return imaging.getSelectedImage();
return "";
}
public static void setVisible(JDialog dialog, boolean modal) {
if (dialog == null)
return;
dialogs.add(dialog);
imaging.setVisible(dialog, modal);
}
public static void setVisible(JPanel panel, String name, int x, int y) {
JFrame frame = new JFrame(name);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocation(x, y);
frame.setVisible(true);
frames.add(frame);
}
public static void setVisible(JFrame frame) {
frames.add(frame);
frame.setVisible(true);
}
public static void close() {
for (JFrame frame : frames)
if (frame != null)
frame.dispose();
for (JDialog dialog : dialogs)
if (dialog != null)
dialog.dispose();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
index 16c604d..0018310 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
@@ -1,301 +1,310 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.PanelImage;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.dialog.BatchDialog;
import deconvolutionlab.module.AboutModule;
import deconvolutionlab.module.AbstractModule;
import deconvolutionlab.module.AlgorithmModule;
import deconvolutionlab.module.BatchModule;
-import deconvolutionlab.module.BorderModule;
import deconvolutionlab.module.CommandModule;
-import deconvolutionlab.module.ComputationModule;
import deconvolutionlab.module.ConfigModule;
import deconvolutionlab.module.ControllerModule;
import deconvolutionlab.module.DirectoryModule;
import deconvolutionlab.module.FFTModule;
import deconvolutionlab.module.GroupedModulePanel;
import deconvolutionlab.module.ImageModule;
import deconvolutionlab.module.LanguageModule;
import deconvolutionlab.module.LicenceModule;
import deconvolutionlab.module.OutputModule;
import deconvolutionlab.module.PSFModule;
+import deconvolutionlab.module.PreprocessingModule;
import deconvolutionlab.module.RunningModule;
import deconvolutionlab.system.SystemInfo;
+/**
+ * This class build the main panel for DeconvolutionLab2. It consists to a
+ * series of collapse/expanded modules that are placed in different tabs. The size
+ * of the panel is dynamically computed,
+ *
+ * @author Daniel Sage
+ *
+ */
public class LabPanel extends JPanel implements ActionListener, ChangeListener {
- private JTabbedPane tab = new JTabbedPane();
- private JButton bnHelp = new JButton("Help");
- private JButton bnQuit = new JButton("Quit");
- private JButton bnSystem = new JButton("System");
- private JButton bnBatch = new JButton("Batch");
- private JButton bnRun = new JButton("Run");
- private JButton bnLaunch = new JButton("Launch");
- private JButton bnClose;
-
- private ImageModule image;
- private PSFModule psf;
- private AlgorithmModule algo;
- private AboutModule about;
- private LicenceModule licence;
- private OutputModule output;
- private ComputationModule computation;
- private BorderModule border;
- private ConfigModule config;
- private BatchModule batch;
- private LanguageModule language;
- private CommandModule command;
- private RunningModule running;
- private DirectoryModule directory;
- private FFTModule fft;
+ private JTabbedPane tab = new JTabbedPane();
+ private JButton bnHelp = new JButton("Help");
+ private JButton bnQuit = new JButton("Quit");
+ private JButton bnSystem = new JButton("System");
+ private JButton bnBatch = new JButton("Batch");
+ private JButton bnRun = new JButton("Run");
+ private JButton bnLaunch = new JButton("Launch");
+ private JButton bnClose;
+
+ private ImageModule image;
+ private PSFModule psf;
+ private AlgorithmModule algo;
+ private AboutModule about;
+ private LicenceModule licence;
+ private OutputModule output;
+ private PreprocessingModule preprocessing;
+ private ConfigModule config;
+ private BatchModule batch;
+ private LanguageModule language;
+ private CommandModule command;
+ private RunningModule running;
+ private DirectoryModule directory;
+ private FFTModule fft;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
- private AbstractModule modules[];
-
+ private AbstractModule modules[];
+
public LabPanel(JButton bnClose) {
this.bnClose = bnClose;
- image = new ImageModule(false);
- psf = new PSFModule(false);
- algo = new AlgorithmModule(true);
- output = new OutputModule(true);
- computation = new ComputationModule(false);
- border = new BorderModule(false);
- controller = new ControllerModule(false);
- batch = new BatchModule(false);
- language = new LanguageModule(false);
- about = new AboutModule(true);
- licence = new LicenceModule(false);
- config = new ConfigModule(false);
+ image = new ImageModule();
+ psf = new PSFModule();
+ algo = new AlgorithmModule();
+ output = new OutputModule();
+ preprocessing = new PreprocessingModule();
+ controller = new ControllerModule();
+ batch = new BatchModule();
+ language = new LanguageModule();
+ about = new AboutModule();
+ licence = new LicenceModule();
+ config = new ConfigModule();
command = new CommandModule();
- running = new RunningModule(false);
- directory = new DirectoryModule(false);
- fft = new FFTModule(false);
+ running = new RunningModule();
+ directory = new DirectoryModule();
+ fft = new FFTModule();
- modules = new AbstractModule[] { image, psf, algo, output, controller, border, computation, batch, directory, fft };
+ modules = new AbstractModule[] { image, psf, algo, output, controller, preprocessing, batch, directory, fft };
Command.active(modules, command);
Command.command();
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
PanelImage bottom = new PanelImage("celegans.jpg");
bottom.setBorder(border);
bottom.setLayout(new GridLayout(1, 6));
bottom.setBorder(border);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Scripting", panelScript);
tab.add("About", panelAbout);
tab.addChangeListener(this);
setLayout(new BorderLayout());
add(tab, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
bnSystem.addActionListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.load();
running.init();
- //sizeModule();
+ algo.open();
+ controller.open();
+ about.open();
+ command.open();
+
+ // sizeModule();
Command.command();
running.update();
image.update();
psf.update();
output.update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnClose)
Config.store();
else if (e.getSource() == bnSystem)
SystemInfo.activate();
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
BatchDialog dlg = new BatchDialog(batch);
Lab.setVisible(dlg, true);
}
-
+
else if (e.getSource() == bnLaunch) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command(), Deconvolution.Finish.ALIVE);
d.launch();
}
else if (e.getSource() == bnRun) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command());
d.deconvolve();
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
list.add(directory);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
- list.add(computation);
- list.add(border);
+ list.add(preprocessing);
list.add(fft);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(batch);
list.add(command);
list.add(language);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
public void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
-
+
Lab.close();
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0)
sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1)
sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2)
sizePanel(panelScript);
if (tab.getSelectedIndex() == 3)
sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 70;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
- setMinimumSize(new Dimension(Constants.widthGUI, 4*hpc));
+ setMinimumSize(new Dimension(Constants.widthGUI, 4 * hpc));
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
index 6a95ed2..e420828 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
@@ -1,336 +1,336 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.gui.GUI;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class SyntheticDialog extends JDialog implements ActionListener, WindowListener {
private SpinnerRangeDouble spnIntensity = new SpinnerRangeDouble(255, -999999, 999999, 1);
- private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(128, 1, 9999, 1);
- private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(128, 1, 9999, 1);
- private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(32, 1, 9999, 1);
+ private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(200, 1, 9999, 1);
+ private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(100, 1, 9999, 1);
+ private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(100, 1, 9999, 1);
private SpinnerRangeDouble spnCenterX = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterY = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterZ = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnParameter1 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter2 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter3 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter4 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private JLabel lbl1 = new JLabel("Parameters 1 of the shape");
private JLabel lbl2 = new JLabel("Parameters 2 of the shape");
private JLabel lbl3 = new JLabel("Parameters 3 of the shape");
private JLabel lbl4 = new JLabel("Parameters 4 of the shape");
private JComboBox<String> cmbShapes;
private JButton bnShow = new JButton("Show");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String shape;
private String command;
public SyntheticDialog(ArrayList<SignalFactory> list) {
super(new JFrame(), "Synthetic");
String[] cmb = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
cmb[i] = list.get(i).getName();
}
cmbShapes = new JComboBox<String>(cmb);
GridPanel pnParams = new GridPanel("parameters", 3);
pnParams.place(8, 0, lbl1);
pnParams.place(8, 1, spnParameter1);
pnParams.place(9, 0, lbl2);
pnParams.place(9, 1, spnParameter2);
pnParams.place(10, 0, lbl3);
pnParams.place(10, 1, spnParameter3);
pnParams.place(11, 0, lbl4);
pnParams.place(11, 1, spnParameter4);
GridPanel pnSize = new GridPanel("size", 3);
pnSize.place(1, 0, "Width [pixels] (nx)");
pnSize.place(1, 1, spnWidth);
pnSize.place(2, 0, "Height [pixels] (ny)");
pnSize.place(2, 1, spnHeight);
pnSize.place(3, 0, "Number of Slices (nz)");
pnSize.place(3, 1, spnSlices);
GridPanel pnIntensity = new GridPanel("intensity", 3);
pnIntensity.place(1, 0, "Signal Intensity");
pnIntensity.place(1, 1, spnIntensity);
GridPanel pnCenter = new GridPanel("center", 3);
pnCenter.place(4, 0, "Center [% of nx] (cx)");
pnCenter.place(4, 1, spnCenterX);
pnCenter.place(5, 0, "Center [% of ny] (cy)");
pnCenter.place(5, 1, spnCenterY);
pnCenter.place(7, 0, "Center [% of nz] (cz)");
pnCenter.place(7, 1, spnCenterZ);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, 3, 1, cmbShapes);
pn.place(1, 0, 3, 1, pnParams);
pn.place(2, 0, 3, 1, pnSize);
pn.place(3, 0, 3, 1, pnIntensity);
pn.place(4, 0, 3, 1, pnCenter);
pn.place(11, 0, bnCancel);
pn.place(11, 1, bnShow);
pn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnShow.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
cmbShapes.addActionListener(this);
add(pn);
pack();
updateInterface();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void updateInterface() {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
String labels[] = factory.getParametersName();
lbl1.setVisible(false);
lbl2.setVisible(false);
lbl3.setVisible(false);
if (labels.length >= 1) {
lbl1.setVisible(true);
lbl1.setText(labels[0]);
}
if (labels.length >= 2) {
lbl2.setVisible(true);
lbl2.setText(labels[1]);
}
if (labels.length >= 3) {
lbl3.setVisible(true);
lbl3.setText(labels[2]);
}
if (labels.length >= 4) {
lbl4.setVisible(true);
lbl4.setText(labels[3]);
}
double params[] = factory.getParameters();
spnParameter1.setVisible(false);
spnParameter2.setVisible(false);
spnParameter3.setVisible(false);
spnParameter4.setVisible(false);
if (params.length >= 1) {
spnParameter1.setVisible(true);
spnParameter1.set(params[0]);
}
if (params.length >= 2) {
spnParameter2.setVisible(true);
spnParameter2.set(params[1]);
}
if (params.length >= 3) {
spnParameter3.setVisible(true);
spnParameter3.set(params[2]);
}
if (params.length >= 4) {
spnParameter4.setVisible(true);
spnParameter4.set(params[3]);
}
pack();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnShow) {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
double params[] = factory.getParameters();
factory.setParameters(params);
factory.intensity(spnIntensity.get());
factory.center(spnCenterX.get(), spnCenterY.get(), spnCenterZ.get());
RealSignal signal = factory.generate(spnWidth.get(), spnHeight.get(), spnSlices.get());
Lab.show(Monitors.createDefaultMonitor(), signal, factory.getName());
}
if (e.getSource() == cmbShapes) {
updateInterface();
}
if (e.getSource() == bnCancel) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
if (e.getSource() == bnOK) {
int nx = spnWidth.get();
int ny = spnHeight.get();
int nz = spnSlices.get();
shape = (String) cmbShapes.getSelectedItem();
command = shape + " ";
SignalFactory factory = SignalFactory.get(shape);
int n = factory.getParameters().length;
if (n >= 1) {
command += "" + spnParameter1.get();
if (n >= 2)
command += " " + spnParameter2.get();
if (n >= 3)
command += " " + spnParameter3.get();
if (n >= 4)
command += " " + spnParameter4.get();
command += " ";
}
command += " size " + nx + " " + ny + " " + nz + " intensity " + + spnIntensity.get() + " ";
if (spnCenterX.get() != 0.5 || spnCenterY.get() != 0.5 || spnCenterZ.get() != 0.5) {
double cx = Math.round(spnCenterX.get() * 1000000) / 1000000.0;
double cy = Math.round(spnCenterY.get() * 1000000) / 1000000.0;
double cz = Math.round(spnCenterZ.get() * 1000000) / 1000000.0;
command += " center " + cx + " " + cy + " " + cz + " ";
}
dispose();
cancel = false;
}
}
/**
* Set the command line parameters to the components of the user interface
*
* @param name String containing the name of shape
* @param parameters String containing all the parameters plus the optional keywords: size, intensity, center
*/
public void setParameters(String name, String parameters) {
cmbShapes.setSelectedItem(name);
SignalFactory factory = SignalFactory.getFactoryByName(name);
if (factory == null)
return;
int np = factory.getParameters().length;
double params[] = NumFormat.parseNumbers(parameters);
if (np >= 1 && params.length >= 1)
spnParameter1.set(params[0]);
if (np >= 2 && params.length >= 2)
spnParameter2.set(params[1]);
if (np >= 3 && params.length >= 3)
spnParameter3.set(params[2]);
if (np >= 4 && params.length >= 4)
spnParameter4.set(params[3]);
double size[] = NumFormat.parseNumbersAfter("size", parameters);
if (size.length > 0)
spnWidth.set((int) size[0]);
if (size.length > 1)
spnHeight.set((int) size[1]);
if (size.length > 2)
spnSlices.set((int) size[2]);
double intensity[] = NumFormat.parseNumbersAfter("intensity", parameters);
if (intensity.length > 0)
spnIntensity.set(intensity[0]);
double center[] = NumFormat.parseNumbersAfter("center", parameters);
if (center.length > 0)
spnCenterX.set(center[0]);
if (center.length > 1)
spnCenterY.set(center[1]);
if (center.length > 2)
spnCenterZ.set(center[2]);
}
public String getShapeName() {
return shape;
}
public String getCommand() {
return command;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
index ad2c0f1..8b6c088 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
@@ -1,72 +1,70 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
-import deconvolutionlab.Lab;
public class AboutModule extends AbstractModule {
- public AboutModule(boolean expanded) {
- super("About", "", "", "", expanded);
+ public AboutModule() {
+ super("About", "", "", "");
}
@Override
public String getCommand() {
setSynopsis("DeconvolutionLab2 " + Constants.version);
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p", Constants.copyright);
html.append("p", "<b>Reference:</b> " + Constants.reference);
html.append("h3", "<b>Authors:</b> " + Constants.authors);
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
setSynopsis("DeconvolutionLab2 " + Constants.version);
return panel;
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
index a75fa58..6c245a7 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
@@ -1,231 +1,237 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public abstract class AbstractModule extends JPanel implements ActionListener {
protected JButton bnTitle = new JButton("");
protected JButton bnSynopsis = new JButton("");
protected JButton bnAction1 = new JButton();
protected JButton bnAction2 = new JButton();
protected JButton bnExpand = new JButton("\u25BA");
private JLabel lblCommand;
protected CardLayout card = new CardLayout();
private JPanel space = new JPanel(card);
private boolean expanded = false;
private GroupedModulePanel mpns;
private JPanel pnExpanded;
private JPanel pnCollapsed;
private String name;
private String key;
private int heightButton = 22;
- public AbstractModule(String name, String key, String action1, String action2, boolean expanded) {
+ public AbstractModule(String name, String key, String action1, String action2) {
this.name = name;
this.key = key;
pnCollapsed = buildCollapsedPanel();
pnExpanded = buildExpandedPanel();
setLayout(new BorderLayout());
- this.expanded = expanded;
bnTitle.setText("<html><b>" + name + "</b></html>");
bnTitle.setHorizontalAlignment(SwingConstants.LEFT);
bnTitle.setPreferredSize(new Dimension(150, heightButton));
bnTitle.setMaximumSize(new Dimension(250, heightButton));
bnTitle.setMinimumSize(new Dimension(120, heightButton));
bnTitle.setMargin(new Insets(1, 1, 1, 1));
bnTitle.addActionListener(this);
bnSynopsis.setHorizontalAlignment(SwingConstants.LEFT);
bnSynopsis.setPreferredSize(new Dimension(200, heightButton));
bnSynopsis.setMargin(new Insets(1, 1, 1, 1));
bnSynopsis.addActionListener(this);
Font font = bnExpand.getFont();
bnExpand.setFont(new Font(font.getFamily(), font.getStyle(), font.getSize()-3));
bnExpand.setPreferredSize(new Dimension(40, heightButton));
bnExpand.setMaximumSize(new Dimension(40, heightButton));
bnExpand.setMinimumSize(new Dimension(40, heightButton));
bnExpand.setMargin(new Insets(1, 1, 1, 1));
bnExpand.addActionListener(this);
JPanel tool0 = new JPanel(new BorderLayout());
JPanel tool1 = new JPanel(new BorderLayout());
tool1.add(bnExpand, BorderLayout.WEST);
tool1.add(bnTitle, BorderLayout.EAST);
tool0.add(tool1, BorderLayout.WEST);
tool0.add(bnSynopsis, BorderLayout.CENTER);
JPanel toola = null;
if (!action1.equals("")) {
bnAction1.setText(action1);
bnAction1.setPreferredSize(new Dimension(70, heightButton));
bnAction1.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction1, BorderLayout.WEST);
}
if (!action2.equals("")) {
bnAction2.setText(action2);
bnAction2.setPreferredSize(new Dimension(70, heightButton));
bnAction2.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction2, BorderLayout.EAST);
}
if (toola != null)
tool0.add(toola, BorderLayout.EAST);
space.add(pnExpanded, "expand");
space.add(pnCollapsed, "collapse");
add(tool0, BorderLayout.NORTH);
add(space, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (expanded)
expand();
else
collapse();
setPreferredSize(pnCollapsed.getPreferredSize());
}
public JPanel buildCollapsedPanel() {
JPanel panel = new JPanel(new BorderLayout());
lblCommand = new JLabel("");
lblCommand.setBorder(BorderFactory.createEtchedBorder());
lblCommand.setHorizontalAlignment(SwingConstants.LEFT);
lblCommand.setPreferredSize(new Dimension(500, 32));
panel.add(lblCommand, BorderLayout.NORTH);
lblCommand.setMinimumSize(new Dimension(500, 36));
return panel;
}
public abstract JPanel buildExpandedPanel();
public abstract String getCommand();
public abstract void close();
public JButton getAction1Button() {
return bnAction1;
}
public JButton getAction2Button() {
return bnAction2;
}
@Override
public String getName() {
return name;
}
public String getKey() {
return key;
}
public String getTitle() {
return bnTitle.getText();
}
public void setCommand(String command) {
lblCommand.setText("<html><p style=\"font-family: monospace\"><small>" + command + "</small></p></html>");
}
public void setSynopsis(String synopsis) {
bnSynopsis.setText(synopsis);
}
public JPanel getCollapsedPanel() {
return pnCollapsed;
}
public JPanel getExpandedPanel() {
return pnExpanded;
}
public void setMultipleModulePanel(GroupedModulePanel mpns) {
this.mpns = mpns;
}
@Override
public Dimension getPreferredSize() {
if (expanded)
return pnExpanded.getPreferredSize();
else
return pnCollapsed.getPreferredSize();
}
public boolean isExpanded() {
return expanded;
}
public void collapse() {
expanded = false;
card.show(space, "collapse");
bnExpand.setText("\u25BA");
}
public void expand() {
expanded = true;
card.show(space, "expand");
bnExpand.setText("\u25BC");
}
+ public void open() {
+ for (AbstractModule module : mpns.getModules())
+ module.collapse();
+ expand();
+ mpns.organize();
+ }
+
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnTitle || e.getSource() == bnExpand || e.getSource() == bnSynopsis) {
if (expanded) {
collapse();
}
else {
for (AbstractModule module : mpns.getModules())
module.collapse();
expand();
}
mpns.organize();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
index 2f15b41..89638c6 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
@@ -1,172 +1,172 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
private JLabel shortname;
- public AlgorithmModule(boolean expanded) {
- super("Algorithm", "-algorithm", "", "Check", expanded);
+ public AlgorithmModule() {
+ super("Algorithm", "-algorithm", "", "Check");
ArrayList<AbstractAlgorithmPanel> deconv = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : deconv)
cmb.addItem(panel.getName());
cmb.addActionListener(this);
}
@Override
public String getCommand() {
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
String cmd = "-algorithm " + algo.getShortnames()[0] + " " + algo.getCommand();
String synopsis = algo.getShortnames()[0] + " " + algo.getCommand();
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
shortname = new JLabel("-------");
Border bl1 = BorderFactory.createEtchedBorder();
Border bl2 = BorderFactory.createEmptyBorder(0, 10, 0, 10);
shortname.setBorder(BorderFactory.createCompoundBorder(bl1, bl2));
cmb = new JComboBox<String>();
cmb.setBorder(BorderFactory.createEtchedBorder());
JPanel pnc = new JPanel();
pnc.add(cmb);
doc = new HTMLPane(100, 1000);
cards = new JPanel(new CardLayout());
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : panels) {
JScrollPane scroll = new JScrollPane(panel.getPanelParameters());
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cards.add(panel.getName(), scroll);
}
cmb.setMaximumRowCount(panels.size());
JPanel top = new JPanel(new BorderLayout());
top.add(cmb, BorderLayout.CENTER);
top.add(shortname, BorderLayout.EAST);
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
cards.setBorder(BorderFactory.createEtchedBorder());
control.add(top);
control.add(cards);
doc.append("h1", "Documentation");
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.NORTH);
panel.add(doc.getPane(), BorderLayout.CENTER);
// cmb.addActionListener(this);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
Config.register(getName(), "algorithm", cmb, Algorithm.getDefaultAlgorithm());
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb) {
doc.clear();
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
doc.append(algo.getDocumentation());
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, name);
String s = "<html><b><p style =\"font-family:georgia\">";
for(int i=0; i<algo.getShortnames().length; i++)
s += (i==0 ? "" : " | ") + algo.getShortnames()[i] ;
shortname.setText(s + "</b></html>");
}
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Algorithm", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.ALGO, deconvolution);
Lab.setVisible(d, false);
}
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
index 578a1a2..eba2bd8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
@@ -1,170 +1,170 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnRun;
private JButton bnLaunch;
- public BatchModule(boolean expanded) {
- super("Batch", "", "", "", expanded);
+ public BatchModule() {
+ super("Batch", "", "", "");
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnRun = new JButton("Run Jobs");
bnLaunch = new JButton("Launch Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 2));
pn.setFloatable(false);
pn.add(bnRun);
pn.add(bnLaunch);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRun) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
else if (e.getSource() == bnLaunch) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
update();
}
private void update() {
setSynopsis("" + table.getRowCount() + " jobs");
}
public int getCountJob() {
return table.getRowCount();
}
public void addJob(String name, String command) {
table.append(new String[] { name, command, "" });
update();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 2) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
}
update();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
index 8c0b2ea..ec13ca5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
@@ -1,92 +1,92 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Lab;
public class CommandModule extends AbstractModule {
private HTMLPane window;
public CommandModule() {
- super("Command", "", "", "Check", true);
+ super("Command", "", "", "Check");
}
public HTMLPane getPane() {
return window;
}
@Override
public JPanel buildExpandedPanel() {
window = new HTMLPane("Monaco", 100, 100);
JPanel panel = new JPanel(new BorderLayout());
panel.add(window.getPane(), BorderLayout.CENTER);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Command", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
window.clear();
window.append("p", command);
}
@Override
public String getCommand() {
return window.getText();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
index 570b9a7..16e0d00 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
@@ -1,185 +1,137 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
-import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import fft.FFT;
public class ComputationModule extends AbstractModule implements ActionListener, ChangeListener {
- private JComboBox<String> cmbMultithreading;
- private JComboBox<String> cmbSystem;
- private JComboBox<String> cmbDisplayFinal;
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbEpsilon;
- private JComboBox<String> cmbNormalization;
boolean init = false;
- public ComputationModule(boolean expanded) {
- super("Computation", "", "Default", "", expanded);
+ public ComputationModule() {
+ super("Computation", "", "Default", "");
}
@Override
public String getCommand() {
String cmd = "";
- if (cmbNormalization.getSelectedIndex() != 0)
- cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
- if (cmbSystem.getSelectedIndex() != 0)
- cmd += " -system no";
- if (cmbMultithreading.getSelectedIndex() != 0)
- cmd += " -multithreading no";
- if (cmbDisplayFinal.getSelectedIndex() != 0)
- cmd += " -display no";
if (cmbFFT.getSelectedIndex() != 0)
cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
if (cmbEpsilon.getSelectedIndex() != 6)
cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
- cmbSystem = new JComboBox<String>(new String[] { "yes", "no" });
- cmbMultithreading = new JComboBox<String>(new String[] { "yes", "no" });
- cmbDisplayFinal = new JComboBox<String>(new String[] { "yes", "no" });
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
cmbEpsilon.setSelectedItem("1E-6");
- cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
-
- cmbNormalization.addActionListener(this);
- cmbNormalization.setSelectedIndex(0);
- cmbNormalization.removeActionListener(this);
GridPanel pnNumeric = new GridPanel(false, 2);
pnNumeric.place(1, 0, "norm");
- pnNumeric.place(1, 1, cmbNormalization);
- pnNumeric.place(1, 2, "PSF normalization (def:1)");
pnNumeric.place(3, 0, new JLabel("fft"));
pnNumeric.place(3, 1, cmbFFT);
pnNumeric.place(3, 2, new JLabel("FFT library (Fourier)"));
- pnNumeric.place(6, 0, new JLabel("system"));
- pnNumeric.place(6, 1, cmbSystem);
- pnNumeric.place(6, 2, new JLabel("Show the system panel"));
- pnNumeric.place(7, 0, new JLabel("display"));
- pnNumeric.place(7, 1, cmbDisplayFinal);
- pnNumeric.place(7, 2, new JLabel("Display the final output"));
- pnNumeric.place(8, 0, new JLabel("multithreading"));
- pnNumeric.place(8, 1, cmbMultithreading);
- pnNumeric.place(8, 2, new JLabel("Activate multithreading"));
pnNumeric.place(9, 0, new JLabel("epsilon"));
pnNumeric.place(9, 1, cmbEpsilon);
pnNumeric.place(9, 2, new JLabel("<html>Machine Epsilon &epsilon;</html>"));
JScrollPane scroll = new JScrollPane(pnNumeric);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
- Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
- Config.register(getName(), "system", cmbSystem, cmbSystem.getItemAt(0));
- Config.register(getName(), "display", cmbDisplayFinal, cmbDisplayFinal.getItemAt(0));
- Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
cmbFFT.addActionListener(this);
- cmbSystem.addActionListener(this);
- cmbDisplayFinal.addActionListener(this);
- cmbMultithreading.addActionListener(this);
cmbEpsilon.addActionListener(this);
- cmbNormalization.addActionListener(this);
getAction1Button().addActionListener(this);
init = true;
return panel;
}
private void update() {
setCommand(getCommand());
if (init)
- setSynopsis("Norm " + cmbNormalization.getSelectedItem() + " " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName());
+ setSynopsis(" " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction1Button()) {
cmbFFT.setSelectedIndex(0);
- cmbMultithreading.setSelectedIndex(0);
- cmbDisplayFinal.setSelectedIndex(0);
- cmbSystem.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
- cmbNormalization.setSelectedIndex(0);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
- cmbMultithreading.removeActionListener(this);
- cmbDisplayFinal.removeActionListener(this);
- cmbSystem.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
- cmbNormalization.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
index 64a71fe..1147e55 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
@@ -1,126 +1,126 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class ConfigModule extends AbstractModule implements ActionListener {
private JButton bnLoad;
private JButton bnSave;
private CustomizedTable table;
private JLabel lblDefault;
- public ConfigModule(boolean expanded) {
- super("Config", "", "", "", expanded);
+ public ConfigModule() {
+ super("Config", "", "", "");
}
@Override
public String getCommand() {
setSynopsis(new File(Config.getFilename()).getName());
return "";
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Key", String.class, 180, false));
columns.add(new CustomizedColumn("Value", String.class, Constants.widthGUI - 80, true));
table = new CustomizedTable(columns, true);
read();
lblDefault = new JLabel(Config.getFilename());
bnLoad = new JButton("Load");
bnSave = new JButton("Save");
lblDefault.setBorder(BorderFactory.createEtchedBorder());
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
button.add(bnLoad);
button.add(bnSave);
JPanel panel = new JPanel(new BorderLayout());
panel.add(lblDefault, BorderLayout.NORTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnLoad.addActionListener(this);
bnSave.addActionListener(this);
setSynopsis(new File(Config.getFilename()).getName());
return panel;
}
private void read() {
String filename = Config.getFilename();
File file = new File(filename);
if (file.exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String entry = line.trim();
if (!entry.startsWith("#")) {
String[] parts = entry.split("=");
if (parts.length == 2)
table.append(parts);
}
}
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void close() {
bnLoad.removeActionListener(this);
bnSave.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
index acb7b86..0cabf3e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
@@ -1,310 +1,308 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.io.IOException;
import java.util.List;
-import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import signal.Constraint;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
-import deconvolutionlab.module.ImageModule.LocalDropTarget;
-import signal.Constraint;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtTime;
private JTextField txtIterations;
private JComboBox<String> cmbConstraint;
private JComboBox<String> cmbStats;
private JComboBox<String> cmbMonitor;
private JComboBox<String> cmbVerbose;
private JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkTime;
- public ControllerModule(boolean expanded) {
- super("Controller", "", "Default", "", expanded);
+ public ControllerModule() {
+ super("Controller", "", "Default", "");
}
@Override
public String getCommand() {
String cmd = "";
if (cmbMonitor.getSelectedIndex() != 0)
cmd += "-monitor " + cmbMonitor.getSelectedItem() + " ";
if (cmbVerbose.getSelectedIndex() != 0)
cmd += "-verbose " + cmbVerbose.getSelectedItem() + " ";
if (cmbStats.getSelectedIndex() != 0)
cmd += "-stats " + cmbStats.getSelectedItem() + " ";
if (cmbConstraint.getSelectedIndex() != 0)
cmd += "-constraint " + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + txtResidu.getText() + " ";
if (chkTime.isSelected())
cmd += "-time " + txtTime.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
chkTime = new JCheckBox("");
chkResidu = new JCheckBox("");
chkReference = new JCheckBox("");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtTime = new JTextField("3600");
txtIterations = new JTextField("Iteration max (mandatory)");
txtIterations.setEditable(false);
cmbMonitor = new JComboBox<String>(new String[] {"console table", "console", "table", "no" });
cmbVerbose = new JComboBox<String>(new String[] {"log", "quiet", "mute", "prolix" });
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
cmbStats = new JComboBox<String>(new String[] {"no", "show", "show + save", "save"});
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true, 2);
pn.place(0, 0, "monitor");
pn.place(0, 2, cmbMonitor);
pn.place(0, 3, "Monitoring message");
pn.place(1, 0, "verbose");
pn.place(1, 2, cmbVerbose);
pn.place(1, 3, "");
pn.place(3, 0, "stats");
pn.place(3, 2, cmbStats);
pn.place(3, 3, "Signal's statistics");
pn.place(4, 0, "constraint");
pn.place(4, 2, cmbConstraint);
pn.place(4, 3, "Additional constraint");
pn.place(5, 0, "residu");
pn.place(5, 1, chkResidu);
pn.place(5, 2, txtResidu);
pn.place(5, 3, "Additional stopping criteria");
pn.place(6, 0, "time");
pn.place(6, 1, chkTime);
pn.place(6, 2, txtTime);
pn.place(6, 3, "Additional stopping criteria");
pn.place(7, 0, "reference");
pn.place(7, 1, chkReference);
pn.place(7, 2, 2, 1, txtReference);
pn.place(8, 2, bnBrowse);
pn.place(8, 3, 1, 1, "Ground-truth file");
JScrollPane scroll = new JScrollPane(pn);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.add(scroll, BorderLayout.CENTER);
// Add drop area
txtReference.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnBrowse.setDropTarget(new LocalDropTarget());
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "time.enable", chkTime, false);
Config.register(getName(), "reference.value", txtReference, "");
Config.register(getName(), "residu.value", txtResidu, "0.01");
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "constraint", cmbConstraint, cmbConstraint.getItemAt(0));
Config.register(getName(), "stats", cmbStats, cmbStats.getItemAt(0));
Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkTime.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtTime.addKeyListener(this);
cmbConstraint.addActionListener(this);
cmbMonitor.addActionListener(this);
cmbVerbose.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkTime.isSelected() ? 1 : 0);
count += (chkReference.isSelected() ? 1 : 0);
setSynopsis("" + count + " controls");
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkTime.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkTime.setSelected(false);
txtReference.setText("");
txtResidu.setText("0.01");
txtTime.setText("3600");
cmbConstraint.setSelectedIndex(0);
cmbStats.setSelectedIndex(0);
cmbMonitor.setSelectedIndex(0);
cmbVerbose.setSelectedIndex(0);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkTime.addChangeListener(this);
}
update();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
@Override
public void close() {
bnBrowse.removeActionListener(this);
chkReference.removeChangeListener(this);
chkResidu.removeChangeListener(this);
cmbVerbose.removeActionListener(this);
cmbMonitor.removeActionListener(this);
cmbConstraint.removeActionListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isFile()) {
txtReference.setText(file.getAbsolutePath());
chkReference.setSelected(true);
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
index 3ab5d1a..cb67a9c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
@@ -1,207 +1,231 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.BoxLayout;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComboBox;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
-import deconvolutionlab.module.ImageModule.LocalDropTarget;
public class DirectoryModule extends AbstractModule implements ActionListener, KeyListener {
private JComboBox<String> cmbPath;
private JTextField txtPath;
private JButton bnBrowse;
+
+ private JCheckBox chkSystem;
+ private JCheckBox chkDisplayFinal;
- public DirectoryModule(boolean expanded) {
- super("Path", "", "Default", "", expanded);
+ public DirectoryModule() {
+ super("Path", "", "Default", "");
}
@Override
public String getCommand() {
String cmd = "";
if (cmbPath.getSelectedIndex() != 0)
cmd += " -path " + txtPath.getText();
+ if (!chkSystem.isSelected())
+ cmd += " -system no";
+ if (!chkDisplayFinal.isSelected())
+ cmd += " -display no";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbPath = new JComboBox<String>(new String[] { "Current", "Specify"});
txtPath = new JTextField("", 35);
bnBrowse = new JButton("Browse");
+ chkSystem = new JCheckBox("Show the system panel");
+ chkDisplayFinal = new JCheckBox("Display the final output");
+
GridPanel pn1 = new GridPanel(true, 3);
pn1.place(0, 0, 3, 1, "Working directory");
pn1.place(1, 0, cmbPath);
pn1.place(1, 1, bnBrowse);
pn1.place(2, 0, 3, 1, txtPath);
+ pn1.place(5, 0, 3, 1, " ");
+ pn1.place(6, 0, 3, 1, chkSystem);
+ pn1.place(7, 0, 3, 1, chkDisplayFinal);
+
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(pn1);
String dir = System.getProperty("user.dir");
Config.register(getName(), "current", cmbPath, cmbPath.getItemAt(0));
Config.register(getName(), "path", txtPath, dir);
+ Config.register(getName(), "system", chkSystem, true);
+ Config.register(getName(), "display", chkDisplayFinal, true);
+
// Add drop area
pn1.setDropTarget(new LocalDropTarget());
txtPath.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnTitle.setDropTarget(new LocalDropTarget());
bnSynopsis.setDropTarget(new LocalDropTarget());
bnExpand.setDropTarget(new LocalDropTarget());
+ chkSystem.addActionListener(this);
+ chkDisplayFinal.addActionListener(this);
cmbPath.addActionListener(this);
txtPath.addKeyListener(this);
bnBrowse.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
if (cmbPath.getSelectedIndex() == 0) {
txtPath.setText(System.getProperty("user.dir"));
txtPath.setEnabled(false);
bnBrowse.setEnabled(false);
}
else {
txtPath.setEnabled(true);
bnBrowse.setEnabled(true);
}
setSynopsis(new File(txtPath.getText()).getName());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtPath.setText(f.getAbsolutePath());
}
}
else if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
}
else if (e.getSource() == getAction1Button()) {
txtPath.setText(System.getProperty("user.dir"));
txtPath.setEnabled(false);
bnBrowse.setEnabled(false);
+ chkDisplayFinal.setSelected(true);
+ chkSystem.setSelected(true);
}
update();
}
@Override
public void close() {
+ chkDisplayFinal.removeActionListener(this);
+ chkSystem.removeActionListener(this);
cmbPath.removeActionListener(this);
txtPath.removeKeyListener(this);
bnBrowse.removeActionListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
cmbPath.setSelectedIndex(1);
bnBrowse.setEnabled(true);
txtPath.setEnabled(true);
if (file.isDirectory())
txtPath.setText(file.getAbsolutePath());
else
txtPath.setText(file.getParent());
update();
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/FFTModule.java
new file mode 100644
index 0000000..4020e17
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/FFTModule.java
@@ -0,0 +1,171 @@
+/*
+ * DeconvolutionLab2
+ *
+ * Conditions of use: You are free to use this software for research or
+ * educational purposes. In addition, we expect you to include adequate
+ * citations and acknowledgments whenever you present or publish results that
+ * are based on it.
+ *
+ * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
+ * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
+ * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
+ */
+
+/*
+ * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
+ *
+ * This file is part of DeconvolutionLab2 (DL2).
+ *
+ * DL2 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
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * DL2. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package deconvolutionlab.module;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JToolBar;
+
+import bilib.component.HTMLPane;
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
+import deconvolution.algorithm.Algorithm;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
+import fft.AbstractFFTLibrary;
+import fft.FFT;
+
+public class FFTModule extends AbstractModule implements ActionListener {
+
+ private CustomizedTable table;
+ private JComboBox<String> cmbFFT;
+ private JComboBox<String> cmbEpsilon;
+ private HTMLPane doc;
+ private JComboBox<String> cmbMultithreading;
+
+ public FFTModule() {
+ super("FFT", "", "Default", "");
+ }
+
+ @Override
+ public String getCommand() {
+ String cmd = " ";
+ if (cmbFFT.getSelectedIndex() != 0)
+ cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
+ if (cmbEpsilon.getSelectedIndex() != 6)
+ cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
+ if (cmbMultithreading.getSelectedIndex() != 0)
+ cmd += " -multithreading no";
+ return cmd;
+ }
+
+ public void update() {
+ AbstractFFTLibrary library = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
+ setCommand(getCommand());
+ setSynopsis(library.getLibraryName());
+ doc.clear();
+ doc.append(library.getCredit());
+ doc.append("<hr>");
+ doc.append(library.getLicence());
+ }
+
+ @Override
+ public JPanel buildExpandedPanel() {
+
+ doc = new HTMLPane(100, 1000);
+ cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
+ cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
+ cmbEpsilon.setSelectedItem("1E-6");
+ cmbMultithreading = new JComboBox<String>(new String[] { "yes", "no" });
+
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("FFT Library", String.class, 100, false));
+ columns.add(new CustomizedColumn("Installed", String.class, 40, false));
+ columns.add(new CustomizedColumn("Installation", String.class, Constants.widthGUI, false));
+ table = new CustomizedTable(columns, true);
+ table.setRowSelectionAllowed(false);
+
+ JToolBar tool = new JToolBar("Path");
+ tool.setBorder(BorderFactory.createEmptyBorder());
+ tool.setLayout(new GridLayout(3, 3));
+ tool.setFloatable(false);
+ tool.add(new JLabel("fft"));
+ tool.add(cmbFFT);
+ tool.add(new JLabel("FFT Library"));
+
+ tool.add(new JLabel("espilon"));
+ tool.add(cmbEpsilon);
+ tool.add(new JLabel("Machine epsilon"));
+
+ tool.add(new JLabel("multithreading"));
+ tool.add(cmbMultithreading);
+ tool.add(new JLabel("Activate multithreading"));
+
+
+ JPanel pn = new JPanel();
+ pn.setLayout(new BorderLayout());
+ pn.add(tool, BorderLayout.NORTH);
+ pn.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
+
+ JPanel panel = new JPanel();
+ panel.setBorder(BorderFactory.createEtchedBorder());
+ panel.setLayout(new BorderLayout());
+ panel.add(pn, BorderLayout.NORTH);
+ panel.add(doc.getPane(), BorderLayout.CENTER);
+ getAction1Button().addActionListener(this);
+
+ Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
+ Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
+ Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
+
+ cmbMultithreading.addActionListener(this);
+ cmbFFT.addActionListener(this);
+ cmbEpsilon.addActionListener(this);
+
+ for(AbstractFFTLibrary lib : FFT.getInstalledLibraries()) {
+ String name = lib.getLibraryName();
+ String i = lib.isInstalled() ? "yes" : "no";
+ String loc = lib.getLocation();
+ table.append(new String[]{name, i, loc});
+ }
+
+ update();
+ return panel;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ if (e.getSource() == getAction1Button()) {
+ cmbFFT.setSelectedIndex(0);;
+ cmbEpsilon.setSelectedItem("1E-6");
+ cmbMultithreading.setSelectedIndex(0);
+ }
+ update();
+ }
+
+ @Override
+ public void close() {
+ cmbFFT.removeActionListener(this);
+ cmbEpsilon.removeActionListener(this);
+ cmbMultithreading.removeActionListener(this);
+ getAction1Button().removeActionListener(this);
+ }
+}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
index 7439be2..848c85d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
@@ -1,362 +1,372 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
+import ij.IJ;
+
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
+import signal.RealSignal;
+import signal.factory.SignalFactory;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
-import signal.RealSignal;
-import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
- public ImageModule(boolean expanded) {
- super("Image", "-image", (Lab.getPlatform() == Imager.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
+ public ImageModule() {
+ super("Image", "-image", (Lab.getPlatform() == Imager.Platform.IMAGEJ ? "Active" : ""), "Check");
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
// Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnTitle.setDropTarget(new LocalDropTarget());
bnSynopsis.setDropTarget(new LocalDropTarget());
bnExpand.setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
bnSynthetic.setToolTipText("Add a new source artificially created");
bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window from the running platform");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
+
+IJ.log("ImageModule, line 170 " + e);
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
- System.out.println(">>edit>> " + name + " == " + factory.getName().trim());
-
if (name.equals(factory.getName().trim())) {
synthetic(true);
return;
}
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
+
+IJ.log(">>>>>>>>>>>>>>> ImageModule, line 273 " + Command.command());
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
+
+IJ.log("ImageModule, line 276 " + Command.command());
+
deconvolution.openImage();
+IJ.log("ImageModule, line 279 " + stack);
+
if (stack) {
RealSignal x = deconvolution.getImage();
+IJ.log("ImageModule, line 283 " + (x == null));
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
index 5227327..111c194 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
@@ -1,251 +1,251 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.Token;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolutionlab.Config;
public class LanguageModule extends AbstractModule implements ActionListener {
private HTMLPane language;
private JComboBox<String> cmb;
private JComboBox<String> gui;
private JTextField txt;
- public LanguageModule(boolean expanded) {
- super("Language", "", "", "", expanded);
+ public LanguageModule() {
+ super("Language", "", "", "");
}
public String getJobName() {
if (txt != null)
return txt.getText();
return "";
}
@Override
public JPanel buildExpandedPanel() {
language = new HTMLPane("Monaco", 100, 100);
cmb = new JComboBox<String>(new String[] { "Command line", "ImageJ Macro", "Java", "Matlab" });
gui = new JComboBox<String>(new String[] { "Run (Headless)", "Launch (with control panel)" });
txt = new JTextField("Job", 8);
JPanel pn = new JPanel(new BorderLayout());
pn.add(cmb, BorderLayout.WEST);
pn.add(txt, BorderLayout.CENTER);
pn.add(gui, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(language.getPane(), BorderLayout.CENTER);
cmb.addActionListener(this);
gui.addActionListener(this);
Config.register(getName(), "language", cmb, cmb.getItemAt(0));
Config.register(getName(), "headless", gui, gui.getItemAt(0));
Config.register(getName(), "job", txt, "Job");
language.clear();
return panel;
}
@Override
public void expand() {
super.expand();
update();
}
public void update() {
if (cmb.getSelectedIndex() == 0) {
language.clear();
String run = gui.getSelectedIndex() == 0 ? " Run " : " Launch ";
language.append("p", "java -jar DeconvolutionLab_2.jar " + run + Command.command());
language.append("p", "");
language.append("p", "java -cp JTransforms.jar:DeconvolutionLab_2.jar DeconvolutionLab2 "+ run + Command.command());
}
else if (cmb.getSelectedIndex() == 1) {
language.clear();
language.append("p", imagej(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 2) {
language.clear();
language.append("p", java(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 3) {
language.clear();
language.append("p", matlab());
}
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb)
update();
if (e.getSource() == gui)
update();
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
update();
}
@Override
public String getCommand() {
return "";
}
private String matlab() {
String job = txt.getText();
String script = "";
String cmd = Command.command();
Deconvolution d = new Deconvolution("Matlab", cmd);
String options = Command.extractOptions(cmd);
AbstractAlgorithm algo = d.getAlgorithm();
if (algo == null)
return "ERROR";
String s = algo.getShortnames()[0];
String param = algo.getParametersAsString();
script += p("% this function returns the deconvolved image as an 3D matrix");
script += p("% image is a 3D matrix containing the image");
script += p("% psf is a 3D matrix containing the PSF");
script += p("function result = " + job + "(image, psf)");
script += p1("% Install first DeconvolutionLab_2.jar into the java directory of Matlab");
script += p1("javaaddpath([matlabroot filesep 'java' filesep 'DeconvolutionLab_2.jar'])");
script += p1("% Run the deconvolution\n");
script += p1("result = DL2." + s + "(image, psf, " + param +" , '" + options +"');");
script += p("end");
return script;
}
private String imagej(boolean headless) {
String job = txt.getText();
String macro = p("// Job: " + job + " ");
macro += p("// Macro generated by DeconvolutionLab2 ");
macro += p("// " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()) + " ");
String param = p("parameters = \"\" ");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = "image = \" NOT DEFINED \" ";
String psf = "psf = \" NOT DEFINED \" ";
String algo = "algo = \" NOT DEFINED \" ";
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p("image = \" -image " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-psf"))
psf = p("psf = \" -psf " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-algorithm"))
algo = p("algorithm = \" -algorithm " + token.parameters.trim() + "\" ");
else
param += p("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\"");
}
String option = macro + image + psf + algo + param;
String cmd = "";
if (headless)
cmd = p("run(\"DeconvolutionLab2 Run\", image + psf + algorithm + parameters)");
else
cmd = p("run(\"DeconvolutionLab2 Launch\", image + psf + algorithm + parameters)");
return option + cmd;
}
private String java(boolean headless) {
String job = txt.getText();
String code = "";
code += p("import deconvolution.Deconvolution;");
code += p("import ij.plugin.PlugIn;");
code += p("");
code += p("public class DeconvolutionLab2_" + job + " implements PlugIn {");
code += p1("public DeconvolutionLab2_" + job + "() {");
String param = p2("String parameters = \"\";");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = p2("String image = \" NOT DEFINED \";");
String psf = p2("String psf = \" NOT DEFINED \";");
String algo = p2("String algo = \" NOT DEFINED \";");
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p2("String image = \" -image " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-psf"))
psf = p2("String psf = \" -psf " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-algorithm"))
algo = p2("String algorithm = \" -algorithm " + token.parameters.trim() + "\";");
else
param += p2("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\";");
}
code += image + psf + algo + param;
code += p2("new Deconvolution(image + psf + algorithm + parameters)");
code += p1("}");
code += p1("");
code += p1("@Override");
code += p1("public void run(String arg0) {");
code += p2(" new DeconvolutionLab2_" + job + "();");
code += p1("}");
code += p("}");
return code;
}
private String p(String content) {
return "<p>" + content + "</p>";
}
private String p1(String content) {
return "<p style=\"padding-left:10px\">" + content + "</p>";
}
private String p2(String content) {
return "<p style=\"padding-left:20px\">" + content + "</p>";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
index 122e3c7..b253b2e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
@@ -1,81 +1,81 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
public class LicenceModule extends AbstractModule {
- public LicenceModule(boolean expanded) {
- super("Licence", "", "", "", expanded);
+ public LicenceModule() {
+ super("Licence", "", "", "");
}
@Override
public String getCommand() {
setSynopsis("GNU General Public License");
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p",
"DeconvolutionLab2 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 Foundation, " +
"either version 3 of the License, or (at your option) any later version.");
html.append("p",
"DeconvolutionLab2 is distributed in the hope that it will be useful, " +
"but WITHOUT ANY WARRANTY; without even the implied warranty " +
"of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " +
"See the GNU General Public License for more details.");
html.append("p",
"You should have received a copy of the GNU General Public License along with " +
"DeconvolutionLab2. If not, see http://www.gnu.org/licenses/.");
panel.add(html.getPane(), BorderLayout.CENTER);
setSynopsis("GNU General Public License");
return panel;
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
index 010cef9..f76c4e5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
@@ -1,231 +1,231 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.OutputDialog;
import deconvolutionlab.output.Output;
import deconvolutionlab.output.Output.View;
public class OutputModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnStack;
private JButton bnSeries;
private JButton bnMIP;
private JButton bnOrtho;
private JButton bnPlanar;
private JButton bnFigure;
- public OutputModule(boolean expanded) {
- super("Output", "", "Clear", "", expanded);
+ public OutputModule() {
+ super("Output", "", "Clear", "");
}
@Override
public String getCommand() {
String cmd = " ";
if (table == null)
return cmd;
for (int i = 0; i < table.getRowCount(); i++) {
String[] values = new String[table.getColumnCount()];
for(int c=0; c<table.getColumnCount(); c++)
values[c] = table.getCell(i, c) == null ? "" : table.getCell(i, c).trim();
cmd += " -out " + values[0] + " " + values[1] + " " + values[2] + " " + values[3] + " " + values[4];
if (values[5].equals(""))
cmd += " noshow";
if (values[6].equals(""))
cmd += " nosave";
}
return cmd;
}
public void update() {
setCommand(getCommand());
setSynopsis(table.getRowCount() + " output" + (table.getRowCount() > 1 ? "s" : ""));
Command.command();
getAction1Button().setEnabled(table.getRowCount() > 0);
}
@Override
public JPanel buildExpandedPanel() {
String[] dynamics = { "intact", "rescaled", "normalized", "clipped" };
String[] types = { "float", "short", "byte" };
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Mode", String.class, 80, false));
columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
columns.add(new CustomizedColumn("Origin", String.class, 120, false));
columns.add(new CustomizedColumn("Show", String.class, 50, false));
columns.add(new CustomizedColumn("Save", String.class, 50, false));
columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(5).setMaxWidth(50);
table.getColumnModel().getColumn(6).setMaxWidth(50);
table.getColumnModel().getColumn(7).setMaxWidth(30);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(3).setMaxWidth(100);
table.addMouseListener(this);
bnStack = new JButton("\u2295 stack");
bnSeries = new JButton("\u2295 series");
bnMIP = new JButton("\u2295 mip");
bnOrtho = new JButton("\u2295 ortho");
bnPlanar = new JButton("\u2295 planar");
bnFigure = new JButton("\u2295 figure");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 6));
pn.setFloatable(false);
pn.add(bnStack);
pn.add(bnSeries);
pn.add(bnMIP);
pn.add(bnOrtho);
pn.add(bnPlanar);
pn.add(bnFigure);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnStack.addActionListener(this);
bnSeries.addActionListener(this);
bnMIP.addActionListener(this);
bnOrtho.addActionListener(this);
bnPlanar.addActionListener(this);
bnFigure.addActionListener(this);
getAction1Button().addActionListener(this);
Config.registerTable(getName(), "output", table);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
View view = null;
if (e.getSource() == bnStack)
view = View.STACK;
else if (e.getSource() == bnSeries)
view = View.SERIES;
else if (e.getSource() == bnMIP)
view = View.MIP;
else if (e.getSource() == bnOrtho)
view = View.ORTHO;
else if (e.getSource() == bnPlanar)
view = View.PLANAR;
else if (e.getSource() == bnFigure)
view = View.FIGURE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out != null)
table.insert(out.getAsString());
//Lab.setVisible(new OutputPanel(view), "panel", 30, 30);
update();
}
if (e.getSource() == getAction1Button()) {
table.removeRows();
}
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 7) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnStack.removeActionListener(this);
bnSeries.removeActionListener(this);
bnMIP.removeActionListener(this);
bnOrtho.removeActionListener(this);
bnPlanar.removeActionListener(this);
bnFigure.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
index 637a7ce..e92dbd0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
@@ -1,350 +1,350 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
- public PSFModule(boolean expanded) {
- super("PSF", "-psf", "", "Check", expanded);
+ public PSFModule() {
+ super("PSF", "-psf", "", "Check");
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
// Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnTitle.setDropTarget(new LocalDropTarget());
bnSynopsis.setDropTarget(new LocalDropTarget());
bnExpand.setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
bnSynthetic.setToolTipText("Add a new source artificially created");
bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim())) {
synthetic(true);
return;
}
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
index 56419f5..d0c4e97 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
@@ -1,73 +1,73 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Config;
public class PreferencesModule extends AbstractModule {
private SpinnerRangeInteger spnMaxItems;
- public PreferencesModule(boolean expanded) {
- super("Preferences", "", "", "", expanded);
+ public PreferencesModule() {
+ super("Preferences", "", "", "");
}
@Override
public String getCommand() {
return "NO";
}
@Override
public JPanel buildExpandedPanel() {
spnMaxItems = new SpinnerRangeInteger(50, 1, 1000, 1);
JPanel panel = new JPanel(new BorderLayout());
GridPanel pn = new GridPanel(true);
pn.place(3, 0, "Maximum number of items in table");
pn.place(3, 1, spnMaxItems);
panel.add(pn, BorderLayout.NORTH);
Config.register(getName(), "maximum-items", spnMaxItems, 50);
return panel;
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/BorderModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PreprocessingModule.java
similarity index 82%
rename from DeconvolutionLab2/src/deconvolutionlab/module/BorderModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/PreprocessingModule.java
index 6d97e0a..d6c61d0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PreprocessingModule.java
@@ -1,243 +1,267 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
+import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import bilib.component.GridPanel;
-import bilib.component.SpinnerRangeInteger;
-import bilib.tools.NumFormat;
-import deconvolution.Command;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Config;
-import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
+import deconvolution.Command;
+import deconvolution.Deconvolution;
+import deconvolutionlab.Config;
+import deconvolutionlab.monitor.Monitors;
-public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
+public class PreprocessingModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
private JLabel lblPad;
private JLabel lblApo;
+ private JComboBox<String> cmbNormalization;
+ private JButton bnTest;
- public BorderModule(boolean expanded) {
- super("Border", "", "Test", "Default", expanded);
+ public PreprocessingModule() {
+ super("Preprocessing", "", "Default", "");
}
@Override
public String getCommand() {
AbstractPadding pxy = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding paz = Padding.getByName((String) cmbPadZ.getSelectedItem());
AbstractApodization axy = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apz = Apodization.getByName((String) cmbApoZ.getSelectedItem());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
String extXY = (ext ? "" + spnExtensionXY.get() : "") + " ";
String extZ = ext ? "" + spnExtensionZ.get() : "";
String cmd = "";
if (!(pxy instanceof NoPadding) || !(paz instanceof NoPadding) || spnExtensionXY.get() > 0 || spnExtensionZ.get() > 0)
cmd += " -pad " + pxy.getShortname() + " " + paz.getShortname() + " " + extXY + extZ;
if (!(axy instanceof UniformApodization) || !(apz instanceof UniformApodization))
cmd += " -apo " + axy.getShortname() + " " + apz.getShortname() + " ";
+ if (cmbNormalization.getSelectedIndex() != 0)
+ cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
+ bnTest = new JButton("Test");
+
lblPad = new JLabel("Information on padding size");
lblPad.setBorder(BorderFactory.createEtchedBorder());
lblApo = new JLabel("Information on apodization energy");
lblApo.setBorder(BorderFactory.createEtchedBorder());
cmbPadXY = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbPadZ = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbApoXY = new JComboBox<String>(Apodization.getApodizationsAsArray());
cmbApoZ = new JComboBox<String>(Apodization.getApodizationsAsArray());
spnExtensionXY = new SpinnerRangeInteger(0, 0, 99999, 1);
spnExtensionZ = new SpinnerRangeInteger(0, 0, 99999, 1);
+ cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
+
+ cmbNormalization.addActionListener(this);
+ cmbNormalization.setSelectedIndex(0);
+ cmbNormalization.removeActionListener(this);
GridPanel pnBorder = new GridPanel(false, 2);
+ pnBorder.place(0, 0, "<html><b>Image</b>");
pnBorder.place(0, 1, "Lateral (XY)");
pnBorder.place(0, 2, "Axial (Z)");
- pnBorder.place(2, 0, "Apodization");
- pnBorder.place(2, 1, cmbApoXY);
- pnBorder.place(2, 2, cmbApoZ);
-
- pnBorder.place(3, 0, "Padding Extension");
- pnBorder.place(3, 1, spnExtensionXY);
- pnBorder.place(3, 2, spnExtensionZ);
-
- pnBorder.place(4, 0, "Padding Constraint");
- pnBorder.place(4, 1, cmbPadXY);
- pnBorder.place(4, 2, cmbPadZ);
- pnBorder.place(5, 0, 3, 1, lblPad);
- pnBorder.place(6, 0, 3, 1, lblApo);
-
+ pnBorder.place(1, 0, "Apodization");
+ pnBorder.place(1, 1, cmbApoXY);
+ pnBorder.place(1, 2, cmbApoZ);
+
+ pnBorder.place(2, 0, "Padding Extension");
+ pnBorder.place(2, 1, spnExtensionXY);
+ pnBorder.place(2, 2, spnExtensionZ);
+
+ pnBorder.place(3, 0, "Padding Constraint");
+ pnBorder.place(3, 1, cmbPadXY);
+ pnBorder.place(3, 2, cmbPadZ);
+ pnBorder.place(4, 0, 3, 1, lblPad);
+ pnBorder.place(5, 0, 3, 1, lblApo);
+ pnBorder.place(6, 2, 3, 1, bnTest);
+ pnBorder.place(7, 0, " ");
+ pnBorder.place(8, 0, "<html><b>PSF</b>");
+ pnBorder.place(9, 0, "Normalization");
+ pnBorder.place(9, 1, cmbNormalization);
+ pnBorder.place(9, 2, "recommended: 1");
+
JScrollPane scroll = new JScrollPane(pnBorder);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
+ Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
+
+ cmbNormalization.addActionListener(this);
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
+ bnTest.addActionListener(this);
getAction1Button().addActionListener(this);
- getAction2Button().addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
- if (e.getSource() == getAction2Button()) {
+ if (e.getSource() == getAction1Button()) {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
cmbPadXY.setSelectedIndex(0);
cmbPadZ.setSelectedIndex(0);
cmbApoXY.setSelectedIndex(0);
cmbApoZ.setSelectedIndex(0);
spnExtensionXY.set(0);
spnExtensionZ.set(0);
+ cmbNormalization.setSelectedIndex(0);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
update();
return;
}
- if (e.getSource() == getAction1Button()) {
+ if (e.getSource() == bnTest) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getAction1Button().setEnabled(false);
getAction2Button().setEnabled(false);
Deconvolution d = new Deconvolution("CheckImage", Command.command());
Apodization apo = d.getController().getApodization();
if (apo == null) {
lblApo.setText("Error in Apodization");
return;
}
Padding pad = d.getController().getPadding();
if (pad == null) {
lblPad.setText("Error in Padding");
return;
}
RealSignal x = d.openImage();
if (x == null) {
lblPad.setText("Error in input image");
lblApo.setText("Error in input image");
return;
}
Monitors m = Monitors.createDefaultMonitor();
RealSignal y = pad.pad(m, x);
apo.apodize(m, y);
lblPad.setText(x.dimAsString() + " > " + y.dimAsString());
lblApo.setText(NumFormat.nice(x.getStats()[5]) + " > " + NumFormat.nice(y.getStats()[5]));
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
update();
}
@Override
public void close() {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
- getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
+ cmbNormalization.removeActionListener(this);
+ bnTest.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java
index 4ce133a..63a2ff8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java
@@ -1,216 +1,216 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 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
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class RunningModule extends AbstractModule implements MouseListener {
private CustomizedTable table;
private String[] valuesMonitor;
private String[] valuesVerbose;
private String[] valuesPath;
private JTextField txtMonitor;
private JTextField txtVerbose;
private JTextField txtPath;
private JTextField txtDirectory;
- public RunningModule(boolean expanded) {
- super("Running", "", "Default", "Browse", expanded);
+ public RunningModule() {
+ super("Running", "", "Default", "Browse");
}
@Override
public String getCommand() {
String cmd = "";
String p = txtPath.getText();
if (!p.equalsIgnoreCase(valuesPath[0]))
cmd += " -path " + txtDirectory.getText().toLowerCase();
if (!txtMonitor.getText().equalsIgnoreCase(valuesMonitor[0]))
cmd += " -monitor " + txtMonitor.getText().toLowerCase();
if (!txtVerbose.getText().equalsIgnoreCase(valuesVerbose[0]))
cmd += " -verbose " + txtVerbose.getText().toLowerCase();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
valuesPath = new String[] { "current", "specify" };
valuesMonitor = new String[] { "console table", "console", "table", "no" };
valuesVerbose = new String[] { "log", "quiet", "mute", "prolix" };
txtDirectory = new JTextField(System.getProperty("user.dir"));
txtPath = new JTextField(valuesPath[0]);
txtMonitor = new JTextField(valuesMonitor[0]);
txtVerbose = new JTextField(valuesVerbose[0]);
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Settings", String.class, 150, false));
columns.add(new CustomizedColumn("State", String.class, 100, false));
columns.add(new CustomizedColumn("Information", String.class, Constants.widthGUI - 250, true));
columns.add(new CustomizedColumn("", String.class, 100, "Change", "Change this setting"));
table = new CustomizedTable(columns, false);
table.getColumnModel().getColumn(3).setMaxWidth(140);
table.getColumnModel().getColumn(3).setMaxWidth(140);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
Config.register(getName(), "Path", txtPath, valuesPath[0]);
Config.register(getName(), "Monitor", txtMonitor, valuesMonitor[0]);
Config.register(getName(), "Verbose", txtVerbose, valuesVerbose[0]);
Config.register(getName(), "Directory", txtDirectory, System.getProperty("user.dir"));
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
table.addMouseListener(this);
return panel;
}
public void init() {
table.append(new String[] { "Path", txtPath.getText(), txtDirectory.getText(), "Change" });
table.append(new String[] { "Monitor", txtMonitor.getText(), "Monitor in table and in console", "Change" });
table.append(new String[] { "Verbose", txtVerbose.getText(), "Level of messages in monitor", "Change" });
update();
}
public void update() {
setCommand(getCommand());
setSynopsis(txtDirectory.getText());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction1Button()) {
for (int row = 0; row < table.getRowCount(); row++) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
setDefault(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
setDefault(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
setDefault(row, valuesVerbose, txtVerbose);
}
}
if (e.getSource() == getAction2Button()) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtDirectory.setText(f.getAbsolutePath());
txtPath.setText(valuesPath[1]);
table.setCell(0, 1, txtPath.getText());
table.setCell(0, 2, txtDirectory.getText());
}
}
update();
}
@Override
public void close() {
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 3) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
toggle(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
toggle(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
toggle(row, valuesVerbose, txtVerbose);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
private void toggle(int row, String values[], JTextField txt) {
for (int i = 0; i < values.length; i++) {
if (table.getCell(row, 1).equalsIgnoreCase(values[i])) {
int k = i == values.length - 1 ? 0 : i + 1;
table.setCell(row, 1, values[k]);
txt.setText(values[k]);
return;
}
}
setDefault(row, values, txt);
}
private void setDefault(int row, String values[], JTextField txt) {
table.setCell(row, 1, values[0]);
txt.setText(values[0]);
}
}

Event Timeline