Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95700653
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 18, 12:20
Size
151 KB
Mime Type
application/octet-stream
Expires
Fri, Dec 20, 12:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23045723
Attached To
R2075 deconvolution
View Options
diff --git a/DeconvolutionLab2.config b/DeconvolutionLab2.config
index 67086af..ec0766e 100644
--- a/DeconvolutionLab2.config
+++ b/DeconvolutionLab2.config
@@ -1,58 +1,74 @@
-#DeconvolutionLab2 [Beta 2]
-#DeconvolutionLab2 [Beta 2]
-#Sun Feb 26 14:32:31 CET 2017
-Algorithm.I.gaussian.mean=0.0
-Algorithm.I.gaussian.stdev=1.0
-Algorithm.I.iterations=10
-Algorithm.I.poisson=0.0
-Algorithm.I.reg=0.1
-Algorithm.I.scale=3
-Algorithm.I.step=1.0
-Algorithm.I.wavelets=Haar
-Algorithm.algorithm=Regularized Inverse Filter [RIF | LRIF]
+#DeconvolutionLab2
+#DeconvolutionLab2
+#Fri Apr 21 13:03:50 CEST 2017
+Algorithm.BVLS.iterations=10
+Algorithm.BVLS.step=1.0
+Algorithm.FISTA.iterations=10
+Algorithm.FISTA.reg=0.1
+Algorithm.FISTA.scale=3
+Algorithm.FISTA.step=1.0
+Algorithm.FISTA.wavelets=Haar
+Algorithm.ICTM.iterations=10
+Algorithm.ICTM.reg=0.1
+Algorithm.ICTM.step=1.0
+Algorithm.ISTA.iterations=10
+Algorithm.ISTA.reg=0.1
+Algorithm.ISTA.scale=3
+Algorithm.ISTA.step=1.0
+Algorithm.ISTA.wavelets=Haar
+Algorithm.LW.iterations=10
+Algorithm.LW.step=1.0
+Algorithm.NNLS.iterations=10
+Algorithm.NNLS.step=1.0
+Algorithm.RIF.reg=0.1
+Algorithm.RL.iterations=10
+Algorithm.RLTV.reg=0.1
+Algorithm.SIM.gaussian.mean=0.0
+Algorithm.SIM.gaussian.stdev=1.0
+Algorithm.SIM.poisson=0.0
+Algorithm.TM.iterations=10
+Algorithm.TM.reg=0.1
+Algorithm.TM.step=1.0
+Algorithm.TRIF.reg=0.1
+Algorithm.VC.iterations=10
+Algorithm.VC.step=1.0
+Algorithm.algorithm=Regularized Inverse Filter
Border.apoxy=Uniform
Border.apoz=Uniform
Border.extxy=0
Border.extz=0
Border.padxy=None
Border.padz=None
-Computation.dim=XYZ
+Computation.display=yes
Computation.epsilon=1E-6
Computation.fft=Fastest
+Computation.multithreading=yes
Computation.normalization=1
-Controller.constraint.enable=false
-Controller.constraint.value=no
-Controller.itmax.enable=true
+Computation.system=yes
+Controller.constraint=no
+Controller.monitor=console table
Controller.reference.enable=false
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.value=0.01
+Controller.stats=no
Controller.time.enable=false
Controller.time.value=3600
-DeconvolutionLab.DeconvolutionDialog.location.h=400
-DeconvolutionLab.DeconvolutionDialog.location.w=600
-DeconvolutionLab.DeconvolutionDialog.location.x=802
-DeconvolutionLab.DeconvolutionDialog.location.y=266
+Controller.verbose=log
DeconvolutionLab.MainDialog.location.h=511
DeconvolutionLab.MainDialog.location.w=593
-DeconvolutionLab.MainDialog.location.x=181
-DeconvolutionLab.MainDialog.location.y=298
-Image.image.row0=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;
-Image.image.selected=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;
+DeconvolutionLab.MainDialog.location.x=108
+DeconvolutionLab.MainDialog.location.y=440
+Image.image.row0=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
+Image.image.selected=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;null
Language.headless=Run (Headless)
Language.job=Job
Language.language=Command line
-PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
-PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
+PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+Path.current=Current
+Path.path=/Users/sage/Desktop/worksmlm/deconvolution
Running.Directory=/Users/dsage/git/deconvolution
-Running.Display=yes
Running.Monitor=console table
-Running.Multithreading=yes
Running.Path=current
-Running.Stats=no
-Running.System=yes
Running.Verbose=log
-System.Frame.location.h=313
-System.Frame.location.w=637
-System.Frame.location.x=0
-System.Frame.location.y=23
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 457d615..ac617a2 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,93 +1,97 @@
#DeconvolutionLab2
#DeconvolutionLab2
-#Fri Apr 21 11:36:46 CEST 2017
+#Fri Apr 21 17:57:52 CEST 2017
Algorithm.BVLS.iterations=10
Algorithm.BVLS.step=1.0
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.4642
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=1.000E-18
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
Algorithm.algorithm=Richardson-Lucy Total Variation
Border.apoxy=Uniform
Border.apoz=Uniform
Border.extxy=0
Border.extz=0
Border.padxy=None
Border.padz=None
Computation.display=yes
Computation.epsilon=1E-6
Computation.fft=Fastest
Computation.multithreading=yes
Computation.normalization=1
Computation.system=no
Controller.constraint=no
-Controller.monitor=console
+Controller.monitor=console table
Controller.reference.enable=true
Controller.reference.value=/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png
-Controller.residu.enable=true
+Controller.residu.enable=false
Controller.residu.value=0.01
Controller.stats=show + save
Controller.time.enable=false
Controller.time.value=1
Controller.verbose=log
-DeconvolutionLab.MainDialog.location.h=596
+DeconvolutionLab.DeconvolutionDialog.location.h=400
+DeconvolutionLab.DeconvolutionDialog.location.w=600
+DeconvolutionLab.DeconvolutionDialog.location.x=265
+DeconvolutionLab.DeconvolutionDialog.location.y=516
+DeconvolutionLab.MainDialog.location.h=633
DeconvolutionLab.MainDialog.location.w=500
-DeconvolutionLab.MainDialog.location.x=851
-DeconvolutionLab.MainDialog.location.y=84
+DeconvolutionLab.MainDialog.location.x=1054
+DeconvolutionLab.MainDialog.location.y=111
Image.image.row0=workspace;directory;/Users/dsage/Desktop/workspace;\u232B
Image.image.row10=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row11=RandomLines;synthetic;RandomLines 100.0 size 128 128 32 intensity 255.0 ;\u232B
Image.image.row12=active;platform;active;\u232B
Image.image.row13=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row14=Applications;directory;/users/dsage/Applications;\u232B
Image.image.row15=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row16=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
Image.image.row1=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 10.0 5.0 size 128 128 128 intensity 255.0 ;\u232B
Image.image.row2=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 8.0 16.0 size 128 128 32 intensity 255.0 ;\u232B
Image.image.row3=Cube of Spherical Beads;synthetic;Cube of Spherical Beads 3.0 0.5 8.0 8.0 size 128 128 128 intensity 255.0 ;\u232B
Image.image.row4=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row5=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
Image.image.row6=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row7=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Image.image.row8=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
Image.image.row9=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
-Image.image.selected=workspace;directory;/Users/dsage/Desktop/workspace;\u232B
+Image.image.selected=RandomLines;synthetic;RandomLines 100.0 size 128 128 32 intensity 255.0 ;\u232B
Language.headless=Run (Headless)
Language.job=Job
Language.language=Java
Output.output.row0=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
Output.output.selected=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
PSF.psf.row0=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
PSF.psf.row1=Sinc;synthetic;Sinc 3.0 3.0 3.0 size 100 128 200 intensity 255.0 ;null
PSF.psf.selected=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
Path.current=Current
-Path.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
+Path.path=/Users/sage/Desktop/worksmlm/deconvolution/DeconvolutionLab2
Running.Directory=/Users/dsage/git/deconvolution/DeconvolutionLab2
Running.Monitor=table
Running.Path=specify
Running.Verbose=quiet
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index 21ed668..0cfdb6a 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,49 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="DeconvolutionLab2" default="build" basedir=".">
<property name="imagej" location="${user.home}/Desktop/ImageJ/plugins" />
<property name="fiji" location="${user.home}/Desktop/Fiji-deconv.app/plugins" />
<property name="matlab" location="/Applications/MATLAB_R2014b.app/java/" />
<property name="doc" location="${user.home}/Desktop/doc/" />
- <property name="javadoc.header" value="<h3>DeconvolutionLab2</h3>	v1.0" />
- <property name="javadoc.footer" value="<h4>DeconvolutionLab2</h4>	<script> var tStamp=new Date(); document.write(tStamp.toUTCString()); </script>" />
- <property name="javadoc.bottom" value='Copyright &copy; <script> var currYear=new Date(); document.write(currYear.getFullYear()); </script>, Biomedical Imaging Group, EPFL, Lausanne, Switzerland. All rights reserved.' />
+ <property name="javadoc.header" value="<h3>DeconvolutionLab2</h3>	v1.0" />
+ <property name="javadoc.footer" value="<h4>DeconvolutionLab2</h4>	<script> var tStamp=new Date(); document.write(tStamp.toUTCString()); </script>" />
+ <property name="javadoc.bottom" value='Copyright &copy; <script> var currYear=new Date(); document.write(currYear.getFullYear()); </script>, Biomedical Imaging Group, EPFL, Lausanne, Switzerland. All rights reserved.' />
<target name="build">
<mkdir dir="${doc}" />
<mkdir dir="bin" />
- <copy todir="bin">
- <fileset dir="ij">
- </fileset>
- </copy>
+ <copy todir="bin"><fileset dir="ij"></fileset></copy>
<copy file="plugins.config" toDir="bin" />
-
<zip destfile="../DeconvolutionLab2-src.zip" basedir="src" />
<zip destfile="../DeconvolutionLab2-cls.zip" basedir="bin" />
<jar destfile="../DeconvolutionLab_2.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="DeconvolutionLab2" />
<attribute name="Class-Path" value="ij.jar jtransforms.jar" />
</manifest>
</jar>
- <javadoc destdir="${doc}"
- author="true"
- version="true"
- overview="${basedir}/overview.html"
- windowtitle="DeconvolutionLab2">
+ <copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
+ <copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
+ <copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
+
+ <javadoc destdir="${doc}" author="true" version="true" overview="${basedir}/overview.html" windowtitle="DeconvolutionLab2">
<fileset dir="src">
<include name="**/*.java" />
<exclude name="**/fft/**" />
<exclude name="**/jfftw/**" />
</fileset>
- <header><![CDATA[${javadoc.header}]]></header>
- <footer><![CDATA[${javadoc.footer}]]></footer>
- <bottom><![CDATA[${javadoc.bottom}]]></bottom>
+ <header>
+ <![CDATA[${javadoc.header}]]>
+ </header>
+ <footer>
+ <![CDATA[${javadoc.footer}]]>
+ </footer>
+ <bottom>
+ <![CDATA[${javadoc.bottom}]]>
+ </bottom>
</javadoc>
- <copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
- <copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
- <copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
-
</target>
+
</project>
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index cdfffc5..3034d78 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.java
@@ -1,130 +1,127 @@
/*
* 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/>.
*/
import java.io.File;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Imager.Platform;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2 {
public static String ack = Constants.name + " " + Constants.version + " " + Constants.copyright;
public static void main(String arg[]) {
-
- System.out.println(ack);
Lab.init(Platform.STANDALONE);
-
if (arg.length == 0) {
System.out.println("Starting lab");
lab(arg);
return;
}
String flag = arg[0].trim().toLowerCase();
if (flag.equalsIgnoreCase("help")) {
System.out.println("Starting help");
help();
return;
}
else if (flag.equalsIgnoreCase("lab")) {
System.out.println("Starting lab");
lab(arg);
}
else if (flag.equalsIgnoreCase("fft")) {
System.out.println("Starting fft");
Lab.checkFFT(Monitors.createDefaultMonitor());
}
else if (flag.equalsIgnoreCase("run")) {
System.out.println("Starting run");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Run", cmd, Deconvolution.Finish.KILL).deconvolve();
}
else if (flag.equalsIgnoreCase("launch")) {
System.out.println("Starting launch");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Launch", cmd, Deconvolution.Finish.KILL).launch();
}
else
System.out.println("" + flag + " command not found");
}
private static void lab(String arg[]) {
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
if (arg.length >= 2) {
String filename = arg[1].trim();
File file = new File(filename);
if (file.exists())
if (file.isFile())
if (file.canRead())
config = filename;
}
Lab.init(Platform.STANDALONE, config);
LabDialog dialog = new LabDialog();
dialog.setVisible(true);
}
public static void help() {
System.out.println("More info:" + Constants.url);
System.out.println("Syntax:");
System.out.println("java -jar DeconvolutionLab_2.jar lab");
System.out.println("java -jar DeconvolutionLab_2.jar run {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar launch {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar fft");
System.out.println("java -jar DeconvolutionLab_2.jar info");
System.out.println("java -jar DeconvolutionLab_2.jar help");
System.out.println("{command} is the full command line for running a deconvolution");
System.out.println("Keywords of {command}: ");
for (String keyword : Command.keywords)
System.out.println("\t" + keyword);
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
Lab.init(Imager.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
new Deconvolution("CommandLine", cmd).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index d80e9e4..e263ea8 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,387 +1,398 @@
/*
* 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 bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
import signal.RealSignal;
import signal.SignalCollector;
/**
* This class is the main class to run deconvolution with or without user interface.
*
* All the parameters are given in the command line (String variable command).
*
* @author Daniel Sage
*
*/
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
private AbstractAlgorithm algo = null;
private Controller controller = new Controller();
private String command = "";
private Features report = new Features();
private String name = "";
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
+ private boolean embeddedStats = false;
+
public Deconvolution(String name, String command) {
this.name = name;
this.finish = Finish.DIE;
setCommand(command);
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
}
public void setCommand(String command) {
this.command = command;
controller = Command.decodeController(command);
algo = Command.decodeAlgorithm(command);
algo.setController(controller);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortnames()[0];
}
public RealSignal deconvolve() {
return deconvolve(image, psf);
}
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
Lab.setVisible(((TableMonitor)monitor).getPanel(), "Monitor of " + name, 10, 10);
if (controller.getFFT() == null) {
run();
return deconvolvedImage;
}
if (!controller.getFFT().isMultithreadable()) {
run();
return deconvolvedImage;
}
if (controller.isMultithreading()) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
return deconvolvedImage;
}
/**
* This method runs the deconvolution with a graphical user interface.
*/
public void launch() {
- TableMonitor tableMonitor = null;
- for(AbstractMonitor monitor : controller.getMonitors())
- if (monitor instanceof TableMonitor)
- tableMonitor = (TableMonitor)monitor;
-
- dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this, tableMonitor, controller.getStats());
+ embeddedStats = true;
+ dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this);
controller.getMonitors().add(new StatusMonitor(dialog.getProgressBar()));
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
Monitors monitors = controller.getMonitors();
report.add("Path", controller.toStringPath());
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
report.add("FFT", controller.getFFT().getName());
report.add("Algorithm", algo.getName());
+ if (embeddedStats) {
+ TableMonitor tableMonitor = null;
+ for(AbstractMonitor monitor : controller.getMonitors())
+ if (monitor instanceof TableMonitor)
+ tableMonitor = (TableMonitor)monitor;
+ if (controller.getStats().getMode() == Stats.Mode.SHOW || controller.getStats().getMode() == Stats.Mode.SHOWSAVE) {
+ controller.getStats().setEmbeddedInFrame(embeddedStats);
+ dialog.addStats(controller.getStats());
+ }
+ if (tableMonitor != null) {
+ dialog.addMonitor(tableMonitor);
+ }
+ }
algo.setController(controller);
deconvolvedImage = algo.run(image, psf, controller.getStats());
report.add("End", NumFormat.time(System.nanoTime() - chrono));
if (finish == Finish.KILL) {
System.out.println("End");
System.exit(0);
}
if (finish == Finish.DIE)
die();
}
public void close() {
if (dialog != null)
dialog.dispose();
SignalCollector.free(image);
SignalCollector.free(psf);
SignalCollector.free(deconvolvedImage);
algo = null;
image = null;
psf = null;
deconvolvedImage = null;
System.gc();
}
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
Token image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
double norm = controller.getNormalizationPSF();
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReference());
features.add("Constraint", controller.getConstraintAsString());
features.add("Padding", controller.getPadding().toString());
features.add("Apodization", controller.getApodization().toString());
features.add("FFT", controller.getFFT() == null ? "null" : controller.getFFT().getName());
}
features.add("Path", controller.getPath());
features.add("Monitor", controller.toStringMonitor());
if (controller.getStats() != null)
features.add("Stats", controller.getStats().toStringStats());
features.add("Running", controller.toStringRunning());
for (Output out : controller.getOuts())
features.add("Output " + out.getName(), out.toString());
return features;
}
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
public void abort() {
algo.getController().abort();
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
image = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return image;
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
psf = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return psf;
}
private static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
if (arg.equalsIgnoreCase("synthetic")) {
signal = Lab.createSynthetic(monitors, cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = Lab.getImage(monitors, cmd);
}
if (arg.equalsIgnoreCase("file")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.openFile(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.openFile(monitors, cmd);
}
}
}
if (arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
}
return signal;
}
public void setAlgorithm(AbstractAlgorithm algo) {
this.algo = algo;
}
public AbstractAlgorithm getAlgorithm() {
return algo;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public RealSignal getOutput() {
return deconvolvedImage;
}
public RealSignal getImage() {
return image;
}
public RealSignal getPSF() {
return psf;
}
public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public String getCommand() {
return command;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 86340c8..b848d0e 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,374 +1,374 @@
/*
* 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.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
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.JToolBar;
import bilib.component.BorderToggledButton;
import bilib.component.PanelImage;
import deconvolution.capsule.AlgorithmCapsule;
import deconvolution.capsule.ImageCapsule;
import deconvolution.capsule.PSFCapsule;
import deconvolution.capsule.RecapCapsule;
import deconvolution.capsule.ReportCapsule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
public class DeconvolutionDialog extends JDialog implements WindowListener, ActionListener, Runnable {
public enum State {
NOTDEFINED, READY, RUN, FINISH
};
public enum Module {
- ALL, RECAP, IMAGE, PSF, ALGO
+ ALL, RECAP, IMAGE, PSF, ALGO, RUN
};
private JButton bnStart = new JButton("Run");
private JButton bnStop = new JButton("Stop");
private JButton bnReset = new JButton("Reset");
private JButton bnHelp = new JButton("Help");
private JButton bnQuit = new JButton("Quit");
private BorderToggledButton bnRecap = new BorderToggledButton("Recap");
private BorderToggledButton bnImage = new BorderToggledButton("Image");
private BorderToggledButton bnPSF = new BorderToggledButton("PSF");
private BorderToggledButton bnAlgo = new BorderToggledButton("Algorithm");
private BorderToggledButton bnReport = new BorderToggledButton("Report");
private BorderToggledButton bnMonitor = new BorderToggledButton("Monitor");
private BorderToggledButton bnStats = new BorderToggledButton("Stats");
+ JToolBar tool = new JToolBar();
private Thread thread = null;
private Deconvolution deconvolution;
private JProgressBar progress = new JProgressBar();
public static Point location = new Point(0, 0);
private JPanel cards = new JPanel(new CardLayout());
private boolean flagMonitor = false;
private boolean flagStats = false;
private ImageCapsule image;
private PSFCapsule psf;
private RecapCapsule recap;
private AlgorithmCapsule algorithm;
private ReportCapsule report;
- private TableMonitor tableMonitor;
-
- public DeconvolutionDialog(Module module, Deconvolution deconvolution, TableMonitor tableMonitor, Stats stats) {
+ public DeconvolutionDialog(Module module, Deconvolution deconvolution) {
super(new JFrame(), deconvolution.getName());
this.deconvolution = deconvolution;
- this.tableMonitor = tableMonitor;
image = new ImageCapsule(deconvolution);
psf = new PSFCapsule(deconvolution);
recap = new RecapCapsule(deconvolution);
algorithm = new AlgorithmCapsule(deconvolution);
report = new ReportCapsule(deconvolution);
// Panel status bar on bottom
progress.setAlignmentX(JLabel.CENTER_ALIGNMENT);
progress.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(progress, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
// Panel bottom
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
// Panel buttons
if (module == Module.ALL) {
PanelImage buttons = new PanelImage("celegans.jpg");
buttons.setLayout(new FlowLayout());
buttons.setBorder(BorderFactory.createEtchedBorder());
buttons.add(bnReset);
buttons.add(bnStop);
buttons.add(bnStart);
bottom.add(buttons);
}
bottom.add(statusBar);
// Panel Image
cards.add(recap.getName(), recap.getPane());
cards.add(image.getName(), image.getPane());
cards.add(psf.getName(), psf.getPane());
cards.add(algorithm.getName(), algorithm.getPane());
cards.add(report.getName(), report.getPane());
- if (tableMonitor != null)
- cards.add("Monitor", tableMonitor.getPanel());
- if (stats != null)
- cards.add("Stats", stats.getPanel());
// Panel Main
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(cards, BorderLayout.CENTER);
panel.add(bottom, BorderLayout.SOUTH);
// Panel tool with all buttons
if (module == Module.ALL) {
- JToolBar tool = new JToolBar();
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 6));
tool.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tool.add(bnRecap);
tool.add(bnImage);
tool.add(bnPSF);
tool.add(bnAlgo);
- if (tableMonitor != null)
- tool.add(bnMonitor);
- if (stats != null)
- tool.add(bnStats);
tool.add(bnReport);
panel.add(tool, BorderLayout.NORTH);
}
add(panel);
bnReset.addActionListener(this);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnStop.addActionListener(this);
bnHelp.addActionListener(this);
bnImage.addActionListener(this);
bnPSF.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
- if (tableMonitor != null)
- bnMonitor.addActionListener(this);
- if (stats != null)
- bnStats.addActionListener(this);
bnReport.addActionListener(this);
this.addWindowListener(this);
setMinimumSize(new Dimension(Constants.widthGUI, 400));
setPreferredSize(new Dimension(Constants.widthGUI, 400));
pack();
Config.registerFrame("DeconvolutionLab", "DeconvolutionDialog", this);
Rectangle rect = Config.getDialog("DeconvolutionLab.DeconvolutionDialog");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
bnStop.setEnabled(false);
if (module == Module.ALL) {
toggle(bnRecap);
recap.update();
}
if (module == Module.IMAGE) {
toggle(bnImage);
deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
image.update();
}
if (module == Module.PSF) {
toggle(bnPSF);
deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
psf.update();
}
if (module == Module.ALGO) {
toggle(bnAlgo);
deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
algorithm.update();
}
if (module == Module.RECAP) {
toggle(bnRecap);
recap.update();
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
if (flagMonitor)
toggle(bnMonitor);
else if (flagStats)
toggle(bnStats);
if (thread == null) {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnStop) {
toggle(bnReport);
if (deconvolution != null)
deconvolution.abort();
}
else if (e.getSource() == bnImage) {
toggle(bnImage);
image.update();
}
else if (e.getSource() == bnPSF) {
toggle(bnPSF);
psf.update();
}
else if (e.getSource() == bnAlgo) {
toggle(bnAlgo);
algorithm.update();
}
else if (e.getSource() == bnRecap) {
toggle(bnRecap);
recap.update();
}
else if (e.getSource() == bnReport) {
toggle(bnReport);
report.update();
}
else if (e.getSource() == bnReset) {
toggle(bnRecap);
- if (tableMonitor != null)
- tableMonitor.clear();
-
bnStart.setEnabled(true);
}
else if (e.getSource() == bnQuit) {
deconvolution.close();
deconvolution = null;
dispose();
}
else if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnMonitor)
toggle(bnMonitor);
else if (e.getSource() == bnStats)
toggle(bnStats);
}
@Override
public void run() {
bnRecap.setEnabled(false);
bnImage.setEnabled(false);
bnPSF.setEnabled(false);
bnAlgo.setEnabled(false);
bnStart.setEnabled(false);
bnStop.setEnabled(true);
deconvolution.setCommand(recap.getCommand());
deconvolution.run();
toggle(bnReport);
bnStop.setEnabled(false);
report.update();
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
thread = null;
}
+ public void addStats(Stats stats) {
+ if (stats != null) {
+ cards.add("Stats", stats.getPanel());
+ tool.add(bnStats);
+ pack();
+ bnStats.addActionListener(this);
+ }
+ }
+
+ public void addMonitor(TableMonitor tableMonitor) {
+ if (tableMonitor != null) {
+ cards.add("Monitor", tableMonitor.getPanel());
+ tool.add(bnMonitor);
+ pack();
+ bnMonitor.addActionListener(this);
+ }
+ }
+
public static void setLocationLaunch(Point l) {
location = l;
}
private void toggle(BorderToggledButton bn) {
((CardLayout) (cards.getLayout())).show(cards, bn.getText());
bnRecap.setSelected(false);
bnImage.setSelected(false);
bnPSF.setSelected(false);
bnAlgo.setSelected(false);
bnMonitor.setSelected(false);
bnStats.setSelected(false);
bnReport.setSelected(false);
bn.setSelected(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
deconvolution.close();
deconvolution = null;
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) {
}
public JProgressBar getProgressBar() {
return progress;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Stats.java b/DeconvolutionLab2/src/deconvolution/Stats.java
index a753b08..c1ca4c1 100644
--- a/DeconvolutionLab2/src/deconvolution/Stats.java
+++ b/DeconvolutionLab2/src/deconvolution/Stats.java
@@ -1,159 +1,170 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.system.SystemUsage;
import signal.RealSignal;
import signal.SignalCollector;
public class Stats {
public enum Mode {NO, SHOW, SAVE, SHOWSAVE};
private CustomizedTable table;
private float[] statsInput;
private Mode mode;
+ private boolean embedded = false;
+
public Stats(Mode mode) {
this.mode = mode;
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
columns.add(new CustomizedColumn("Mean", String.class, 100, false));
columns.add(new CustomizedColumn("Minimum", String.class, 100, false));
columns.add(new CustomizedColumn("Maximum", String.class, 100, false));
columns.add(new CustomizedColumn("Stdev", String.class, 100, false));
columns.add(new CustomizedColumn("Energy", 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("Signal", 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));
table = new CustomizedTable(columns, true);
}
+ public void setEmbeddedInFrame(boolean embedded) {
+ this.embedded = embedded;
+ }
+
+ /**
+ * Show the stats table in a frame if it is not yet embedded in another frame.
+ */
public void show() {
+ if (embedded)
+ return;
if (mode == Mode.SHOW || mode == Mode.SHOWSAVE) {
JFrame frame = new JFrame("Stats");
frame.getContentPane().add(getPanel());
frame.pack();
Lab.setVisible(frame);
}
}
public void save(Monitors monitors, String path) {
if (mode == Mode.SAVE || mode == Mode.SHOWSAVE) {
String filename = path + File.separator + "stats.csv";
monitors.log("Stats save " + filename);
table.saveCSV(filename);
}
}
public void addInput(RealSignal x) {
statsInput = x.getStats();
table.append(compute(x, 0, "", "", "", ""));
}
public void add(RealSignal x, int iterations) {
table.append(compute(x, iterations, "", "", "", ""));
}
public void add(RealSignal x, int iterations, String time, String psnr, String snr, String residu) {
table.append(compute(x, iterations, time, psnr, snr, residu));
}
public String[] compute(RealSignal x, int iterations, String time, String psnr, String snr, String residu) {
float params[] = null;
if (x != null)
params = x.getStats();
String[] row = new String[12];
row[0] = "" + iterations;
row[1] = (params == null ? "-" : "" + params[0]);
row[2] = (params == null ? "-" : "" + params[1]);
row[3] = (params == null ? "-" : "" + params[2]);
row[4] = (params == null ? "-" : "" + params[3]);
row[5] = (params == null ? "-" : "" + params[5]);
row[6] = time;
row[7] = NumFormat.bytes(SystemUsage.getHeapUsed());
row[8] = SignalCollector.sumarize();
row[9] = psnr;
row[10] = snr;
row[11] = residu;
return row;
}
public JPanel getPanel() {
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(Constants.widthGUI, 400));
JPanel panel = new JPanel(new BorderLayout());
panel = new JPanel(new BorderLayout());
panel.add(scroll);
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
}
public String toStringStats() {
if (mode == Mode.SHOW)
return "show";
if (mode == Mode.SAVE)
return "save";
if (mode == Mode.SHOWSAVE)
return "show and save";
return "no";
}
public Mode getMode() {
return mode;
}
public float[] getStatsInput() {
return statsInput;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index 5a8026b..699f287 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,408 +1,409 @@
/*
* 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.ArrayList;
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 signal.Constraint;
+import signal.RealSignal;
+import signal.SignalCollector;
+import signal.apodization.Apodization;
+import signal.padding.Padding;
import bilib.tools.NumFormat;
+import deconvolution.DeconvolutionDialog;
import deconvolution.Stats;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.system.SystemInfo;
import fft.AbstractFFT;
import fft.FFT;
-import signal.Constraint;
-import signal.RealSignal;
-import signal.SignalCollector;
-import signal.apodization.Apodization;
-import signal.padding.Padding;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h;
protected boolean threaded;
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint;
protected int iterMax = 0;
protected AbstractFFT fft;
protected Controller controller;
public AbstractAlgorithm() {
setController(new Controller());
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public AbstractAlgorithm(Controller controller) {
this.controller = controller;
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract String[] getShortnames();
public abstract double getMemoryFootprintRatio();
public abstract int getComplexityNumberofFFT();
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(RealSignal image, RealSignal psf) {
return run(image, psf, new Stats(Stats.Mode.NO));
}
public RealSignal run(RealSignal image, RealSignal psf, Stats stats) {
if (controller.isSystem())
SystemInfo.activate();
Padding pad = controller.getPadding();
Apodization apo = controller.getApodization();
double norm = controller.getNormalizationPSF();
fft = controller.getFFT();
controller.setIterationsMax(iterMax);
if (image == null)
return null;
if (psf == null)
return null;
// Prepare the controller and the outputs
Monitors monitors = controller.getMonitors();
monitors.setVerbose(controller.getVerbose());
monitors.log("Path: " + controller.toStringPath());
monitors.log("Algorithm: " + getName());
// Prepare the signal and the PSF
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? iterMax + " iterations" : "direct");
controller.setIterationsMax(iterMax);
monitors.log(getShortnames()[0] + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
-
+
controller.start(y, stats);
h.circular();
// FFT
fft.init(monitors, y.nx, y.ny, y.nz);
controller.setFFT(fft);
monitors.log(getShortnames()[0] + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortnames()[0] + 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();
}
SignalCollector.free(y);
SignalCollector.free(h);
x.setName("x");
RealSignal result = pad.crop(monitors, x);
controller.finish(result);
monitors.log(getName() + " is finished");
SignalCollector.free(x);
if (controller.isDisplayFinal())
Lab.show(monitors, result, "Final Display of " + getShortnames()[0]);
result.setName("Output of " + this.getShortnames()[0]);
return result;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public int getIterationsMax() {
return iterMax;
}
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() ? ", " + iterMax + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for (int i = 0; i < p.length; i++)
if (i == p.length - 1)
param += p[i];
else
param += p[i] + ", ";
return param;
}
public AbstractFFT getFFT() {
return controller.getFFT();
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
controller.setFFT(fft);
}
public String getPath() {
return controller.getPath();
}
public void setPath(String path) {
controller.setPath(path);
}
public boolean isSystem() {
return controller.isSystem();
}
public void setSystem(boolean system) {
controller.setSystem(system);
}
public boolean isMultithreading() {
return controller.isMultithreading();
}
public void setMultithreading(boolean multithreading) {
controller.setMultithreading(multithreading);
}
public boolean isDisplayFinal() {
return controller.isDisplayFinal();
}
public void setDisplayFinal(boolean displayFinal) {
controller.setDisplayFinal(displayFinal);
}
public double getNormalizationPSF() {
return controller.getNormalizationPSF();
}
public void setNormalizationPSF(double normalizationPSF) {
controller.setNormalizationPSF(normalizationPSF);
}
public double getEpsilon() {
return controller.getEpsilon();
}
public void setEpsilon(double epsilon) {
controller.setEpsilon(epsilon);
}
public Padding getPadding() {
return controller.getPadding();
}
public void setPadding(Padding padding) {
controller.setPadding(padding);
}
public Apodization getApodization() {
return controller.getApodization();
}
public void setApodization(Apodization apodization) {
controller.setApodization(apodization);
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public void setMonitors(Monitors monitors) {
controller.setMonitors(monitors);
}
public Verbose getVerbose() {
return controller.getVerbose();
}
public void setVerbose(Verbose verbose) {
controller.setVerbose(verbose);
}
public Constraint.Mode getConstraint() {
return controller.getConstraint();
}
public void setConstraint(Constraint.Mode constraint) {
controller.setConstraint(constraint);
}
public Stats getStats() {
return controller.getStats();
}
public void setStats(Stats stats) {
controller.setStats(stats);
}
public double getResiduMin() {
return controller.getResiduMin();
}
public void setResiduMin(double residuMin) {
controller.setResiduMin(residuMin);
}
public double getTimeLimit() {
return controller.getTimeLimit();
}
public void setTimeLimit(double timeLimit) {
controller.setTimeLimit(timeLimit);
}
public String getReference() {
return controller.getReference();
}
public void setReference(String reference) {
controller.setReference(reference);
}
public ArrayList<Output> getOuts() {
return controller.getOuts();
}
public void setOuts(ArrayList<Output> outs) {
controller.setOuts(outs);
}
public void addOutput(Output out) {
controller.addOutput(out);
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index 5701561..0e2b292 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,638 +1,631 @@
/*
* 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.io.File;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
+import signal.Assessment;
+import signal.ComplexSignal;
+import signal.Constraint;
+import signal.RealSignal;
+import signal.apodization.Apodization;
+import signal.padding.Padding;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Stats;
import deconvolutionlab.Constants;
import deconvolutionlab.Output;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFT;
import fft.FFT;
-import signal.Assessment;
-import signal.ComplexSignal;
-import signal.Constraint;
-import signal.RealSignal;
-import signal.apodization.Apodization;
-import signal.padding.Padding;
/**
* This is an important class to manage all the common task of the algorithm.
* The method start() is called before at the starting of the algorithm. The
* method ends() is called at the end of every iterations for the iterative
* algorithm. It returns true if one the stopping criteria is true. The method
* finish() is called when the algorithm is completely terminated.
*
* @author Daniel Sage
*
*/
public class Controller {
private String path;
private boolean system;
private boolean multithreading;
private boolean displayFinal;
private double normalizationPSF;
private double epsilon;
private Padding padding;
private Apodization apodization;
private ArrayList<Output> outs;
private Stats stats;
private Constraint.Mode constraintMode;
private double residuMin;
private double timeLimit;
private String reference;
private Monitors monitors;
private Verbose verbose;
private AbstractFFT fft;
private int iterationsMax = 100;
private boolean doResidu = false;
private boolean doTime = false;
private boolean doReference = false;
private boolean doConstraint = false;
private boolean abort = false;
private double timeStarting = 0;
private double memoryStarting = 0;
private double residu = Double.MAX_VALUE;
private int iterations = 0;
private double memoryPeak = 0;
private double snr = 0;
private double psnr = 0;
private RealSignal refImage;
private RealSignal prevImage;
private RealSignal x;
private Timer timer;
public Controller() {
doResidu = false;
doTime = false;
doReference = false;
doConstraint = false;
timeStarting = System.nanoTime();
setPath(System.getProperty("user.dir"));
setSystem(true);
setMultithreading(true);
setDisplayFinal(true);
setFFT(FFT.getFastestFFT().getDefaultFFT());
setNormalizationPSF(1);
setEpsilon(1e-6);
setPadding(new Padding());
setApodization(new Apodization());
monitors = new Monitors();
monitors.add(new ConsoleMonitor());
monitors.add(new TableMonitor("Monitor", Constants.widthGUI, 240));
setVerbose(Verbose.Log);
setStats(new Stats(Stats.Mode.NO));
setConstraint(Constraint.Mode.NO);
setResiduMin(-1);
setTimeLimit(-1);
setReference("");
setOuts(new ArrayList<Output>());
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
public void setIterationsMax(int iterationsMax) {
this.iterationsMax = iterationsMax;
}
public boolean needSpatialComputation() {
return doConstraint || doResidu || doReference;
}
/**
* Call one time at the beginning of the algorithms
*
* @param x
* the input signal
*/
public void start(RealSignal x, Stats stats) {
this.x = x;
this.stats = stats;
stats.show();
stats.addInput(x);
iterations = 0;
timer = new Timer();
timer.schedule(new Updater(), 0, 100);
timeStarting = System.nanoTime();
memoryStarting = SystemUsage.getHeapUsed();
if (doConstraint && x != null)
Constraint.setModel(x);
if (doReference) {
refImage = new Deconvolution("Reference", "-image file " + reference).openImage();
if (refImage == null)
monitors.error("Impossible to load the reference image " + reference);
else
monitors.log("Reference image loaded");
}
for (Output out : outs)
out.executeStarting(monitors, x, this);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
boolean out = false;
for (Output output : outs)
out = out | output.is(iterations);
if (doConstraint || doResidu || doReference || out) {
if (fft == null)
fft = FFT.createDefaultFFT(monitors, X.nx, X.ny, X.nz);
x = fft.inverse(X, x);
return ends(x);
}
return ends((RealSignal) null);
}
public boolean ends(RealSignal x) {
this.x = x;
if (doConstraint || doResidu || doReference)
compute(iterations, x, doConstraint, doResidu, doReference);
for (Output out : outs)
out.executeIterative(monitors, x, this, iterations);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
double timeElapsed = getTimeSecond();
boolean stopIter = (iterations >= iterationsMax);
boolean stopTime = doTime && (timeElapsed >= timeLimit);
boolean stopResd = doResidu && (residu <= residuMin);
monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed));
addStats();
String prefix = "Stopped>> by ";
if (abort)
monitors.log(prefix + "abort");
if (stopIter)
monitors.log(prefix + "iteration " + iterations + " > " + iterationsMax);
if (stopTime)
monitors.log(prefix + "time " + timeElapsed + " > " + timeLimit);
if (stopResd)
monitors.log(prefix + "residu " + NumFormat.nice(residu) + " < " + NumFormat.nice(residuMin));
return abort | stopIter | stopTime | stopResd;
}
public void finish(RealSignal x) {
this.x = x;
boolean ref = doReference;
boolean con = doConstraint;
boolean res = doResidu;
if (con || res || ref)
compute(iterations, x, con, res, ref);
addStats();
stats.save(monitors, path);
for (Output out : outs)
out.executeFinal(monitors, x, this);
monitors.log("Time: " + NumFormat.seconds(getTimeNano()) + " Peak:" + getMemoryAsString());
if (timer != null)
timer.cancel();
}
private void compute(int iterations, RealSignal x, boolean con, boolean res, boolean ref) {
if (x == null)
return;
if (con && constraintMode != null)
new Constraint(monitors).apply(x, constraintMode);
if (ref && refImage != null) {
String s = "";
psnr = Assessment.psnr(x, refImage);
snr = Assessment.snr(x, refImage);
s += " PSNR: " + NumFormat.nice(psnr);
s += " SNR: " + NumFormat.nice(snr);
monitors.log("@" + iterations + " " + s);
}
residu = Double.MAX_VALUE;
if (res && prevImage != null) {
residu = Assessment.relativeResidu(x, prevImage);
prevImage = x.duplicate();
monitors.log("@" + iterations + " Residu: " + NumFormat.nice(residu));
}
}
private void addStats() {
String pnsrText = doReference ? NumFormat.nice(psnr) : "n/a";
String snrText = doReference ? NumFormat.nice(snr) : "n/a";
String residuText = doResidu ? NumFormat.nice(residu) : "n/a";
stats.add(x, iterations, NumFormat.seconds(getTimeNano()), pnsrText, snrText, residuText);
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
public double getTimeSecond() {
return (System.nanoTime() - timeStarting) * 1e-9;
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
if (constraintMode == null)
return "null";
return constraintMode.name().toLowerCase();
}
public String getStoppingCriteriaAsString(AbstractAlgorithm algo) {
String stop = algo.isIterative() ? "iterations limit=" + algo.getIterationsMax() + ", " : "direct, ";
stop += doTime ? ", time limit=" + NumFormat.nice(timeLimit * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
public double getMemory() {
return memoryPeak - memoryStarting;
}
public String getMemoryAsString() {
return NumFormat.bytes(getMemory());
}
public int getIterations() {
return iterations;
}
private void update() {
memoryPeak = Math.max(memoryPeak, SystemUsage.getHeapUsed());
}
public AbstractFFT getFFT() {
return fft;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path
* the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the system
*/
public boolean isSystem() {
return system;
}
/**
* @param system
* the system to set
*/
public void setSystem(boolean system) {
this.system = system;
}
/**
* @return the multithreading
*/
public boolean isMultithreading() {
return multithreading;
}
/**
* @param multithreading
* the multithreading to set
*/
public void setMultithreading(boolean multithreading) {
this.multithreading = multithreading;
}
/**
* @return the displayFinal
*/
public boolean isDisplayFinal() {
return displayFinal;
}
/**
* @param displayFinal
* the displayFinal to set
*/
public void setDisplayFinal(boolean displayFinal) {
this.displayFinal = displayFinal;
}
/**
* @return the normalizationPSF
*/
public double getNormalizationPSF() {
return normalizationPSF;
}
/**
* @param normalizationPSF
* the normalizationPSF to set
*/
public void setNormalizationPSF(double normalizationPSF) {
this.normalizationPSF = normalizationPSF;
}
/**
* @return the epsilon
*/
public double getEpsilon() {
return epsilon;
}
/**
* @param epsilon
* the epsilon to set
*/
public void setEpsilon(double epsilon) {
this.epsilon = epsilon;
}
/**
* @return the padding
*/
public Padding getPadding() {
return padding;
}
/**
* @param padding
* the padding to set
*/
public void setPadding(Padding padding) {
this.padding = padding;
}
/**
* @return the apodization
*/
public Apodization getApodization() {
return apodization;
}
/**
* @param apodization
* the apodization to set
*/
public void setApodization(Apodization apodization) {
this.apodization = apodization;
}
/**
* @return the monitors
*/
public Monitors getMonitors() {
return monitors;
}
/**
* @param monitors
* the monitors to set
*/
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
/**
* @return the verbose
*/
public Verbose getVerbose() {
return verbose;
}
/**
* @param verbose
* the verbose to set
*/
public void setVerbose(Verbose verbose) {
this.verbose = verbose;
}
public Constraint.Mode getConstraint() {
return constraintMode;
}
public void setConstraint(Constraint.Mode constraintMode) {
doConstraint = constraintMode != Constraint.Mode.NO;
this.constraintMode = constraintMode;
}
/**
* @return the stats
*/
public Stats getStats() {
return stats;
}
/**
* @param stats
* the stats to set
*/
public void setStats(Stats stats) {
this.stats = stats;
}
/**
* @return the residuMin
*/
public double getResiduMin() {
return residuMin;
}
/**
* @param residuMin
* the residuMin to set
*/
public void setResiduMin(double residuMin) {
doResidu = residuMin > 0;
this.residuMin = residuMin;
}
/**
* @return the timeLimit
*/
public double getTimeLimit() {
return timeLimit;
}
/**
* @param timeLimit
* the timeLimit to set
*/
public void setTimeLimit(double timeLimit) {
doTime = timeLimit > 0;
this.timeLimit = timeLimit;
}
/**
* @return the reference
*/
public String getReference() {
return reference;
}
/**
* @param reference
* the reference to set
*/
public void setReference(String reference) {
doReference = false;
if (reference == null)
return;
if (reference.equals(""))
return;
doReference = true;
this.reference = reference;
}
/**
* @return the outs
*/
public ArrayList<Output> getOuts() {
return outs;
}
/**
* @param outs
* the outs to set
*/
public void setOuts(ArrayList<Output> outs) {
this.outs = outs;
}
public void addOutput(Output out) {
this.outs.add(out);
}
public String toStringMonitor() {
String s = "[" + verbose.name().toLowerCase() + "] ";
for (AbstractMonitor monitor : monitors) {
s += "" + monitor.getName() + " ";
}
return s;
}
- /**
- * @return the stats
- */
public Stats.Mode getStatsMode() {
return stats.getMode();
}
- /**
- * @param stats
- * the stats to set
- */
public void setStatsMode(Stats.Mode mode) {
this.stats = new Stats(mode);
}
public String toStringRunning() {
String s = "";
s += "system " + (system ? "shown" : "hidden ");
s += ", multithreading " + (multithreading ? "on" : "off ");
s += ", display final " + (displayFinal ? "on " : "off ");
return s;
}
public String toStringPath() {
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)";
}
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index 71510bd..4bd3f9d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,526 +1,524 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bilib.tools.NumFormat;
import bilib.tools.WebBrowser;
import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import imagej.IJImager;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.SignalFactory;
import signal.factory.Sphere;
/**
* This class contains a collection of useful static methods to manage all the
* peripherical aspects of the deconvolution, such as load, display, or save an
* image.
* <p>
* At the construction of the class, the config is loaded. In practice, any
* deconvolution program has to start with Lab.init(Platform).
*
* @author Daniel Sage
*
*/
public class Lab {
private static Imager imaging;
private static ArrayList<JFrame> frames;
private static ArrayList<JDialog> dialogs;
static {
frames = new ArrayList<JFrame>();
dialogs = new ArrayList<JDialog>();
imaging = new IJImager();
Config.init(System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
/**
* Initializes the Lab with a give platform.
*
* @param platform
* The platform is ImageJ, ICY, or Matlab.
*/
public static void init(Imager.Platform platform) {
init(platform, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
/**
* Initializes the Lab with a give platform and a given configuration file
*
* @param platform
* @param configFilename
*/
public static void init(Imager.Platform platform, String configFilename) {
switch (platform) {
case IMAGEJ:
imaging = new IJImager();
break;
case ICY:
imaging = new IcyImager();
break;
default:
imaging = new IJImager();
break;
}
Config.init(configFilename);
}
/**
* Returns the platform.
*
* @return
*/
public static Imager.Platform getPlatform() {
return imaging.getPlatform();
}
/**
* Open a web page on the DeconvolutionLab2.
*/
public static void help() {
WebBrowser.open(Constants.url);
}
/**
* Checks the installed FFT libraries on a small (40, 30, 20) signal.
*
* @param monitors
*/
public static void checkFFT(Monitors monitors) {
ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
for (AbstractFFTLibrary library : libraries) {
RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
double chrono = System.nanoTime();
AbstractFFT fft = library.getDefaultFFT();
fft.init(monitors, y.nx, y.ny, y.nz);
RealSignal x = fft.inverse(fft.transform(y));
chrono = System.nanoTime() - chrono;
double residu = y.getEnergy() - x.getEnergy();
monitors.log("\t residu of reconstruction: " + residu);
monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
}
}
public static ContainerImage createContainer(Monitors monitors, String title) {
monitors.log("Create Live Real Signal " + title);
return imaging.createContainer(title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title) {
imaging.append(container, signal, title, Imager.Type.FLOAT);
monitors.log("Add Live Real Signal " + title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imager.Type type) {
imaging.append(container, signal, title, type);
monitors.log("Add Live Real Signal " + title);
}
/**
* Displays a the module of complex signal.
*
* @param monitors
* @param signal
* @param title
*/
public static void show(Monitors monitors, ComplexSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, ComplexComponent.MODULE);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param signal
*/
public static void show(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param monitors
* @param signal
*/
public static void show(Monitors monitors, RealSignal signal) {
if (signal == null) {
monitors.error("This image does not exist.");
return;
}
monitors.log("Show Real Signal " + signal.name);
imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images.
*
* @param monitors
* @param signal
* @param title
*/
public static void show(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, Imager.Type.FLOAT, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images using a given type.
*
* @param monitors
* @param signal
* @param title
* @param type
*/
public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, signal.nz / 2);
}
/**
* Displays a real 3D signal a z-stack of images using a given type and
* shows the slice number z.
*
* @param monitors
* @param signal
* @param title
* @param type
* @param z
*/
public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, z);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
imaging.save(signal, filename, Imager.Type.FLOAT);
monitors.log("Save Real Signal " + filename);
}
public static void save(Monitors monitors, RealSignal signal, String filename, Imager.Type type) {
imaging.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
public static RealSignal createSynthetic(Monitors monitors, String cmd) {
RealSignal signal = SignalFactory.createFromCommand(cmd);
if (signal == null)
monitors.error("Unable to create " + cmd);
else
monitors.log("Create " + cmd);
return signal;
}
/**
* Return the active image.
*
- * @param monitors
* @return
*/
public static RealSignal getImage() {
return getImager().getActiveImage();
}
/**
* Return an image from the platform with a specified name.
*
- * @param monitors
+ * @param name
* @return
*/
public static RealSignal getImage(String name) {
return getImager().getImageByName(name);
}
/**
* Return an image from the platform with a specified name.
*
* @param monitors
* @param name
* @return
*/
public static RealSignal getImage(Monitors monitors, String name) {
RealSignal signal = getImager().getImageByName(name);
if (signal == null)
monitors.error("Unable to get " + name);
else
monitors.log("Load " + name);
return signal;
}
/**
* Open an image from the disk.
*
- * @param monitors
* @param filename
* @return
*/
public static RealSignal openFile(String filename) {
return imaging.open(filename);
}
/**
* Open an image from the disk.
*
* @param monitors
* @param filename
* @return
*/
public static RealSignal openFile(Monitors monitors, String filename) {
RealSignal signal = imaging.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
/**
* Open a series of image from a directory.
*
* @param path
* @return
*/
public static RealSignal openDir(String path) {
return openDir(Monitors.createDefaultMonitor(), path);
}
/**
* Open a series of image from a directory.
*
* @param monitors
* @param path
* @return
*/
public static RealSignal openDir(Monitors monitors, String path) {
String parts[] = path.split(" pattern ");
String dirname = path;
String regex = "";
if (parts.length == 2) {
dirname = parts[0].trim();
regex = parts[1].trim();
}
File file = new File(dirname + File.separator);
if (!file.isDirectory()) {
monitors.error("Dir " + dirname + " is not a directory.");
return null;
}
String[] list = file.list();
ArrayList<RealSignal> slices = new ArrayList<RealSignal>();
int nx = 0;
int ny = 0;
Pattern pattern = Pattern.compile(regex);
for (String filename : list) {
if (pattern.matcher(filename).find()) {
RealSignal slice = imaging.open(dirname + File.separator + filename);
if (slice != null) {
slices.add(slice);
nx = Math.max(nx, slice.nx);
ny = Math.max(ny, slice.ny);
monitors.log("Image " + path + File.separator + filename + " is loaded.");
}
}
else {
monitors.error("Error in loading image " + path + File.separator + filename);
}
}
int nz = slices.size();
if (nz <= 0) {
monitors.error("Dir " + path + " do no contain valid images.");
return null;
}
RealSignal signal = new RealSignal(file.getName(), nx, ny, nz);
for (int z = 0; z < slices.size(); z++)
signal.setSlice(z, slices.get(z));
return signal;
}
public static void showOrthoview(RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
return;
}
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(RealSignal signal) {
if (signal == null) {
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
imaging.show(signal.createOrthoview(hx, hy, hz), signal.name, Imager.Type.FLOAT, 0);
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
public static void showMIP(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal.createMIP(), signal.name, Imager.Type.FLOAT, 0);
}
public static void showMIP(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show MIP " + title + " this image does not exist.");
return;
}
imaging.show(signal.createMIP(), title, Imager.Type.FLOAT, 0);
}
public static void showPlanar(RealSignal signal) {
if (signal == null) {
return;
}
imaging.show(signal.createMontage(), signal.name, Imager.Type.FLOAT, 0);
}
public static void showPlanar(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Planar " + title + " this image does not exist.");
return;
}
imaging.show(signal.createMontage(), title, Imager.Type.FLOAT, 0);
}
/*
public static RealSignal create(Monitors monitors, String name) {
RealSignal signal = imaging.create(name);
if (signal != null)
monitors.log("Created the real signal " + name + " " + signal.toString());
else
monitors.error("Impossible to create the real signal " + name);
return signal;
}
public static RealSignal create(Monitors monitors) {
RealSignal signal = imaging.create();
if (signal != null)
monitors.log("Created the real signal from the active window " + signal.toString());
else
monitors.error("Impossible to create the real signal from the active window");
return signal;
}
*/
public static Imager getImager() {
return imaging;
}
public static String getActiveImage() {
if (imaging.isSelectable())
return imaging.getSelectedImage();
return "";
}
public static void setVisible(JDialog dialog, boolean modal) {
if (dialog == null)
return;
dialogs.add(dialog);
imaging.setVisible(dialog, modal);
}
public static void setVisible(JPanel panel, String name, int x, int y) {
JFrame frame = new JFrame(name);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocation(x, y);
frame.setVisible(true);
frames.add(frame);
}
public static void setVisible(JFrame frame) {
frames.add(frame);
frame.setVisible(true);
}
public static void close() {
for (JFrame frame : frames)
if (frame != null)
frame.dispose();
for (JDialog dialog : dialogs)
if (dialog != null)
dialog.dispose();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index eb6a621..e89ab05 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,368 +1,371 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import bilib.tools.NumFormat;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import signal.Constraint;
import signal.RealSignal;
public class Output {
public enum View {
STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE
};
public enum Dynamic {
INTACT, RESCALED, NORMALIZED, CLIPPED
};
private ContainerImage container = null;
private int px = 0;
private int py = 0;
private int pz = 0;
private boolean center = true;
private String name = "";
private boolean save = true;
private boolean show = true;
private View view = View.STACK;
private Imager.Type type = Imager.Type.FLOAT;
private Dynamic dynamic = Dynamic.INTACT;
private int frequency = 0;
public Output(View view, int frequency, String param) {
String[] tokens = param.trim().split(" ");
this.view = view;
this.frequency = frequency;
this.name = "";
this.center = true;
this.save = true;
this.show = true;
this.container = Lab.createContainer(Monitors.createDefaultMonitor(), "");
for (int i = 0; i < tokens.length; i++) {
boolean found = false;
String p = tokens[i].trim().toLowerCase();
if (p.startsWith("@")) {
found = true;
}
if (p.startsWith("noshow")) {
show = false;
found = true;
}
if (p.startsWith("nosave")) {
save = false;
found = true;
}
for (Dynamic d : Dynamic.values()) {
if (p.toLowerCase().equals(d.name().toLowerCase())) {
dynamic = d;
found = true;
}
}
for (View v : View.values()) {
if (p.toLowerCase().equals(v.name().toLowerCase())) {
view = v;
found = true;
}
}
for (Imager.Type t : Imager.Type.values()) {
if (p.toLowerCase().equals(t.name().toLowerCase())) {
type = t;
found = true;
}
}
if (p.startsWith("(") && p.endsWith(")")) {
double pos[] = NumFormat.parseNumbers(p);
if (pos.length > 0)
px = (int) Math.round(pos[0]);
if (pos.length > 1)
py = (int) Math.round(pos[1]);
if (pos.length > 2)
pz = (int) Math.round(pos[2]);
found = true;
center = false;
}
if (!found)
name += tokens[i] + " ";
name = name.trim();
}
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, boolean center) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = center;
this.frequency = frequency;
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, int px, int py, int pz) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = false;
this.px = px;
this.py = py;
this.pz = pz;
this.frequency = frequency;
}
public boolean is(int iterations) {
if (frequency == 0)
return false;
return iterations % frequency == 0;
}
public View getView() {
return view;
}
public String getName() {
return name;
}
public int extractFrequency(String param) {
String line = param.trim();
if (!line.startsWith("@"))
line = "@0 " + line;
String parts[] = line.split(" ");
if (parts.length >= 1) {
return (int) Math.round(NumFormat.parseNumber(parts[0], 0));
}
return 0;
}
public void setKeypoint(int px, int py, int pz) {
this.px = px;
this.py = py;
this.pz = pz;
this.center = false;
}
public String[] getAsString() {
String t = (type == Imager.Type.FLOAT ? "" : type.name().toLowerCase());
String d = (dynamic == Dynamic.INTACT ? "" : dynamic.name().toLowerCase());
String k = "";
if (!center)
k = " (" + px + "," + py + "," + pz + ")";
else
k = "";
String sa = save ? "\u2713" : "";
String sh = show ? "\u2713" : "";
String fr = frequency > 0 ? " @" + frequency : "";
return new String[] { view.name().toLowerCase() + fr, name, d, t, k, sh, sa, "\u232B" };
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
if (signal == null)
return;
execute(monitors, signal, controller, true, false, false, 0);
}
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
if (signal == null)
return;
execute(monitors, signal, controller, false, false, true, 0);
}
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
if (signal == null)
return;
execute(monitors, signal, controller, false, true, false, iter);
}
private void execute(Monitors monitors, RealSignal signal, Controller controller, boolean start, boolean live, boolean finish, int iter) {
String title = name;
if (live)
if (!is(iter))
return;
if (controller != null && live) {
if (controller.getIterations() > 0) {
title += "@" + controller.getIterations();
}
}
RealSignal x = null;
Constraint constraint = new Constraint(monitors);
switch (dynamic) {
case RESCALED:
x = signal.duplicate();
constraint.rescaled(x, 0, 255);
break;
case CLIPPED:
x = signal.duplicate();
float[] stats = controller.getStats().getStatsInput();
if (stats != null)
constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
float[] stats1 = controller.getStats().getStatsInput();
if (stats1 != null)
constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
String filename = controller.getPath() + File.separator + title + ".tif";
switch (view) {
case STACK:
if (show && !live)
Lab.show(monitors, x, title, type, (center ? x.nz / 2 : pz));
if (save && !live)
Lab.save(monitors, x, filename, type);
break;
case SERIES:
for (int k = 0; k < x.nz; k++) {
RealSignal slice = x.getSlice(k);
+ String z = "-z" + String.format("%06d", k) ;
if (show && !live)
- Lab.show(monitors, slice, title, type);
- if (save && !live)
- Lab.save(monitors, slice, filename, type);
+ Lab.show(monitors, slice, title + z, type);
+ if (save && !live) {
+ String zfilename = controller.getPath() + File.separator + title + z + ".tif";
+ Lab.save(monitors, slice, zfilename, type);
+ }
}
break;
case ORTHO:
if (!start)
orthoview(monitors, x, title, filename, live);
break;
case FIGURE:
if (!start)
figure(monitors, x, title, filename, live);
break;
case MIP:
if (!start)
mip(monitors, x, title, filename, live);
break;
case PLANAR:
if (!start)
planar(monitors, x, title, filename, live);
break;
default:
break;
}
}
private void mip(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMIP();
if (show && live) {
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void orthoview(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createOrthoview(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void figure(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createFigure(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void planar(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMontage();
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
@Override
public String toString() {
String t = type.name().toLowerCase();
String v = view.name().toLowerCase();
String d = dynamic.name().toLowerCase();
String f = frequency > 0 ? " every " + frequency + " iterations" : "";
String k = (center ? "" : " keypoint = (" + px + "," + py + "," + pz + ")");
return v + " " + name + " format = (" + d + ", " + t + ") " + k + f;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
index 70a6d4e..659c79e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
@@ -1,169 +1,170 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
private JLabel shortname;
public AlgorithmModule(boolean expanded) {
super("Algorithm", "-algorithm", "", "Check", expanded);
ArrayList<AbstractAlgorithmPanel> deconv = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : deconv)
cmb.addItem(panel.getName());
cmb.addActionListener(this);
}
@Override
public String getCommand() {
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
String cmd = "-algorithm " + algo.getShortnames()[0] + " " + algo.getCommand();
String synopsis = algo.getShortnames()[0] + " " + algo.getCommand();
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
shortname = new JLabel("-------");
Border bl1 = BorderFactory.createEtchedBorder();
Border bl2 = BorderFactory.createEmptyBorder(0, 10, 0, 10);
shortname.setBorder(BorderFactory.createCompoundBorder(bl1, bl2));
cmb = new JComboBox<String>();
JPanel pnc = new JPanel();
pnc.add(cmb);
doc = new HTMLPane(100, 1000);
cards = new JPanel(new CardLayout());
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : panels) {
JScrollPane scroll = new JScrollPane(panel.getPanelParameters());
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cards.add(panel.getName(), scroll);
}
cmb.setMaximumRowCount(panels.size());
JPanel top = new JPanel(new BorderLayout());
top.add(cmb, BorderLayout.CENTER);
top.add(shortname, BorderLayout.EAST);
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
cards.setBorder(BorderFactory.createEtchedBorder());
control.add(top);
control.add(cards);
doc.append("h1", "Documentation");
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.NORTH);
panel.add(doc.getPane(), BorderLayout.CENTER);
// cmb.addActionListener(this);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
Config.register(getName(), "algorithm", cmb, Algorithm.getDefaultAlgorithm());
panel.setBorder(BorderFactory.createEtchedBorder());
+
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb) {
doc.clear();
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
doc.append(algo.getDocumentation());
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, name);
String s = "<html><b><p style =\"font-family:georgia\">";
for(int i=0; i<algo.getShortnames().length; i++)
s += (i==0 ? "" : " | ") + algo.getShortnames()[i] ;
shortname.setText(s + "</b></html>");
}
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Algorithm", Command.command());
- DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.ALGO, deconvolution, null, null);
+ DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.ALGO, deconvolution);
Lab.setVisible(d, false);
}
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
index 47cfaab..578a1a2 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
@@ -1,169 +1,170 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnRun;
private JButton bnLaunch;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnRun = new JButton("Run Jobs");
bnLaunch = new JButton("Launch Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 2));
pn.setFloatable(false);
pn.add(bnRun);
pn.add(bnLaunch);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRun) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
else if (e.getSource() == bnLaunch) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
+ update();
}
private void update() {
setSynopsis("" + table.getRowCount() + " jobs");
}
public int getCountJob() {
return table.getRowCount();
}
public void addJob(String name, String command) {
table.append(new String[] { name, command, "" });
update();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 2) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
}
update();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
index abc1941..8c0b2ea 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
@@ -1,92 +1,92 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Lab;
public class CommandModule extends AbstractModule {
private HTMLPane window;
public CommandModule() {
super("Command", "", "", "Check", true);
}
public HTMLPane getPane() {
return window;
}
@Override
public JPanel buildExpandedPanel() {
window = new HTMLPane("Monaco", 100, 100);
JPanel panel = new JPanel(new BorderLayout());
panel.add(window.getPane(), BorderLayout.CENTER);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Command", Command.command());
- DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution, null, null);
+ DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
window.clear();
window.append("p", command);
}
@Override
public String getCommand() {
return window.getText();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
index e66b396..aa8b097 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
@@ -1,266 +1,265 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import signal.Constraint;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtTime;
private JTextField txtIterations;
private JComboBox<String> cmbConstraint;
private JComboBox<String> cmbStats;
private JComboBox<String> cmbMonitor;
private JComboBox<String> cmbVerbose;
private JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkTime;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbMonitor.getSelectedIndex() != 0)
cmd += "-monitor " + cmbMonitor.getSelectedItem() + " ";
if (cmbVerbose.getSelectedIndex() != 0)
cmd += "-verbose " + cmbVerbose.getSelectedItem() + " ";
if (cmbStats.getSelectedIndex() != 0)
cmd += "-stats " + cmbStats.getSelectedItem() + " ";
if (cmbConstraint.getSelectedIndex() != 0)
cmd += "-constraint " + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + txtResidu.getText() + " ";
if (chkTime.isSelected())
cmd += "-time " + txtTime.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
chkTime = new JCheckBox("");
chkResidu = new JCheckBox("");
chkReference = new JCheckBox("");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtTime = new JTextField("3600");
txtIterations = new JTextField("Iteration max (mandatory)");
txtIterations.setEditable(false);
cmbMonitor = new JComboBox<String>(new String[] {"console table", "console", "table", "no" });
cmbVerbose = new JComboBox<String>(new String[] {"log", "quiet", "mute", "prolix" });
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
cmbStats = new JComboBox<String>(new String[] {"no", "show", "show + save", "save"});
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true, 2);
pn.place(0, 0, "monitor");
pn.place(0, 2, cmbMonitor);
pn.place(0, 3, "Monitoring message");
pn.place(1, 0, "verbose");
pn.place(1, 2, cmbVerbose);
pn.place(1, 3, "");
pn.place(3, 0, "stats");
pn.place(3, 2, cmbStats);
pn.place(3, 3, "Signal's statistics");
pn.place(4, 0, "constraint");
pn.place(4, 2, cmbConstraint);
pn.place(4, 3, "Additional constraint");
pn.place(5, 0, "residu");
pn.place(5, 1, chkResidu);
pn.place(5, 2, txtResidu);
pn.place(5, 3, "Additional stopping criteria");
pn.place(6, 0, "time");
pn.place(6, 1, chkTime);
pn.place(6, 2, txtTime);
pn.place(6, 3, "Additional stopping criteria");
pn.place(7, 0, "reference");
pn.place(7, 1, chkReference);
pn.place(7, 2, 2, 1, txtReference);
pn.place(8, 2, bnBrowse);
pn.place(8, 3, 1, 1, "Ground-truth file");
JScrollPane scroll = new JScrollPane(pn);
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
- panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "time.enable", chkTime, false);
Config.register(getName(), "reference.value", txtReference, "");
Config.register(getName(), "residu.value", txtResidu, "0.01");
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "constraint", cmbConstraint, cmbConstraint.getItemAt(0));
Config.register(getName(), "stats", cmbStats, cmbStats.getItemAt(0));
Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkTime.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtTime.addKeyListener(this);
cmbConstraint.addActionListener(this);
cmbMonitor.addActionListener(this);
cmbVerbose.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkTime.isSelected() ? 1 : 0);
count += (chkReference.isSelected() ? 1 : 0);
setSynopsis("" + count + " controls");
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkTime.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkTime.setSelected(false);
txtReference.setText("");
txtResidu.setText("0.01");
txtTime.setText("3600");
cmbConstraint.setSelectedIndex(0);
cmbStats.setSelectedIndex(0);
cmbMonitor.setSelectedIndex(0);
cmbVerbose.setSelectedIndex(0);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkTime.addChangeListener(this);
}
update();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
@Override
public void close() {
bnBrowse.removeActionListener(this);
chkReference.removeChangeListener(this);
chkResidu.removeChangeListener(this);
cmbVerbose.removeActionListener(this);
cmbMonitor.removeActionListener(this);
cmbConstraint.removeActionListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
index 0e11e00..7439be2 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
@@ -1,362 +1,362 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
super("Image", "-image", (Lab.getPlatform() == Imager.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
// Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnTitle.setDropTarget(new LocalDropTarget());
bnSynopsis.setDropTarget(new LocalDropTarget());
bnExpand.setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
bnSynthetic.setToolTipText("Add a new source artificially created");
bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window from the running platform");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
System.out.println(">>edit>> " + name + " == " + factory.getName().trim());
if (name.equals(factory.getName().trim())) {
synthetic(true);
return;
}
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
deconvolution.openImage();
if (stack) {
RealSignal x = deconvolution.getImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
- DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution, null, null);
+ DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
index 01bf3fe..7fbad60 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
@@ -1,236 +1,236 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
public class OutputModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnStack;
private JButton bnSeries;
private JButton bnMIP;
private JButton bnOrtho;
private JButton bnPlanar;
private JButton bnFigure;
public OutputModule(boolean expanded) {
- super("Output", "", "", "Default", expanded);
+ super("Output", "", "Clear", "", expanded);
}
@Override
public String getCommand() {
String cmd = " ";
if (table == null)
return cmd;
for (int i = 0; i < table.getRowCount(); i++) {
String[] values = new String[table.getColumnCount()];
for(int c=0; c<table.getColumnCount(); c++)
values[c] = table.getCell(i, c) == null ? "" : table.getCell(i, c).trim();
cmd += " -out " + values[0] + " " + values[1] + " " + values[2] + " " + values[3] + " " + values[4];
if (values[5].equals(""))
cmd += " noshow";
if (values[6].equals(""))
cmd += " nosave";
}
return cmd;
}
public void update() {
setCommand(getCommand());
setSynopsis(table.getRowCount() + " output" + (table.getRowCount() > 1 ? "s" : ""));
Command.command();
getAction1Button().setEnabled(table.getRowCount() > 0);
}
@Override
public JPanel buildExpandedPanel() {
String[] dynamics = { "intact", "rescaled", "normalized", "clipped" };
String[] types = { "float", "short", "byte" };
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Mode", String.class, 80, false));
columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
columns.add(new CustomizedColumn("Keypoint", String.class, 120, false));
columns.add(new CustomizedColumn("Show", String.class, 50, false));
columns.add(new CustomizedColumn("Save", String.class, 50, false));
columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(5).setMaxWidth(50);
table.getColumnModel().getColumn(6).setMaxWidth(50);
table.getColumnModel().getColumn(7).setMaxWidth(30);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(3).setMaxWidth(100);
table.addMouseListener(this);
bnStack = new JButton("\u2295 stack");
bnSeries = new JButton("\u2295 series");
bnMIP = new JButton("\u2295 mip");
bnOrtho = new JButton("\u2295 ortho");
bnPlanar = new JButton("\u2295 planar");
bnFigure = new JButton("\u2295 figure");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 6));
pn.setFloatable(false);
pn.add(bnStack);
pn.add(bnSeries);
pn.add(bnMIP);
pn.add(bnOrtho);
pn.add(bnPlanar);
pn.add(bnFigure);
JToolBar tool = new JToolBar("Path");
tool.setBorder(BorderFactory.createEmptyBorder());
tool.setLayout(new BorderLayout());
tool.setFloatable(false);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(tool, BorderLayout.NORTH);
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnStack.addActionListener(this);
bnSeries.addActionListener(this);
bnMIP.addActionListener(this);
bnOrtho.addActionListener(this);
bnPlanar.addActionListener(this);
bnFigure.addActionListener(this);
getAction1Button().addActionListener(this);
Config.registerTable(getName(), "output", table);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
View view = null;
if (e.getSource() == bnStack)
view = View.STACK;
else if (e.getSource() == bnSeries)
view = View.SERIES;
else if (e.getSource() == bnMIP)
view = View.MIP;
else if (e.getSource() == bnOrtho)
view = View.ORTHO;
else if (e.getSource() == bnPlanar)
view = View.PLANAR;
else if (e.getSource() == bnFigure)
view = View.FIGURE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out != null)
table.insert(out.getAsString());
//Lab.setVisible(new OutputPanel(view), "panel", 30, 30);
update();
}
if (e.getSource() == getAction1Button()) {
table.removeRows();
}
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 7) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnStack.removeActionListener(this);
bnSeries.removeActionListener(this);
bnMIP.removeActionListener(this);
bnOrtho.removeActionListener(this);
bnPlanar.removeActionListener(this);
bnFigure.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
index 3019f59..637a7ce 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
@@ -1,350 +1,350 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
super("PSF", "-psf", "", "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
// Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnTitle.setDropTarget(new LocalDropTarget());
bnSynopsis.setDropTarget(new LocalDropTarget());
bnExpand.setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
bnSynthetic.setToolTipText("Add a new source artificially created");
bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim())) {
synthetic(true);
return;
}
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
- DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution, null, null);
+ DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
Event Timeline
Log In to Comment