Page MenuHomec4science

No OneTemporary

File Metadata

Created
Sat, Aug 24, 12:17
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index f98f514..d929b86 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,77 +1,80 @@
#DeconvolutionLab2 [Beta 1]
#DeconvolutionLab2 [Beta 1]
-#Wed Feb 01 21:16:58 CET 2017
+#Thu Feb 02 15:10:59 CET 2017
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.LW.iterations=10
Algorithm.LW.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.apoz=Uniform
Border.extxy=0
Border.extz=0
Border.normalization=1
Border.padxy=None
Border.padz=None
Controller.constraint.enable=false
Controller.constraint.snapshot=1
Controller.constraint.value=No
Controller.reference.enable=false
Controller.reference.snapshot=1
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.snapshot=1
Controller.residu.value=0.01
Controller.savestats.enable=false
Controller.savestats.snapshot=1
Controller.savestats.value=Stats
Controller.showstats.enable=false
Controller.showstats.snapshot=1
Controller.showstats.value=Stats
DeconvolutionLab.MainDialog.location.h=579
DeconvolutionLab.MainDialog.location.w=573
DeconvolutionLab.MainDialog.location.x=5
DeconvolutionLab.MainDialog.location.y=23
Fourier.dim=XYZ
Fourier.epsilon=1E-6
Fourier.fft=Academic
-Image.image.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
-Image.image.row1=resolution;directory;/Users/dsage/Desktop/DeconvolutionLab2-Course/resolution;
-Image.image.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+Image.image.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
+Image.image.row1=resolution;directory;/Users/dsage/Desktop/DeconvolutionLab2-Course/resolution;null
+Image.image.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
Language.headless=Run (Headless)
Language.language=Command line
-Monitor.monitor=console table
+Monitor.disable.console=false
+Monitor.disable.display=false
+Monitor.disable.multithreading=false
+Monitor.disable.table=false
Monitor.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
Monitor.time.value=3600
-Monitor.time=no limit
-Monitor.verbose=log
-Output.output.row0=ortho;Noname;;;;\u2713;\u2713;
-Output.output.selected=ortho;Noname;;;;\u2713;\u2713;
-PSF.psf.row0=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;
-PSF.psf.row1=Defocus;synthetic;Defocus 100.0 0.0 3.0 10.0 10.0 size 3 3 100 ;
-PSF.psf.selected=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;
+Monitor.time=No time limitation
+Monitor.verbose=Verbose\: log
+Output.output.row0=ortho;Noname;;;;\u2713;\u2713;null
+Output.output.selected=ortho;Noname;;;;\u2713;\u2713;null
+PSF.psf.row0=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;null
+PSF.psf.row1=Defocus;synthetic;Defocus 100.0 0.0 3.0 10.0 10.0 size 3 3 100 ;null
+PSF.psf.selected=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;null
diff --git a/DeconvolutionLab2/plugins.config b/DeconvolutionLab2/plugins.config
index 0b36b23..f5c275f 100644
--- a/DeconvolutionLab2/plugins.config
+++ b/DeconvolutionLab2/plugins.config
@@ -1,20 +1,20 @@
# Name: DeconvolutionLab 2
# Daniel Sage
# Biomedical Imaging Group
# Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
# Date: 11 July 2016
-Plugins>DeconvolutionLab2, "DeconvolutionLab2 Lab", DeconvolutionLab2_
+Plugins>DeconvolutionLab2, "DeconvolutionLab2 Lab", DeconvolutionLab2_Lab
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Launch", DeconvolutionLab2_Launch
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Run", DeconvolutionLab2_Run
Plugins>DeconvolutionLab2, "DeconvolutionLab2 FFT", DeconvolutionLab2_FFT
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Help", DeconvolutionLab2_Help
Plugins>DeconvolutionLab2>Course, "Bigradient", DeconvolutionLab2_Course_Bigradient
Plugins>DeconvolutionLab2>Course, "Border", DeconvolutionLab2_Course_Border
Plugins>DeconvolutionLab2>Course, "Noise", DeconvolutionLab2_Course_Noise
Plugins>DeconvolutionLab2>Course, "Resolution", DeconvolutionLab2_Course_Resolution
Plugins>DeconvolutionLab2>Course, "SpectralAnaylsis", DeconvolutionLab2_Course_SpectralAnaylsis
diff --git a/DeconvolutionLab2/src/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index 7442cc2..3ee918d 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,296 +1,286 @@
/*
* 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 java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lab.tools.NumFormat;
import signal.Constraint;
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;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
public class Command {
public static String keywords[] = {
"-image", "-psf", "-algorithm",
- "-path", "-monitor", "-verbose", "-time",
+ "-path", "-disable", "-verbose", "-time",
"-constraint", "-residu", "-reference", "-savestats", "-showstats",
"-out", "-pad", "-apo", "-norm", "-fft"
};
private static AbstractModule modules[];
private static CommandModule command;
- private static LanguageModule language;
- public static void active(AbstractModule[] m, CommandModule c, LanguageModule l) {
+ public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
- language = l;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
-
- //if (language != null)
- // language.update();
-
+
return cmd;
}
/**
* 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++) {
CommandSegment segment = segments.get(i);
String next = (i + 1 < segments.size() ? segments.get(i + 1).keyword : "");
int end = (i + 1 < segments.size() ? segments.get(i + 1).index - next.length() : command.length());
tokens.add(new Token(segment.keyword, command, segment.index, end));
}
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 key) {
int index = -1;
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
do {
index = command.indexOf(key, index + 1);
if (index >= 0) {
segments.add(new CommandSegment(key, index + key.length()));
}
}
while (index >= 0);
return segments;
}
public static AbstractAlgorithm decodeAlgorithm(Token token, Controller controller) {
String option = token.option;
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
double params[] = parseNumeric(token.parameters);
if (params != null) {
algo.setParameters(params);
if (algo.isIterative())
controller.setIterationMax(algo.getController().getIterationMax());
}
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 void decodeController(Token token, Controller controller) {
int freq = 1;
String line = token.parameters;
if (token.parameters.startsWith("@")) {
String parts[] = token.parameters.split(" ");
if (parts.length >= 1) {
freq = (int)NumFormat.parseNumber(parts[0], 1);
line = token.parameters.substring(parts[0].length(), token.parameters.length()).trim();
}
}
if (token.keyword.equals("-constraint")) {
controller.setConstraint(freq, Constraint.getByName(line.trim()));
}
else if (token.keyword.equals("-residu")) {
double stop = NumFormat.parseNumber(line, -1);
controller.setResiduStop(freq, stop);
}
else if (token.keyword.equals("-reference")) {
controller.setReference(freq, line);
}
else if (token.keyword.equals("-savestats")) {
controller.setSaveStats(freq, line);
}
else if (token.keyword.equals("-showstats")) {
controller.setShowStats(freq, line);
}
else if (token.keyword.equals("-time")) {
double stop = NumFormat.parseNumber(line, Double.MAX_VALUE);
controller.setTimeStop(stop);
}
}
public static double decodeNormalization(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return 0;
else
return NumFormat.parseNumber(token.parameters, 1);
}
- public static Monitors decodeMonitors(Token token) {
+ public static boolean decodeDisable(Token token, String word) {
String p = token.parameters.toLowerCase();
- Monitors monitors = new Monitors();
- if (p.endsWith("no"))
- return monitors;
String parts[] = p.split(" ");
for(String part : parts) {
- if (part.trim().equals("console"))
- monitors.add(new ConsoleMonitor());
- if (part.trim().equals("table"))
- monitors.add(new TableMonitor(400, 400));
+ if (part.trim().equals(word))
+ return false;
}
- return monitors;
+ return true;
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
int extXY = 0;
int extZ = 0;
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);
if (ext.length > 0)
extXY = (int)Math.round(ext[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);
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 8dfbc8a..bf4cf98 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,607 +1,667 @@
/*
* 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 java.io.File;
import java.util.ArrayList;
import javax.swing.JFrame;
-import javax.swing.JTabbedPane;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.OutputCollection;
import deconvolutionlab.monitor.AbstractMonitor;
+import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import lab.tools.NumFormat;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.factory.SignalFactory;
import signal.padding.Padding;
public class Deconvolution implements Runnable {
private AbstractAlgorithm algo = null;
private String path;
private Monitors monitors = Monitors.createDefaultMonitor();
private Verbose verbose = Verbose.Log;
private Controller controller;
private OutputCollection outs;
private Padding padding = new Padding();
private Apodization apodization = new Apodization();
private double factorNormalization = 1.0;
private AbstractFFTLibrary fftlib;
private String command = "";
private boolean live = false;
- private ArrayList<String> results = new ArrayList<String>();
+ private ArrayList<String> report = new ArrayList<String>();
private String name = "";
private boolean exit = false;
+ private boolean watcherMonitor = true;
+ private boolean watcherConsole = true;
+ private boolean watcherDisplay = true;
+ private boolean watcherMultithreading = true;
+
+ private ArrayList<DeconvolutionListener> listeners = new ArrayList<DeconvolutionListener>();
+
public Deconvolution(String command) {
super();
monitors = Monitors.createDefaultMonitor();
this.command = command;
decode();
}
public void setCommand(String command) {
this.command = command;
decode();
}
public String getCommand() {
return command;
}
public Monitors getMonitors() {
if (monitors == null)
return Monitors.createDefaultMonitor();
return monitors;
}
/**
* This method runs the deconvolution without graphical user interface.
*
* @param exit
* System.exit call is true
*/
public void deconvolve(boolean exit) {
this.exit = exit;
- for (AbstractMonitor monitor : monitors) {
- if (monitor instanceof TableMonitor) {
- String t = algo == null ? "Monitor " + name : name + " " + algo.getName();
- JFrame frame = new JFrame(t);
- frame.add(((TableMonitor) monitor).getPanel());
- frame.pack();
- frame.setVisible(true);
- }
+ monitors = new Monitors();
+ if (watcherConsole)
+ monitors.add(new ConsoleMonitor());
+
+ if (watcherMonitor) {
+ TableMonitor m = new TableMonitor(440, 440);
+ monitors.add(m);
+ String t = algo == null ? "Monitor " + name : name + " " + algo.getName();
+ JFrame frame = new JFrame(t);
+ frame.add(m.getPanel());
+ frame.pack();
+ frame.setVisible(true);
}
if (fftlib == null) {
run();
return;
}
if (!fftlib.isMultithreadable()) {
run();
return;
}
- Thread thread = new Thread(this);
- thread.setPriority(Thread.MIN_PRIORITY);
- thread.start();
+
+ if (watcherMultithreading) {
+ Thread thread = new Thread(this);
+ thread.setPriority(Thread.MIN_PRIORITY);
+ thread.start();
+ }
+ else {
+ run();
+ }
+
}
/**
* This method runs the deconvolution with a graphical user interface.
*
* @param job
* Name of the job of deconvolution
* @param exit
* System.exit call is true
*/
public void launch(String job, boolean exit) {
this.name = job;
this.exit = exit;
DeconvolutionDialog d = new DeconvolutionDialog(this);
- for (AbstractMonitor monitor : monitors) {
- if (monitor instanceof TableMonitor) {
- String t = algo == null ? "Monitor " + name : name + " " + algo.getName();
- d.addTableMonitor(t, ((TableMonitor) monitor));
- }
+
+ monitors = new Monitors();
+ if (watcherConsole)
+ monitors.add(new ConsoleMonitor());
+
+ if (watcherMonitor) {
+ TableMonitor m = new TableMonitor(440, 440);
+ monitors.add(m);
+ d.addTableMonitor("Monitor", m);
}
+
}
public void decode() {
algo = null;
path = System.getProperty("user.dir");
- monitors = Monitors.createDefaultMonitor();
+ if (monitors==null)
+ monitors = Monitors.createDefaultMonitor();
verbose = Verbose.Log;
controller = new Controller();
outs = new OutputCollection();
padding = new Padding();
apodization = new Apodization();
factorNormalization = 1.0;
fftlib = FFT.getLibraryByName("Academic");
live = false;
- results = new ArrayList<String>();
-
ArrayList<Token> tokens = Command.parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-algorithm"))
algo = Command.decodeAlgorithm(token, controller);
- if (token.keyword.equalsIgnoreCase("-monitor"))
- monitors = Command.decodeMonitors(token);
+ if (token.keyword.equalsIgnoreCase("-disable")) {
+ watcherMonitor = Command.decodeDisable(token, "monitor");
+ watcherConsole = Command.decodeDisable(token, "console");
+ watcherDisplay = Command.decodeDisable(token, "display");
+ watcherMultithreading = Command.decodeDisable(token, "multithreading");
+ }
if (token.keyword.equalsIgnoreCase("-verbose"))
verbose = Verbose.getByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current")) {
path = token.parameters;
}
if (token.keyword.equalsIgnoreCase("-fft"))
fftlib = FFT.getLibraryByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-pad"))
padding = Command.decodePadding(token);
if (token.keyword.equalsIgnoreCase("-apo"))
apodization = Command.decodeApodization(token);
if (token.keyword.equalsIgnoreCase("-norm"))
factorNormalization = Command.decodeNormalization(token);
if (token.keyword.equalsIgnoreCase("-constraint"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-time"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-residu"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-reference"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-savestats"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-showstats"))
Command.decodeController(token, controller);
if (token.keyword.equals("-out")) {
Output out = Command.decodeOut(token);
if (out != null)
outs.add(out);
}
}
if (name.equals("") && algo != null)
name = algo.getShortname();
}
public void setApodization(ArrayList<AbstractApodization> apos) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
if (apos.size() >= 1)
apoXY = apos.get(0);
if (apos.size() >= 2)
apoZ = apos.get(1);
this.apodization = new Apodization(apoXY, apoXY, apoZ);
}
@Override
public void run() {
+ double chrono = System.nanoTime();
+
+ for(DeconvolutionListener listener : listeners)
+ listener.started();
+
live = true;
if (monitors != null)
monitors.setVerbose(verbose);
- results.add("Path: " + checkPath(path));
+ report.add("Path: " + checkPath(path));
monitors.log("Path: " + checkPath(path));
RealSignal image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
+ report.add("Image: Not valid");
if (exit)
System.exit(-101);
return;
}
+ report.add("Image: " + image.dimAsString());
+
monitors.log("Image: " + image.nx + " x " + image.ny + " x " + image.nz);
RealSignal y = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
+ report.add("PSF: Not valid");
if (exit)
System.exit(-102);
return;
}
+ report.add("PSF: " + psf.dimAsString());
monitors.log("PSF: " + psf.nx + " x " + psf.ny + " x " + psf.nz);
monitors.log("PSF: normalization " + (factorNormalization <= 0 ? "no" : factorNormalization));
RealSignal h = psf.changeSizeAs(y).normalize(factorNormalization);
if (algo == null) {
monitors.error("Algorithm: not valid");
if (exit)
System.exit(-103);
return;
}
if (controller == null) {
monitors.error("Controller: not valid");
if (exit)
System.exit(-104);
return;
}
AbstractFFT fft;
if (fftlib != null)
fft = FFT.createFFT(monitors, fftlib, image.nx, image.ny, image.nz);
else
fft = FFT.createDefaultFFT(monitors, image.nx, image.ny, image.nz);
+ report.add("FFT: " + fft.getName());
+
algo.setFFT(fft);
controller.setFFT(fft);
algo.setController(controller);
if (outs != null) {
outs.setPath(path);
controller.setOutputs(outs);
}
monitors.log("Algorithm: " + algo.getName());
+ report.add("Algorithm: " + algo.getName());
RealSignal x = algo.run(monitors, y, h, true);
RealSignal result = padding.crop(monitors, x);
if (outs != null)
outs.executeFinal(monitors, result, controller);
live = false;
+ for(DeconvolutionListener listener : listeners)
+ listener.finish();
+
+ report.add("End " + algo.getName() + " in " + NumFormat.time(System.nanoTime()-chrono));
+
+ if (watcherDisplay)
+ Lab.show(monitors, result, "Result of " + algo.getShortname());
if (exit) {
System.out.println("End");
System.exit(0);
}
-
+
}
+ /**
+ * This methods make a recap of the deconvolution. Useful before starting the processing.
+ *
+ * @return list of messages to print
+ */
public ArrayList<String> recap() {
ArrayList<String> lines = new ArrayList<String>();
Token image = Command.extract(command, "-image");
if (image == null)
lines.add("<b>Image</b>: <span color=\"red\">keyword -image not found</span>");
else
lines.add("<b>Image</b>: " + image.parameters);
String norm = (factorNormalization < 0 ? " (no normalization)" : " (normalization to " + factorNormalization + ")");
Token psf = Command.extract(command, "-psf");
if (psf == null)
lines.add("<b>PSF</b>: <span color=\"red\">keyword -psf not found</span>");
else
lines.add("<b>PSF</b>: " + psf.parameters + norm);
if (algo == null) {
lines.add("<b>Algorithm</b>: <span color=\"red\">not valid</span>");
}
else {
Controller controller = algo.getController();
String con = ", " + controller.getConstraintAsString() + " constraint";
lines.add("<b>Algorithm</b>: " + algo.toString() + con);
lines.add("<b>Stopping Criteria</b>: " + controller.getStoppingCriteria(algo));
lines.add("<b>Reference</b>: " + controller.getReference());
lines.add("<b>Stats</b>: " + controller.getShowStats() + " " + controller.getSaveStats());
lines.add("<b>Padding</b>: " + padding.toString());
lines.add("<b>Apodization</b>: " + apodization.toString());
if (algo.getFFT() != null)
lines.add("<b>FFT</b>: " + algo.getFFT().getName());
}
lines.add("<b>Path</b>: " + path);
String m = "";
if (monitors != null) {
for (AbstractMonitor monitor : monitors)
m += monitor.getName() + " ";
}
- String v = "";
- if (verbose != null)
- v = "(" + verbose.name().toLowerCase() + ")";
- lines.add("<b>Monitor</b>:" + m + " " + v);
-
+ lines.add("<b>Verbose</b>: " + verbose.name().toLowerCase());
+ lines.add("<b>Monitor</b>: " + (watcherMonitor ? "on" : "off"));
+ lines.add("<b>Console</b>: " + (watcherConsole ? "on" : "off"));
+ lines.add("<b>Final Display</b>: " + (watcherDisplay ? "on" : "off"));
+ lines.add("<b>Multithreading</b>: " + (watcherMultithreading ? "on" : "off"));
+
if (outs == null)
lines.add("<b>Outputs</b>: not valid");
else
lines.addAll(outs.getInformation());
return lines;
}
public ArrayList<String> checkAlgo() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal psf = openPSF();
if (psf == null) {
lines.add("No valid PSF");
return lines;
}
if (algo == null) {
lines.add("No valid algorithm");
return lines;
}
Controller controller = algo.getController();
RealSignal y = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal h = psf.changeSizeAs(y).normalize(factorNormalization);
int iter = controller.getIterationMax();
algo.getController().setIterationMax(1);
RealSignal x = algo.run(monitors, y, h, true);
Lab.show(monitors, x, "Estimate after 1 iteration");
lines.add("Time: " + NumFormat.seconds(controller.getTimeNano()));
lines.add("Peak Memory: " + controller.getMemoryAsString());
controller.setIterationMax(iter);
return lines;
}
public ArrayList<String> checkImage() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal signal = padding.pad(monitors, getApodization().apodize(monitors, image));
lines.add("<b>Image</b>");
lines.add("Original size " + image.dimAsString() + " padded to " + signal.dimAsString());
lines.add("Original: " + formatStats(image));
lines.add("Preprocessing: " + formatStats(signal));
Lab.show(monitors, signal, "Image");
return lines;
}
public ArrayList<String> checkPSF() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal psf = openPSF();
if (psf == null) {
lines.add("No valid PSF");
return lines;
}
RealSignal signal = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal h = psf.changeSizeAs(signal);
lines.add("<b>PSF</b>");
lines.add("Original size " + psf.dimAsString() + " padded to " + h.dimAsString());
String e = NumFormat.nice(h.getEnergy());
h.normalize(factorNormalization);
lines.add("Original: " + formatStats(psf));
lines.add("Preprocessing: " + formatStats(h));
lines.add("Energy = " + e + " and after normalization=" + NumFormat.nice(h.getEnergy()));
Lab.show(monitors, h, "Padded and Normalized PSF");
return lines;
}
- public ArrayList<String> getDeconvolutionResults() {
- return results;
+ public ArrayList<String> getDeconvolutionReports() {
+ return report;
}
public String getName() {
return name;
}
public boolean isLive() {
return live;
}
public void abort() {
live = false;
algo.getController().abort();
}
public Padding getPadding1() {
return padding;
}
public Apodization getApodization() {
return apodization;
}
public OutputCollection getOuts() {
return outs;
}
public AbstractAlgorithm getAlgo() {
return algo;
}
public String getPath() {
return path;
}
public String checkPath(String path) {
File dir = new File(path);
if (dir.exists()) {
if (dir.isDirectory()) {
if (dir.canWrite())
return path + " (writable)";
else
return path + " (non-writable)";
}
else {
return path + " (non-directory)";
}
}
else {
return path + " (not-valid)";
}
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
+ if (token.parameters.startsWith(">>>"))
+ return null;
return getImage(monitors, token);
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
+ if (token.parameters.startsWith(">>>"))
+ return null;
return getImage(monitors, token);
}
private RealSignal getImage(Monitors monitors, Token token) {
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
if (arg.equalsIgnoreCase("synthetic")) {
String parts[] = cmd.split(" ");
if (parts.length <= 0)
return null;
String shape = parts[0];
for (String name : SignalFactory.getAllName()) {
if (shape.equalsIgnoreCase(name.toLowerCase())) {
double params[] = Command.parseNumeric(cmd);
SignalFactory factory = SignalFactory.getFactoryByName(shape);
if (factory == null)
return null;
double amplitude = params.length > 0 ? params[0] : 1;
double background = params.length > 1 ? params[1] : 0;
factory.intensity(background, amplitude);
int np = factory.getParameters().length;
double[] features = new double[np];
for (int i = 0; i < Math.min(np, params.length); i++)
features[i] = params[i + 2];
factory.setParameters(features);
int nx = params.length > np + 2 ? (int) Math.round(params[np + 2]) : 128;
int ny = params.length > np + 3 ? (int) Math.round(params[np + 3]) : 128;
int nz = params.length > np + 4 ? (int) Math.round(params[np + 4]) : 128;
double cx = params.length > np + 5 ? params[np + 5] : 0.5;
double cy = params.length > np + 6 ? params[np + 6] : 0.5;
double cz = params.length > np + 7 ? params[np + 7] : 0.5;
factory = factory.center(cx, cy, cz);
RealSignal x = factory.generate(nx, ny, nz);
return x;
}
}
}
if (arg.equalsIgnoreCase("file") || arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
RealSignal signal = null;
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.open(monitors, path + File.separator + cmd);
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.open(monitors, cmd);
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
return signal;
}
if (arg.equalsIgnoreCase("platform")) {
return Lab.getImager().create(cmd);
}
return null;
}
private static String formatStats(RealSignal x) {
float stats[] = x.getStats();
String s = " mean=" + NumFormat.nice(stats[0]);
s += " stdev=" + NumFormat.nice(stats[1]);
s += " min=" + NumFormat.nice(stats[3]);
s += " max=" + NumFormat.nice(stats[2]);
return s;
}
+
+ public void addDeconvolutionListener(DeconvolutionListener listener) {
+ listeners.add(listener);
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 0eaa65e..2bd4aff 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,271 +1,299 @@
/*
* 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.gui.GUI;
+
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
import javax.swing.text.BadLocationException;
+import lab.component.HTMLPane;
+import lab.system.SystemBar;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
-import ij.gui.GUI;
-import lab.component.HTMLPane;
-import lab.system.SystemBar;
-public class DeconvolutionDialog extends JDialog implements ActionListener, Runnable, KeyListener {
+public class DeconvolutionDialog extends JDialog implements ActionListener, Runnable, KeyListener, DeconvolutionListener {
+ public enum State {NOTDEFINED, READY, RUN, FINISH};
+
private JButton bnStart = new JButton("Run");
private JButton bnQuit = new JButton("Quit");
private JButton bnRecap = new JButton("Recap");
private JButton bnImage = new JButton("Check Image");
private JButton bnPSF = new JButton("Check PSF");
private JButton bnAlgo = new JButton("Check Algo");
private JButton bnHelp = new JButton("Help");
private JTabbedPane tab = new JTabbedPane();
private HTMLPane pnCommand;
private HTMLPane pnResume;
private JButton job = null;
private Thread thread = null;
private Deconvolution deconvolution;
+ private State state = State.NOTDEFINED;
public DeconvolutionDialog(Deconvolution deconvolution) {
super(new JFrame(), deconvolution.getName() + " " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()));
this.deconvolution = deconvolution;
JProgressBar status = new JProgressBar();
deconvolution.getMonitors().add(new StatusMonitor(status));
pnCommand = new HTMLPane("Monaco", 100, 100);
pnCommand.append("p", deconvolution.getCommand());
pnResume = new HTMLPane("Verdana", 600, 150);
tab.add("Resume", pnResume.getPane());
pnCommand.setEditable(true);
pnCommand.addKeyListener(this);
JPanel bn = new JPanel();
bn.setLayout(new GridLayout(1, 5));
bn.setBorder(BorderFactory.createEtchedBorder());
bn.add(bnRecap);
bn.add(bnImage);
bn.add(bnPSF);
bn.add(bnAlgo);
bn.add(bnStart);
status.setAlignmentX(JLabel.CENTER_ALIGNMENT);
status.setBorder(BorderFactory.createLoweredBevelBorder());
JToolBar statusBar = new JToolBar();
statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
statusBar.setFloatable(false);
statusBar.setLayout(new BorderLayout());
statusBar.add(bnHelp, BorderLayout.WEST);
statusBar.add(status, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
bottom.add(bn);
bottom.add(new SystemBar(200));
bottom.add(statusBar);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(pnCommand.getPane(), BorderLayout.NORTH);
panel.add(bottom, BorderLayout.SOUTH);
panel.add(tab, BorderLayout.CENTER);
add(panel);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnPSF.addActionListener(this);
bnImage.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
bnHelp.addActionListener(this);
+ deconvolution.addDeconvolutionListener(this);
- setMinimumSize(new Dimension(200, 400));
+ setMinimumSize(new Dimension(400, 200));
pack();
GUI.center(this);
setVisible(true);
print(deconvolution.recap());
+ state = State.READY;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
- if (thread == null) {
+ if (state == State.FINISH)
+ print(deconvolution.getDeconvolutionReports());
+ else if (thread == null) {
job = bnStart;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
+ finish();
if (deconvolution != null)
deconvolution.abort();
}
}
else if (e.getSource() == bnRecap) {
if (thread == null) {
job = bnRecap;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnImage) {
if (thread == null) {
job = bnImage;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnPSF) {
if (thread == null) {
job = bnPSF;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnAlgo) {
if (thread == null) {
job = bnAlgo;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnQuit) {
dispose();
}
else if (e.getSource() == bnHelp)
Lab.help();
}
@Override
public void run() {
+
bnRecap.setEnabled(false);
bnAlgo.setEnabled(false);
bnPSF.setEnabled(false);
bnImage.setEnabled(false);
- bnStart.setText("Stop");
+ bnStart.setEnabled(false);
String command = pnCommand.getText();
deconvolution.setCommand(command);
if (job == bnStart) {
- // tab.setSelectedIndex(1);
- print(deconvolution.recap());
+ if (tab.getTabCount() > 1)
+ tab.setSelectedIndex(1);
+ else
+ print(deconvolution.recap());
deconvolution.run();
- print(deconvolution.getDeconvolutionResults());
+ print(deconvolution.getDeconvolutionReports());
}
else if (job == bnRecap) {
tab.setSelectedIndex(0);
print(deconvolution.recap());
}
else if (job == bnImage) {
tab.setSelectedIndex(0);
print(deconvolution.checkImage());
}
else if (job == bnPSF) {
tab.setSelectedIndex(0);
print(deconvolution.checkPSF());
}
else if (job == bnAlgo) {
tab.setSelectedIndex(0);
print(deconvolution.checkAlgo());
}
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
- bnStart.setText("Start");
+ bnStart.setEnabled(true);
thread = null;
}
private void print(ArrayList<String> lines) {
pnResume.clear();
for (String line : lines)
pnResume.append("p", line);
}
public void addTableMonitor(String title, TableMonitor tm) {
tab.add(title, tm.getPanel());
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
int len = pnCommand.getDocument().getLength();
String command = pnCommand.getDocument().getText(0, len);
deconvolution.setCommand(command);
print(deconvolution.recap());
}
catch (BadLocationException e1) {
e1.printStackTrace();
}
}
+ @Override
+ public void started() {
+ bnStart.setEnabled(true);
+ bnStart.setText("Abort");
+ state = State.RUN;
+ tab.setSelectedIndex(0);
+ }
+
+ @Override
+ public void finish() {
+ bnStart.setEnabled(true);
+ bnStart.setText("Report");
+ state = State.FINISH;
+ tab.setSelectedIndex(0);
+ }
+
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index 7a8c629..7e88e00 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,181 +1,182 @@
/*
* 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.algorithm;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import lab.tools.NumFormat;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import signal.Operations;
import signal.RealSignal;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
protected RealSignal y = null;
protected RealSignal h = null;
protected RealSignal reference = null;
protected Controller controller = null;
protected AbstractFFT fft = null;
public AbstractAlgorithm() {
this.controller = new Controller();
}
public abstract String getName();
public abstract String getShortname();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract void setParameters(double[] params);
public abstract double getRegularizationFactor();
public abstract double getStepFactor();
public abstract double[] getParameters();
public abstract double[] getDefaultParameters();
public RealSignal run(Monitors monitors, RealSignal image, RealSignal psf, boolean threaded) {
String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
monitors.log(getShortname() + " is starting (" + iterations + ")");
y = image.duplicate();
h = psf.duplicate();
controller.setMonitors(monitors);
controller.start(y);
h = Operations.circularShift(h);
if (fft == null)
fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
else
fft.init(monitors, y.nx, y.ny, y.nz);
monitors.log(getShortname() + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortname() + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
controller.finish(x);
monitors.log(getName() + " is finished");
return x;
}
public AbstractFFT getFFT() {
return fft;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
controller.setAlgorithm(getName());
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
- s += (isRegularized() ? ", &lambda=" + getRegularizationFactor() : "");
- s += (isStepControllable() ? ", &gamma=" + getStepFactor() : "");
+ s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
+ s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index 8532c1a..895597e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,359 +1,359 @@
/*
* 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 imagej.IJImager;
import java.io.File;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.swing.JFrame;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.tools.NumFormat;
import lab.tools.WebBrowser;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.Sphere;
import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
public class Lab {
private static PlatformImager imager;
private static Lab instance = null;
private static Platform platform = Platform.IMAGEJ;
private static CustomizedTable tableStats = null;
private static JFrame frameStats = null;
static {
imager = new IJImager();
createStats();
}
private static void createStats() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Algorithm", String.class, 100, false));
columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
columns.add(new CustomizedColumn("Image Mean", String.class, 100, false));
columns.add(new CustomizedColumn("Image Minimum", String.class, 100, false));
columns.add(new CustomizedColumn("Image Maximum", String.class, 100, false));
columns.add(new CustomizedColumn("Image Stdev", String.class, 100, false));
columns.add(new CustomizedColumn("Image norm1", String.class, 100, false));
columns.add(new CustomizedColumn("Image norm2", String.class, 100, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Peak", String.class, 100, false));
columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
columns.add(new CustomizedColumn("SNR", String.class, 100, false));
columns.add(new CustomizedColumn("Residu", String.class, 100, false));
tableStats = new CustomizedTable(columns, true);
}
public static Platform getPlatform() {
return platform;
}
public static void getInstance(Platform p) {
platform = p;
if (instance == null) {
instance = new Lab();
switch (p) {
case STANDALONE:
imager = new LabImager();
break;
case IMAGEJ:
imager = new IJImager();
break;
case ICY:
imager = new IcyImager();
break;
default:
imager = new LabImager();
break;
}
}
}
public static void help() {
WebBrowser.open(Constants.url);
}
public static void checkFFT(Monitors monitors) {
- ArrayList<AbstractFFTLibrary> libraries = FFT.getLibraries();
+ ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
for (int k = 1; k <= 3; k++)
for (AbstractFFTLibrary library : libraries) {
RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
double chrono = System.nanoTime();
AbstractFFT fft = FFT.createDefaultFFT(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(fft.getName() + " Test " + k);
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 void appendShowLive(Monitors monitors, String key, RealSignal signal, String title, String code) {
imager.appendShowLive(key, signal, title);
monitors.log("Add Live Real Signal " + title);
}
public static void appendShowLive(Monitors monitors, String key, RealSignal signal, String title, PlatformImager.Type type) {
imager.appendShowLive(key, signal, title, type);
monitors.log("Add Live Real Signal " + 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);
imager.show(signal, title);
}
public static void show(Monitors monitors, ComplexSignal signal, String title, ComplexComponent complex) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imager.show(signal, title, complex);
}
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);
imager.show(signal, title);
}
public static void show(Monitors monitors, RealSignal signal, String title, PlatformImager.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imager.show(signal, title, type);
}
public static void show(Monitors monitors, RealSignal signal, String title, PlatformImager.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imager.show(signal, title, type);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
imager.save(signal, filename);
monitors.log("Save Real Signal " + filename);
}
public static void save(Monitors monitors, RealSignal signal, String filename, PlatformImager.Type type) {
imager.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
public static void firstStats(Monitors monitors, String name, Controller controller, boolean show, boolean save) {
if (controller == null)
return;
Lab.createStats();
if (show) {
frameStats = new JFrame(name);
frameStats.getContentPane().add(tableStats.getPane(600, 200));
frameStats.pack();
frameStats.setVisible(true);
}
nextStats(monitors, "Start", controller, show, save);
}
public static void nextStats(Monitors monitors, String name, Controller controller, boolean show, boolean save) {
if (tableStats == null)
return;
if (controller == null)
return;
tableStats.append(controller.stats(name));
monitors.log("Stats " + name);
if (show && frameStats != null) {
if (!frameStats.isVisible())
frameStats.setVisible(true);
frameStats.requestFocus();
}
}
public static void lastStats(Monitors monitors, String filename, Controller controller, boolean show, boolean save) {
if (controller == null)
return;
if (tableStats == null)
return;
nextStats(monitors, "End", controller, show, save);
if (save) {
monitors.log("Stats " + filename);
tableStats.saveCSV(filename + ".csv");
}
}
public static RealSignal open(Monitors monitors, String filename) {
RealSignal signal = imager.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
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 = imager.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(nx, ny, nz);
for (int z = 0; z < slices.size(); z++)
signal.setSlice(z, slices.get(z));
return signal;
}
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;
}
imager.show(signal.createOrthoview(hx, hy, hz), title);
}
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;
imager.show(signal.createOrthoview(hx, hy, hz), title);
}
public static void showMIP(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show MIP " + title + " this image does not exist.");
return;
}
imager.show(signal.createMIP(), title);
}
public static void showMontage(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Montage " + title + " this image does not exist.");
return;
}
imager.show(signal.createMontage(), title);
}
public static RealSignal create(Monitors monitors, String name) {
RealSignal signal = imager.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 = imager.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 PlatformImager getImager() {
return imager;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
index 2652188..2540c63 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
@@ -1,365 +1,365 @@
/*
* 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.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
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.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
-import deconvolutionlab.modules.MonitoringModule;
+import deconvolutionlab.modules.WatcherModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
import lab.component.PanelImage;
import lab.system.SystemPanel;
public class LabDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnClose = new JButton("Close");
private JButton bnQuit = new JButton("Quit");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnSystem = new JButton("System");
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
- private MonitoringModule monitoring;
+ private WatcherModule watcher;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelProgra;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
public LabDialog() {
super(new JFrame(), Constants.name);
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(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);
command = new CommandModule();
- monitoring = new MonitoringModule(false);
+ watcher = new WatcherModule(false);
doDialog();
- modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, monitoring };
+ modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, watcher };
- Command.active(modules, command, language);
+ Command.active(modules, command);
Command.command();
addWindowListener(this);
addComponentListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.registerFrame("DeconvolutionLab", "MainDialog", this);
pack();
setVisible(true);
Config.load();
sizeModule();
Command.command();
image.update();
psf.update();
output.update();
}
private void doDialog() {
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelProgra = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
PanelImage bottom = new PanelImage("celegans.jpg");
bottom.setLayout(new GridLayout(1, 7));
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
bottom.setBorder(b2);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnQuit);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Programming", panelProgra);
tab.add("About", panelAbout);
tab.addChangeListener(this);
JPanel base = new JPanel(new BorderLayout());
base.add(bottom, BorderLayout.CENTER);
//base.add(statusBar, BorderLayout.SOUTH);
add(tab, BorderLayout.CENTER);
add(base, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnHelp.addActionListener(this);
bnQuit.addActionListener(this);
bnSystem.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp) {
Lab.help();
}
else if (e.getSource() == bnSystem) {
SystemPanel.show(400, 400);
}
else if (e.getSource() == bnClose) {
Config.store();
close();
dispose();
}
else if (e.getSource() == bnQuit) {
close();
dispose();
}
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
new BatchDialog(batch);
}
else if (e.getSource() == bnLaunch) {
new Deconvolution(Command.command()).launch("", false);
}
else if (e.getSource() == bnRun) {
new Deconvolution(Command.command()).deconvolve(false);
}
}
@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(monitoring);
+ list.add(watcher);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
list.add(border);
list.add(fourier);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(command);
list.add(language);
list.add(batch);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
Config.store();
close();
dispose();
}
@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) {
}
private void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
bnQuit.removeActionListener(this);
removeWindowListener(this);
}
@Override
public void dispose() {
super.dispose();
if (Lab.getPlatform() == Platform.STANDALONE) System.exit(0);
}
@Override
public void componentResized(ComponentEvent e) {
sizeModule();
}
@Override
public void componentMoved(ComponentEvent e) {
}
@Override
public void componentShown(ComponentEvent e) {
sizeModule();
}
@Override
public void componentHidden(ComponentEvent e) {
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0) sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1) sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2) sizePanel(panelProgra);
if (tab.getSelectedIndex() == 3) sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 60;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
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/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 73a8615..42637fc 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,235 +1,239 @@
/*
* 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.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
import deconvolutionlab.PlatformImager;
import ij.gui.GUI;
import lab.component.GridPanel;
import lab.component.SpinnerRangeInteger;
public class OutputDialog extends JDialog implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Snapshot");
private Output out;
private View view;
private GridPanel pnOrtho;
+ private static int count = 1;
+
public OutputDialog(View view) {
- super(new JFrame(), "Output");
+ super(new JFrame(), "Create a new output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
+ txtName.setText(view.name().substring(0, 2) + (count++));
+
GridPanel pn = new GridPanel(view.name());
pn.place(0, 0, "Name");
pn.place(0, 1, 2, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(2, 2, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(5, 2, lblIter);
}
pn.place(6, 0, 3, 1, chkShow);
pn.place(7, 0, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(7, 0, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
pack();
GUI.center(this);
setModal(true);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
dispose();
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
PlatformImager.Type type = PlatformImager.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
dispose();
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
index 7fc18a6..1f54884 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
@@ -1,221 +1,227 @@
/*
* 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.modules;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
+import java.awt.Font;
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 {
private JButton bnTitle;
private JButton bnSynopsis;
private JButton bnAction1 = new JButton();
private JButton bnAction2 = new JButton();
private JLabel lblCommand;
private JButton bnExpand;
private 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) {
this.name = name;
this.key = key;
pnCollapsed = buildCollapsedPanel();
pnExpanded = buildExpandedPanel();
setLayout(new BorderLayout());
this.expanded = expanded;
bnTitle = new JButton("<html><b>" + name + "</b></html>");
bnTitle.setHorizontalAlignment(SwingConstants.LEFT);
- bnTitle.setPreferredSize(new Dimension(160, 20));
- bnTitle.setMaximumSize(new Dimension(250, 20));
- bnTitle.setMinimumSize(new Dimension(120, 20));
+ bnTitle.setPreferredSize(new Dimension(150, heightButton));
+ bnTitle.setMaximumSize(new Dimension(250, heightButton));
+ bnTitle.setMinimumSize(new Dimension(120, heightButton));
bnTitle.addActionListener(this);
bnSynopsis = new JButton("");
bnSynopsis.setHorizontalAlignment(SwingConstants.LEFT);
- bnSynopsis.setPreferredSize(new Dimension(200, 20));
+ bnSynopsis.setPreferredSize(new Dimension(200, heightButton));
bnSynopsis.addActionListener(this);
bnExpand = new JButton("\u25BA");
- bnExpand.setPreferredSize(new Dimension(40, 20));
- bnExpand.setMaximumSize(new Dimension(40, 20));
- bnExpand.setMinimumSize(new Dimension(40, 20));
+ 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.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(50, 20));
+ bnAction1.setPreferredSize(new Dimension(70, heightButton));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction1, BorderLayout.WEST);
}
if (!action2.equals("")) {
bnAction2.setText(action2);
- bnAction2.setPreferredSize(new Dimension(50, 20));
+ bnAction2.setPreferredSize(new Dimension(70, heightButton));
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, 30));
+ 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");
}
@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/modules/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
index 3dc93d5..cc97a88 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
@@ -1,199 +1,199 @@
/*
* 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.modules;
import java.awt.BorderLayout;
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.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.component.GridPanel;
import lab.component.HTMLPane;
import lab.tools.NumFormat;
import signal.Signal;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import fft.AbstractFFTLibrary;
import fft.FFT;
public class FFTModule extends AbstractModule implements ActionListener, ChangeListener {
private HTMLPane info;
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbType;
private JComboBox<String> cmbSep;
private JComboBox<String> cmbEpsilon;
private CustomizedTable table;
public FFTModule(boolean expanded) {
super("Fourier", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbFFT.getSelectedIndex() != 0)
cmd += " -fft " + (String) cmbFFT.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 120, false));
columns.add(new CustomizedColumn("Installed", String.class, 120, false));
columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
table = new CustomizedTable(columns, true);
table.setRowSelectionAllowed(false);
info = new HTMLPane(100, 100);
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbType = new JComboBox<String>(new String[] { "float" });
cmbSep = new JComboBox<String>(new String[] { "XYZ" });
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");
GridPanel pnNumeric = new GridPanel(false, 3);
pnNumeric.place(3, 0, new JLabel("FFT Fourier Library"));
pnNumeric.place(3, 1, cmbFFT);
pnNumeric.place(6, 0, new JLabel("FFT Dimension"));
pnNumeric.place(6, 1, cmbSep);
pnNumeric.place(7, 0, new JLabel("<html>Machine Epsilon &epsilon;</html>"));
pnNumeric.place(7, 1, cmbEpsilon);
pnNumeric.place(8, 0, new JLabel("Data Type"));
pnNumeric.place(8, 1, cmbType);
JScrollPane scroll2 = new JScrollPane(pnNumeric);
scroll2.setBorder(BorderFactory.createEmptyBorder());
scroll2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel control = new JPanel(new BorderLayout());
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
control.add(scroll2, BorderLayout.NORTH);
control.add(info.getPane(), BorderLayout.CENTER);
control.add(table.getPane(80, 80), BorderLayout.SOUTH);
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.CENTER);
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
Config.register(getName(), "dim", cmbSep, "XYZ");
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
cmbEpsilon.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
fillInstallation();
return panel;
}
private void fillInstallation() {
- ArrayList<AbstractFFTLibrary> libs = FFT.getLibraries();
+ ArrayList<AbstractFFTLibrary> libs = FFT.getRegisteredLibraries();
for (AbstractFFTLibrary lib : libs) {
String name = lib.getLibraryName();
String installed = lib.isInstalled() ? " Yes" : "No";
String location = lib.getLocation();
table.append(new String[] { name, installed, location });
}
AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
info.clear();
info.append("p", fftlib.getLicence());
}
private void update() {
setCommand(getCommand());
Signal.epsilon = NumFormat.parseNumber((String) cmbEpsilon.getSelectedItem(), 1e-6);
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmbFFT || e.getSource() == cmbSep) {
AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
info.clear();
info.append("p", fftlib.getLicence());
}
if (e.getSource() == getAction1Button()) {
cmbFFT.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
cmbFFT.setSelectedIndex(0);
cmbType.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
cmbEpsilon.addActionListener(this);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index d3a6253..d65ba6c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,339 +1,341 @@
/*
* 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.modules;
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 deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.ImageSelector;
import deconvolutionlab.Lab;
import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.tools.Files;
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", "Select", "Show", expanded);
}
@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, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
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);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
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
+ 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) {
Deconvolution deconvolution = new Deconvolution(Command.command());
file(deconvolution.getPath());
}
else if (e.getSource() == bnDirectory) {
Deconvolution deconvolution = new Deconvolution(Command.command());
dir(deconvolution.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())
display();
update();
}
public void platform() {
PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
String name = selector.getSelectedImage();
if (name != null)
if (name != "")
table.insert(new String[] { name, "platform", name, "" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
dlg.setVisible(true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
}
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, 1));
}
}
dlg.setVisible(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();
System.out.println("edit " + row + " " + name);
for (SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
System.out.println("edit " + row + " " + filename + " " + new File(filename).exists() + " " + new File(filename).isDirectory());
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() {
int row = table.getSelectedRow();
if (row < 0)
return;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int row = table.getSelectedRow();
RealSignal x = new Deconvolution(getCommand()).openImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@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(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index fde611d..e79c845 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
@@ -1,341 +1,343 @@
/*
* 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.modules;
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 lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.ImageSelector;
import deconvolutionlab.Lab;
import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
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", "Select", "Show", expanded);
}
@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);
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);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
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
+ 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) {
Deconvolution deconvolution = new Deconvolution(Command.command());
file(deconvolution.getPath());
}
else if (e.getSource() == bnDirectory) {
Deconvolution deconvolution = new Deconvolution(Command.command());
dir(deconvolution.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())
display();
update();
}
public void platform() {
PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
String name = selector.getSelectedImage();
if (name != null)
if (name != "")
table.insert(new String[] {name, "platform", name, "" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
dlg.setVisible(true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
}
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, 1));
}
}
dlg.setVisible(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();
System.out.println("edit " + row + " " + name);
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
System.out.println("edit " + row + " " + filename + " " + new File(filename).exists() + " " +new File(filename).isDirectory());
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() {
int row = table.getSelectedRow();
if (row < 0)
return;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int row = table.getSelectedRow();
- RealSignal x = new Deconvolution(getCommand() + " -nodisplay -nomonitor").openImage();
+ RealSignal x = new Deconvolution(getCommand()).openPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@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(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
similarity index 90%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
index e167fa8..580553f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
@@ -1,211 +1,208 @@
/*
* 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.modules;
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 javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import deconvolution.Command;
import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.tools.Files;
-public class MonitoringModule extends AbstractModule implements ActionListener, KeyListener {
+public class WatcherModule extends AbstractModule implements ActionListener, KeyListener {
private JTextField txtTime;
private JTextField txtPath;
private JButton bnBrowse;
private JComboBox<String> cmbTime;
private JComboBox<String> cmbPath;
private JComboBox<String> cmbVerbose;
private JCheckBox chkDisableTable;
private JCheckBox chkDisableConsole;
private JCheckBox chkDisableDisplay;
private JCheckBox chkDisableMultithreading;
- public MonitoringModule(boolean expanded) {
- super("Monitor", "", "", "", expanded);
+ public WatcherModule(boolean expanded) {
+ super("Watcher", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
boolean t = chkDisableTable.isSelected();
boolean c = chkDisableConsole.isSelected();
boolean d = chkDisableDisplay.isSelected();
boolean m = chkDisableMultithreading.isSelected();
if (cmbPath.getSelectedIndex() != 0)
cmd += " -path " + txtPath.getText();
if (cmbTime.getSelectedIndex() != 0)
cmd += " -time " + txtTime.getText();
if (c || t || d || m)
cmd += " -disable " + (t ? "monitor " : "") +
(c ? "console " : "") + (d ? "display " : "") + (m ? "multithreading " : "");
if (cmbVerbose.getSelectedIndex() != 0) {
String parts[] = ((String)cmbVerbose.getSelectedItem()).split(" ");
cmd += " -verbose " + parts[1];
}
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbTime = new JComboBox<String>(new String[] { "No time limitation", "Specify limit (s) ..." });
cmbPath = new JComboBox<String>(new String[] { "Current", "Specify ..." });
cmbVerbose = new JComboBox<String>(new String[] { "Verbose: log", "Verbose: quiet ", "Verbose: prolix", "Verbose: mute" });
- chkDisableTable = new JCheckBox("Monitor");
- chkDisableConsole = new JCheckBox("Console");
- chkDisableDisplay = new JCheckBox("Display");
- chkDisableMultithreading = new JCheckBox("Multithreading");
+ chkDisableTable = new JCheckBox("No Monitor");
+ chkDisableConsole = new JCheckBox("No Console");
+ chkDisableDisplay = new JCheckBox("No Display");
+ chkDisableMultithreading = new JCheckBox("No Multithreading");
txtTime = new JTextField("3600");
txtPath = new JTextField("...", 30);
bnBrowse = new JButton("Browse");
GridPanel pn = new GridPanel("Output Directory", 3);
pn.place(0, 1, cmbPath);
pn.place(0, 2, bnBrowse);
pn.place(1, 0, 4, 1, txtPath);
GridPanel pn2 = new GridPanel("Settings", 3);
- pn2.place(2, 0, cmbTime);
- pn2.place(2, 1, txtTime);
+ pn2.place(2, 0, 2, 1, cmbTime);
+ pn2.place(2, 2, txtTime);
pn2.place(2, 3, cmbVerbose);
-
- GridPanel pn3 = new GridPanel("Disable", 3);
- pn3.place(4, 0, chkDisableTable);
- pn3.place(4, 1, chkDisableConsole);
- pn3.place(4, 2, chkDisableDisplay);
- pn3.place(4, 3, chkDisableMultithreading);
+ pn2.place(4, 0, chkDisableTable);
+ pn2.place(4, 1, chkDisableConsole);
+ pn2.place(4, 2, chkDisableDisplay);
+ pn2.place(4, 3, chkDisableMultithreading);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(pn);
panel.add(pn2);
- panel.add(pn3);
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
Config.register(getName(), "path", cmbPath, cmbPath.getItemAt(0));
Config.register(getName(), "time", cmbTime, cmbTime.getItemAt(0));
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "path", txtPath, new File(System.getProperty("user.dir")).getAbsolutePath());
Config.register(getName(), "disable.table", chkDisableTable, "false");
Config.register(getName(), "disable.console", chkDisableConsole, "false");
Config.register(getName(), "disable.display", chkDisableDisplay, "false");
Config.register(getName(), "disable.multithreading", chkDisableMultithreading, "false");
cmbVerbose.addActionListener(this);
cmbPath.addActionListener(this);
cmbTime.addActionListener(this);
chkDisableTable.addActionListener(this);
chkDisableConsole.addActionListener(this);
chkDisableDisplay.addActionListener(this);
chkDisableMultithreading.addActionListener(this);
txtTime.addKeyListener(this);
bnBrowse.addActionListener(this);
txtPath.addKeyListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
setSynopsis(txtPath.getText());
if (cmbPath != null) {
boolean b = cmbPath.getSelectedIndex() != 0;
bnBrowse.setEnabled(b);
txtPath.setEnabled(b);
}
if (txtTime != null) {
boolean b = cmbTime.getSelectedIndex() != 0;
txtTime.setEnabled(b);
}
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());
}
}
if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
}
update();
}
@Override
public void close() {
chkDisableTable.removeActionListener(this);
chkDisableConsole.removeActionListener(this);
chkDisableDisplay.removeActionListener(this);
chkDisableMultithreading.removeActionListener(this);
cmbVerbose.removeActionListener(this);
cmbTime.removeActionListener(this);
txtTime.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();
}
}
diff --git a/DeconvolutionLab2/src/fft/FFT.java b/DeconvolutionLab2/src/fft/FFT.java
index 9e6a539..dc3ed84 100644
--- a/DeconvolutionLab2/src/fft/FFT.java
+++ b/DeconvolutionLab2/src/fft/FFT.java
@@ -1,135 +1,144 @@
/*
* 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 fft;
import java.util.ArrayList;
import deconvolutionlab.monitor.Monitors;
import fft.academic.Academic;
import fft.academic.AcademicLibrary;
import fft.fftw.FFTW3D;
import fft.fftw.FFTWLibrary;
import fft.jtransforms.JTransforms;
import fft.jtransforms.JTransformsLibrary;
public class FFT {
private static ArrayList<AbstractFFTLibrary> libraries = new ArrayList<AbstractFFTLibrary>();
+ private static ArrayList<AbstractFFTLibrary> registers = new ArrayList<AbstractFFTLibrary>();
static {
Monitors monitors = Monitors.createDefaultMonitor();
AcademicLibrary academic = new AcademicLibrary();
if (academic.isInstalled()) {
libraries.add(academic);
monitors.log("AcademicFFT Added");
}
else {
monitors.log("AcademicFFT not found");
}
JTransformsLibrary jtransform = new JTransformsLibrary();
if (jtransform.isInstalled()) {
libraries.add(jtransform);
monitors.log("JTransforms Added");
}
else {
monitors.log("JTransforms not found");
}
FFTWLibrary jfftw = new FFTWLibrary(monitors);
if (jfftw.isInstalled()) {
libraries.add(jfftw);
monitors.log("FFTW Added");
}
else {
monitors.log("FFTW not found");
}
+
+ registers.add(academic);
+ registers.add(jtransform);
+ registers.add(jfftw);
}
- public static ArrayList<AbstractFFTLibrary> getLibraries() {
+ public static ArrayList<AbstractFFTLibrary> getRegisteredLibraries() {
+ return registers;
+ }
+
+ public static ArrayList<AbstractFFTLibrary> getInstalledLibraries() {
return libraries;
}
public static String[] getLibrariesAsArray() {
String[] libs = new String[libraries.size()];
for (int i = 0; i < libraries.size(); i++)
libs[i] = libraries.get(i).getLibraryName();
return libs;
}
public static AbstractFFT createFFT(Monitors monitors, AbstractFFTLibrary fftlib, int nx, int ny, int nz) {
String name = fftlib.getLibraryName().toLowerCase();
AbstractFFT fft = null;
String n = name.trim().toLowerCase();
if (n.equals("academic")) {
fft = new Academic();
fft.init(monitors, nx, ny, nz);
return fft;
}
if (n.equals("jtransforms")) {
fft = new JTransforms();
fft.init(monitors, nx, ny, nz);
return fft;
}
if (n.equals("fftw2")) {
fft = new FFTW3D();
fft.init(monitors, nx, ny, nz);
return fft;
}
return createDefaultFFT(monitors, nx, ny, nz);
}
public static AbstractFFTLibrary getLibraryByName(String name) {
- for (AbstractFFTLibrary library : getLibraries())
+ for (AbstractFFTLibrary library : getInstalledLibraries())
if (library.getLibraryName().equals(name))
return library;
return new AcademicLibrary();
}
public static AbstractFFT createDefaultFFT(Monitors monitors, int nx, int ny, int nz) {
AbstractFFT fft = new Academic();
fft.init(monitors, nx, ny, nz);
return fft;
}
public static String getLicence(String name) {
- for (AbstractFFTLibrary lib : getLibraries()) {
+ for (AbstractFFTLibrary lib : getInstalledLibraries()) {
for (AbstractFFT fft : lib.getFFTs())
if (name.equals(fft.getName()))
return lib.getLicence();
}
return "Unknown FFT library";
}
}
diff --git a/DeconvolutionLab2/src/lab/system/SystemBar.java b/DeconvolutionLab2/src/lab/system/SystemBar.java
index 6a47847..939516c 100644
--- a/DeconvolutionLab2/src/lab/system/SystemBar.java
+++ b/DeconvolutionLab2/src/lab/system/SystemBar.java
@@ -1,88 +1,86 @@
/*
* 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 lab.system;
import java.awt.BorderLayout;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.BoxLayout;
import javax.swing.JToolBar;
public class SystemBar extends JToolBar {
private Timer timer = new Timer();
private TimerTask updater = new Updater();
private SystemHeap heap;
private SystemCPU load;
public SystemBar(int refreshTime) {
super("System Bar");
setFloatable(false);
heap = new SystemHeap();
load = new SystemCPU();
restart(refreshTime);
setLayout(new BorderLayout());
- setFloatable(true);
- setLayout(new BorderLayout());
add(heap, BorderLayout.CENTER);
add(load, BorderLayout.EAST);
}
public void update() {
heap.repaint();
load.repaint();
}
public void restart(int refreshTime) {
if (updater != null) {
updater.cancel();
updater = null;
}
updater = new Updater();
timer.schedule(updater, 0, refreshTime);
}
public void close() {
timer.cancel();
timer = null;
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/lab/system/SystemCPU.java b/DeconvolutionLab2/src/lab/system/SystemCPU.java
index 76ccf87..531e509 100644
--- a/DeconvolutionLab2/src/lab/system/SystemCPU.java
+++ b/DeconvolutionLab2/src/lab/system/SystemCPU.java
@@ -1,99 +1,100 @@
/*
* 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 lab.system;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import deconvolutionlab.Constants;
public class SystemCPU extends JLabel {
private double peak;
public SystemCPU() {
super("");
setBorder(BorderFactory.createEtchedBorder());
setPreferredSize(new Dimension(200, 20));
setMinimumSize(new Dimension(200, 20));
setMaximumSize(new Dimension(200, 20));
}
public void reset() {
peak = 0;
}
@Override
public void paintComponent(Graphics g) {
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
double l = 20;
for (Method method : os.getClass().getDeclaredMethods()) {
method.setAccessible(true);
if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) {
try {
if (method.getName().contains("ProcessCpuLoad") )
l = Double.parseDouble(method.invoke(os).toString());
}
catch (Exception e) {}
}
}
double used = l;
double maxi = 100;
peak = Math.max(used, peak);
super.paintComponent(g);
- int w = Constants.widthGUI;
+ int w = getWidth();
g.setColor(new Color(10, 10, 10, 30));
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
int posp = (int)Math.round(w*peak/maxi);
String u = String.format("%3.3f", used);
g.setColor(new Color(10, 10, 160, 30));
g.fillRect(0, 0, posu, 30);
g.fillRect(0, 0, posp, 30);
g.setColor(new Color(160, 10, 10));
- g.drawString(u + "%", posu, 13);
+ g.drawString(u + "%", 10, 13);
+ g.drawString("100%", w-50, 13);
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/lab/system/SystemHeap.java b/DeconvolutionLab2/src/lab/system/SystemHeap.java
index a33bb14..537956e 100644
--- a/DeconvolutionLab2/src/lab/system/SystemHeap.java
+++ b/DeconvolutionLab2/src/lab/system/SystemHeap.java
@@ -1,87 +1,86 @@
/*
* 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 lab.system;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import lab.tools.NumFormat;
public class SystemHeap extends JLabel {
private double peak;
public SystemHeap() {
super("");
setBorder(BorderFactory.createEtchedBorder());
setPreferredSize(new Dimension(200, 20));
setMinimumSize(new Dimension(200, 20));
setMaximumSize(new Dimension(200, 20));
}
public void reset() {
peak = 0;
}
@Override
public void paintComponent(Graphics g) {
MemoryUsage mem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
double used = mem.getUsed();
double maxi = mem.getMax();
peak = Math.max(used, peak);
super.paintComponent(g);
int w = getWidth();
g.setColor(new Color(10, 10, 10, 30));
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
int posp = (int)Math.round(w*peak/maxi);
- int posm = w-40;
String u = NumFormat.bytes(used);
String m = NumFormat.bytes(maxi);
g.setColor(new Color(10, 10, 160, 30));
g.fillRect(0, 0, posu, 30);
g.fillRect(0, 0, posp, 30);
g.setColor(new Color(160, 10, 10));
- g.drawString(u, posu, 13);
+ g.drawString(u, 10, 13);
//g.drawString(p, posp, 13);
- g.drawString(m, posm, 13);
+ g.drawString(m, w-60, 13);
}
}
\ No newline at end of file

Event Timeline