Page MenuHomec4science

No OneTemporary

File Metadata

Created
Thu, Dec 19, 16:29
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/DeconvolutionLab2/.classpath b/DeconvolutionLab2/.classpath
index 646093d..5aa6316 100644
--- a/DeconvolutionLab2/.classpath
+++ b/DeconvolutionLab2/.classpath
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="var" path="ICY_HOME/icy.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="ij"/>
+ <classpathentry kind="lib" path="lib/JTransforms.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index a06e35c..191f1f2 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,77 +1,82 @@
#DeconvolutionLab2 [Beta 2]
#DeconvolutionLab2 [Beta 2]
-#Sun Feb 12 14:16:42 WET 2017
+#Tue Feb 21 19:20:33 WET 2017
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW+.iterations=10
Algorithm.LW+.step=1.0
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=0.1
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
-Algorithm.algorithm=Landweber
+Algorithm.algorithm=Regularized Inverse Filter
Border.apoxy=Uniform
Border.apoz=Uniform
Border.extxy=0
Border.extz=0
-Border.normalization=1
Border.padxy=None
Border.padz=None
-Controller.constraint.enable=true
+Computation.dim=XYZ
+Computation.epsilon=1E-6
+Computation.fft=Academic
+Computation.normalization=1
+Controller.constraint.enable=false
Controller.constraint.value=no
Controller.itmax.enable=true
Controller.reference.enable=false
Controller.reference.value=
-Controller.residu.enable=true
+Controller.residu.enable=false
Controller.residu.value=0.01
Controller.time.enable=false
Controller.time.value=3600
-DeconvolutionLab.MainDialog.location.h=584
-DeconvolutionLab.MainDialog.location.w=503
-DeconvolutionLab.MainDialog.location.x=0
-DeconvolutionLab.MainDialog.location.y=34
-Fourier.dim=XYZ
-Fourier.epsilon=1E-6
-Fourier.fft=JTransforms
-Image.image.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
-Image.image.row1=Drosophila.tif;file;/Users/dsage/Desktop/Drosophila/Drosophila.tif;null
-Image.image.row2=Drosophila.tif;file;/Users/dsage/Desktop/Drosophila.tif;null
-Image.image.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+DeconvolutionLab.MainDialog.location.h=381
+DeconvolutionLab.MainDialog.location.w=544
+DeconvolutionLab.MainDialog.location.x=334
+DeconvolutionLab.MainDialog.location.y=383
+Image.image.row0=IMG_0517.JPG;file;/Users/dsage/Desktop/IMG_0517.JPG;null
+Image.image.row1=RandomLines;synthetic;RandomLines 100.0 0.0 300.0 size 512 512 32 ;\u232B
+Image.image.row2=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.row3=Applications;platform;Applications;\u232B
+Image.image.row4=Applications;directory;/users/dsage/Applications;\u232B
+Image.image.row5=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.row6=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
+Image.image.selected=IMG_0517.JPG;file;/Users/dsage/Desktop/IMG_0517.JPG;null
Language.headless=Run (Headless)
Language.job=Job
Language.language=Command line
-Output.output.row0=figure @1;FI1;;;;\u2713;;
-Output.output.row1=stats;ST2;;;;\u2713;\u2713;null
-Output.output.row2=ortho;OR1;;;;\u2713;\u2713;null
-Output.output.selected=figure @1;FI1;;;;\u2713;;
-PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
-PSF.psf.row1=PSF BWz\=100nm.tif;file;/Users/dsage/Desktop/Drosophila/PSF BWz\=100nm.tif;null
-PSF.psf.row2=PSFdBW.tif;file;/Users/dsage/Desktop/PSFdBW.tif;null
-PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
-Path\ &\ Watcher.current=Specify
-Path\ &\ Watcher.display=display final
-Path\ &\ Watcher.monitor=monitor full
-Path\ &\ Watcher.multithreading=multithreading enabled
-Path\ &\ Watcher.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
-Path\ &\ Watcher.verbose=verbose log
+Output.output.row0=stats;ST1;;;;\u2713;\u2713;\u232B
+Output.output.row1=ortho;OR1;;;;\u2713;\u2713;\u232B
+Output.output.selected=stats;ST1;;;;\u2713;\u2713;\u232B
+PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+PSF.psf.row1=Chrome Apps.localized;directory;/users/dsage/applications/Chrome Apps.localized;\u232B
+PSF.psf.row2=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
+PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+Running.Directory=/Users/dsage/Applications
+Running.Display=final
+Running.Monitor=full
+Running.Multithreading=enable
+Running.Path=specify
+Running.Stats=no
+Running.System=yes
+Running.Verbose=log
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index b42d6ec..8254ace 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,27 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="DeconvolutionLab2" default="build" basedir=".">
-
+<project name="Test" 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_R2016a.app/java/"/>
+ <property name="fiji" location="${user.home}/Desktop/Fiji.app/plugins"/>
<target name="build">
<mkdir dir="bin"/>
- <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="."/>
- </manifest>
- </jar>
-
- <copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
- <copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
- <copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
-
+ <copy toDir="${fiji}" file="./bin/Test_Orientation.class" />
+ <copy toDir="${imagej}" file="./bin/Test_Orientation.class" />
+ <copy toDir="${fiji}" file="./bin/Test_Cytoplasm_Segmentation.class" />
+ <copy toDir="${imagej}" file="./bin/Test_Cytoplasm_Segmentation.class" />
+ <copy toDir="${fiji}" file="./bin/Test_Tracing_Axon.class" />
+ <copy toDir="${imagej}" file="./bin/Test_Tracing_Axon.class" />
+ <copy toDir="${fiji}" file="./bin/Test_Tracing_Axon$Path.class" />
+ <copy toDir="${imagej}" file="./bin/Test_Tracing_Axon$Path.class" />
</target>
</project>
\ No newline at end of file
diff --git a/DeconvolutionLab2/plugins.config b/DeconvolutionLab2/plugins.config
index 42a1d64..28aec9d 100644
--- a/DeconvolutionLab2/plugins.config
+++ b/DeconvolutionLab2/plugins.config
@@ -1,13 +1,14 @@
# Name: DeconvolutionLab 2
# Daniel Sage
# Biomedical Imaging Group
# Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
# Date: 11 July 2016
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Lab", DeconvolutionLab2_Lab
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Launch", DeconvolutionLab2_Launch
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Run", DeconvolutionLab2_Run
Plugins>DeconvolutionLab2, "DeconvolutionLab2 FFT", DeconvolutionLab2_FFT
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Help", DeconvolutionLab2_Help
+Plugins>DeconvolutionLab2, "Example_6c Help", Example_6c
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/DL2.java b/DeconvolutionLab2/src/DL2.java
index deee0fa..3dd6620 100644
--- a/DeconvolutionLab2/src/DL2.java
+++ b/DeconvolutionLab2/src/DL2.java
@@ -1,239 +1,237 @@
import java.io.File;
import deconvolution.Deconvolution;
-import deconvolutionlab.Config;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.LabDialog;
import ij.ImagePlus;
-import ij.Macro;
import ij.WindowManager;
import matlab.Converter;
import signal.RealSignal;
/*
* 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/>.
*/
/**
* This class is dedicated to the Matlab interface for DeconvolutionLab2
* @author sage
*
*/
public class DL2 {
public static void lab() {
- String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- LabDialog dialog = new LabDialog();
- dialog.setVisible(true);
+ Lab.init(Imaging.Platform.MATLAB, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ LabDialog dlg = new LabDialog();
+ Lab.setVisible(dlg, false);
}
public static void run(String command) {
- new Deconvolution(command).deconvolve(false);
+ new Deconvolution("Matlab", command).deconvolve();
}
public static void launch(String command) {
- new Deconvolution(command).launch("matlab", false);
+ new Deconvolution("Matlab", command).launch();
}
public static Object get(String image) {
ImagePlus imp = WindowManager.getCurrentImage();
if (imp != null)
return Converter.get(imp);
return null;
}
public static Object run(Object arrayImage, Object arrayPSF, String algo) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -image platform input -psf platform psf -algorithm " + algo;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static void help() {
Lab.help();
}
public static void clear() {
int ids[] = WindowManager.getIDList();
for(int id : ids) {
ImagePlus imp = WindowManager.getImage(id);
if (imp != null)
imp.close();
}
}
public static Object DIV(Object arrayImage, Object arrayPSF) {
return DIV(arrayImage, arrayPSF, "");
}
public static Object DIV(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm DIV " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab DIV", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object CONV(Object arrayImage, Object arrayPSF) {
return CONV(arrayImage, arrayPSF, "");
}
public static Object CONV(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm CONV " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab CONV", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object NIF(Object arrayImage, Object arrayPSF) {
return NIF(arrayImage, arrayPSF, "");
}
public static Object NIF(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm NIF " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab NIF", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object TRIF(Object arrayImage, Object arrayPSF, double regularizationFactor) {
return TRIF(arrayImage, arrayPSF, regularizationFactor, "");
}
public static Object TRIF(Object arrayImage, Object arrayPSF, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm TRIF " + regularizationFactor + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab TRIF", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RIF(Object arrayImage, Object arrayPSF, double regularizationFactor) {
return RIF(arrayImage, arrayPSF, regularizationFactor, "");
}
public static Object RIF(Object arrayImage, Object arrayPSF, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RIF " + regularizationFactor + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab RIF", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RL(Object arrayImage, Object arrayPSF, double itmax) {
return RL(arrayImage, arrayPSF, itmax, "");
}
public static Object RL(Object arrayImage, Object arrayPSF, double itmax, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RL " + itmax + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab RL", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RLTV(Object arrayImage, Object arrayPSF, double itmax, double regularizationFactor) {
return RLTV(arrayImage, arrayPSF, itmax, regularizationFactor, "");
}
public static Object RLTV(Object arrayImage, Object arrayPSF, double itmax, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RLTV " + itmax + " " + regularizationFactor + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab RLTV", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object LW(Object arrayImage, Object arrayPSF, double itmax, double gamma) {
return LW(arrayImage, arrayPSF, itmax, gamma, "");
}
public static Object LW(Object arrayImage, Object arrayPSF, double itmax, double gamma, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm LW " + itmax + " " + gamma + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab LW", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object NNLS(Object arrayImage, Object arrayPSF, double itmax, double gamma) {
return LW(arrayImage, arrayPSF, itmax, gamma, "");
}
public static Object NNLS(Object arrayImage, Object arrayPSF, double itmax, double gamma, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm LW+ " + itmax + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab NNLS", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object TM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda) {
return TM(arrayImage, arrayPSF, itmax, gamma, lambda, "");
}
public static Object TM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm TM " + itmax + " " + gamma + " " + lambda + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab TM", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object ICTM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda) {
return ICTM(arrayImage, arrayPSF, itmax, gamma, lambda, "");
}
public static Object ICTM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm ICTM " + itmax + " " + gamma + " " + lambda + " " + options;
- Deconvolution d = new Deconvolution(command);
- RealSignal result = d.deconvolve(image, psf, false);
+ Deconvolution d = new Deconvolution("Matlab ICTM", command);
+ RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index 91bc5d3..2bbdc3e 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.java
@@ -1,135 +1,133 @@
/*
* 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.Config;
import deconvolutionlab.Constants;
+import deconvolutionlab.Imaging;
+import deconvolutionlab.Imaging.Platform;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.dialog.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.getInstance(Platform.STANDALONE);
+ 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(cmd).deconvolve(true);
+ 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(cmd).launch("", true);
+ 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;
}
- Config.getInstance(config);
+ 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.print("Keywords of {command}: ");
for (String keyword : Command.keywords)
System.out.print(keyword + " ");
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
- deconvolutionlab.Lab.getInstance(Platform.STANDALONE);
- String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- new Deconvolution(cmd).deconvolve(false);
+ Lab.init(Imaging.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ new Deconvolution("CommandLine", cmd).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java b/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
index 943f976..c83d1cf 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
@@ -1,44 +1,44 @@
/*
* 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 deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_FFT implements PlugIn {
@Override
public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
+ Lab.init(Imaging.Platform.IMAGEJ);
Lab.checkFFT(Monitors.createDefaultMonitor());
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Help.java b/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
index 1b08f49..9b96214 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
@@ -1,43 +1,43 @@
/*
* 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 ij.plugin.PlugIn;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
+import ij.plugin.PlugIn;
public class DeconvolutionLab2_Help implements PlugIn {
@Override
public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
+ Lab.init(Imaging.Platform.IMAGEJ);
Lab.help();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java b/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
index d99963b..30480ac 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
@@ -1,50 +1,49 @@
/*
* 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 deconvolutionlab.Config;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.dialog.LabDialog;
import ij.IJ;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Lab implements PlugIn {
@Override
public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
- String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- new LabDialog().setVisible(true);
+ Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ LabDialog dlg = new LabDialog();
+ Lab.setVisible(dlg, false);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
index 8a3d331..ce705e2 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
@@ -1,55 +1,54 @@
/*
* 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.Deconvolution;
-import deconvolutionlab.Config;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.dialog.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Launch implements PlugIn {
@Override
public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
- String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- if (Macro.getOptions() == null)
- new LabDialog().setVisible(true);
+ Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ if (Macro.getOptions() == null) {
+ LabDialog dlg = new LabDialog();
+ Lab.setVisible(dlg, false);
+ }
else
- new Deconvolution(Macro.getOptions()).launch("", false);
+ new Deconvolution("Macro", Macro.getOptions()).launch();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
index ce534b5..528e7b4 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
@@ -1,55 +1,55 @@
/*
* 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.Deconvolution;
import deconvolutionlab.Config;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.dialog.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Run implements PlugIn {
@Override
public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
- String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- if (Macro.getOptions() == null)
- new LabDialog().setVisible(true);
+ Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ if (Macro.getOptions() == null) {
+ LabDialog dlg = new LabDialog();
+ Lab.setVisible(dlg, false);
+ }
else
- new Deconvolution(Macro.getOptions()).deconvolve(false);
+ new Deconvolution("Run", Macro.getOptions()).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
index d4ec21f..9a0a65d 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
@@ -1,92 +1,92 @@
package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Course_Bigradient implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "bigradient" + File.separator;
private String data = root + "data" + File.separator + "bigradient" + File.separator;
public DeconvolutionLab2_Course_Bigradient() {
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "TRIF").mkdir();
new File(res + "RIF").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW-ITER").mkdir();
new File(res + "LW+").mkdir();
new File(res + "LW+-ITER").mkdir();
new File(res + "RL").mkdir();
new File(res + "RL-ITER").mkdir();
new File(res + "RLTV").mkdir();
new File(res + "RLTV-ITER").mkdir();
new File(res + "FISTA").mkdir();
new File(res + "FISTA-ITER").mkdir();
String psf = " -psf file " + data + "psf.tif -reference " + data + "ref.tif ";
String noisy = " -image file convnoise.tif";
- new Deconvolution("-image file " + data + "ref.tif" + psf + " -algorithm SIM 0 1 1 -out stack convnoise -out stack conbnoise_8 rescaled byte noshow").deconvolve(false);
+ new Deconvolution("run", "-image file " + data + "ref.tif" + psf + " -algorithm SIM 0 1 1 -out stack convnoise -out stack conbnoise_8 rescaled byte noshow").deconvolve();
- new Deconvolution(noisy + psf + " -algorithm NIF -out stack NIF").deconvolve(false);
- new Deconvolution(noisy + psf + " -algorithm DIV -out stack DIV").deconvolve(false);
+ new Deconvolution("run", noisy + psf + " -algorithm NIF -out stack NIF").deconvolve();
+ new Deconvolution("run", noisy + psf + " -algorithm DIV -out stack DIV").deconvolve();
for(int i=0; i<=3; i++) {
double p = Math.pow(5, i-10);
String name = "RIF" + String.format("%02d", i);
- new Deconvolution(noisy + psf + " -algorithm RIF " + p + out("RIF" + File.separator, name)).deconvolve(false);
+ new Deconvolution("run", noisy + psf + " -algorithm RIF " + p + out("RIF" + File.separator, name)).deconvolve();
}
for(int i=0; i<=3; i++) {
double p = Math.pow(5, i-10);
String name = "TRIF" + String.format("%02d", i);
- new Deconvolution(noisy + psf + " -algorithm TRIF " + p + out("TRIF" + File.separator, name)).deconvolve(false);
+ new Deconvolution("run", noisy + psf + " -algorithm TRIF " + p + out("TRIF" + File.separator, name)).deconvolve();
}
String lw = " -algorithm LW 20 1 -out mip @2 LW-ITER/I -out stats @1 LW nosave";
- new Deconvolution(noisy + psf + lw).deconvolve(false);
+ new Deconvolution("run", noisy + psf + lw).deconvolve();
new File(res + "LW-ITER/I.tif").delete();
String lwp = " -algorithm LW+ 20 1 -out mip @2 LW+-ITER/I -out stats @1 LW+ nosave";
- new Deconvolution(noisy + psf + lwp).deconvolve(false);
+ new Deconvolution("run", noisy + psf + lwp).deconvolve();
new File(res + "LW+-ITER/I.tif").delete();
String rl = " -algorithm RL 20 -out mip @2 RL-ITER/I -out stats @1 RL nosave";
- new Deconvolution(noisy + psf + rl).deconvolve(false);
+ new Deconvolution("run", noisy + psf + rl).deconvolve();
new File(res + "RL-ITER/I.tif").delete();
- String rltv = " -algorithm RLRV 20 10 -out mip @2 RLTV-ITER/I -out stats @1 RLTV nosave";
- new Deconvolution(noisy + psf + rltv).deconvolve(false);
+ String rltv = " -algorithm RLTV 20 10 -out mip @2 RLTV-ITER/I -out stats @1 RLTV nosave";
+ new Deconvolution("run", noisy + psf + rltv).deconvolve();
new File(res + "RLTV-ITER/I.tif").delete();
String fista = " -algorithm FISTA 20 1 1 Spline3 3 -mip @2 FISTA-ITER/I -out stats @1 FISTA nosave";
- new Deconvolution(noisy + psf + fista).deconvolve(false);
+ new Deconvolution("run", noisy + psf + fista).deconvolve();
new File(res + "FISTA-ITER/I.tif").delete();
}
private static String out(String root, String name) {
return "out stats " + root + name +
" -out stack " + root + name + "_32 -out stack " + root + name + "_8 rescaled byte noshow";
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Bigradient();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Bigradient();
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
index e472c08..8522104 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
@@ -1,108 +1,108 @@
package course;
// Course Version 2
import ij.plugin.PlugIn;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import signal.RealSignal;
import signal.factory.Cube;
import signal.factory.Gaussian;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2_Course_Border implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "border" + File.separator;
public DeconvolutionLab2_Course_Border() {
Monitors monitors = Monitors.createDefaultMonitor();
new File(res).mkdir();
System.setProperty("user.dir", res);
int nx = 200;
int ny = 200;
int nz = 40;
RealSignal im = new Cube(22, .1).intensity(0, 100).center(0.25, 0.00, 0.05).generate(nx, ny, nz);
RealSignal i0 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.05, 0.05).generate(nx, ny, nz);
RealSignal i1 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.10, 0.05).generate(nx, ny, nz);
RealSignal i2 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.15, 0.05).generate(nx, ny, nz);
im.max(i1.max(i2).max(i0));
RealSignal g = new Gaussian(10, 10, 10).intensity(0, 101).generate(nx, ny, nz);
Lab.save(monitors, im, res + "ref.tif");
Lab.save(monitors, g, res + "psf.tif");
String psf = " -psf file " + "psf.tif";
String ref = " -image file " + "ref.tif";
String cst = " -image synthetic constant 250 0 size 200 200 40";
String algo = " -algorithm CONV -out ortho REFo (64,32,16)";
- new Deconvolution(ref + " -psf synthetic impulse " + algo).deconvolve(false);
+ new Deconvolution("run", ref + " -psf synthetic impulse " + algo).deconvolve();
algo = " -algorithm CONV -stack CONV -out ortho CONVo rescaled byte (64,32,16) -out mip CONVp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 200 200 -out ortho PADo200 rescaled byte (64,32,16) -out mip PADp200 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 100 100 -out ortho PADo100 rescaled byte (64,32,16) -out mip PADp100 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 40 40 -out ortho PADo40 rescaled byte (64,32,16) -out mip PADp40 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 20 20 -out ortho PADo20 rescaled byte (64,32,16) -out mip PADp20 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 10 10 -out ortho PADo10 rescaled byte (64,32,16) -out mip PADp10 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 5 5 -out ortho PADo2 rescaled byte (64,32,16) -out mip PADp2 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -apo HANN HANN -out ortho HANNo rescaled byte (64,32,16) -out mip HANNp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -apo TUKEY TUKEY -out ortho TUKEYo rescaled byte (64,32,16) -out mip TUKEYp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV --pad NO NO 8 8 apo HANN HANN -out ortho PAD8_HANNo rescaled byte (64,32,16) -out mip PAD8_HANNp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve(false);
+ new Deconvolution("run", ref + psf + algo).deconvolve();
algo = " -algorithm CONV -apo HANN HANN -out ortho HANN_CSTo rescaled byte -out mip HANN_CSTp rescaled byte";
- new Deconvolution(cst + psf + algo).deconvolve(false);
+ new Deconvolution("run", cst + psf + algo).deconvolve();
algo = " -algorithm CONV -apo TUKEY TUKEY -out ortho TUKEY_CSTo rescaled byte -out mip TUKEY_CSTp rescaled byte";
- new Deconvolution(cst + psf + algo).deconvolve(false);
+ new Deconvolution("run", cst + psf + algo).deconvolve();
algo = " -algorithm CONV -pad E2 E2 -out ortho PADpPower2FFTW rescaled byte (64,32,16) -out mip PADpPower2FFTW rescaled byte";
- new Deconvolution(cst + psf + algo + " -fft FFTW2 ").deconvolve(false);
- new Deconvolution(cst + psf + algo + " -fft Academic ").deconvolve(false);
- new Deconvolution(cst + psf + algo + " -fft JTransforms ").deconvolve(false);
+ new Deconvolution("run", cst + psf + algo + " -fft FFTW2 ").deconvolve();
+ new Deconvolution("run", cst + psf + algo + " -fft Academic ").deconvolve();
+ new Deconvolution("run", cst + psf + algo + " -fft JTransforms ").deconvolve();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Border();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Border();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Celegans.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Celegans.java
index 9343fed..74caf94 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Celegans.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Celegans.java
@@ -1,91 +1,91 @@
package course;
// Course Version 2
import ij.ImagePlus;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.plugin.PlugIn;
import ij.process.ColorProcessor;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
public class DeconvolutionLab2_Course_Celegans implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + File.separator;
private String res = root + "Results" + File.separator + "c-elegans" + File.separator;
private String data = root + "Data" + File.separator + "c-elegans" + File.separator;
public DeconvolutionLab2_Course_Celegans() {
new File(res).mkdir();
System.setProperty("user.dir", res);
run(" -algorithm RIF 0.000001 ", "RIF6_");
run(" -algorithm RIF 0.0000001 ", "RIF7_");
//run(" -algorithm RL 100 ", "RL_");
run(" -algorithm LW+ 200 1 ", "LW+_");
//run(" -algorithm I ", "IN_");
//run(" -algorithm RIF 0.001 ", "RIF3_");
//run(" -algorithm RIF 0.0001 ", "RIF4_");
//run(" -algorithm RIF 0.00001 ", "RIF5_");
//run(" -algorithm VC 100 ", "VC");
//run(" -algorithm RLTV 10 0.1 ", "RLTV");
//run(" -algorithm FISTA 50 1 0.1 ", "FISTA");
//run(" -algorithm ISTA 50 1 0.1 ", "ISTA");
}
private void run(String a, String name) {
String channels[] = new String[] { "CY3", "FITC", "DAPI"};
ImagePlus[] ort = new ImagePlus[3];
ImagePlus[] fig = new ImagePlus[3];
for (int i=0; i<3; i++) {
String channel = channels[i];
String psf = " -psf file " + data + "psf-CElegans-" + channel + ".tif";
String img = " -image file " + data + "CElegans-" + channel +".tif";
String param = " -fft JTransforms -disable display multithreading";
String algo = a + out(name + channel);
- new Deconvolution(img + psf + algo + param).deconvolve(false);
+ new Deconvolution("deconvolve", img + psf + algo + param).deconvolve();
ort[i] = new Opener().openImage( res + name + channel + "_ortho_8.tif");
fig[i] = new Opener().openImage( res + name + channel + "_figure_8.tif");
}
new FileSaver(color(ort)).saveAsTiff(res + name + "-ortho-rgb.tif");
new FileSaver(color(fig)).saveAsTiff(res + name + "-figure-rgb.tif");
}
private static String out(String name) {
return
" -out ortho " + name + "_ortho_8 rescaled byte (160,180,50) noshow" +
" -out mip " + name + "_mip_8 rescaled byte noshow" +
" -out figure " + name + "_figure_8 rescaled byte (160,180,50) ";
}
private static ImagePlus color(ImagePlus imp[]) {
int nx = imp[0].getWidth();
int ny = imp[0].getHeight();
ColorProcessor cp = new ColorProcessor(nx, ny);
byte r[] = (byte[])imp[0].getProcessor().getPixels();
byte g[] = (byte[])imp[1].getProcessor().getPixels();
byte b[] = (byte[])imp[2].getProcessor().getPixels();
cp.setRGB(r, g, b);
ImagePlus out = new ImagePlus( "rgb", cp);
out.show();
return out;
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Celegans();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Celegans();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
index b2ab8a3..d82785c 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
@@ -1,67 +1,67 @@
package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.Cube;
public class DeconvolutionLab2_Course_Noise implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "noise" + File.separator;
public DeconvolutionLab2_Course_Noise() {
Monitors monitors = Monitors.createDefaultMonitor();
new File(res).mkdir();
System.setProperty("user.dir", res);
int nx = 560;
int ny = 120;
int nz = 1;
String size = " size " + nx + " " + ny + " " + nz;
RealSignal im = new Cube(50, 0.25).intensity(0, 100).center(0.2, 0.5, 0).generate(nx, ny, nz);
RealSignal i1 = new Cube(50, 0.25).intensity(0, 70).center(0.4, 0.5, 0).generate(nx, ny, nz);
RealSignal i2 = new Cube(50, 0.25).intensity(0, 40).center(0.6, 0.5, 0).generate(nx, ny, nz);
RealSignal i3 = new Cube(50, 0.25).intensity(0, 10).center(0.8, 0.5, 0).generate(nx, ny, nz);
im.plus(i1);
im.plus(i2);
im.plus(i3);
Lab.show(monitors, im, "im.tif");
Lab.save(monitors, im, res + "im.tif");
String psf = " -psf synthetic impulse 1 0 " + size;
String image = " -image file im.tif";
// Simulation
String name = "SIM m 0 s 50 p 0";
String out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
- new Deconvolution(psf + image + " -algorithm " + name + out).run();
+ new Deconvolution("noise", psf + image + " -algorithm " + name + out).run();
name = "SIM m 0 s 00 p 150";
out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
- new Deconvolution(psf + image + " -algorithm " + name + out).run();
+ new Deconvolution("noise", psf + image + " -algorithm " + name + out).run();
name = "SIM m 0 s 15 p 30";
out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
- new Deconvolution(psf + image + " -algorithm " + name + out).run();
+ new Deconvolution("noise", psf + image + " -algorithm " + name + out).run();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Noise();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Noise();
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java
index aac3931..bc5b2f5 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java
@@ -1,85 +1,85 @@
package course;
import java.io.File;
import java.util.Random;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.Constant;
import signal.factory.Cube;
public class DeconvolutionLab2_Course_Piecewise implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "piecewise" + File.separator;
public DeconvolutionLab2_Course_Piecewise() {
Monitors monitors = Monitors.createDefaultMonitor();
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "RIF").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW+").mkdir();
new File(res + "RL").mkdir();
new File(res + "RLTV").mkdir();
new File(res + "ISTA").mkdir();
new File(res + "FISTA").mkdir();
int nx = 128;
int ny = 128;
int nz = 128;
int spacing = 16;
Random rand = new Random(1234);
RealSignal x = new Constant().intensity(0, 10).generate(nx, ny, nz);
for(int i = 0; i< 12; i++) {
double xc = (rand.nextDouble()*0.6 + 0.2);
double yc = (rand.nextDouble()*0.6 + 0.2);
double zc = (rand.nextDouble()*0.6 + 0.2);
double size = 15 + (rand.nextDouble()*30);
double ampl = (rand.nextDouble()+0.5)*10;
x.plus(new Cube(size, 0.1).intensity(0, ampl).center(xc, yc, zc).generate(nx, ny, nz));
}
Lab.show(monitors, x, "reference");
Lab.save(monitors, x, res + "ref.tif");
String algo = " ";
String ground = " -image file " + res + "ref.tif ";
//String psf = " -psf file ../../Data/resolution/psfgl.tif";
String psf = " -psf synthetic gaussian 100.0 0.0 1.2 1.2 3.6 size ";
// nx + " " + ny + " " + nz;
String signal = " -image file signal.tif -reference " + res + "ref.tif -disable monitor";
String paramout = " intact float (" + spacing + "," + spacing + "," + spacing + ")";
algo = " -algorithm CONV -out stats @3 PR nosave -out stack PR -out ortho PRo ";
- new Deconvolution(ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve(false);
+ new Deconvolution("run", ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve();
algo = " -algorithm SIM 0 1 1 -out stats @3 SIM nosave -out stack signal -out ortho SIGNALo ";
- new Deconvolution(ground + psf + algo).deconvolve(false);
+ new Deconvolution("run", ground + psf + algo).deconvolve();
algo = " -algorithm NIF -out ortho NIF " + paramout;
- new Deconvolution(signal + psf + algo).deconvolve(false);
+ new Deconvolution("run", signal + psf + algo).deconvolve();
algo = " -algorithm RLTV 15 0.01 -out stats @1 RLTV nosave -out ortho @1 RLTV/RLTV" + paramout;
- new Deconvolution(signal + psf + algo).deconvolve(false);
+ new Deconvolution("run", signal + psf + algo).deconvolve();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Piecewise();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Piecewise();
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
index 8bb6558..da209dd 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
@@ -1,76 +1,76 @@
package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.GridSpots;
public class DeconvolutionLab2_Course_Resolution implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "resolution" + File.separator;
public DeconvolutionLab2_Course_Resolution() {
Monitors monitors = Monitors.createDefaultMonitor();
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "RIF").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW+").mkdir();
new File(res + "RL").mkdir();
int nx = 128;
int ny = 128;
int nz = 128;
int spacing = 16;
RealSignal x = new GridSpots(3, 0.1, spacing).intensity(0, 255).generate(nx, ny, nz);
Lab.show(monitors, x, "reference");
Lab.save(monitors, x, res + "ref.tif");
String algo = " ";
String ground = " -image file " + res + "ref.tif ";
//String psf = " -psf file ../../Data/resolution/psfgl.tif";
String psf = " -psf synthetic gaussian 100.0 0.0 1.2 1.2 3.6 size " + nx + " " + ny + " " + nz;
String signal = " -image file signal.tif -reference " + res + "ref.tif -disable monitor";
String paramout = " intact float (" + spacing + "," + spacing + "," + spacing + ")";
algo = " -algorithm CONV -out stats @3 PR -out stack PR -out ortho PRo ";
- new Deconvolution(ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve(false);
+ new Deconvolution("run", ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve();
algo = " -algorithm SIM 0 1.5 0 -out stats @3 SIM -out stack signal -out ortho SIGNALo ";
- new Deconvolution(ground + psf + algo).deconvolve(false);
+ new Deconvolution("run", ground + psf + algo).deconvolve();
algo = " -algorithm NIF -out ortho NIF " + paramout;
- new Deconvolution(signal + psf + algo).deconvolve(false);
+ new Deconvolution("run", signal + psf + algo).deconvolve();
for(int i=0; i<=24; i++) {
double p = Math.pow(10, i-18);
algo = " -algorithm RIF " + p + " -out ortho @5 RIF/RIF" + i + paramout;
- new Deconvolution(signal + psf + algo).deconvolve(false);
+ new Deconvolution("run", signal + psf + algo).deconvolve();
}
algo = " -algorithm LW+ 305 1 -out stats @3 LW+ nosave -out ortho @25 LW+/LW+" + paramout;
- new Deconvolution(signal + psf + algo).deconvolve(false);
+ new Deconvolution("run", signal + psf + algo).deconvolve();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Resolution();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Resolution();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
index 55ed4e0..776bf70 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
@@ -1,160 +1,159 @@
package course;
-import ij.plugin.PlugIn;
-
import java.io.File;
import javax.swing.filechooser.FileSystemView;
+import deconvolution.Deconvolution;
+import deconvolutionlab.Imaging;
+import deconvolutionlab.Lab;
+import deconvolutionlab.monitor.Monitors;
+import fft.AbstractFFT;
+import fft.FFT;
+import ij.plugin.PlugIn;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.factory.DoG;
import signal.factory.Gaussian;
import signal.factory.complex.ComplexSignalFactory;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Lab;
-import deconvolutionlab.PlatformImager;
-import deconvolutionlab.monitor.Monitors;
-import fft.AbstractFFT;
-import fft.FFT;
public class DeconvolutionLab2_Course_SpectralAnaylsis implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "star" + File.separator;
private String data = root + "data" + File.separator + "star" + File.separator;
public DeconvolutionLab2_Course_SpectralAnaylsis() {
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "TRIF").mkdir();
new File(res + "TRIF-FILTER").mkdir();
new File(res + "RIF").mkdir();
new File(res + "RIF-FILTER").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW-ITER").mkdir();
new File(res + "LW+").mkdir();
new File(res + "LW+-ITER").mkdir();
new File(res + "RL").mkdir();
new File(res + "RL-ITER").mkdir();
new File(res + "NOISELESS").mkdir();
new File(res + "PERTURBATION").mkdir();
new File(res + "SIMULATION").mkdir();
new File(res + "ICTM").mkdir();
new File(res + "ICTM-ITER").mkdir();
Monitors monitors = Monitors.createDefaultMonitor();
int nx = 256;
int ny = 256;
int nz = 1;
String size = " size " + nx + " " + ny + " " + nz;
double noise = 0.04;
double poisson = 0.01;
double wiener = Math.sqrt(noise * 2.0 / Math.PI);
System.out.println("Wiener value " + wiener);
AbstractFFT fft = FFT.createDefaultFFT(monitors, nx, ny, nz);
ComplexSignal L = ComplexSignalFactory.laplacian(nx, ny, nz);
RealSignal laplacian = fft.inverse(L).circular().rescale(monitors);
- Lab.save(monitors, laplacian, res + "laplacian.tif", PlatformImager.Type.BYTE);
+ Lab.save(monitors, laplacian, res + "laplacian.tif", Imaging.Type.BYTE);
RealSignal h = new DoG(2, 3.6).generate(nx, ny, nz);
h.times(0.7f);
h.plus(new Gaussian(1.5, 1.5, 1.5).generate(nx, ny, nz));
Lab.save(monitors, h, res + "psf.tif");
h.plus(new Gaussian(0.5, 0.5, 0.5).generate(nx, ny, nz));
Lab.save(monitors, h, res + "psfPerturbated.tif");
String psf = " -psf file psf.tif -fft FFTW2";
String impulse = " -psf synthetic impulse 100.0 0.0 " + size;
String image = " -image file " + data + "ref.tif";
String constant = " -image constant 0 0 " + size;
// Simulation
String algo = " -algorithm CONV " + out("CONV");
- new Deconvolution(psf + image + algo).deconvolve(false);
+ new Deconvolution("run", psf + image + algo).deconvolve();
algo = " -algorithm CONV " + out("CONV-PERTURBATED");
- new Deconvolution(psf + image + algo).deconvolve(false);
+ new Deconvolution("run", psf + image + algo).deconvolve();
ComplexSignal H = fft.transform(h);
ComplexSignal H2 = Operations.multiply(H, H);
ComplexSignal LP = ComplexSignalFactory.laplacian(nx, ny, nz);
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("SIM");
- new Deconvolution(psf + image + algo).deconvolve(false);
+ new Deconvolution("run", psf + image + algo).deconvolve();
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("NOISE");
- new Deconvolution(impulse + constant + algo).deconvolve(false);
+ new Deconvolution("run", impulse + constant + algo).deconvolve();
// No Noise
String nonoise = " -image file CONV.tif -psf file psfPerturbated.tif";
- new Deconvolution(nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E0 " + out("NOISELESS/NIF0")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-3 " + out("NOISELESS/NIF-1")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-6 " + out("NOISELESS/NIF-6")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-9 " + out("NOISELESS/NIF-9")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-12 " + out("NOISELESS/NIF-12")).deconvolve(false);
- new Deconvolution(nonoise + " -algorithm DIV " + out("NOISELESS/DIV")).deconvolve(false);
+ new Deconvolution("run", nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E0 " + out("NOISELESS/NIF0")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-3 " + out("NOISELESS/NIF-1")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-6 " + out("NOISELESS/NIF-6")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-9 " + out("NOISELESS/NIF-9")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-12 " + out("NOISELESS/NIF-12")).deconvolve();
+ new Deconvolution("run", nonoise + " -algorithm DIV " + out("NOISELESS/DIV")).deconvolve();
// Pertubatation
String pertubation = " -image file CONV.tif -psf file psfPerturbated.tif";
- new Deconvolution(pertubation + " -algorithm TRIF " + wiener + out("PERTURBATION/WIF")).deconvolve(false);
- new Deconvolution(pertubation + " -algorithm NIF " + out("PERTURBATION/NIF")).deconvolve(false);
- new Deconvolution(pertubation + " -algorithm DIV " + out("PERTURBATION/DIV")).deconvolve(false);
+ new Deconvolution("run", pertubation + " -algorithm TRIF " + wiener + out("PERTURBATION/WIF")).deconvolve();
+ new Deconvolution("run", pertubation + " -algorithm NIF " + out("PERTURBATION/NIF")).deconvolve();
+ new Deconvolution("run", pertubation + " -algorithm DIV " + out("PERTURBATION/DIV")).deconvolve();
// Noisy
String simulation = " -image file SIM.tif " + psf;
- new Deconvolution(simulation + " -algorithm TRIF " + wiener + out("SIMULATION/WIF")).deconvolve(false);
- new Deconvolution(simulation + " -algorithm NIF "+ out("SIMULATION/NIF")).deconvolve(false);
- new Deconvolution(simulation + " -algorithm DIV" + out("SIMULATION/DIV")).deconvolve(false);
+ new Deconvolution("run", simulation + " -algorithm TRIF " + wiener + out("SIMULATION/WIF")).deconvolve();
+ new Deconvolution("run", simulation + " -algorithm NIF "+ out("SIMULATION/NIF")).deconvolve();
+ new Deconvolution("run", simulation + " -algorithm DIV" + out("SIMULATION/DIV")).deconvolve();
algo = " -algorithm LW+ 100 0.5 -out mip @1 LW+-ITER/I ";
- new Deconvolution(simulation + algo + out("LW+/LW+")).deconvolve(false);
+ new Deconvolution("run", simulation + algo + out("LW+/LW+")).deconvolve();
new File(res + "LW+-ITER/I.tif").delete();
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "RIF/RIF" + String.format("%02d", i);
- new Deconvolution(simulation + " -algorithm RIF " + p + out(name)).deconvolve(false);
+ new Deconvolution("run", simulation + " -algorithm RIF " + p + out(name)).deconvolve();
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "RIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "TRIF/TRIF" + String.format("%02d", i);
- new Deconvolution(simulation + " -algorithm TRIF " + p + out(name)).deconvolve(false);
+ new Deconvolution("run", simulation + " -algorithm TRIF " + p + out(name)).deconvolve();
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "TRIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
algo = " -algorithm RL 100 -out mip @1 RL-ITER/I ";
- new Deconvolution(simulation + algo + out("RL/RL")).deconvolve(false);
+ new Deconvolution("run", simulation + algo + out("RL/RL")).deconvolve();
new File(res + "RL-ITER/I.tif").delete();
algo = " -algorithm ICTM 100 1.5 0.001 -out mip @1 ICTM-ITER/I ";
- new Deconvolution(simulation + algo + out("ICTM/ICTM")).deconvolve(false);
+ new Deconvolution("run", simulation + algo + out("ICTM/ICTM")).deconvolve();
new File(res + "ICTM-ITER/I.tif").delete();
}
private static String out(String name) {
return " -out stats " + name +
" -out stack " + name + " noshow -out ortho " + name + "-BYTE rescaled byte noshow";
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index 8f358b8..240bfb3 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,310 +1,468 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Output;
+import deconvolutionlab.OutputCollection;
import deconvolutionlab.Output.View;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.CommandModule;
+import deconvolutionlab.monitor.Verbose;
+import fft.AbstractFFT;
+import fft.AbstractFFTLibrary;
+import fft.FFT;
import lab.tools.NumFormat;
import signal.Constraint;
+import signal.Operations;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
import wavelets.Wavelets;
public class Command {
- public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft" };
+ public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-system", "-stats", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft", "-epsilon" };
private static AbstractModule modules[];
private static CommandModule command;
public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
return cmd;
}
+
+ public static void decode(String command, Deconvolution deconvolution) {
+
+ AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
+ boolean flagSystem = true;
+ boolean flagDisplay = true;
+ boolean flagMultithreading = true;
+ int monitor = 4;
+ int stats = 4;
+ Verbose verbose = Verbose.Log;
+ String path = System.getProperty("user.dir");
+ Controller controller = new Controller();
+ OutputCollection outs = new OutputCollection();
+ Padding pad = new Padding();
+ Apodization apo = new Apodization();
+ double norm = 1.0;
+ AbstractFFTLibrary fft = FFT.getLibraryByName("Academic");
+ ArrayList<Token> tokens = parse(command);
+ for (Token token : tokens) {
+ if (token.keyword.equalsIgnoreCase("-algorithm"))
+ algo = Command.decodeAlgorithm(token, controller);
+
+ if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
+ path = token.parameters;
+
+ if (token.keyword.equalsIgnoreCase("-monitor"))
+ monitor = decodeMonitor(token);
+ if (token.keyword.equalsIgnoreCase("-stats"))
+ stats = decodeStats(token);
+ if (token.keyword.equalsIgnoreCase("-system"))
+ flagSystem = decodeSystem(token);
+
+ if (token.keyword.equalsIgnoreCase("-display"))
+ flagDisplay = decodeDisplay(token);
+
+ if (token.keyword.equalsIgnoreCase("-multithreading"))
+ flagMultithreading = decodeMultithreading(token);
+
+ if (token.keyword.equalsIgnoreCase("-verbose"))
+ verbose = Verbose.getByName(token.parameters);
+
+ if (token.keyword.equalsIgnoreCase("-fft"))
+ fft = FFT.getLibraryByName(token.parameters);
+
+ if (token.keyword.equalsIgnoreCase("-pad"))
+ pad = decodePadding(token);
+
+ if (token.keyword.equalsIgnoreCase("-apo"))
+ apo = decodeApodization(token);
+
+ if (token.keyword.equalsIgnoreCase("-norm"))
+ norm = decodeNormalization(token);
+
+ if (token.keyword.equalsIgnoreCase("-constraint"))
+ decodeController(token, controller);
+
+ if (token.keyword.equalsIgnoreCase("-time"))
+ decodeController(token, controller);
+
+ if (token.keyword.equalsIgnoreCase("-residu"))
+ decodeController(token, controller);
+
+ if (token.keyword.equalsIgnoreCase("-reference"))
+ decodeController(token, controller);
+
+ if (token.keyword.equalsIgnoreCase("-epsilon"))
+ Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
+
+ if (token.keyword.equals("-out")) {
+ Output out = decodeOut(token);
+ if (out != null)
+ outs.add(out);
+ }
+ }
+
+ deconvolution.setAlgorithm(algo, controller);
+ deconvolution.setPath(path);
+ deconvolution.setNormalization(norm);
+ deconvolution.setPadding(pad);
+ deconvolution.setApodization(apo);
+ deconvolution.setOutput(outs);
+ deconvolution.setVerbose(verbose);
+ deconvolution.setFFT(fft);
+ deconvolution.setMonitor(monitor);
+ deconvolution.setStats(stats);
+ deconvolution.setFlags(flagDisplay, flagMultithreading, flagSystem);
+ }
+
/**
* This methods first segments the command line, then create all the tokens
* of the command line
*
* @param command
* Command line
* @return the list of tokens extracted from the command line
*/
public static ArrayList<Token> parse(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
ArrayList<Token> tokens = new ArrayList<Token>();
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
Token token = new Token(keyword, command, begin, end);
tokens.add(token);
}
return tokens;
}
public static Token extract(String command, String keyword) {
ArrayList<Token> tokens = parse(command);
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase(keyword))
return token;
return (Token) null;
}
public static double[] parseNumeric(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static ArrayList<CommandSegment> findSegment(String command, String keyword) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
String regex = "(?<!\\w)" + keyword + "(?!\\w)";
if (command == null)
return segments;
Matcher matcher = Pattern.compile(regex).matcher(command);
while (matcher.find()) {
segments.add(new CommandSegment(keyword, matcher.start()));
}
return segments;
}
public static String extractOptions(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
String options = "";
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
if (keyword != "-image" && keyword != "-psf" && keyword != "-algorithm")
options += keyword + " " + command.substring(begin, end);
}
return options;
}
public static AbstractAlgorithm decodeAlgorithm(Token token, Controller controller) {
String option = token.option;
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
double params[] = parseNumeric(token.parameters);
if (params != null) {
algo.setParameters(params);
- if (algo.isIterative())
- controller.setIterationMax(algo.getController().getIterationMax());
+ if (algo.isIterative() && params.length >= 1)
+ controller.setIterationMax((int)params[0]);
}
if (algo.isWaveletsBased()) {
for (String wavelet : Wavelets.getWaveletsAsArray()) {
int pos = token.parameters.toLowerCase().indexOf(wavelet.toLowerCase());
if (pos >= 0)
algo.setWavelets(wavelet);
}
}
return algo;
}
public static Output decodeOut(Token token) {
int freq = 0;
String line = token.parameters;
String parts[] = token.parameters.split(" ");
for (int i = 0; i < Math.min(2, parts.length); i++) {
if (parts[i].startsWith("@"))
freq = (int) NumFormat.parseNumber(parts[i], 0);
}
String p = token.parameters.toLowerCase();
Output out = null;
if (p.startsWith("stack"))
out = new Output(View.STACK, freq, line.substring("stack".length(), line.length()));
if (p.startsWith("series"))
out = new Output(View.SERIES, freq, line.substring("series".length(), line.length()));
if (p.startsWith("mip"))
out = new Output(View.MIP, freq, line.substring("mip".length(), line.length()));
if (p.startsWith("ortho"))
out = new Output(View.ORTHO, freq, line.substring("ortho".length(), line.length()));
if (p.startsWith("figure"))
out = new Output(View.FIGURE, freq, line.substring("figure".length(), line.length()));
if (p.startsWith("planar"))
out = new Output(View.PLANAR, freq, line.substring("planar".length(), line.length()));
- if (p.startsWith("stats"))
- out = new Output(View.STATS, freq, line.substring("stats".length(), line.length()));
- if (p.startsWith("profile"))
- out = new Output(View.PROFILE, freq, line.substring("profile".length(), line.length()));
return out;
}
public static void decodeController(Token token, Controller controller) {
-
- int freq = 1;
String line = token.parameters;
if (token.parameters.startsWith("@")) {
String parts[] = token.parameters.split(" ");
if (parts.length >= 1) {
- freq = (int) NumFormat.parseNumber(parts[0], 1);
line = token.parameters.substring(parts[0].length(), token.parameters.length()).trim();
}
}
if (token.keyword.equals("-constraint"))
controller.setConstraint(Constraint.getByName(line.trim()));
else if (token.keyword.equals("-residu"))
controller.setResiduStop(NumFormat.parseNumber(line, -1));
else if (token.keyword.equals("-reference"))
controller.setReference(line);
else if (token.keyword.equals("-time"))
controller.setTimeStop(NumFormat.parseNumber(line, Double.MAX_VALUE));
}
public static double decodeNormalization(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return 0;
else
return NumFormat.parseNumber(token.parameters, 1);
}
- public static boolean decodeMonitor(Token token) {
+ public static int decodeMonitor(Token token) {
+ String parts[] = token.parameters.toLowerCase().split(" ");
+ int m = 0;
+ for(String p : parts) {
+ if (p.startsWith("no"))
+ return 0;
+ if (p.equals("false"))
+ return 0;
+ if (p.equals("0"))
+ return 0;
+ if (p.equals("1"))
+ return 1;
+ if (p.equals("2"))
+ return 2;
+ if (p.equals("3"))
+ return 3;
+ if (p.equals("console"))
+ m += 1;
+ if (p.equals("table"))
+ m += 2;
+ }
+ return m;
+ }
+
+ public static int decodeStats(Token token) {
+ String parts[] = token.parameters.toLowerCase().split(" ");
+ int m = 0;
+ for(String p : parts) {
+ if (p.startsWith("no"))
+ return 0;
+ if (p.equals("false"))
+ return 0;
+ if (p.equals("0"))
+ return 0;
+ if (p.equals("1"))
+ return 1;
+ if (p.equals("2"))
+ return 2;
+ if (p.equals("3"))
+ return 3;
+ if (p.equals("show"))
+ m += 1;
+ if (p.equals("save"))
+ m += 2;
+ }
+ return m;
+ }
+
+
+ public static boolean decodeMonitorConsole(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
- if (p.equals("console"))
+ return true;
+ }
+
+ public static boolean decodeSystem(Token token) {
+ String p = token.parameters.toLowerCase();
+ if (p.startsWith("no"))
+ return false;
+ if (p.equals("0"))
+ return false;
+ if (p.equals("false"))
return false;
return true;
}
public static boolean decodeDisplay(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
return true;
}
public static boolean decodeMultithreading(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
if (p.startsWith("dis"))
return false;
return true;
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
int extXY = 0;
int extZ = 0;
String param = token.parameters.trim();
String[] parts = param.split(" ");
if (parts.length > 0)
padXY = Padding.getByShortname(parts[0].trim());
if (parts.length > 1)
padZ = Padding.getByShortname(parts[1].trim());
double[] ext = NumFormat.parseNumbers(param);
if (ext.length > 0)
extXY = (int) Math.round(ext[0]);
if (ext.length > 1)
extZ = (int) Math.round(ext[1]);
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
public static Apodization decodeApodization(Token token) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
String[] parts = token.parameters.trim().split(" ");
if (parts.length >= 1)
apoXY = Apodization.getByShortname(parts[0].trim());
if (parts.length >= 2)
apoZ = Apodization.getByShortname(parts[1].trim());
return new Apodization(apoXY, apoXY, apoZ);
}
+
+ public static String getPath() {
+ command();
+ ArrayList<Token> tokens = parse(command.getCommand());
+ String path = System.getProperty("user.dir");
+
+ for (Token token : tokens)
+ if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
+ path = token.parameters;
+ return path;
+ }
+
+
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index d6bb36d..b8c3eda 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,676 +1,687 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.io.File;
import java.util.ArrayList;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
+import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.OutputCollection;
+import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
+import deconvolutionlab.system.SystemInfo;
import fft.AbstractFFTLibrary;
-import fft.FFT;
import lab.tools.NumFormat;
import signal.RealSignal;
-import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
-import signal.apodization.UniformApodization;
import signal.factory.SignalFactory;
import signal.padding.Padding;
public class Deconvolution implements Runnable {
- private AbstractAlgorithm algo = null;
+ public enum Finish {
+ DIE, ALIVE, KILL
+ };
- private String path;
- private Monitors monitors = Monitors.createDefaultMonitor();
- private Verbose verbose = Verbose.Log;
- private Controller controller;
- private OutputCollection outs;
+ private AbstractAlgorithm algo = null;
- private Padding pad = new Padding();
- private Apodization apo = new Apodization();
- private double norm = 1.0;
- private AbstractFFTLibrary fft;
+ private String path;
+ private double norm = 1.0;
+ private Padding pad = new Padding();
+ private Apodization apo = new Apodization();
+ private OutputCollection outs;
+ private Verbose verbose = Verbose.Log;
+ private AbstractFFTLibrary fft;
+ private int flagMonitor = 3;
+ private int flagStats = 0;
+ private boolean flagDisplay = true;
+ private boolean flagMultithreading = true;
+ private boolean flagSystem = true;
- private String command = "";
- private boolean live = false;
+ private Monitors monitors = new Monitors();
- private ArrayList<String> report = new ArrayList<String>();
+ private String command = "";
+ private boolean live = false;
- private String name = "";
- private boolean exit = false;
+ private Features report = new Features();
- private boolean watcherMonitor = true;
- private boolean watcherConsole = true;
- private boolean watcherDisplay = true;
- private boolean watcherMultithreading = true;
-
- private ArrayList<DeconvolutionListener> listeners = new ArrayList<DeconvolutionListener>();
-
- private boolean imageLoaded = false;
- private RealSignal image;
- private RealSignal psf;
- private RealSignal result;
+ private String name = "";
+
+ private ArrayList<DeconvolutionListener> listeners = new ArrayList<DeconvolutionListener>(); private boolean imageLoaded = false;
+ private RealSignal image;
+ private RealSignal psf;
+ private RealSignal result;
+
+ private Finish finish = Finish.DIE;
+ private DeconvolutionDialog dialog;
- public Deconvolution(String command) {
- super();
- monitors = Monitors.createDefaultMonitor();
- this.command = command;
- decode();
+ private TableStats tableStats;
+ private TableMonitor tableMonitor;
+
+ public Deconvolution(String name, String command) {
+ this.name = name;
+ tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
+ tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
+ this.finish = Finish.DIE;
+ setCommand(command);
+ }
+
+ public Deconvolution(String name, String command, Finish finish) {
+ this.name = name;
+ tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
+ tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
+ this.finish = finish;
+ setCommand(command);
}
-
public void setCommand(String command) {
this.command = command;
- decode();
+ Command.decode(command, this);
+ this.command = command;
+ if (name.equals("") && algo != null)
+ name = algo.getShortname();
+ monitors = Monitors.createDefaultMonitor();
+ live = false;
}
- public String getCommand() {
- return command;
+ public void close() {
+ if (dialog != null)
+ dialog.dispose();
+ finalize();
}
-
- public Monitors getMonitors() {
- if (monitors == null)
- return Monitors.createDefaultMonitor();
- return monitors;
+
+ public void finalize() {
+ algo = null;
+ image = null;
+ psf = null;
+ monitors = null;
+ System.gc();
}
/**
* This method runs the deconvolution without graphical user interface.
*
* @param exit
* System.exit call is true
*/
- public RealSignal deconvolve(RealSignal image, RealSignal psf, boolean exit) {
+ public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
- this.exit = exit;
imageLoaded = true;
- monitors = createMonitors();
- deconvolve();
+ runDeconvolve();
return result;
}
- public RealSignal deconvolve(boolean exit) {
+ public RealSignal deconvolve() {
this.image = null;
this.psf = null;
- this.exit = exit;
imageLoaded = false;
- monitors = createMonitors();
- deconvolve();
+ runDeconvolve();
return result;
}
/**
* This method runs the deconvolution without graphical user interface.
*
* @param exit
* System.exit call is true
*/
- private void deconvolve() {
+ private void runDeconvolve() {
+ if ((flagMonitor & 2) == 2) {
+ monitors.add(tableMonitor);
+ tableMonitor.show();
+ }
+
+ if ((flagStats & 1) == 1) {
+ tableStats.show();
+ }
+
if (fft == null) {
run();
return;
}
-
+
if (!fft.isMultithreadable()) {
run();
return;
}
-
- if (watcherMultithreading) {
+
+ if (flagMultithreading) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
}
-
-
/**
* This method runs the deconvolution with a graphical user interface.
*
* @param job
* Name of the job of deconvolution
- * @param exit
- * System.exit call is true
*/
- public void launch(String job, boolean exit) {
- this.name = job;
- this.exit = exit;
- DeconvolutionDialog d = new DeconvolutionDialog(this);
- monitors = new Monitors();
- monitors.add(new StatusMonitor(d.getProgressBar()));
- if (watcherConsole)
- monitors.add(new ConsoleMonitor());
-
- if (watcherMonitor) {
- TableMonitor m = new TableMonitor(440, 440);
- monitors.add(m);
- d.addTableMonitor("Monitor", m);
- }
- }
-
- public void decode() {
-
- algo = null;
+ public void launch() {
+ dialog = new DeconvolutionDialog(this, tableMonitor, tableStats);
- path = System.getProperty("user.dir");
- if (monitors==null)
- monitors = Monitors.createDefaultMonitor();
- verbose = Verbose.Log;
-
- controller = new Controller();
- outs = new OutputCollection();
-
- pad = new Padding();
- apo = new Apodization();
- norm = 1.0;
- fft = FFT.getLibraryByName("Academic");
-
- live = false;
+ Lab.setVisible(dialog, false);
+ monitors = new Monitors();
+ monitors.add(new StatusMonitor(dialog.getProgressBar()));
- ArrayList<Token> tokens = Command.parse(command);
- for (Token token : tokens) {
- if (token.keyword.equalsIgnoreCase("-algorithm"))
- algo = Command.decodeAlgorithm(token, controller);
-
- if (token.keyword.equalsIgnoreCase("-monitor"))
- watcherMonitor = Command.decodeMonitor(token);
-
- if (token.keyword.equalsIgnoreCase("-display"))
- watcherDisplay = Command.decodeDisplay(token);
-
- if (token.keyword.equalsIgnoreCase("-multithreading"))
- watcherMultithreading = Command.decodeMultithreading(token);
-
- if (token.keyword.equalsIgnoreCase("-verbose"))
- verbose = Verbose.getByName(token.parameters);
-
- if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
- path = token.parameters;
-
- if (token.keyword.equalsIgnoreCase("-fft"))
- fft = FFT.getLibraryByName(token.parameters);
-
- if (token.keyword.equalsIgnoreCase("-pad"))
- pad = Command.decodePadding(token);
-
- if (token.keyword.equalsIgnoreCase("-apo"))
- apo = Command.decodeApodization(token);
-
- if (token.keyword.equalsIgnoreCase("-norm"))
- norm = Command.decodeNormalization(token);
-
- if (token.keyword.equalsIgnoreCase("-constraint"))
- Command.decodeController(token, controller);
-
- if (token.keyword.equalsIgnoreCase("-time"))
- Command.decodeController(token, controller);
-
- if (token.keyword.equalsIgnoreCase("-residu"))
- Command.decodeController(token, controller);
-
- if (token.keyword.equalsIgnoreCase("-reference"))
- Command.decodeController(token, controller);
-
- if (token.keyword.equals("-out")) {
- Output out = Command.decodeOut(token);
- if (out != null)
- outs.add(out);
- }
+ if ((flagMonitor & 2) == 2) {
+ monitors.add(tableMonitor);
}
- if (name.equals("") && algo != null)
- name = algo.getShortname();
}
- public Monitors createMonitors() {
+ public Monitors createMonitors1() {
Monitors monitors = new Monitors();
-
- if (watcherConsole)
- monitors.add(new ConsoleMonitor());
-
- if (watcherMonitor) {
- TableMonitor m = new TableMonitor(440, 440);
- monitors.add(m);
- m.show(algo == null ? "Monitor " + name : name + " " + algo.getName());
- }
return monitors;
}
-
- public void setApodization(ArrayList<AbstractApodization> apos) {
- AbstractApodization apoXY = new UniformApodization();
- AbstractApodization apoZ = new UniformApodization();
- if (apos.size() >= 1)
- apoXY = apos.get(0);
- if (apos.size() >= 2)
- apoZ = apos.get(1);
- this.apo = new Apodization(apoXY, apoXY, apoZ);
- }
@Override
public void run() {
double chrono = System.nanoTime();
-
- for(DeconvolutionListener listener : listeners)
+
+ if ((flagMonitor & 1) == 1)
+ monitors.add(new ConsoleMonitor());
+
+ if (flagSystem)
+ SystemInfo.activate();
+
+ for (DeconvolutionListener listener : listeners)
listener.started();
-
+
live = true;
if (monitors != null)
monitors.setVerbose(verbose);
-
- report.add("Path: " + checkPath(path));
+
+ report.add("Path", checkPath(path));
monitors.log("Path: " + checkPath(path));
-
+
if (!imageLoaded)
image = openImage();
-
+
if (image == null) {
monitors.error("Image: Not valid " + command);
- report.add("Image: Not valid");
- if (exit)
+ report.add("Image", "Not valid");
+ if (finish == Finish.KILL)
System.exit(-101);
return;
}
- report.add( "Image: " + image.dimAsString());
+ report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
-
+
if (!imageLoaded)
psf = openPSF();
-
+
if (psf == null) {
monitors.error("PSF: not valid");
- report.add("PSF: Not valid");
- if (exit)
+ report.add("PSF", "Not valid");
+ if (finish == Finish.KILL)
System.exit(-102);
return;
}
- report.add( "PSF: " + psf.dimAsString());
+ report.add("PSF", psf.dimAsString());
monitors.log("PSF: " + psf.dimAsString());
-
if (algo == null) {
monitors.error("Algorithm: not valid");
- if (exit)
+ if (finish == Finish.KILL)
System.exit(-103);
return;
}
+ Controller controller = algo.getController();
if (controller == null) {
monitors.error("Controller: not valid");
- if (exit)
+ if (finish == Finish.KILL)
System.exit(-104);
return;
}
- report.add("FFT: " + fft.getLibraryName());
+
+ if (flagStats > 0)
+ controller.setTableStats(tableStats);
+
+ report.add("FFT", fft.getLibraryName());
if (outs != null) {
outs.setPath(path);
controller.setOutputs(outs);
}
monitors.log("Algorithm: " + algo.getName());
- report.add("Algorithm: " + algo.getName());
+ report.add("Algorithm", algo.getName());
algo.setController(controller);
result = algo.run(monitors, image, psf, fft, pad, apo, norm, true);
live = false;
- for(DeconvolutionListener listener : listeners)
+ for (DeconvolutionListener listener : listeners)
listener.finish();
-
- report.add("End " + algo.getName() + " in " + NumFormat.time(System.nanoTime()-chrono));
-
- if (watcherDisplay)
+
+ report.add("End", algo.getName() + " in " + NumFormat.time(System.nanoTime() - chrono));
+
+ if (flagDisplay)
Lab.show(monitors, result, "Result of " + algo.getShortname());
- if (exit) {
+ if (finish == Finish.KILL) {
System.out.println("End");
System.exit(0);
}
+
+ if (finish == Finish.DIE)
+ finalize();
}
/**
- * This methods make a recap of the deconvolution. Useful before starting the processing.
+ * This methods make a recap of the deconvolution. Useful before starting
+ * the processing.
*
* @return list of messages to print
*/
- public ArrayList<String> recap() {
- ArrayList<String> lines = new ArrayList<String>();
+ public Features recap() {
+ Features features = new Features();
Token image = Command.extract(command, "-image");
- if (image == null)
- lines.add("<b>Image</b>: <span color=\"red\">keyword -image not found</span>");
- else
- lines.add("<b>Image</b>: " + image.parameters);
+ features.add("Image", image == null ? "keyword -image not found" : image.parameters);
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
- if (psf == null)
- lines.add("<b>PSF</b>: <span color=\"red\">keyword -psf not found</span>");
- else
- lines.add("<b>PSF</b>: " + psf.parameters + normf);
+ features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
- lines.add("<b>Algorithm</b>: <span color=\"red\">not valid</span>");
+ features.add("Algorithm", "not valid>");
}
else {
-
- algo.setController(controller);
- lines.add("<b>Algorithm</b>: " + algo.toString());
- lines.add("<b>Stopping Criteria</b>: " + controller.getStoppingCriteriaAsString(algo));
- lines.add("<b>Reference</b>: " + controller.getReference());
- lines.add("<b>Constraint</b>: " + controller.getConstraintAsString());
- lines.add("<b>Padding</b>: " + pad.toString());
- lines.add("<b>Apodization</b>: " + apo.toString());
- if (algo.getFFT() != null)
- lines.add("<b>FFT</b>: " + algo.getFFT().getName());
- }
- lines.add("<b>Path</b>: " + path);
-
- lines.add("<b>Verbose</b>: " + verbose.name().toLowerCase());
- lines.add("<b>Monitor</b>: " + (watcherMonitor ? "on" : "off"));
- lines.add("<b>Final Display</b>: " + (watcherDisplay ? "on" : "off"));
- lines.add("<b>Multithreading</b>: " + (watcherMultithreading ? "on" : "off"));
-
+ 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", pad.toString());
+ features.add("Apodization", apo.toString());
+ features.add("FFT", algo.getFFT() == null ? "" : algo.getFFT().getName());
+ }
+ features.add("Path", path);
+
+ String monitor = "";
+ if (flagMonitor == 0)
+ monitor = " monitor: no ";
+ if (flagMonitor == 1)
+ monitor = " monitor: console (" + verbose.name().toLowerCase() + ")";
+ if (flagMonitor == 2)
+ monitor = " monitor: table (" + verbose.name().toLowerCase() + ")";
+ if (flagMonitor == 3)
+ monitor = " monitor: console table (" + verbose.name().toLowerCase() + ")";
+ String stats = "";
+ if (flagStats == 0)
+ stats = " stats: no ";
+ if (flagStats == 1)
+ stats = " stats: show ";
+ if (flagStats == 2)
+ stats = " stats: save ";
+ if (flagStats == 3)
+ stats = " stats: show save";
+ String running = "";
+ running += " multithreading: " + (flagMultithreading ? "on " : "off ");
+ running += " display: " + (flagDisplay ? "on " : "off ");
+ running += " system: " + (flagSystem ? "shown" : "hidden ");
+
+ features.add("Monitor", monitor);
+ features.add("Stats", stats);
+ features.add("Running", running);
if (outs == null)
- lines.add("<b>Outputs</b>: not valid");
+ features.add("Output", "not valid");
else
- lines.addAll(outs.getInformation());
- return lines;
+ for (Output out : outs)
+ features.add("Output " + out.getName(), out.toString());
+ return features;
}
- public ArrayList<String> checkAlgo() {
- ArrayList<String> lines = new ArrayList<String>();
+ public Features checkAlgo() {
+ Features features = new Features();
RealSignal image = openImage();
if (image == null) {
- lines.add("No valid input image");
- return lines;
+ features.add("Image", "No valid input image");
+ return features;
}
if (pad == null) {
- lines.add("No valid padding");
- return lines;
+ features.add("Padding", "No valid padding");
+ return features;
}
if (apo == null) {
- lines.add("No valid apodization");
- return lines;
+ features.add("Apodization", "No valid apodization");
+ return features;
}
RealSignal psf = openPSF();
if (psf == null) {
- lines.add("No valid PSF");
- return lines;
+ features.add("Image", "No valid PSF");
+ return features;
}
if (algo == null) {
- lines.add("No valid algorithm");
- return lines;
+ features.add("Algorithm", "No valid algorithm");
+ return features;
}
+ Controller controller = algo.getController();
if (controller == null) {
- lines.add("No valid controller");
- return lines;
+ features.add("Controller", "No valid controller");
+ return features;
}
algo.setController(controller);
int iter = controller.getIterationMax();
controller.setIterationMax(1);
RealSignal x = algo.run(monitors, image, psf, fft, pad, apo, norm, true);
Lab.show(monitors, x, "Estimate after 1 iteration");
- lines.add("Time: " + NumFormat.seconds(controller.getTimeNano()));
- lines.add("Peak Memory: " + controller.getMemoryAsString());
+ features.add("Time", NumFormat.seconds(controller.getTimeNano()));
+ features.add("Peak Memory", controller.getMemoryAsString());
controller.setIterationMax(iter);
- return lines;
+ return features;
}
- public ArrayList<String> checkImage() {
- ArrayList<String> lines = new ArrayList<String>();
+ public Features checkImage() {
+ Features features = new Features();
RealSignal image = openImage();
if (image == null) {
- lines.add("No valid input image");
- return lines;
+ features.add("Image", "No valid input image");
+ return features;
}
if (pad == null) {
- lines.add("No valid padding");
- return lines;
+ features.add("Padding", "No valid padding");
+ return features;
}
if (apo == null) {
- lines.add("No valid apodization");
- return lines;
+ features.add("Apodization", "No valid apodization");
+ return features;
}
RealSignal signal = pad.pad(monitors, getApodization().apodize(monitors, image));
- lines.add("<b>Image</b>");
- lines.add("Original size " + image.dimAsString() + " padded to " + signal.dimAsString());
- lines.add("Original: " + formatStats(image));
- lines.add("Preprocessing: " + formatStats(signal));
-
- Lab.show(monitors, signal, "Image");
- return lines;
+ float stats[] = signal.getStats();
+ float stati[] = image.getStats();
+ features.add("Size", image.dimAsString() + " padded to " + signal.dimAsString());
+ features.add("Mean", NumFormat.nice(stati[0]) + " > " + NumFormat.nice(stats[0]));
+ features.add("Minimun", NumFormat.nice(stati[1]) + " > " + NumFormat.nice(stats[1]));
+ features.add("Maximum", NumFormat.nice(stati[2]) + " > " + NumFormat.nice(stats[2]));
+ features.add("Stdev", NumFormat.nice(stati[3]) + " > " + NumFormat.nice(stats[3]));
+ features.add("Energy", NumFormat.nice(stati[5]) + " > " + NumFormat.nice(stats[5]));
+ return features;
}
- public ArrayList<String> checkPSF() {
- ArrayList<String> lines = new ArrayList<String>();
+ public Features checkPSF() {
+ Features features = new Features();
RealSignal image = openImage();
if (image == null) {
- lines.add("No valid input image");
- return lines;
+ features.add("Image", "No valid input image");
+ return features;
}
if (pad == null) {
- lines.add("No valid padding");
- return lines;
+ features.add("Padding", "No valid padding");
+ return features;
}
if (apo == null) {
- lines.add("No valid apodization");
- return lines;
+ features.add("Apodization", "No valid apodization");
+ return features;
}
RealSignal psf = openPSF();
if (psf == null) {
- lines.add("No valid PSF");
- return lines;
+ features.add("PSF", "No valid PSF");
+ return features;
}
RealSignal signal = pad.pad(monitors, getApodization().apodize(monitors, image));
RealSignal h = psf.changeSizeAs(signal);
- lines.add("<b>PSF</b>");
- lines.add("Original size " + psf.dimAsString() + " padded to " + h.dimAsString());
+ features.add("Original size", psf.dimAsString() + " padded to " + h.dimAsString());
String e = NumFormat.nice(h.getEnergy());
h.normalize(norm);
- lines.add("Original: " + formatStats(psf));
- lines.add("Preprocessing: " + formatStats(h));
- lines.add("Energy = " + e + " and after normalization=" + NumFormat.nice(h.getEnergy()));
- Lab.show(monitors, h, "Padded and Normalized PSF");
- return lines;
+
+ float stath[] = h.getStats();
+ float statp[] = psf.getStats();
+
+ // return new float[] { (float) mean, min, max, (float) stdev, (float)
+ // norm1, (float) norm2 };
+
+ features.add("Size", psf.dimAsString() + " padded to " + h.dimAsString());
+ features.add("Mean", NumFormat.nice(statp[0]) + " > " + NumFormat.nice(stath[0]));
+ features.add("Minimun", NumFormat.nice(statp[1]) + " > " + NumFormat.nice(stath[1]));
+ features.add("Maximum", NumFormat.nice(statp[2]) + " > " + NumFormat.nice(stath[2]));
+ features.add("Stdev", NumFormat.nice(statp[3]) + " > " + NumFormat.nice(stath[3]));
+ features.add("Energy", NumFormat.nice(statp[5]) + " > " + NumFormat.nice(stath[5]));
+ features.add("Total", NumFormat.nice(statp[4]) + " > " + NumFormat.nice(stath[4]));
+ return features;
}
- public ArrayList<String> getDeconvolutionReports() {
+ public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
public boolean isLive() {
return live;
}
public void abort() {
live = false;
algo.getController().abort();
}
- public Padding getPadding() {
- return pad;
- }
-
- public Apodization getApodization() {
- return apo;
- }
-
- public OutputCollection getOuts() {
- return outs;
- }
-
- public AbstractAlgorithm getAlgo() {
- return algo;
- }
-
- public String getPath() {
- return path;
- }
-
public String checkPath(String path) {
File dir = new File(path);
if (dir.exists()) {
if (dir.isDirectory()) {
if (dir.canWrite())
return path + " (writable)";
else
return path + " (non-writable)";
}
else {
return path + " (non-directory)";
}
}
else {
return path + " (not-valid)";
}
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
return getImage(monitors, token);
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
return getImage(monitors, token);
}
private RealSignal getImage(Monitors monitors, Token token) {
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
if (arg.equalsIgnoreCase("synthetic")) {
String parts[] = cmd.split(" ");
if (parts.length <= 0)
return null;
String shape = parts[0];
for (String name : SignalFactory.getAllName()) {
if (shape.equalsIgnoreCase(name.toLowerCase())) {
double params[] = Command.parseNumeric(cmd);
SignalFactory factory = SignalFactory.getFactoryByName(shape);
if (factory == null)
return null;
double amplitude = params.length > 0 ? params[0] : 1;
double background = params.length > 1 ? params[1] : 0;
factory.intensity(background, amplitude);
int np = factory.getParameters().length;
double[] features = new double[np];
for (int i = 0; i < Math.min(np, params.length); i++)
features[i] = params[i + 2];
factory.setParameters(features);
int nx = params.length > np + 2 ? (int) Math.round(params[np + 2]) : 128;
int ny = params.length > np + 3 ? (int) Math.round(params[np + 3]) : 128;
int nz = params.length > np + 4 ? (int) Math.round(params[np + 4]) : 128;
double cx = params.length > np + 5 ? params[np + 5] : 0.5;
double cy = params.length > np + 6 ? params[np + 6] : 0.5;
double cz = params.length > np + 7 ? params[np + 7] : 0.5;
factory = factory.center(cx, cy, cz);
RealSignal x = factory.generate(nx, ny, nz);
return x;
}
}
}
if (arg.equalsIgnoreCase("file") || arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
RealSignal signal = null;
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.open(monitors, path + File.separator + cmd);
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.open(monitors, cmd);
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
return signal;
}
if (arg.equalsIgnoreCase("platform")) {
return Lab.getImager().create(cmd);
}
return null;
}
- private static String formatStats(RealSignal x) {
- float stats[] = x.getStats();
- String s = " mean=" + NumFormat.nice(stats[0]);
- s += " stdev=" + NumFormat.nice(stats[1]);
- s += " min=" + NumFormat.nice(stats[3]);
- s += " max=" + NumFormat.nice(stats[2]);
- return s;
- }
-
public void addDeconvolutionListener(DeconvolutionListener listener) {
listeners.add(listener);
}
+ public OutputCollection getOuts() {
+ return outs;
+ }
+
+ public void setAlgorithm(AbstractAlgorithm algo, Controller controller) {
+ this.algo = algo;
+ if (algo != null && controller != null) {
+ algo.setController(controller);
+ }
+ }
+
+ public AbstractAlgorithm getAlgo() {
+ return algo;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setNormalization(double norm) {
+ this.norm = norm;
+ }
+
+ public void setPadding(Padding pad) {
+ this.pad = pad;
+ }
+
+ public Padding getPadding() {
+ return pad;
+ }
+
+ public void setApodization(Apodization apo) {
+ this.apo = apo;
+ }
+
+ public Apodization getApodization() {
+ return apo;
+ }
+
+ public void setOutput(OutputCollection outs) {
+ this.outs = outs;
+ }
+
+ public void setVerbose(Verbose verbose) {
+ this.verbose = verbose;
+ }
+
+ public void setFFT(AbstractFFTLibrary fft) {
+ this.fft = fft;
+ }
+
+ public void setMonitor(int flagMonitor) {
+ this.flagMonitor = flagMonitor;
+ }
+
+ public void setStats(int flagStats) {
+ this.flagStats = flagStats;
+ }
+
+ public void setFlags(boolean flagDisplay, boolean flagMultithreading, boolean flagSystem) {
+ this.flagDisplay = flagDisplay;
+ this.flagMultithreading = flagMultithreading;
+ this.flagSystem = flagSystem;
+ }
+
+ public String getCommand() {
+ return command;
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 7d7f83f..a6d4307 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,319 +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 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.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
-import javax.swing.JTabbedPane;
+import javax.swing.JSplitPane;
import javax.swing.JToolBar;
-import javax.swing.text.BadLocationException;
-import lab.component.HTMLPane;
-import lab.system.SystemBar;
+import deconvolution.modules.AlgorithmDModule;
+import deconvolution.modules.RecapDModule;
+import deconvolution.modules.ImageDModule;
+import deconvolution.modules.PSFDModule;
+import deconvolution.modules.ReportDModule;
+import deconvolutionlab.Config;
import deconvolutionlab.Lab;
-import deconvolutionlab.monitor.StatusMonitor;
+import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.TableMonitor;
+import lab.component.BorderToggledButton;
+import lab.component.CustomizedTable;
+import lab.component.JPanelImage;
-public class DeconvolutionDialog extends JDialog implements ActionListener, Runnable, KeyListener, DeconvolutionListener {
+public class DeconvolutionDialog extends JDialog implements ActionListener, Runnable, DeconvolutionListener {
- public enum State {NOTDEFINED, READY, RUN, FINISH};
-
- private JButton bnStart = new JButton("Run");
- private JButton bnQuit = new JButton("Quit");
- private JButton bnRecap = new JButton("Recap");
- private JButton bnImage = new JButton("Check Image");
- private JButton bnPSF = new JButton("Check PSF");
- private JButton bnAlgo = new JButton("Check Algo");
- private JButton bnHelp = new JButton("Help");
- private JTabbedPane tab = new JTabbedPane();
-
- private HTMLPane pnCommand;
- private HTMLPane pnResume;
-
- private JButton job = null;
- private Thread thread = null;
-
- private Deconvolution deconvolution;
- private State state = State.NOTDEFINED;
- private JProgressBar progress = new JProgressBar();
-
- public static Point location = new Point(0, 0);
-
- public DeconvolutionDialog(Deconvolution deconvolution) {
- super(new JFrame(), deconvolution.getName() + " " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()));
+ public enum State {
+ NOTDEFINED, READY, RUN, FINISH
+ };
- this.deconvolution = deconvolution;
+ 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");
+
+ private String job = "";
+ private Thread thread = null;
+
+ private Deconvolution deconvolution;
+ private State state = State.NOTDEFINED;
+ private JProgressBar progress = new JProgressBar();
- pnCommand = new HTMLPane("Monaco", 100, 100);
- pnCommand.append("p", deconvolution.getCommand());
- pnResume = new HTMLPane("Verdana", 450, 150);
+ public static Point location = new Point(0, 0);
- tab.add("Resume", pnResume.getPane());
+ private JPanel cards = new JPanel(new CardLayout());
+
+ private boolean flagMonitor = false;
+ private boolean flagStats = false;
+
+ private ImageDModule image;
+ private PSFDModule psf;
+ private RecapDModule recap;
+ private AlgorithmDModule algorithm;
+ private ReportDModule report;
+
+ public DeconvolutionDialog(Deconvolution deconvolution, TableMonitor tableMonitor, TableStats tableStats) {
+ super(new JFrame(), deconvolution.getName());
+
+ this.deconvolution = deconvolution;
+
+ image = new ImageDModule(deconvolution);
+ psf = new PSFDModule(deconvolution);
+ recap = new RecapDModule(deconvolution);
+ algorithm = new AlgorithmDModule(deconvolution);
+ report = new ReportDModule(deconvolution);
+
+ // Panel tool with all buttons
+ 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);
+ tool.add(bnMonitor);
+ tool.add(bnStats);
+ tool.add(bnReport);
- pnCommand.setEditable(true);
- pnCommand.addKeyListener(this);
- JPanel bn = new JPanel();
- bn.setLayout(new GridLayout(1, 5));
- bn.setBorder(BorderFactory.createEtchedBorder());
- bn.add(bnRecap);
- bn.add(bnImage);
- bn.add(bnPSF);
- bn.add(bnAlgo);
- bn.add(bnStart);
+ // Panel buttons
+ JPanelImage buttons = new JPanelImage("celegans.jpg");
+ buttons.setLayout(new FlowLayout());
+ buttons.setBorder(BorderFactory.createEtchedBorder());
+ buttons.add(bnReset);
+ buttons.add(bnStop);
+ buttons.add(bnStart);
+ // 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));
- bottom.add(bn);
- bottom.add(new SystemBar(200));
+ 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 (tableStats != null)
+ cards.add("Stats", tableStats.getPanel());
+
+ // Panel Main
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
- panel.add(pnCommand.getPane(), BorderLayout.NORTH);
+ panel.add(tool, BorderLayout.NORTH);
+ panel.add(cards, BorderLayout.CENTER);
panel.add(bottom, BorderLayout.SOUTH);
- panel.add(tab, BorderLayout.CENTER);
add(panel);
+ bnReset.addActionListener(this);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
+ bnStop.addActionListener(this);
bnPSF.addActionListener(this);
bnImage.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
bnHelp.addActionListener(this);
+ bnMonitor.addActionListener(this);
+ bnStats.addActionListener(this);
deconvolution.addDeconvolutionListener(this);
setMinimumSize(new Dimension(400, 200));
- setLocation(location);
-
pack();
- location.x = location.x + 20;
- location.y = location.y + 20;
+ Config.registerFrame("DeconvolutionLab", "DeconvolutionDialog", this);
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- double width = screenSize.getWidth();
- double height = screenSize.getHeight();
- if (location.x + 400 > width)
- location.x = 0;
- if (location.y + 200 > height)
- location.y = 0;
- setVisible(true);
+ Rectangle rect = Config.getDialog("DeconvolutionLab.DeconvolutionDialog");
+ if (rect.x > 0 && rect.y > 0)
+ setLocation(rect.x, rect.y);
- print(deconvolution.recap());
+ bnStop.setEnabled(false);
+
+ toggle(bnRecap);
state = State.READY;
+
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
- if (state == State.FINISH)
- print(deconvolution.getDeconvolutionReports());
- else if (thread == null) {
- job = bnStart;
+ if (flagMonitor)
+ toggle(bnMonitor);
+ else if (flagStats)
+ toggle(bnStats);
+
+ if (thread == null) {
+ job = bnStart.getText();
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
- else {
- finish();
- if (deconvolution != null)
- deconvolution.abort();
- }
+ }
+ else if (e.getSource() == bnStop) {
+ toggle(bnReport);
+ finish();
+ if (deconvolution != null)
+ deconvolution.abort();
}
else if (e.getSource() == bnRecap) {
+ toggle(bnRecap);
if (thread == null) {
- job = bnRecap;
+ job = bnRecap.getText();
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnImage) {
+ toggle(bnImage);
if (thread == null) {
- job = bnImage;
+ job = bnImage.getText();
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnPSF) {
+ toggle(bnPSF);
if (thread == null) {
- job = bnPSF;
+ job = bnPSF.getText();
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnAlgo) {
+ toggle(bnAlgo);
if (thread == null) {
- job = bnAlgo;
+ job = bnAlgo.getText();
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
-
+ else if (job.equals(bnRecap.getText())) {
+ toggle(bnRecap);
+ recap.update();
+ }
+ else if (e.getSource() == bnReport) {
+ toggle(bnReport);
+ report.update();
+ }
+ else if (e.getSource() == bnReset) {
+ toggle(bnRecap);
+ state = State.READY;
+ bnStart.setEnabled(true);
+ }
else if (e.getSource() == bnQuit) {
+ deconvolution.finalize();
+ 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);
- bnAlgo.setEnabled(false);
- bnPSF.setEnabled(false);
bnImage.setEnabled(false);
- bnStart.setEnabled(false);
- String command = pnCommand.getText();
- deconvolution.setCommand(command);
- if (job == bnStart) {
- if (tab.getTabCount() > 1)
- tab.setSelectedIndex(1);
- else
- print(deconvolution.recap());
+ bnPSF.setEnabled(false);
+ bnAlgo.setEnabled(false);
+
+ deconvolution.setCommand(recap.getCommand());
+ if (job.equals(bnStart.getText())) {
+ bnStart.setEnabled(false);
+ bnStop.setEnabled(true);
deconvolution.run();
- print(deconvolution.getDeconvolutionReports());
- }
- else if (job == bnRecap) {
- tab.setSelectedIndex(0);
- print(deconvolution.recap());
- }
- else if (job == bnImage) {
- tab.setSelectedIndex(0);
- print(deconvolution.checkImage());
- }
- else if (job == bnPSF) {
- tab.setSelectedIndex(0);
- print(deconvolution.checkPSF());
- }
- else if (job == bnAlgo) {
- tab.setSelectedIndex(0);
- print(deconvolution.checkAlgo());
+ toggle(bnReport);
+ bnStop.setEnabled(false);
}
+ else if (job.equals(bnImage.getText()))
+ image.update();
+ else if (job.equals(bnPSF.getText()))
+ psf.update();
+ else if (job.equals(bnAlgo.getText()))
+ algorithm.update();
+
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
- bnStart.setEnabled(true);
thread = null;
}
-
- private void print(ArrayList<String> lines) {
- pnResume.clear();
- for (String line : lines)
- pnResume.append("p", line);
- }
-
- public void addTableMonitor(String title, TableMonitor tm) {
- tab.add(title, tm.getPanel());
- }
@Override
- public void keyTyped(KeyEvent e) {
+ public void started() {
+ state = State.RUN;
}
@Override
- public void keyPressed(KeyEvent e) {
+ public void finish() {
+ state = State.FINISH;
}
- @Override
- public void keyReleased(KeyEvent e) {
- try {
- int len = pnCommand.getDocument().getLength();
- String command = pnCommand.getDocument().getText(0, len);
- deconvolution.setCommand(command);
- print(deconvolution.recap());
- }
- catch (BadLocationException e1) {
- e1.printStackTrace();
- }
- }
-
- @Override
- public void started() {
- bnStart.setEnabled(true);
- bnStart.setText("Abort");
- state = State.RUN;
- }
-
- @Override
- public void finish() {
- bnStart.setEnabled(true);
- bnStart.setText("Report");
- state = State.FINISH;
- tab.setSelectedIndex(0);
- }
-
public JProgressBar getProgressBar() {
return progress;
}
-
+
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);
+
+ }
+
}
diff --git a/DeconvolutionLab2/src/deconvolution/Features.java b/DeconvolutionLab2/src/deconvolution/Features.java
new file mode 100644
index 0000000..23f2a0c
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/Features.java
@@ -0,0 +1,16 @@
+package deconvolution;
+
+import java.util.ArrayList;
+
+public class Features extends ArrayList<String[]>{
+
+ public Features() {
+ super();
+ }
+
+
+ public void add(String feature, String value) {
+ add(new String[] {feature, value});
+ }
+
+}
diff --git a/DeconvolutionLab2/src/deconvolution/Token.java b/DeconvolutionLab2/src/deconvolution/Token.java
index d9e36ab..c556f42 100644
--- a/DeconvolutionLab2/src/deconvolution/Token.java
+++ b/DeconvolutionLab2/src/deconvolution/Token.java
@@ -1,54 +1,53 @@
/*
* 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;
public class Token {
public String keyword;
public String parameters = "?";
public String option = "?";
public Token(String keyword, String command, int begin, int end) {
this.keyword = keyword;
-
this.parameters = command.substring(begin, end).trim();
String arg[] = parameters.split(" ");
option = arg.length >= 1 ? arg[0].trim() : "";
}
@Override
public String toString() {
return keyword + " [" + option + "]" + parameters;
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index c7dd629..321badc 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,217 +1,217 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import lab.tools.NumFormat;
import signal.Operations;
import signal.RealSignal;
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> {
protected RealSignal y = null;
protected RealSignal h = null;
protected Controller controller = null;
protected AbstractFFT fft = null;
public AbstractAlgorithm() {
this.controller = new Controller();
}
public abstract String getName();
public abstract String getShortname();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract void setParameters(double[] params);
public abstract double getRegularizationFactor();
public abstract double getStepFactor();
public abstract double[] getParameters();
public abstract double[] getDefaultParameters();
public RealSignal run(Monitors monitors,
RealSignal image, RealSignal psf,
AbstractFFTLibrary fftlib, Padding pad, Apodization apo, double norm, boolean threaded) {
-
+
if (image == null)
return null;
if (psf == null)
return null;
if (fftlib != null)
fft = FFT.createFFT(monitors, fftlib, image.nx, image.ny, image.nz);
else
fft = FFT.createDefaultFFT(monitors, image.nx, image.ny, image.nz);
controller.setFFT(fft);
y = (pad == null ? image.duplicate() : pad.pad(monitors, apo.apodize(monitors, image)));
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y).normalize(norm);
monitors.log("PSF: " + h.dimAsString());
monitors.log("PSF: normalization " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
monitors.log(getShortname() + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
controller.start(y);
h = Operations.circularShift(h);
if (fft == null)
fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
else
fft.init(monitors, y.nx, y.ny, y.nz);
monitors.log(getShortname() + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortname() + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
controller.finish(x);
monitors.log(getName() + " is finished");
-
+
RealSignal result = pad.crop(monitors, x);
-
+
return result;
}
public AbstractFFT getFFT() {
return fft;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
controller.setAlgorithm(getName());
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + 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;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
index cbc399c..59f96d4 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
@@ -1,164 +1,162 @@
/*
* 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;
public class Algorithm {
private static ArrayList<AbstractAlgorithmPanel> list;
static {
list = new ArrayList<AbstractAlgorithmPanel>();
list.add(new RegularizedInverseFilterPanel());
list.add(new TikhonovRegularizationInverseFilterPanel());
list.add(new NaiveInverseFilterPanel());
list.add(new FISTAPanel());
list.add(new ISTAPanel());
list.add(new LandweberPanel());
list.add(new LandweberPositivityPanel());
list.add(new RichardsonLucyPanel());
list.add(new RichardsonLucyTVPanel());
list.add(new TikhonovMillerPanel());
list.add(new ICTMPanel());
list.add(new VanCittertPanel());
list.add(new IdentityPanel());
list.add(new ConvolutionPanel());
list.add(new SimulationPanel());
list.add(new NonStabilizedDivisionPanel());
}
public static ArrayList<AbstractAlgorithmPanel> getAvailableAlgorithms() {
return list;
}
public static ArrayList<AbstractAlgorithmPanel> getAvailableDeconvolutionAlgorithms() {
ArrayList<AbstractAlgorithmPanel> list = new ArrayList<AbstractAlgorithmPanel>();
list = new ArrayList<AbstractAlgorithmPanel>();
list.add(new RegularizedInverseFilterPanel());
list.add(new TikhonovRegularizationInverseFilterPanel());
list.add(new NaiveInverseFilterPanel());
list.add(new FISTAPanel());
list.add(new ISTAPanel());
list.add(new LandweberPanel());
list.add(new LandweberPositivityPanel());
list.add(new RichardsonLucyPanel());
list.add(new RichardsonLucyTVPanel());
list.add(new TikhonovMillerPanel());
list.add(new ICTMPanel());
list.add(new VanCittertPanel());
return list;
}
public static ArrayList<AbstractAlgorithmPanel> getAvailableSimulationAlgorithms() {
ArrayList<AbstractAlgorithmPanel> list = new ArrayList<AbstractAlgorithmPanel>();
list.add(new IdentityPanel());
list.add(new ConvolutionPanel());
list.add(new SimulationPanel());
list.add(new NonStabilizedDivisionPanel());
return list;
}
-
-
public static AbstractAlgorithm getDefaultAlgorithm() {
return new Identity();
}
public static AbstractAlgorithm createAlgorithm(String name) {
if (name == null)
return getDefaultAlgorithm();
String n = name.trim().toLowerCase();
int i = 0;
if (list.get(i++).isNamed(n))
return new RegularizedInverseFilter(0.1);
if (list.get(i++).isNamed(n))
return new TikhonovRegularizationInverseFilter(1.0);
if (list.get(i++).isNamed(n))
return new NaiveInverseFilter();
if (list.get(i++).isNamed(n))
return new FISTA(10, 1, 1, "Haar", 3);
if (list.get(i++).isNamed(n))
return new ISTA(10, 1, 1, "Haar", 3);
if (list.get(i++).isNamed(n))
return new Landweber(10, 1);
if (list.get(i++).isNamed(n))
return new LandweberPositivity(10, 1);
if (list.get(i++).isNamed(n))
return new RichardsonLucy(10);
if (list.get(i++).isNamed(n))
return new RichardsonLucyTV(10, 1);
if (list.get(i++).isNamed(n))
return new TikhonovMiller(10, 1, 0.1);
if (list.get(i++).isNamed(n))
return new ICTM(10, 1, 0.1);
if (list.get(i++).isNamed(n))
return new VanCittert(10, 1);
if (list.get(i++).isNamed(n))
return new Identity();
if (list.get(i++).isNamed(n))
return new Convolution();
if (list.get(i++).isNamed(n))
return new Simulation(0, 1, 0);
if (list.get(i++).isNamed(n))
return new NonStabilizedDivision();
return getDefaultAlgorithm();
}
public static AbstractAlgorithmPanel getPanel(String name) {
for (AbstractAlgorithmPanel panel : getAvailableAlgorithms()) {
if (panel.getShortname().equals(name.trim()))
return panel;
if (panel.getName().equals(name.trim()))
return panel;
}
return null;
}
public static ArrayList<String> getShortnames() {
ArrayList<String> list = new ArrayList<String>();
for (AbstractAlgorithmPanel algo : getAvailableAlgorithms()) {
list.add(algo.getShortname());
}
return list;
}
public static String getDocumentation(String name) {
for (AbstractAlgorithmPanel algo : getAvailableAlgorithms()) {
if (name.equals(algo.getName()))
return algo.getDocumentation();
}
return "Unknown Algorithm";
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index d7f08f1..e74c18e 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,333 +1,345 @@
/*
* 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.Timer;
import java.util.TimerTask;
import deconvolution.Deconvolution;
-import deconvolutionlab.Lab;
import deconvolutionlab.OutputCollection;
+import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.Monitors;
+import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFT;
import fft.FFT;
-import lab.system.SystemUsage;
import lab.tools.NumFormat;
import signal.Assessment;
import signal.ComplexSignal;
import signal.Constraint;
import signal.RealSignal;
-import signal.Signal;
public class Controller {
private int iterationsMax = 100;
private double timeMax = 1000;
private double residuMin = -1;
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 Constraint.Mode constraint = Constraint.Mode.NO;
private OutputCollection outs = null;
private String referenceName = "";
private String showstatsName = "";
private String savestatsName = "";
private RealSignal refImage;
private RealSignal prevImage;
private RealSignal x;
private Timer timer;
private AbstractFFT fft;
private String algo = "";
- private float statsInput[];
-
+ private TableStats tableStats;
+ private float[] statsInput;
+
private Monitors monitors = new Monitors();
public Controller() {
constraint = Constraint.Mode.NO;
doResidu = false;
doTime = false;
doReference = false;
doConstraint = false;
}
+ public void setTableStats(TableStats tableStats) {
+ this.tableStats = tableStats;
+ }
+
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
public void setAlgorithm(String algo) {
this.algo = algo;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
public int getIterationMax() {
return iterationsMax;
}
public void setIterationMax(int iterationsMax) {
this.iterationsMax = iterationsMax;
}
public void setTimeStop(double timeMax) {
this.doTime = true;
this.timeMax = timeMax * 1e9;
}
public void setResiduStop(double residuMin) {
this.doResidu = true;
this.residuMin = residuMin;
}
public void setReference(String referenceName) {
this.doReference = true;
this.referenceName = referenceName;
}
public void setConstraint(Constraint.Mode constraint) {
this.doConstraint = true;
this.constraint = constraint;
}
public void setOutputs(OutputCollection outs) {
this.outs = outs;
}
public void start(RealSignal x) {
this.x = x;
statsInput = x.getStats();
+ if (tableStats != null)
+ tableStats.nextStats(monitors, stats());
iterations = 0;
timer = new Timer();
timer.schedule(new Updater(), 0, 100);
timeStarting = System.nanoTime();
memoryStarting = SystemUsage.getHeapUsed();
- Signal.bytes = 0;
if (doConstraint && x != null)
Constraint.setModel(x);
if (doReference) {
- refImage = new Deconvolution("-image file " + referenceName).openImage();
+ refImage = new Deconvolution("Reference", "-image file " + referenceName).openImage();
if (refImage == null)
monitors.error("Impossible to load the reference image " + referenceName);
else
monitors.log("Reference image loaded");
}
if (outs != null)
outs.executeStarting(monitors, x, this);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
boolean out = outs == null ? false : outs.hasShow(iterations);
if (doConstraint || doResidu || doReference || out) {
if (fft == null)
fft = FFT.createDefaultFFT(monitors, X.nx, X.ny, X.nz);
- x = new RealSignal(X.nx, X.ny, X.nz, false);
- fft.inverse(X, x);
+ 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);
if (outs != null)
outs.executeIterative(monitors, x, this, iterations);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
double timeElapsed = getTimeNano();
boolean stopIter = (iterations >= iterationsMax);
boolean stopTime = doTime && (timeElapsed >= timeMax);
boolean stopResd = doResidu && (residu <= residuMin);
- monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed) + " Memory: " + NumFormat.bytes(Signal.bytes));
+ monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed));
+
+ if (tableStats != null)
+ tableStats.nextStats(monitors, stats());
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 + " > " + timeMax);
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);
+ if (tableStats != null)
+ tableStats.lastStats(monitors, stats());
+
if (outs != null)
outs.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 && constraint != null)
new Constraint(monitors).apply(x, constraint);
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));
}
}
- public String[] stats(String name) {
+ public String[] stats() {
+ if (tableStats == null)
+ return null;
float params[] = null;
if (x != null)
params = x.getStats();
String[] row = new String[15];
- row[0] = name;
+ row[0] = tableStats.getName();
row[1] = algo;
row[2] = "" + iterations;
row[3] = (params == null ? "-" : "" + params[0]);
row[4] = (params == null ? "-" : "" + params[1]);
row[5] = (params == null ? "-" : "" + params[2]);
row[6] = (params == null ? "-" : "" + params[3]);
row[7] = (params == null ? "-" : "" + params[4]);
row[8] = (params == null ? "-" : "" + params[5]);
row[9] = NumFormat.seconds(getTimeNano());
row[10] = NumFormat.bytes(SystemUsage.getHeapUsed());
row[11] = NumFormat.bytes(memoryPeak);
row[12] = doReference ? NumFormat.nice(psnr) : "n/a";
row[13] = doReference ? NumFormat.nice(snr) : "n/a";
row[14] = doResidu ? NumFormat.nice(residu) : "n/a";
return row;
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
public Constraint.Mode getConstraint() {
return constraint;
}
public String getReference() {
return doReference ? referenceName : "no ground-truth";
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
if (constraint == null)
return "null";
return constraint.name().toLowerCase();
}
public String getStoppingCriteriaAsString(AbstractAlgorithm algo) {
String stop = algo.isIterative() ? " iterations limit=" + getIterationMax() + ", " : "direct, ";
stop += doTime ? ", time limit=" + NumFormat.nice(timeMax * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
public float[] getStatsInput() {
return statsInput;
}
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());
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
index b98a130..3be1344 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
@@ -1,126 +1,126 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class RichardsonLucy extends AbstractAlgorithm implements Callable<RealSignal> {
public RichardsonLucy(int iter) {
super();
controller.setIterationMax(iter);
}
// x(k+1) = x(k) *. Hconj * ( y /. H x(k))
@Override
public RealSignal call() {
ComplexSignal H = fft.transform(h);
- ComplexSignal U = new ComplexSignal(y.nx, y.ny, y.nz);
+ ComplexSignal U = new ComplexSignal("RL-U", y.nx, y.ny, y.nz);
RealSignal x = y.duplicate();
RealSignal p = y.duplicate();
RealSignal u = y.duplicate();
while (!controller.ends(x)) {
fft.transform(x, U);
U.times(H);
fft.inverse(U, u);
Operations.divide(y, u, p);
fft.transform(p, U);
U.timesConjugate(H);
fft.inverse(U, u);
x.times(u);
}
return x;
}
@Override
public String getName() {
return "Richardson-Lucy";
}
@Override
public String getShortname() {
return "RL";
}
@Override
public boolean isRegularized() {
return false;
}
@Override
public boolean isStepControllable() {
return false;
}
@Override
public boolean isIterative() {
return true;
}
@Override
public boolean isWaveletsBased() {
return false;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
controller.setIterationMax((int) Math.round(params[0]));
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10 };
}
@Override
public double[] getParameters() {
return new double[] { controller.getIterationMax() };
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java
index 35eebd6..f16801a 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java
@@ -1,219 +1,219 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class RichardsonLucyTV extends AbstractAlgorithm implements Callable<RealSignal> {
private double lambda = 0.1;
public RichardsonLucyTV(int iter, double lambda) {
super();
controller.setIterationMax(iter);
this.lambda = lambda;
}
// x(k+1) = x(k) *. Hconj * ( y /. H x(k))
@Override
public RealSignal call() {
ComplexSignal H = fft.transform(h);
- ComplexSignal U = new ComplexSignal(y.nx, y.ny, y.nz);
+ ComplexSignal U = new ComplexSignal("RLTV-U",y.nx, y.ny, y.nz);
RealSignal x = y.duplicate();
RealSignal gx = y.duplicate();
RealSignal gy = y.duplicate();
RealSignal gz = y.duplicate();
RealSignal ggx = y.duplicate();
RealSignal ggy = y.duplicate();
RealSignal ggz = y.duplicate();
RealSignal u = gx; // resued memory
RealSignal p = gy; // resued memory
RealSignal tv = gz; // resued memory
while(!controller.ends(x)) {
gradientX(x, gx);
gradientY(x, gy);
gradientZ(x, gz);
normalize(gx, gy, gz);
gradientX(gx, ggx);
gradientY(gy, ggy);
gradientZ(gz, ggz);
compute((float)lambda, ggx, ggy, ggz, tv);
fft.transform(x, U);
U.times(H);
fft.inverse(U, u);
Operations.divide(y, u, p);
fft.transform(p, U);
U.timesConjugate(H);
fft.inverse(U, u);
x.times(u);
x.times(tv);
}
return x;
}
private void compute(float lambda, RealSignal gx, RealSignal gy, RealSignal gz, RealSignal tv) {
int nxy = gx.nx * gy.ny;
for(int k=0; k<gx.nz; k++)
for(int i=0; i< nxy; i++) {
double dx = gx.data[k][i];
double dy = gy.data[k][i];
double dz = gz.data[k][i];
tv.data[k][i] = (float)(1.0 / ( (dx+dy+dz) * lambda + 1.0));
}
//Log.info("Norm TV "+ Math.sqrt(norm));
}
public void gradientX(RealSignal signal, RealSignal output) {
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
for(int k=0; k<nz; k++)
for(int j=0; j<ny; j++)
for(int i=0; i<nx-1; i++) {
int index = i + signal.nx*j;
output.data[k][index] = signal.data[k][index] - signal.data[k][index+1];
}
}
public void gradientY(RealSignal signal, RealSignal output) {
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
for(int k=0; k<nz; k++)
for(int j=0; j<ny-1; j++)
for(int i=0; i<nx; i++) {
int index = i + signal.nx*j;
output.data[k][index] = signal.data[k][index] - signal.data[k][index+nx];
}
}
public void gradientZ(RealSignal signal, RealSignal output) {
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
for(int k=0; k<nz-1; k++)
for(int j=0; j<ny; j++)
for(int i=0; i<nx; i++) {
int index = i + signal.nx*j;
output.data[k][index] = signal.data[k][index] - signal.data[k+1][index];
}
}
public void normalize(RealSignal x, RealSignal y, RealSignal z) {
int nx = x.nx;
int ny = y.ny;
int nz = z.nz;
- float e = (float)RealSignal.epsilon;
+ float e = (float) Operations.epsilon;
for(int k=0; k<nz; k++)
for(int i=0; i<nx*ny; i++) {
double norm = Math.sqrt(x.data[k][i] * x.data[k][i] + y.data[k][i] * y.data[k][i] + z.data[k][i] * z.data[k][i]);
if (norm < e) {
x.data[k][i] = e;
y.data[k][i] = e;
z.data[k][i] = e;
}
else {
x.data[k][i] /= norm;
y.data[k][i] /= norm;
z.data[k][i] /= norm;
}
}
}
@Override
public String getName() {
return "Richardson-Lucy TV";
}
@Override
public String getShortname() {
return "RLTV";
}
@Override
public boolean isRegularized() {
return true;
}
@Override
public boolean isStepControllable() {
return true;
}
@Override
public boolean isIterative() {
return true;
}
@Override
public boolean isWaveletsBased() {
return false;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
controller.setIterationMax((int)Math.round(params[0]));
if (params.length > 1)
lambda = (float)params[1];
}
@Override
public double[] getDefaultParameters() {
return new double[] {10, 0.1};
}
@Override
public double[] getParameters() {
return new double[] {controller.getIterationMax(), lambda};
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return 0.0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java b/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
index 527cfeb..5fa917c 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
@@ -1,150 +1,150 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import lab.tools.PsRandom;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class Simulation extends AbstractAlgorithm implements Callable<RealSignal> {
private static PsRandom rand = new PsRandom(1234);
private double mean = 0.0;
private double stdev = 10.0;
private double poisson = 0.0;
public Simulation(double mean, double stdev, double poisson) {
super();
this.mean = mean;
this.stdev = stdev;
this.poisson = poisson;
}
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = Operations.multiply(H, Y);
RealSignal x = fft.inverse(X);
gaussian(x, mean, stdev);
poisson(x, poisson);
return x;
}
public void gaussian(RealSignal x, double mean, double sd) {
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
slice[j] += (float) rand.nextGaussian(mean, sd);
}
}
public void poisson(RealSignal x, double factor) {
- if (factor < RealSignal.epsilon)
+ if (factor < Operations.epsilon)
return;
double f = 1.0/(factor);
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
- if (slice[j] > RealSignal.epsilon) {
+ if (slice[j] > Operations.epsilon) {
slice[j] = (float)(rand.nextPoissonian(f*(slice[j])) * factor);
}
}
}
@Override
public String getName() {
return "Simulation";
}
@Override
public String getShortname() {
return "SIM";
}
@Override
public boolean isRegularized() {
return false;
}
@Override
public boolean isStepControllable() {
return false;
}
@Override
public boolean isIterative() {
return false;
}
@Override
public boolean isWaveletsBased() {
return false;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
mean = params[0];
if (params.length > 1)
stdev = params[1];
if (params.length > 2)
poisson = params[2];
}
@Override
public double[] getDefaultParameters() {
return new double[] {0, 1, 0};
}
@Override
public double[] getParameters() {
return new double[] {mean, stdev, poisson};
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilter.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilter.java
index 4528b8d..9f534fe 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilter.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilter.java
@@ -1,139 +1,140 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
+import signal.Operations;
import signal.RealSignal;
public class TikhonovRegularizationInverseFilter extends AbstractAlgorithm implements Callable<RealSignal> {
private double lambda = 0.1;
public TikhonovRegularizationInverseFilter(double lambda) {
super();
this.lambda = lambda;
}
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = compute(Y, H);
RealSignal x = fft.inverse(X);
return x;
}
private ComplexSignal compute(ComplexSignal Y, ComplexSignal H) {
int nx = H.nx;
int ny = H.ny;
int nz = H.nz;
int nxy = nx * ny*2;
double ya, yb, ha, hb, fa, fb, mag, ta, tb;
- double epsilon2 = RealSignal.epsilon * RealSignal.epsilon;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ double epsilon2 = Operations.epsilon * Operations.epsilon;
+ ComplexSignal result = new ComplexSignal("TM", nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
ha = H.data[k][i];
hb = H.data[k][i+1];
ya = Y.data[k][i];
yb = Y.data[k][i+1];
fa = ha*ha - hb*hb + lambda;
fb = 2f * ha * hb;
mag = fa*fa + fb*fb;
ta = (ha*fa + hb*fb) / (mag >= epsilon2 ? mag : epsilon2);
tb = (hb*fa - ha*fb) / (mag >= epsilon2 ? mag : epsilon2);
result.data[k][i] = (float)(ya*ta - yb*tb);
result.data[k][i+1] = (float)(ya*tb + ta*yb);
}
return result;
}
@Override
public String getName() {
return "Tikhonov Regularization";
}
@Override
public String getShortname() {
return "TRIF";
}
@Override
public boolean isRegularized() {
return true;
}
@Override
public boolean isStepControllable() {
return false;
}
@Override
public boolean isIterative() {
return false;
}
@Override
public boolean isWaveletsBased() {
return false;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
lambda = (float)params[0];
}
@Override
public double[] getDefaultParameters() {
return new double[] {0.1};
}
@Override
public double[] getParameters() {
return new double[] {lambda};
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return 0.0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java b/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java
new file mode 100644
index 0000000..af73615
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java
@@ -0,0 +1,31 @@
+package deconvolution.modules;
+
+import javax.swing.JFrame;
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+
+public abstract class AbstractDModule {
+
+ protected Deconvolution deconvolution;
+ protected JSplitPane split;
+
+ public AbstractDModule(Deconvolution deconvolution) {
+ this.deconvolution = deconvolution;
+ }
+
+ public JSplitPane getPane() {
+ return split;
+ }
+
+ public void show(String name) {
+ JFrame frame = new JFrame(name);
+ update();
+ frame.getContentPane().add(split);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+ public abstract void update();
+ public abstract String getName();
+}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
new file mode 100644
index 0000000..97cc404
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
@@ -0,0 +1,45 @@
+package deconvolution.modules;
+
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+import lab.component.CustomizedTable;
+import lab.component.JPanelImage;
+
+public class AlgorithmDModule extends AbstractDModule {
+
+ private JPanelImage pnImage;
+ private CustomizedTable table;
+
+
+ public AlgorithmDModule(Deconvolution deconvolution) {
+ super(deconvolution);
+ pnImage = new JPanelImage();
+ table = new CustomizedTable(new String[] { "Features", "Values" }, false);
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnImage);
+ update();
+ }
+
+ public void update() {
+ if (pnImage == null)
+ return;
+ if (table == null)
+ return;
+ table.removeRows();
+ for (String[] feature : deconvolution.checkAlgo())
+ table.append(feature);
+ split.setDividerLocation(0.5);
+ split.repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "Algorithm";
+ }
+
+
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
new file mode 100644
index 0000000..10bc92a
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
@@ -0,0 +1,54 @@
+package deconvolution.modules;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+import lab.component.CustomizedTable;
+import lab.component.JPanelImage;
+import signal.RealSignal;
+
+public class ImageDModule extends AbstractDModule {
+
+ private JPanelImage pnImage;
+ private CustomizedTable table;
+ private BufferedImage img;
+
+ public ImageDModule(Deconvolution deconvolution) {
+ super(deconvolution);
+ pnImage = new JPanelImage();
+ table = new CustomizedTable(new String[] { "Features", "Values" }, false);
+ pnImage.setPreferredSize(new Dimension(300, 300));
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 200), pnImage);
+
+ update();
+ }
+
+ public void update() {
+ if (pnImage == null)
+ return;
+ if (table == null)
+ return;
+
+ RealSignal signal = deconvolution.openImage();
+ table.removeRows();
+ if (signal == null) {
+ table.append(new String[] {"ERROR", "No open image"});
+ return;
+ }
+ img = signal.createPreviewMIPZ();
+ pnImage.setImage(img);
+ for (String[] feature : deconvolution.checkImage())
+ table.append(feature);
+ split.setDividerLocation(0.5);
+ }
+
+ @Override
+ public String getName() {
+ return "Image";
+ }
+
+
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
new file mode 100644
index 0000000..ecaa0e9
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
@@ -0,0 +1,48 @@
+package deconvolution.modules;
+
+import java.awt.image.BufferedImage;
+
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+import lab.component.CustomizedTable;
+import lab.component.JPanelImage;
+import signal.RealSignal;
+
+public class PSFDModule extends AbstractDModule {
+
+ private JPanelImage pnImage;
+ private CustomizedTable table;
+
+ public PSFDModule(Deconvolution deconvolution) {
+ super(deconvolution);
+ pnImage = new JPanelImage();
+ table = new CustomizedTable(new String[] { "Features", "Values" }, false);
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnImage);
+ }
+
+ public void update() {
+ if (pnImage == null)
+ return;
+ if (table == null)
+ return;
+ RealSignal signal = deconvolution.openPSF();
+ table.removeRows();
+ if (signal == null) {
+ table.append(new String[] {"ERROR", "No open image"});
+ return;
+ }
+ BufferedImage img = signal.createPreviewMIPZ();
+ pnImage.setImage(img);
+ for (String[] feature : deconvolution.checkPSF())
+ table.append(feature);
+ split.setDividerLocation(0.5);
+ split.repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "PSF";
+ }
+
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
new file mode 100644
index 0000000..4b343f8
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
@@ -0,0 +1,70 @@
+package deconvolution.modules;
+
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JSplitPane;
+import javax.swing.text.BadLocationException;
+
+import deconvolution.Deconvolution;
+import lab.component.CustomizedTable;
+import lab.component.HTMLPane;
+
+public class RecapDModule extends AbstractDModule implements KeyListener {
+
+ private HTMLPane pnCommand;
+ private CustomizedTable table;
+
+ public RecapDModule(Deconvolution deconvolution) {
+ super(deconvolution);
+ // Panel command
+ pnCommand = new HTMLPane("Monaco", "#10FF10", "100020", 100, 100);
+ pnCommand.append("p", deconvolution.getCommand());
+ pnCommand.setEditable(true);
+ pnCommand.addKeyListener(this);
+ table = new CustomizedTable(new String[] { "Features", "Values" }, false);
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnCommand.getPane());
+ update();
+ }
+
+ public void update() {
+ if (table == null)
+ return;
+ split.setDividerLocation(0.5);
+ split.repaint();
+ }
+
+ public String getCommand() {
+ return pnCommand.getText();
+ }
+ @Override
+ public String getName() {
+ return "Command";
+ }
+
+ @Override
+ public void keyTyped(KeyEvent e) {
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ try {
+ int len = pnCommand.getDocument().getLength();
+ String command = pnCommand.getDocument().getText(0, len);
+ deconvolution.setCommand(command);
+ table.removeRows();
+ for (String[] feature : deconvolution.recap())
+ table.append(feature);
+ }
+ catch (BadLocationException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
new file mode 100644
index 0000000..eecfe06
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
@@ -0,0 +1,42 @@
+package deconvolution.modules;
+
+import java.awt.image.BufferedImage;
+
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+import lab.component.CustomizedTable;
+import lab.component.JPanelImage;
+import signal.RealSignal;
+
+public class ReportDModule extends AbstractDModule {
+
+ private JPanelImage pnImage;
+ private CustomizedTable table;
+
+ public ReportDModule(Deconvolution deconvolution) {
+ super(deconvolution);
+ pnImage = new JPanelImage();
+ table = new CustomizedTable(new String[] { "Features", "Values" }, false);
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnImage);
+ }
+
+ public void update() {
+ if (pnImage == null)
+ return;
+ if (table == null)
+ return;
+ table.removeRows();
+ for (String[] feature : deconvolution.getDeconvolutionReports())
+ table.append(feature);
+ split.setDividerLocation(0.5);
+ split.repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "Report";
+ }
+
+
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Config.java b/DeconvolutionLab2/src/deconvolutionlab/Config.java
index 94b06a1..9c2934c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Config.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Config.java
@@ -1,349 +1,385 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
+import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Properties;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
+import deconvolutionlab.monitor.Monitors;
import lab.component.CustomizedTable;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolutionlab.monitor.Monitors;
public class Config {
private static String project = Constants.name;
private static String filename;
private static HashMap<String, Object> inits;
- private static HashMap<String, JComponent> components;
- private static HashMap<String, CustomizedTable> tables;
- private static HashMap<String, JDialog> dialogs;
+ private static HashMap<String, JComponent> components = new HashMap<String, JComponent>();
+ private static HashMap<String, CustomizedTable> tables = new HashMap<String, CustomizedTable>();;
+ private static HashMap<String, JDialog> dialogs = new HashMap<String, JDialog>();
private static Monitors monitors = Monitors.createDefaultMonitor();
- public static Config getInstance(String filename) {
+ public static Config init(String filename) {
Config.filename = filename;
Config.inits = new HashMap<String, Object>();
Config.components = new HashMap<String, JComponent>();
Config.tables = new HashMap<String, CustomizedTable>();
Config.dialogs = new HashMap<String, JDialog>();
return new Config();
}
public static void setFilename(String filename) {
Config.filename = filename;
}
public static String getFilename() {
return filename;
}
public static boolean check() {
File file = new File(Config.filename);
- if (!file.exists()) return false;
- if (file.isDirectory()) return false;
+ if (!file.exists())
+ return false;
+ if (file.isDirectory())
+ return false;
return true;
}
public static void register(String module, String key, JComponent component, Object init) {
- if (component == null) return;
+ if (component == null)
+ return;
components.put(module + "." + key, component);
inits.put(module + "." + key, init);
setValue(key, init);
}
public static void registerTable(String module, String key, CustomizedTable table) {
- if (table == null) return;
+ if (table == null)
+ return;
tables.put(module + "." + key, table);
}
public static void registerFrame(String module, String key, JDialog dialog) {
- if (dialog == null) return;
+ if (dialog == null)
+ return;
dialogs.put(module + "." + key, dialog);
}
public static String getAsString(String key) {
Object object = getValue(key);
if (object instanceof String)
return ((String) object);
else if (object instanceof Double)
return ((Double) object).toString();
else if (object instanceof Integer)
return ((Integer) object).toString();
- else if (object instanceof Boolean) return ((Boolean) object).toString();
+ else if (object instanceof Boolean)
+ return ((Boolean) object).toString();
return null;
}
public static double getAsDouble(String key) {
Object object = getValue(key);
if (object instanceof Double)
return ((Double) object).doubleValue();
- else if (object instanceof Integer) return ((Integer) object).intValue();
+ else if (object instanceof Integer)
+ return ((Integer) object).intValue();
return 0;
}
private static void setValue(String key, Object value) {
JComponent component = components.get(key);
- if (component == null) return;
+ if (component == null)
+ return;
- if (value == null) value = inits.get(key);
+ if (value == null)
+ value = inits.get(key);
if (component instanceof JTextField) {
JTextField txt = (JTextField) component;
txt.setText(value.toString());
}
else if (component instanceof JComboBox) {
JComboBox<String> cmb = (JComboBox<String>) component;
cmb.setSelectedItem(value.toString());
}
else if (component instanceof JLabel) {
JLabel lbl = (JLabel) component;
lbl.setText(value.toString());
}
else if (component instanceof JCheckBox) {
JCheckBox chk = (JCheckBox) component;
chk.setSelected(value.toString().equals("true"));
}
else if (component instanceof SpinnerRangeDouble) {
SpinnerRangeDouble spn = (SpinnerRangeDouble) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.doubleValue());
}
else if (value instanceof String) {
try {
spn.set(Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof SpinnerRangeInteger) {
SpinnerRangeInteger spn = (SpinnerRangeInteger) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.intValue());
}
else if (value instanceof String) {
try {
spn.set((int) Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
String source = value.toString();
for (int i = 0; i < tab.getTabCount(); i++)
- if (source.equals(tab.getTitleAt(i))) tab.setSelectedIndex(i);
+ if (source.equals(tab.getTitleAt(i)))
+ tab.setSelectedIndex(i);
}
}
private static Object getValue(String key) {
JComponent component = components.get(key);
- if (component == null) return inits.get(key);
+ if (component == null)
+ return inits.get(key);
if (component instanceof JTextField)
return ((JTextField) component).getText();
else if (component instanceof JComboBox)
return (String) ((JComboBox) component).getSelectedItem();
else if (component instanceof JCheckBox)
return ((JCheckBox) component).isSelected() ? "true" : "false";
else if (component instanceof JLabel)
return ((JLabel) component).getText();
else if (component instanceof SpinnerRangeDouble)
return new Double(((SpinnerRangeDouble) component).get());
else if (component instanceof SpinnerRangeInteger)
return new Integer(((SpinnerRangeInteger) component).get());
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
return tab.getTitleAt(tab.getSelectedIndex());
}
return inits.get(key);
}
public static void load() {
Properties props = new Properties();
try {
FileInputStream in = new FileInputStream(filename);
props.load(in);
}
catch (Exception e) {
props = new Properties();
}
for (String key : components.keySet()) {
Object init = inits.get(key);
String value = props.getProperty(key, init.toString());
setValue(key, value);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
for (int i = 0; i < 100; i++) {
String keyrow = key + ".row" + i;
String value = props.getProperty(keyrow, "???");
- if (!value.equals("???")) table.append(value.split(";"));
+ if (!value.equals("???"))
+ table.append(value.split(";"));
}
String selected[] = props.getProperty(key + ".selected", "???").split(";");
int ncol = Math.min(table.getColumnCount(), selected.length) - 1;
for (int i = 0; i < table.getRowCount(); i++) {
int n = 0;
- for (int j = 0; j < ncol; j++)
+ for (int j = 0; j < ncol; j++) {
n += table.getCell(i, j).trim().equals(selected[j].trim()) ? 1 : 0;
- if (n == ncol) table.setRowSelectionInterval(i, i);
+ }
+ if (n == ncol)
+ table.setRowSelectionInterval(i, i);
}
}
for (String key : dialogs.keySet()) {
int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "" + 0), 0);
int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "" + 0), 0);
int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "" + 400), 400);
int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "" + 400), 400);
dialogs.get(key).setSize(w, h);
dialogs.get(key).setLocation(x, y);
}
monitors.log("Load Config from " + filename + " (" + components.size() + " items)");
}
public static boolean store() {
Properties props = new Properties();
for (String key : components.keySet()) {
String s = getAsString(key);
- if (s != null) props.setProperty(key, s);
+ if (s != null)
+ props.setProperty(key, s);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
int nrows = table.getRowCount();
for (int row = 0; row < nrows; row++)
props.setProperty(key + ".row" + row, table.getRowCSV(row, ";"));
int row = table.getSelectedRow();
- if (row >= 0) props.setProperty(key + ".selected", table.getRowCSV(row, ";"));
+ if (row >= 0)
+ props.setProperty(key + ".selected", table.getRowCSV(row, ";"));
}
for (String key : dialogs.keySet()) {
JDialog dialog = dialogs.get(key);
props.setProperty(key + ".location.x", "" + dialog.getLocation().x);
props.setProperty(key + ".location.y", "" + dialog.getLocation().y);
props.setProperty(key + ".location.w", "" + dialog.getSize().width);
props.setProperty(key + ".location.h", "" + dialog.getSize().height);
}
try {
FileOutputStream out = new FileOutputStream(filename);
props.store(out, project);
}
catch (Exception e) {
monitors.error("Store Config to " + filename + " (" + components.size() + " items)");
return false;
}
monitors.log("Store Config to " + filename + " (" + components.size() + " items)");
File file = new File(filename);
if (file.exists()) {
String line = "";
try {
BufferedReader br = new BufferedReader(new FileReader(filename));
ArrayList<String> keys = new ArrayList<String>();
ArrayList<String> headers = new ArrayList<String>();
line = br.readLine();
- if (line != null) if (!line.startsWith("#"))
- keys.add(line);
- else
- headers.add(line);
+ if (line != null)
+ if (!line.startsWith("#"))
+ keys.add(line);
+ else
+ headers.add(line);
while (line != null) {
if (!line.startsWith("#"))
keys.add(line);
else
headers.add(line);
line = br.readLine();
}
br.close();
Collections.sort(keys);
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
for (String ln : headers)
bw.write(ln + "\n");
for (String ln : keys)
bw.write(ln + "\n");
bw.close();
}
catch (Exception ex) {
monitors.error("ERROR " + filename + " line: " + line);
return false;
}
}
return true;
}
public static ArrayList<String> list() {
ArrayList<String> list = new ArrayList<String>();
for (String key : components.keySet()) {
list.add(key + " = " + getValue(key));
}
return list;
}
public static void print() {
ArrayList<String> list = list();
System.out.println("--");
for (String line : list)
System.out.println(line);
System.out.println("--");
}
public static void printInit() {
for (String key : inits.keySet()) {
Object object = inits.get(key);
- if (object != null) System.out.println("Default " + key + " = " + (object.toString()));
+ if (object != null)
+ System.out.println("Default " + key + " = " + (object.toString()));
}
}
+
+ public static Rectangle getDialog(String key) {
+ Properties props = new Properties();
+ try {
+ FileInputStream in = new FileInputStream(filename);
+ props.load(in);
+ }
+ catch (Exception e) {
+ props = new Properties();
+ }
+
+ int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "-1"), -1);
+ int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "-1"), -1);
+ int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "-1"), -1);
+ int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "-1"), -1);
+ return new Rectangle(x, y, w, h);
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/ImageSelector.java b/DeconvolutionLab2/src/deconvolutionlab/ImageSelector.java
deleted file mode 100644
index 366179f..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/ImageSelector.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package deconvolutionlab;
-
-import imagej.IJImageSelector;
-
-public class ImageSelector {
-
- private PlatformImageSelector pis;
-
- public ImageSelector(Platform platform) {
-
- if (platform == Platform.IMAGEJ)
- pis = new IJImageSelector();
-
- else if (platform == Platform.ICY)
- pis = new plugins.sage.deconvolutionlab.IcyImageSelector();
- else
- pis = new LabImageSelector();
- }
-
- public PlatformImageSelector getImageSelector() {
- return pis;
- }
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/PlatformImager.java b/DeconvolutionLab2/src/deconvolutionlab/Imaging.java
similarity index 62%
rename from DeconvolutionLab2/src/deconvolutionlab/PlatformImager.java
rename to DeconvolutionLab2/src/deconvolutionlab/Imaging.java
index 5f2c155..5947a2d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/PlatformImager.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Imaging.java
@@ -1,69 +1,97 @@
/*
* 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.util.ArrayList;
+
+import javax.swing.JDialog;
+
+import imagej.IJImager;
+import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-import deconvolutionlab.monitor.Monitors;
-public abstract class PlatformImager {
-
+public abstract class Imaging {
+
+ public enum Type {FLOAT, SHORT, BYTE};
+ public enum Platform {IMAGEJ, ICY, STANDALONE, MATLAB};
+
public class ContainerImage {
public Object object;
}
-
- public enum Type {FLOAT, SHORT, BYTE};
-
+
+ public abstract void setVisible(JDialog dialog, boolean modal);
+ public abstract Platform getPlatform();
public abstract RealSignal create();
public abstract RealSignal create(String name);
-
public abstract ContainerImage createContainer(String title);
-
public abstract void show(ComplexSignal signal, String title, ComplexComponent complex);
- public abstract void show(ComplexSignal signal, String title);
-
- public abstract void append(ContainerImage container, RealSignal signal, String title);
+ public abstract void show(RealSignal signal, String title, Imaging.Type type, int z);
public abstract void append(ContainerImage container, RealSignal signal, String title, Type type);
-
- public abstract void show(RealSignal signal, String title);
- public abstract void show(RealSignal signal, String title, Type type);
- public abstract void show(RealSignal signal, String title, PlatformImager.Type type, int z);
-
- public abstract void save(RealSignal signal, String filename);
public abstract void save(RealSignal signal, String filename, Type type);
-
public abstract RealSignal open(String filename);
-
public abstract String getName();
+ public abstract String getSelectedImage();
+ public abstract boolean isSelectable();
+
+
+ public static ArrayList<Imaging> getImagings() {
+ ArrayList<Imaging> imagings = new ArrayList<Imaging>();
+ try {
+ Imaging imaging = new IJImager();
+ if (imaging != null) {
+ imagings.add(imaging);
+ }
+ }
+ catch (NoClassDefFoundError ex) {
+ }
+ try {
+ Imaging imaging = new IcyImager();
+ if (imaging != null) {
+ imagings.add(imaging);
+ }
+ }
+ catch (NoClassDefFoundError ex) {
+ }
+ return imagings;
+ }
+
+ public static ArrayList<String> getImagingByName() {
+ ArrayList<Imaging> imagings = getImagings();
+ ArrayList<String> names = new ArrayList<String>();
+ for (Imaging imaging : imagings)
+ names.add(imaging.getName());
+ return names;
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index 98222ea..2637431 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,362 +1,303 @@
/*
* 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.JFrame;
+import javax.swing.JDialog;
-import deconvolution.algorithm.Controller;
-import deconvolutionlab.PlatformImager.ContainerImage;
+import deconvolutionlab.Imaging.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import imagej.IJImager;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
import lab.tools.NumFormat;
import lab.tools.WebBrowser;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.Sphere;
public class Lab {
- private static PlatformImager imager;
- private static Lab instance = null;
- private static Platform platform = Platform.IMAGEJ;
-
- private static CustomizedTable tableStats = null;
- private static JFrame frameStats = null;
+ private static Imaging imaging;
static {
- imager = new IJImager();
- createStats();
+ imaging = new IJImager();
+ Config.init(System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
- private static void createStats() {
-
- ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
- columns.add(new CustomizedColumn("Name", String.class, 100, false));
- columns.add(new CustomizedColumn("Algorithm", String.class, 100, false));
- columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
- columns.add(new CustomizedColumn("Image Mean", String.class, 100, false));
- columns.add(new CustomizedColumn("Image Minimum", String.class, 100, false));
- columns.add(new CustomizedColumn("Image Maximum", String.class, 100, false));
- columns.add(new CustomizedColumn("Image Stdev", String.class, 100, false));
- columns.add(new CustomizedColumn("Image norm1", String.class, 100, false));
- columns.add(new CustomizedColumn("Image norm2", String.class, 100, false));
- columns.add(new CustomizedColumn("Time", String.class, 100, false));
- columns.add(new CustomizedColumn("Memory", String.class, 100, false));
- columns.add(new CustomizedColumn("Peak", String.class, 100, false));
- columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
- columns.add(new CustomizedColumn("SNR", String.class, 100, false));
- columns.add(new CustomizedColumn("Residu", String.class, 100, false));
- tableStats = new CustomizedTable(columns, true);
-
+ public static Imaging.Platform getPlatform() {
+ return imaging.getPlatform();
}
- public static Platform getPlatform() {
- return platform;
+ public static void init(Imaging.Platform p) {
+ init(p, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
- public static void getInstance(Platform p) {
- platform = p;
- if (instance == null) {
- instance = new Lab();
- switch (p) {
- case STANDALONE:
- imager = new LabImager();
- break;
- case IMAGEJ:
- imager = new IJImager();
- break;
- case ICY:
- imager = new IcyImager();
- break;
- default:
- imager = new LabImager();
- break;
- }
+ public static void init(Imaging.Platform platform, String config) {
+ switch (platform) {
+ case IMAGEJ:
+ imaging = new IJImager();
+ break;
+ case ICY:
+ imaging = new IcyImager();
+ break;
+ default:
+ imaging = new IJImager();
+ break;
}
+
+ Config.init(System.getProperty("user.dir")+File.separator+"DeconvolutionLab2.config");
}
public static void help() {
WebBrowser.open(Constants.url);
}
public static void checkFFT(Monitors monitors) {
ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
for (int k = 1; k <= 3; k++)
for (AbstractFFTLibrary library : libraries) {
RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
double chrono = System.nanoTime();
AbstractFFT fft = 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(fft.getName() + " Test " + k);
monitors.log("\t residu of reconstruction: " + residu);
monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
}
}
-
+
public static ContainerImage createContainer(Monitors monitors, String title) {
monitors.log("Create Live Real Signal " + title);
- return imager.createContainer(title);
+ return imaging.createContainer(title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title) {
- imager.append(container, signal, title);
+ imaging.append(container, signal, title, Imaging.Type.FLOAT);
monitors.log("Add Live Real Signal " + title);
}
- public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, PlatformImager.Type type) {
- imager.append(container, signal, title, type);
+ public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imaging.Type type) {
+ imaging.append(container, signal, title, type);
monitors.log("Add Live Real Signal " + title);
}
public static void show(Monitors monitors, ComplexSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
- imager.show(signal, title);
+ imaging.show(signal, title, ComplexComponent.MODULE);
}
public static void show(Monitors monitors, ComplexSignal signal, String title, ComplexComponent complex) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
- imager.show(signal, title, complex);
+ imaging.show(signal, title, complex);
}
- public static void show(Monitors monitors, RealSignal signal, String 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);
- imager.show(signal, title);
+ imaging.show(signal, title, Imaging.Type.FLOAT, signal.nz / 2);
}
- public static void show(Monitors monitors, RealSignal signal, String title, PlatformImager.Type type) {
+ public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
- imager.show(signal, title, type);
+ imaging.show(signal, title, type, signal.nz / 2);
}
- public static void show(Monitors monitors, RealSignal signal, String title, PlatformImager.Type type, int z) {
+ public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
- imager.show(signal, title, type);
+ imaging.show(signal, title, type, z);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
- imager.save(signal, filename);
+ imaging.save(signal, filename, Imaging.Type.FLOAT);
monitors.log("Save Real Signal " + filename);
}
- public static void save(Monitors monitors, RealSignal signal, String filename, PlatformImager.Type type) {
- imager.save(signal, filename, type);
+ public static void save(Monitors monitors, RealSignal signal, String filename, Imaging.Type type) {
+ imaging.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
- public static void firstStats(Monitors monitors, String name, String[] stats, boolean show, boolean save) {
- if (stats == null)
- return;
-
- Lab.createStats();
-
- if (show) {
- frameStats = new JFrame(name);
- frameStats.getContentPane().add(tableStats.getPane(600, 200));
- frameStats.pack();
- frameStats.setVisible(true);
- }
- }
-
- public static void nextStats(Monitors monitors, String name, String[] stats, boolean show, boolean save) {
- if (tableStats == null)
- return;
- if (stats == null)
- return;
- tableStats.append(stats);
- monitors.log("Stats " + name);
- if (show && frameStats != null) {
- if (!frameStats.isVisible())
- frameStats.setVisible(true);
- frameStats.requestFocus();
- }
- }
-
- public static void lastStats(Monitors monitors, String filename, String[] stats, boolean show, boolean save) {
- if (stats == null)
- return;
- if (tableStats == null)
- return;
- if (save) {
- monitors.log("Stats " + filename);
- tableStats.saveCSV(filename + ".csv");
- }
- }
-
public static RealSignal open(Monitors monitors, String filename) {
- RealSignal signal = imager.open(filename);
+ RealSignal signal = imaging.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
public static RealSignal openDir(Monitors monitors, String path) {
String parts[] = path.split(" pattern ");
String dirname = path;
String regex = "";
if (parts.length == 2) {
dirname = parts[0].trim();
regex = parts[1].trim();
}
File file = new File(dirname + File.separator);
if (!file.isDirectory()) {
monitors.error("Dir " + dirname + " is not a directory.");
return null;
}
String[] list = file.list();
ArrayList<RealSignal> slices = new ArrayList<RealSignal>();
int nx = 0;
int ny = 0;
Pattern pattern = Pattern.compile(regex);
for (String filename : list) {
if (pattern.matcher(filename).find()) {
- RealSignal slice = imager.open(dirname + File.separator + filename);
+ 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(nx, ny, nz);
+ 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(Monitors monitors, RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
- imager.show(signal.createOrthoview(hx, hy, hz), title);
+ imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.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;
- imager.show(signal.createOrthoview(hx, hy, hz), title);
+ imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.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;
}
- imager.show(signal.createMIP(), title);
+ imaging.show(signal.createMIP(), title, Imaging.Type.FLOAT, 0);
}
public static void showMontage(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Montage " + title + " this image does not exist.");
return;
}
- imager.show(signal.createMontage(), title);
+ imaging.show(signal.createMontage(), title, Imaging.Type.FLOAT, 0);
}
public static RealSignal create(Monitors monitors, String name) {
- RealSignal signal = imager.create(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 = imager.create();
+ 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 PlatformImager getImager() {
- return imager;
+ public static Imaging 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;
+ imaging.setVisible(dialog, modal);
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java b/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java
deleted file mode 100644
index cd5d8c9..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package deconvolutionlab;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.DefaultListModel;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.ListSelectionModel;
-
-import ij.ImagePlus;
-import ij.WindowManager;
-import ij.gui.GUI;
-
-public class LabImageSelector extends PlatformImageSelector {
-
- @Override
- public boolean isSelectable() {
- return true;
- }
-
- @Override
- public String getSelectedImage() {
- Dialog dialog = new Dialog();
- dialog.setVisible(true);
- if (dialog.wasCancel())
- return "";
- return dialog.getName();
- }
-
- public class Dialog extends JDialog implements ActionListener, WindowListener {
-
- private JList<String> list;
- private JButton bnOK = new JButton("OK");
- private JButton bnCancel = new JButton("Cancel");
- private boolean cancel = false;
- private String name = "";
-
- public Dialog() {
- super(new JFrame(), "Image Selection");
-
- JPanel bn = new JPanel(new GridLayout(1, 2));
- bn.add(bnCancel);
- bn.add(bnOK);
-
- JPanel panel = new JPanel(new BorderLayout());
- int[] ids = WindowManager.getIDList();
-
- if (ids != null) {
- DefaultListModel listModel = new DefaultListModel();
- list = new JList(listModel);
- for (int id : ids) {
- ImagePlus idp = WindowManager.getImage(id);
- if (idp != null) {
- ((DefaultListModel) listModel).addElement(idp.getTitle());
- }
- }
- list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- JScrollPane listScroller = new JScrollPane(list);
- listScroller.setPreferredSize(new Dimension(250, 80));
- panel.add(listScroller, BorderLayout.CENTER);
- }
- else {
- panel.add(new JLabel("No open images."));
- }
- panel.add(bn, BorderLayout.SOUTH);
- panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- bnOK.addActionListener(this);
- bnCancel.addActionListener(this);
- add(panel);
- pack();
- addWindowListener(this);
- GUI.center(this);
- setModal(true);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- bnOK.removeActionListener(this);
- bnCancel.removeActionListener(this);
- if (e.getSource() == bnCancel) {
- cancel = true;
- name = "";
- dispose();
- return;
- }
- else if (e.getSource() == bnOK) {
- cancel = false;
- name = (String) list.getSelectedValue();
- dispose();
- }
- }
-
- public String getName() {
- return name;
- }
-
- public boolean wasCancel() {
- return cancel;
- }
-
- @Override
- public void windowOpened(WindowEvent e) {
- }
-
- @Override
- public void windowClosing(WindowEvent e) {
- dispose();
- cancel = true;
- name = "";
- return;
- }
-
- @Override
- public void windowClosed(WindowEvent e) {
- }
-
- @Override
- public void windowIconified(WindowEvent e) {
- }
-
- @Override
- public void windowDeiconified(WindowEvent e) {
- }
-
- @Override
- public void windowActivated(WindowEvent e) {
- }
-
- @Override
- public void windowDeactivated(WindowEvent e) {
- }
-
- }
-
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabImager.java b/DeconvolutionLab2/src/deconvolutionlab/LabImager.java
deleted file mode 100644
index 4d6702a..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/LabImager.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * 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 ij.ImagePlus;
-import ij.ImageStack;
-import ij.WindowManager;
-import ij.io.FileSaver;
-import ij.io.Opener;
-import ij.process.FloatProcessor;
-import ij.process.ImageProcessor;
-import signal.ComplexComponent;
-import signal.ComplexSignal;
-import signal.RealSignal;
-
-public class LabImager extends PlatformImager {
-
- public static RealSignal create(ImagePlus imp) {
- int nx = imp.getWidth();
- int ny = imp.getHeight();
- int nz = imp.getStackSize();
- RealSignal signal = new RealSignal(nx, ny, nz);
- for (int k = 0; k < nz; k++) {
- ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
- signal.setXY(k, (float[]) ip.getPixels());
- }
- return signal;
- }
-
- @Override
- public RealSignal create() {
- return build(WindowManager.getCurrentImage());
- }
-
- @Override
- public RealSignal create(String name) {
- ImagePlus imp = null;
- if (name.equalsIgnoreCase("active"))
- imp = WindowManager.getCurrentImage();
- else
- imp = WindowManager.getImage(name);
- if (imp == null)
- imp = WindowManager.getCurrentImage();
- return build(imp);
- }
-
- @Override
- public RealSignal open(String filename) {
- Opener opener = new Opener();
- ImagePlus imp = opener.openImage(filename);
- return build(imp);
- }
-
- @Override
- public void show(RealSignal signal, String title) {
- show(signal, title, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void show(RealSignal signal, String title, PlatformImager.Type type) {
- show(signal, title, type, signal.nz / 2);
- }
-
- @Override
- public void show(RealSignal signal, String title, PlatformImager.Type type, int z) {
- ImagePlus imp = build(signal, type);
- if (imp != null) {
- imp.setTitle(title);
- int nz = imp.getStackSize();
- imp.show();
- imp.setSlice(Math.max(1, Math.min(nz, z)));
- imp.getProcessor().resetMinAndMax();
- }
- }
-
- public ContainerImage createContainer(String title) {
- return new ContainerImage();
- }
-
- @Override
- public void append(ContainerImage container, RealSignal signal, String title) {
- append(container, signal, title, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void append(ContainerImage container, RealSignal signal, String title, PlatformImager.Type type) { ImagePlus cont = (ImagePlus) container.object;
- if (container.object == null) {
- ImageStack stack = new ImageStack(signal.nx, signal.ny);
- stack.addSlice(build(signal, type).getProcessor());
- stack.addSlice(build(signal, type).getProcessor());
- container.object = new ImagePlus(title, stack);
- ((ImagePlus)container.object).show();
- }
- else {
- cont.getStack().addSlice(build(signal, type).getProcessor());
- cont.setSlice(cont.getStack().getSize());
- cont.updateAndDraw();
- cont.getProcessor().resetMinAndMax();
- }
- }
-
- @Override
- public void save(RealSignal signal, String filename) {
- save(signal, filename, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void save(RealSignal signal, String filename, PlatformImager.Type type) {
- ImagePlus imp = build(signal, type);
- if (imp != null) {
- if (imp.getStackSize() == 1) {
- new FileSaver(imp).saveAsTiff(filename);
- }
- else {
- new FileSaver(imp).saveAsTiffStack(filename);
- }
- }
- }
-
- @Override
- public void show(ComplexSignal signal, String title) {
- show(signal, title, ComplexComponent.MODULE);
- }
-
- @Override
- public void show(ComplexSignal signal, String title, ComplexComponent complex) {
- ImageStack stack = new ImageStack(signal.nx, signal.ny);
- for (int k = 0; k < signal.nz; k++) {
- float[] plane = null;
- switch (complex) {
- case REAL:
- plane = signal.getRealXY(k);
- break;
- case IMAGINARY:
- plane = signal.getImagXY(k);
- break;
- case MODULE:
- plane = signal.getModuleXY(k);
- break;
- default:
- plane = signal.getModuleXY_dB(k);
- }
- stack.addSlice(new FloatProcessor(signal.nx, signal.ny, plane));
- }
- new ImagePlus(title, stack).show();
- }
-
- private RealSignal build(ImagePlus imp) {
- if (imp == null)
- return null;
- int nx = imp.getWidth();
- int ny = imp.getHeight();
- int nz = imp.getStackSize();
- RealSignal signal = new RealSignal(nx, ny, nz);
- for (int k = 0; k < nz; k++) {
- ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
- signal.setXY(k, (float[]) ip.getPixels());
- }
- return signal;
- }
-
- private ImagePlus build(RealSignal signal, PlatformImager.Type type) {
- if (signal == null)
- return null;
-
- ImageStack stack = new ImageStack(signal.nx, signal.ny);
- for (int k = 0; k < signal.nz; k++) {
- ImageProcessor ip = new FloatProcessor(signal.nx, signal.ny, signal.getXY(k));
- switch (type) {
- case BYTE:
- stack.addSlice(ip.convertToByteProcessor(false));
- break;
- case SHORT:
- stack.addSlice(ip.convertToShortProcessor(false));
- break;
- case FLOAT:
- stack.addSlice(ip);
- default:
- break;
- }
- }
- return new ImagePlus("", stack);
- }
-
- @Override
- public String getName() {
- return "ImageJ";
- }
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index aa6d7e4..13392de 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,378 +1,370 @@
/*
* 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 deconvolution.algorithm.Controller;
-import deconvolutionlab.PlatformImager.ContainerImage;
+import deconvolutionlab.Imaging.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import lab.tools.NumFormat;
import signal.Constraint;
import signal.RealSignal;
public class Output {
public enum View {
- STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE, STATS, PROFILE
+ 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 PlatformImager.Type type = PlatformImager.Type.FLOAT;
+ private Imaging.Type type = Imaging.Type.FLOAT;
private Dynamic dynamic = Dynamic.INTACT;
private int frequency = 0;
private String path = "";
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 (PlatformImager.Type t : PlatformImager.Type.values()) {
+ for (Imaging.Type t : Imaging.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, PlatformImager.Type type, boolean center) {
+ public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.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, PlatformImager.Type type, int px, int py, int pz) {
+ public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.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 void setPath(String path) {
this.path = path;
}
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 == PlatformImager.Type.FLOAT ? "" : type.name().toLowerCase());
+ String t = (type == Imaging.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, "" };
+ return new String[] { view.name().toLowerCase() + fr, name, d, t, k, sh, sa, "\u232B" };
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, true, false, false, 0);
}
-
+
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, false, false, true, 0);
}
-
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
execute(monitors, signal, controller, false, true, false, iter);
}
-
+
public void execute(Monitors monitors, RealSignal signal, Controller controller, boolean start, boolean live, boolean finish, int iter) {
if (signal == null)
return;
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.getStatsInput();
if (stats != null)
constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
float[] stats1 = controller.getStatsInput();
if (stats1 != null)
constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
String filename = path + File.separator + title + ".tif";
-
+
switch (view) {
- case STATS:
- if (start)
- Lab.firstStats(monitors, name, controller.stats(name), show, save);
- Lab.nextStats(monitors, title, controller.stats(name), show, save);
- if (finish)
- Lab.lastStats(monitors, name, controller.stats(name), show, save);
- break;
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);
if (show && !live)
Lab.show(monitors, slice, title, type);
if (save && !live)
Lab.save(monitors, slice, filename, 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/OutputCollection.java b/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
index b7a5581..db2b6d3 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
@@ -1,92 +1,83 @@
/*
* 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.util.ArrayList;
import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
-public class OutputCollection {
-
- private ArrayList<Output> list = new ArrayList<Output>();
+public class OutputCollection extends ArrayList<Output> {
public void setPath(String path) {
- for (Output out : list)
+ for (Output out : this)
out.setPath(path);
}
- public void add(Output out) {
- if (out != null) {
- list.add(out);
- }
- }
-
public boolean hasShow(int iterations) {
boolean flag = false;
- for (Output out : list)
+ for (Output out : this)
flag = flag | out.is(iterations);
return flag;
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
- for (Output out : list)
+ for (Output out : this)
if (out != null)
out.executeStarting(monitors, signal, controller);
}
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
- for (Output out : list)
+ for (Output out : this)
if (out != null)
out.executeFinal(monitors, signal, controller);
}
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
- for (Output out : list)
+ for (Output out : this)
if (out != null)
out.executeIterative(monitors, signal, controller, iter);
}
public ArrayList<String> getInformation() {
ArrayList<String> lines = new ArrayList<String>();
- for (Output out : list) {
+ for (Output out : this) {
if (out == null)
- lines.add("ERR>" + list.size());
+ lines.add("ERR>" + this.size());
else
lines.add("" + out.toString());
}
return lines;
-
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Platform.java b/DeconvolutionLab2/src/deconvolutionlab/Platform.java
deleted file mode 100644
index 52df21f..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/Platform.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.util.ArrayList;
-
-import imagej.IJImager;
-import plugins.sage.deconvolutionlab.IcyImager;
-
-public enum Platform {
-
- IMAGEJ, ICY, STANDALONE, MATLAB;
-
- public static ArrayList<PlatformImager> getImagers() {
- ArrayList<PlatformImager> imagers = new ArrayList<PlatformImager>();
- try {
- PlatformImager imager = new IJImager();
- if (imager != null) {
- imagers.add(imager);
- }
- }
- catch (NoClassDefFoundError ex) {
- }
-
- try {
- PlatformImager imager = new IcyImager();
- if (imager != null) {
- imagers.add(imager);
- }
- }
- catch (NoClassDefFoundError ex) {
- }
-
- imagers.add(new LabImager());
- return imagers;
- }
-
- public static ArrayList<String> getNameImagers() {
- ArrayList<PlatformImager> imagers = getImagers();
- ArrayList<String> names = new ArrayList<String>();
- for (PlatformImager imager : imagers)
- names.add(imager.getName());
- return names;
- }
-};
diff --git a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
new file mode 100644
index 0000000..e4d3114
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
@@ -0,0 +1,93 @@
+package deconvolutionlab;
+
+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 deconvolutionlab.monitor.Monitors;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+
+public class TableStats {
+
+ private JPanel panel;
+ private CustomizedTable table;
+ private String name;
+ private boolean save;
+ private String path;
+
+ public TableStats(String name, int width, int height, String path, boolean save) {
+ this.name = name;
+ this.save = save;
+ this.path = path;
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Name", String.class, 100, false));
+ columns.add(new CustomizedColumn("Algorithm", String.class, 100, false));
+ columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
+ columns.add(new CustomizedColumn("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("Norm1", String.class, 100, false));
+ columns.add(new CustomizedColumn("Norm2", String.class, 100, false));
+ columns.add(new CustomizedColumn("Time", String.class, 100, false));
+ columns.add(new CustomizedColumn("Memory", String.class, 100, false));
+ columns.add(new CustomizedColumn("Peak", String.class, 100, false));
+ columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
+ columns.add(new CustomizedColumn("SNR", String.class, 100, false));
+ columns.add(new CustomizedColumn("Residu", String.class, 100, false));
+ table = new CustomizedTable(columns, true);
+
+ JScrollPane scroll = new JScrollPane(table);
+ scroll.setPreferredSize(new Dimension(width, height));
+ JPanel main = new JPanel(new BorderLayout());
+
+ main.add(scroll, BorderLayout.CENTER);
+ panel = new JPanel(new BorderLayout());
+ panel.add(main);
+ panel.setBorder(BorderFactory.createEtchedBorder());
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void nextStats(Monitors monitors, String[] stats) {
+ if (table == null)
+ return;
+ if (stats == null)
+ return;
+ table.append(stats);
+ monitors.log("Stats ");
+ }
+
+ public void lastStats(Monitors monitors, String[] stats) {
+ if (stats == null)
+ return;
+ if (table == null)
+ return;
+ if (save) {
+ String filename = path + File.separator + name + ".csv";
+ monitors.log("Stats save " + filename);
+ table.saveCSV(filename);
+ }
+ }
+
+ public JPanel getPanel() {
+ return panel;
+ }
+
+ public void show() {
+ JFrame frame = new JFrame(name);
+ frame.getContentPane().add(panel);
+ frame.pack();
+ frame.setVisible(true);
+ }
+
+}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
index ad5bec2..cd7e6e5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
@@ -1,156 +1,154 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import deconvolution.Command;
import deconvolution.Deconvolution;
+import deconvolutionlab.Constants;
+import deconvolutionlab.Lab;
import deconvolutionlab.modules.BatchModule;
import ij.gui.GUI;
import lab.component.GridPanel;
import lab.component.HTMLPane;
public class BatchDialog extends JDialog implements ActionListener, WindowListener {
private JTextField txt = new JTextField("job", 10);
private HTMLPane pnCommand;
private JButton bnAdd = new JButton("Add Job");
private JButton bnCancel = new JButton("Cancel");
private BatchModule module;
public BatchDialog(BatchModule module) {
super(new JFrame(), "Batch");
this.module = module;
txt.setText("job" + module.getCountJob());
- Deconvolution deconvolution = new Deconvolution(Command.command());
- pnCommand = new HTMLPane("Monaco", 300, 100);
+ Deconvolution deconvolution = new Deconvolution(txt.getText(), Command.command());
+ pnCommand = new HTMLPane("Monaco", Constants.widthGUI, 100);
pnCommand.append("p", deconvolution.getCommand());
pnCommand.setEditable(true);
GridPanel pn = new GridPanel(true, 5);
pn.place(1, 0, "Job Name");
pn.place(1, 1, txt);
GridPanel bn = new GridPanel(false);
bn.place(11, 0, bnCancel);
bn.place(11, 1, bnAdd);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(pnCommand.getPane(), BorderLayout.CENTER);
panel.add(bn, BorderLayout.SOUTH);
bnAdd.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
- GUI.center(this);
- setModal(true);
- setVisible(true);
setMinimumSize(new Dimension(400, 300));
-
}
private void addJob() {
module.addJob(txt.getText(), pnCommand.getText());
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnAdd) {
addJob();
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
return;
}
else if (e.getSource() == bnCancel) {
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
addJob();
dispose();
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
index bef50a5..d5d1bcb 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
@@ -1,362 +1,145 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.GridLayout;
import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
-import java.io.File;
-import java.util.ArrayList;
-import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
-import javax.swing.border.Border;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import deconvolution.Command;
-import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
-import deconvolutionlab.modules.AboutModule;
-import deconvolutionlab.modules.AbstractModule;
-import deconvolutionlab.modules.AlgorithmModule;
-import deconvolutionlab.modules.BatchModule;
-import deconvolutionlab.modules.BorderModule;
-import deconvolutionlab.modules.CommandModule;
-import deconvolutionlab.modules.ConfigModule;
-import deconvolutionlab.modules.ControllerModule;
-import deconvolutionlab.modules.FFTModule;
-import deconvolutionlab.modules.GroupedModulePanel;
-import deconvolutionlab.modules.ImageModule;
-import deconvolutionlab.modules.LanguageModule;
-import deconvolutionlab.modules.LicenceModule;
-import deconvolutionlab.modules.OutputModule;
-import deconvolutionlab.modules.PSFModule;
-import deconvolutionlab.modules.PathModule;
-import deconvolutionlab.modules.WatcherModule;
-import lab.component.JPanelImage;
-import lab.system.SystemPanel;
-import lab.tools.Files;
+import deconvolutionlab.system.SystemInfo;
-public class LabDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
+public class LabDialog extends JDialog implements ComponentListener, ActionListener, WindowListener {
- private JTabbedPane tab = new JTabbedPane();
- private JButton bnHelp = new JButton("Help");
- private JButton bnClose = new JButton("Close");
- private JButton bnQuit = new JButton("Quit");
- private JButton bnBatch = new JButton("Batch");
- private JButton bnRun = new JButton("Run");
- private JButton bnLaunch = new JButton("Launch");
-
- private ImageModule image;
- private PSFModule psf;
- private AlgorithmModule algo;
- private AboutModule about;
- private LicenceModule licence;
- private OutputModule output;
- private FFTModule fourier;
- private BorderModule border;
- private ConfigModule config;
- private BatchModule batch;
- private LanguageModule language;
- private CommandModule command;
- private WatcherModule watcher;
-
- private ControllerModule controller;
-
- private GroupedModulePanel panelDeconv;
- private GroupedModulePanel panelAdvanc;
- private GroupedModulePanel panelScript;
- private GroupedModulePanel panelAbout;
- private AbstractModule modules[];
+ private LabPanel panel;
+ private JButton bnClose = new JButton("Close");
public LabDialog() {
super(new JFrame(), Constants.name);
- image = new ImageModule(false);
- psf = new PSFModule(false);
- algo = new AlgorithmModule(true);
- output = new OutputModule(true);
- fourier = new FFTModule(false);
- border = new BorderModule(false);
- controller = new ControllerModule(false);
- batch = new BatchModule(false);
- language = new LanguageModule(false);
- about = new AboutModule(true);
- licence = new LicenceModule(false);
- config = new ConfigModule(false);
- command = new CommandModule();
- watcher = new WatcherModule(false);
-
- doDialog();
- modules = new AbstractModule[] {image, psf, algo, output, controller, border, fourier, watcher, batch };
-
- Command.active(modules, command);
- Command.command();
-
- addWindowListener(this);
- addComponentListener(this);
- ((GroupedModulePanel) tab.getSelectedComponent()).organize();
- setMinimumSize(new Dimension(500, 500));
Config.registerFrame("DeconvolutionLab", "MainDialog", this);
-
+ panel = new LabPanel(bnClose);
+ getContentPane().add(panel);
pack();
- setVisible(true);
- Config.load();
- sizeModule();
- Command.command();
- image.update();
- psf.update();
- output.update();
- }
-
- private void doDialog() {
-
- panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
- panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
- panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
- panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
- Border b2 = BorderFactory.createEmptyBorder(5, 5, 5, 5);
- JPanelImage bottom = new JPanelImage("celegans.jpg");
- bottom.setBorder(b2);
-
- bottom.setLayout(new GridLayout(1, 5));
- bottom.setBorder(b2);
-
- bottom.add(bnHelp);
- bottom.add(bnClose);
- bottom.add(bnBatch);
- bottom.add(bnRun);
- bottom.add(bnLaunch);
+ addWindowListener(this);
+ addComponentListener(this);
+ bnClose.addActionListener(this);
- tab.add("Deconvolution", panelDeconv);
- tab.add("Advanced", panelAdvanc);
- tab.add("Scripting", panelScript);
- tab.add("About", panelAbout);
- tab.addChangeListener(this);
+ Rectangle rect = Config.getDialog("DeconvolutionLab.MainDialog");
+ if (rect.x > 0 && rect.y > 0)
+ setLocation(rect.x, rect.y);
- add(tab, BorderLayout.CENTER);
- add(bottom, BorderLayout.SOUTH);
-
- bnBatch.addActionListener(this);
- bnRun.addActionListener(this);
- bnLaunch.addActionListener(this);
- bnClose.addActionListener(this);
- bnQuit.addActionListener(this);
- bnHelp.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
-
- if (e.getSource() == bnHelp) {
- Lab.help();
- }
- else if (e.getSource() == bnClose) {
+ if (e.getSource() == bnClose) {
Config.store();
+ SystemInfo.close();
+ panel.close();
dispose();
+ return;
}
- else if (e.getSource() == bnQuit) {
- dispose();
- }
- else if (e.getSource() == bnBatch) {
- tab.setSelectedIndex(2);
- batch.expand();
- sizeModule();
- new BatchDialog(batch);
- }
- else if (e.getSource() == bnLaunch) {
- new Deconvolution(Command.command()).launch("", false);
- }
- else if (e.getSource() == bnRun) {
- new Deconvolution(Command.command()).deconvolve(false);
- }
- }
-
- @Override
- public void stateChanged(ChangeEvent e) {
- ((GroupedModulePanel) tab.getSelectedComponent()).organize();
- Command.command();
- }
-
- private ArrayList<AbstractModule> buildDeconvolutionPanel() {
- ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
- list.add(image);
- list.add(psf);
- list.add(algo);
- list.add(watcher);
- return list;
- }
-
- private ArrayList<AbstractModule> buildAdvancedPanel() {
- ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
- list.add(output);
- list.add(controller);
- list.add(border);
- list.add(fourier);
- return list;
- }
-
- private ArrayList<AbstractModule> buildProgrammingPanel() {
- ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
- list.add(batch);
- list.add(command);
- list.add(language);
- return list;
- }
-
- private ArrayList<AbstractModule> buildAboutPanel() {
- ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
- list.add(about);
- list.add(licence);
- list.add(config);
- return list;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
+ panel.close();
Config.store();
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
- private void close() {
- for (AbstractModule module : modules)
- module.close();
- bnLaunch.removeActionListener(this);
- bnRun.removeActionListener(this);
- bnBatch.removeActionListener(this);
- bnClose.removeActionListener(this);
- bnHelp.removeActionListener(this);
- removeWindowListener(this);
- }
-
@Override
public void dispose() {
super.dispose();
- if (Lab.getPlatform() == Platform.STANDALONE) System.exit(0);
+ if (Lab.getPlatform() == Imaging.Platform.STANDALONE)
+ System.exit(0);
}
@Override
public void componentResized(ComponentEvent e) {
- sizeModule();
+ panel.sizeModule();
}
@Override
public void componentMoved(ComponentEvent e) {
Point p = this.getLocation();
p.x += this.getWidth();
DeconvolutionDialog.setLocationLaunch(p);
}
@Override
public void componentShown(ComponentEvent e) {
- sizeModule();
+ panel.sizeModule();
}
@Override
public void componentHidden(ComponentEvent e) {
}
-
- public void sizeModule() {
- if (tab.getSelectedIndex() == 0) sizePanel(panelDeconv);
- if (tab.getSelectedIndex() == 1) sizePanel(panelAdvanc);
- if (tab.getSelectedIndex() == 2) sizePanel(panelScript);
- if (tab.getSelectedIndex() == 3) sizePanel(panelAbout);
- }
-
- private void sizePanel(GroupedModulePanel panel) {
- Dimension dim = getSize();
- int hpc = 60;
- int npc = hpc * panel.getModules().size();
- Dimension small = new Dimension(dim.width, hpc);
- Dimension large = new Dimension(dim.width, dim.height - npc);
- for (AbstractModule module : panel.getModules()) {
- if (module.isExpanded()) {
- module.setPreferredSize(large);
- module.setMaximumSize(large);
- module.setMinimumSize(small);
- module.getExpandedPanel().setPreferredSize(large);
- module.getExpandedPanel().setMaximumSize(large);
- module.getExpandedPanel().setMinimumSize(small);
- }
- else {
- module.setPreferredSize(small);
- module.setMaximumSize(small);
- module.setMinimumSize(small);
- module.getCollapsedPanel().setPreferredSize(small);
- module.getCollapsedPanel().setMaximumSize(small);
- module.getCollapsedPanel().setMinimumSize(small);
- }
- }
- }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabPanel.java
similarity index 73%
copy from DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
copy to DeconvolutionLab2/src/deconvolutionlab/dialog/LabPanel.java
index bef50a5..7e31acf 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabPanel.java
@@ -1,362 +1,300 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
-import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.io.File;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
-import deconvolutionlab.modules.PathModule;
-import deconvolutionlab.modules.WatcherModule;
+import deconvolutionlab.modules.RunningModule;
+import deconvolutionlab.system.SystemInfo;
import lab.component.JPanelImage;
-import lab.system.SystemPanel;
-import lab.tools.Files;
-public class LabDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
+public class LabPanel extends JPanel implements ActionListener, ChangeListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
- private JButton bnClose = new JButton("Close");
private JButton bnQuit = new JButton("Quit");
+ private JButton bnSystem = new JButton("System");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
-
+ private JButton bnClose;
+
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
- private WatcherModule watcher;
+ private RunningModule running;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
- public LabDialog() {
- super(new JFrame(), Constants.name);
+ private ArrayList<Deconvolution> deconvolutions = new ArrayList<Deconvolution>();
+
+ public LabPanel(JButton bnClose) {
+ this.bnClose = bnClose;
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
- watcher = new WatcherModule(false);
-
- doDialog();
- modules = new AbstractModule[] {image, psf, algo, output, controller, border, fourier, watcher, batch };
-
+ running = new RunningModule(false);
+ modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, batch, running };
Command.active(modules, command);
Command.command();
- addWindowListener(this);
- addComponentListener(this);
- ((GroupedModulePanel) tab.getSelectedComponent()).organize();
- setMinimumSize(new Dimension(500, 500));
- Config.registerFrame("DeconvolutionLab", "MainDialog", this);
-
- pack();
- setVisible(true);
- Config.load();
- sizeModule();
- Command.command();
- image.update();
- psf.update();
- output.update();
- }
-
- private void doDialog() {
-
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
- Border b2 = BorderFactory.createEmptyBorder(5, 5, 5, 5);
+ Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
JPanelImage bottom = new JPanelImage("celegans.jpg");
- bottom.setBorder(b2);
-
- bottom.setLayout(new GridLayout(1, 5));
- bottom.setBorder(b2);
+ bottom.setBorder(border);
+
+ bottom.setLayout(new GridLayout(1, 6));
+ bottom.setBorder(border);
bottom.add(bnHelp);
+ bottom.add(bnSystem);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
-
+
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Scripting", panelScript);
tab.add("About", panelAbout);
tab.addChangeListener(this);
+ setLayout(new BorderLayout());
add(tab, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
-
+
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
+ bnSystem.addActionListener(this);
+
+ ((GroupedModulePanel) tab.getSelectedComponent()).organize();
+ setMinimumSize(new Dimension(500, 500));
+
+ Config.load();
+ running.init();
+ sizeModule();
+ Command.command();
+ running.update();
+ image.update();
+ psf.update();
+ output.update();
}
@Override
public void actionPerformed(ActionEvent e) {
- if (e.getSource() == bnHelp) {
+ if (e.getSource() == bnHelp)
Lab.help();
- }
- else if (e.getSource() == bnClose) {
+ else if (e.getSource() == bnClose)
Config.store();
- dispose();
- }
- else if (e.getSource() == bnQuit) {
- dispose();
- }
+ else if (e.getSource() == bnSystem)
+ SystemInfo.activate();
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
- new BatchDialog(batch);
+ BatchDialog dlg = new BatchDialog(batch);
+ Lab.setVisible(dlg, true);
}
+
else if (e.getSource() == bnLaunch) {
- new Deconvolution(Command.command()).launch("", false);
+ String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
+ Deconvolution d = new Deconvolution(job, Command.command(), Deconvolution.Finish.ALIVE);
+ d.launch();
+ deconvolutions.add(d);
}
else if (e.getSource() == bnRun) {
- new Deconvolution(Command.command()).deconvolve(false);
+ String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
+ Deconvolution d = new Deconvolution(job, Command.command());
+ d.deconvolve();
+ deconvolutions.add(d);
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
- list.add(watcher);
+ list.add(running);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
list.add(border);
list.add(fourier);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(batch);
list.add(command);
list.add(language);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
- @Override
- public void windowOpened(WindowEvent e) {
- }
-
- @Override
- public void windowClosing(WindowEvent e) {
- Config.store();
- dispose();
- }
-
- @Override
- public void windowClosed(WindowEvent e) {
- }
-
- @Override
- public void windowIconified(WindowEvent e) {
- }
-
- @Override
- public void windowDeiconified(WindowEvent e) {
- }
-
- @Override
- public void windowActivated(WindowEvent e) {
- }
-
- @Override
- public void windowDeactivated(WindowEvent e) {
- }
-
- private void close() {
+ public void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
- removeWindowListener(this);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (Lab.getPlatform() == Platform.STANDALONE) System.exit(0);
- }
-
- @Override
- public void componentResized(ComponentEvent e) {
- sizeModule();
- }
-
- @Override
- public void componentMoved(ComponentEvent e) {
- Point p = this.getLocation();
- p.x += this.getWidth();
- DeconvolutionDialog.setLocationLaunch(p);
- }
-
- @Override
- public void componentShown(ComponentEvent e) {
- sizeModule();
+
+ for(Deconvolution deconvolution : deconvolutions)
+ deconvolution.close();
}
- @Override
- public void componentHidden(ComponentEvent e) {
- }
-
public void sizeModule() {
- if (tab.getSelectedIndex() == 0) sizePanel(panelDeconv);
- if (tab.getSelectedIndex() == 1) sizePanel(panelAdvanc);
- if (tab.getSelectedIndex() == 2) sizePanel(panelScript);
- if (tab.getSelectedIndex() == 3) sizePanel(panelAbout);
+ if (tab.getSelectedIndex() == 0)
+ sizePanel(panelDeconv);
+ if (tab.getSelectedIndex() == 1)
+ sizePanel(panelAdvanc);
+ if (tab.getSelectedIndex() == 2)
+ sizePanel(panelScript);
+ if (tab.getSelectedIndex() == 3)
+ sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 60;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 6a8111b..66fb214 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,238 +1,238 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolutionlab.Imaging;
+import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
-import deconvolutionlab.PlatformImager;
import ij.gui.GUI;
import lab.component.GridPanel;
import lab.component.SpinnerRangeInteger;
public class OutputDialog extends JDialog implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Snapshot");
private Output out;
private View view;
private GridPanel pnOrtho;
private static int count = 1;
public OutputDialog(View view) {
super(new JFrame(), "Create a new output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(view.name());
pn.place(0, 0, "Name");
pn.place(0, 1, 2, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(2, 2, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(5, 2, lblIter);
}
pn.place(6, 0, 3, 1, chkShow);
pn.place(7, 0, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(8, 0, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
pack();
GUI.center(this);
setModal(true);
- setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
dispose();
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
- PlatformImager.Type type = PlatformImager.Type.values()[cmbType.getSelectedIndex()];
+ Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
dispose();
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
index bf68e73..4c2a8ac 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
@@ -1,312 +1,311 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.gui.GUI;
import lab.component.GridPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class SyntheticDialog extends JDialog implements ActionListener, WindowListener {
private SpinnerRangeDouble spnSignal = new SpinnerRangeDouble(100, -999999, 999999, 1);
private SpinnerRangeDouble spnBackground = new SpinnerRangeDouble(0, -999999, 999999, 1);
private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(32, 1, 9999, 1);
private SpinnerRangeDouble spnCenterX = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterY = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterZ = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnParameter1 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter2 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter3 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private JLabel lbl1 = new JLabel("Parameters 1 of the shape");
private JLabel lbl2 = new JLabel("Parameters 2 of the shape");
private JLabel lbl3 = new JLabel("Parameters 3 of the shape");
private JComboBox<String> cmbShapes;
private JButton bnShow = new JButton("Show");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String shape;
private String command;
public SyntheticDialog(ArrayList<SignalFactory> list) {
super(new JFrame(), "Synthetic");
String[] cmb = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
cmb[i] = list.get(i).getName();
}
cmbShapes = new JComboBox<String>(cmb);
GridPanel pnIntensity = new GridPanel("Intensity", 3);
pnIntensity.place(1, 0, "Signal Intensity");
pnIntensity.place(1, 1, spnSignal);
pnIntensity.place(2, 0, "Background Intensity");
pnIntensity.place(2, 1, spnBackground);
GridPanel pnSize = new GridPanel("Dimension", 3);
pnSize.place(1, 0, "Width [pixels] (nx)");
pnSize.place(1, 1, spnWidth);
pnSize.place(2, 0, "Height [pixels] (ny)");
pnSize.place(2, 1, spnHeight);
pnSize.place(3, 0, "Number of Slices (nz)");
pnSize.place(3, 1, spnSlices);
GridPanel pnCenter = new GridPanel("Center", 3);
pnCenter.place(4, 0, "Center [% of nx] (cx)");
pnCenter.place(4, 1, spnCenterX);
pnCenter.place(5, 0, "Center [% of ny] (cy)");
pnCenter.place(5, 1, spnCenterY);
pnCenter.place(7, 0, "Center [% of nz] (cz)");
pnCenter.place(7, 1, spnCenterZ);
GridPanel pnParams = new GridPanel("Specific Parameters", 3);
pnParams.place(8, 0, lbl1);
pnParams.place(8, 1, spnParameter1);
pnParams.place(9, 0, lbl2);
pnParams.place(9, 1, spnParameter2);
pnParams.place(10, 0, lbl3);
pnParams.place(10, 1, spnParameter3);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, 3, 1, cmbShapes);
pn.place(1, 0, 3, 1, pnIntensity);
pn.place(2, 0, 3, 1, pnParams);
pn.place(3, 0, 3, 1, pnSize);
pn.place(4, 0, 3, 1, pnCenter);
pn.place(11, 0, bnCancel);
pn.place(11, 1, bnShow);
pn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnShow.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
cmbShapes.addActionListener(this);
add(pn);
pack();
updateInterface();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void updateInterface() {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
String labels[] = factory.getParametersName();
lbl1.setVisible(false);
lbl2.setVisible(false);
lbl3.setVisible(false);
if (labels.length >= 1) {
lbl1.setVisible(true);
lbl1.setText(labels[0]);
}
if (labels.length >= 2) {
lbl2.setVisible(true);
lbl2.setText(labels[1]);
}
if (labels.length >= 3) {
lbl3.setVisible(true);
lbl3.setText(labels[2]);
}
double params[] = factory.getParameters();
spnParameter1.setVisible(false);
spnParameter2.setVisible(false);
spnParameter3.setVisible(false);
if (params.length >= 1) {
spnParameter1.setVisible(true);
spnParameter1.set(params[0]);
}
if (params.length >= 2) {
spnParameter2.setVisible(true);
spnParameter2.set(params[1]);
}
if (params.length >= 3) {
spnParameter3.setVisible(true);
spnParameter3.set(params[2]);
}
pack();
-
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnShow) {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
double params[] = factory.getParameters();
factory.setParameters(params);
factory.center(spnCenterX.get(), spnCenterX.get(), spnCenterX.get());
RealSignal signal = factory.generate(spnWidth.get(), spnWidth.get(), spnWidth.get());
Lab.show(Monitors.createDefaultMonitor(), signal, factory.getName());
}
if (e.getSource() == cmbShapes) {
updateInterface();
}
if (e.getSource() == bnCancel) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
if (e.getSource() == bnOK) {
int nx = spnWidth.get();
int ny = spnHeight.get();
int nz = spnSlices.get();
shape = (String) cmbShapes.getSelectedItem();
command = shape + " " + spnSignal.get() + " " + spnBackground.get() + " ";
SignalFactory factory = SignalFactory.get(shape);
int n = factory.getParameters().length;
if (n >= 1) {
command += "" + spnParameter1.get();
if (n >= 2)
command += " " + spnParameter2.get();
if (n >= 3)
command += " " + spnParameter3.get();
command += " ";
}
command += " size " + nx + " " + ny + " " + nz + " ";
if (spnCenterX.get() != 0.5 || spnCenterY.get() != 0.5 || spnCenterZ.get() != 0.5) {
double cx = Math.round(spnCenterX.get() * 1000000) / 1000000.0;
double cy = Math.round(spnCenterY.get() * 1000000) / 1000000.0;
double cz = Math.round(spnCenterZ.get() * 1000000) / 1000000.0;
command += " center " + cx + " " + cy + " " + cz + " ";
}
dispose();
cancel = false;
}
}
public void setParameters(String name, String parameters) {
double params[] = NumFormat.parseNumbers(parameters);
cmbShapes.setSelectedItem(name);
SignalFactory factory = SignalFactory.getFactoryByName(name);
if (factory == null)
return;
int np = factory.getParameters().length;
if (params.length > 0)
spnSignal.set(params[0]);
if (params.length > 1)
spnBackground.set(params[1]);
if (params.length > 2 + np)
spnWidth.set((int) params[2 + np]);
if (params.length > 3 + np)
spnHeight.set((int) params[3 + np]);
if (params.length > 4 + np)
spnSlices.set((int) params[4 + np]);
if (params.length > 5 + np)
spnCenterX.set(params[5 + np]);
if (params.length > 6 + np)
spnCenterY.set(params[6 + np]);
if (params.length > 7 + np)
spnCenterZ.set(params[7 + np]);
if (np >= 1 && params.length > 2 + np)
spnParameter1.set(params[2]);
if (np >= 2 && params.length > 3 + np)
spnParameter2.set(params[3]);
if (np >= 3 && params.length > 4 + np)
spnParameter3.set(params[4]);
}
public String getShapeName() {
return shape;
}
public String getCommand() {
return command;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
index ca832f1..6412960 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
@@ -1,78 +1,78 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
-import lab.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
+import lab.component.HTMLPane;
public class AboutModule extends AbstractModule {
public AboutModule(boolean expanded) {
super("About", "", "Help", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p", Constants.copyright);
html.append("p", "<b>Reference:</b> " + Constants.reference);
html.append("h3", "<b>Authors:</b> " + Constants.authors);
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (getAction1Button() == e.getSource())
Lab.help();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
index 0200308..4cdc1f8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
@@ -1,145 +1,144 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
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.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.JSeparator;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import lab.component.HTMLPane;
import deconvolution.Command;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
+import lab.component.HTMLPane;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
public AlgorithmModule(boolean expanded) {
super("Algorithm", "-algorithm", "", "", 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.getShortname() + " " + algo.getCommand();
String synopsis = name;
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
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 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));
control.add(cmb);
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);
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);
}
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/modules/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
index 81f4650..60af627 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
@@ -1,189 +1,189 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.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 deconvolution.Deconvolution;
import deconvolutionlab.Constants;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnScript;
private JButton bnRunAll;
private JButton bnRunJob;
private JButton bnLaunchAll;
private JButton bnLaunchJob;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnScript = new JButton("Create Script (not yet implemented)");
bnRunAll = new JButton("Run All Jobs");
bnRunJob = new JButton("Run Selected Jobs");
bnLaunchAll = new JButton("Launch All Jobs");
bnLaunchJob = new JButton("Launch Selected 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, 5));
pn.setFloatable(false);
pn.add(bnScript);
pn.add(bnRunAll);
pn.add(bnRunJob);
pn.add(bnLaunchAll);
pn.add(bnLaunchJob);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnScript.addActionListener(this);
bnRunAll.addActionListener(this);
bnRunJob.addActionListener(this);
bnLaunchAll.addActionListener(this);
bnLaunchJob.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRunJob) {
int rows[] = table.getSelectedRows();
for (int row : rows) {
- new Deconvolution(table.getCell(row, 1)).deconvolve(false);
+ new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
}
else if (e.getSource() == bnLaunchJob) {
int rows[] = table.getSelectedRows();
for (int row : rows) {
- new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0), false);
+ new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
}
else if (e.getSource() == bnRunAll) {
for (int row = 0; row < table.getRowCount(); row++) {
- new Deconvolution(table.getCell(row, 1)).deconvolve(false);
+ new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
}
else if (e.getSource() == bnLaunchAll) {
for (int row = 0; row < table.getRowCount(); row++) {
- new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0), false);
+ new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
}
}
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/modules/BorderModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
index 18bf0ac..e72be64 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
@@ -1,304 +1,247 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.ArrayList;
import javax.swing.BorderFactory;
-import javax.swing.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 deconvolution.Command;
import deconvolution.Deconvolution;
+import deconvolution.Features;
import deconvolutionlab.Config;
+import deconvolutionlab.monitor.Monitors;
import lab.component.GridPanel;
-import lab.component.HTMLPane;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
- private JComboBox<String> cmbNormalization;
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
- private HTMLPane info;
+ private JLabel lblPad;
+ private JLabel lblApo;
private boolean build = false;
public BorderModule(boolean expanded) {
super("Border", "", "Test", "Default", expanded);
}
@Override
public String getCommand() {
AbstractPadding pxy = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding paz = Padding.getByName((String) cmbPadZ.getSelectedItem());
AbstractApodization axy = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apz = Apodization.getByName((String) cmbApoZ.getSelectedItem());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
String extXY = (ext ? "" + spnExtensionXY.get() : "") + " ";
String extZ = ext ? "" + spnExtensionZ.get() : "";
String cmd = "";
if (!(pxy instanceof NoPadding) || !(paz instanceof NoPadding) || spnExtensionXY.get() > 0 || spnExtensionZ.get() > 0)
cmd += " -pad " + pxy.getShortname() + " " + paz.getShortname() + " " + extXY + extZ;
if (!(axy instanceof UniformApodization) || !(apz instanceof UniformApodization))
cmd += " -apo " + axy.getShortname() + " " + apz.getShortname() + " ";
- if (cmbNormalization.getSelectedIndex() != 0)
- cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
- info = new HTMLPane(100, 100);
-
+ lblPad = new JLabel("Information on padding size");
+ lblPad.setBorder(BorderFactory.createEtchedBorder());
+ lblApo = new JLabel("Information on apodization energy");
+ lblApo.setBorder(BorderFactory.createEtchedBorder());
cmbPadXY = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbPadZ = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbApoXY = new JComboBox<String>(Apodization.getApodizationsAsArray());
cmbApoZ = new JComboBox<String>(Apodization.getApodizationsAsArray());
spnExtensionXY = new SpinnerRangeInteger(0, 0, 99999, 1);
spnExtensionZ = new SpinnerRangeInteger(0, 0, 99999, 1);
- cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
- GridPanel pnBorder = new GridPanel("Border Artifact Cancelation", 3);
- pnBorder.place(0, 2, "Lateral (XY)");
- pnBorder.place(0, 4, "Axial (Z)");
+ GridPanel pnBorder = new GridPanel(false, 3);
+ pnBorder.place(0, 1, "Lateral (XY)");
+ pnBorder.place(0, 2, "Axial (Z)");
pnBorder.place(2, 0, "Apodization");
- pnBorder.place(2, 2, cmbApoXY);
- pnBorder.place(2, 4, cmbApoZ);
+ pnBorder.place(2, 1, cmbApoXY);
+ pnBorder.place(2, 2, cmbApoZ);
pnBorder.place(3, 0, "Padding Extension");
- pnBorder.place(3, 2, spnExtensionXY);
- pnBorder.place(3, 4, spnExtensionZ);
+ pnBorder.place(3, 1, spnExtensionXY);
+ pnBorder.place(3, 2, spnExtensionZ);
pnBorder.place(4, 0, "Padding Constraint");
- pnBorder.place(4, 2, cmbPadXY);
- pnBorder.place(4, 4, cmbPadZ);
-
- pnBorder.place(5, 0, "PSF Normalization");
- pnBorder.place(5, 2, cmbNormalization);
- pnBorder.place(5, 4, "1, recommended");
-
- JScrollPane scroll1 = new JScrollPane(pnBorder);
- scroll1.setBorder(BorderFactory.createEmptyBorder());
- scroll1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- scroll1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
-
- 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));
- control.add(scroll1);
- control.add(info.getPane());
+ pnBorder.place(4, 1, cmbPadXY);
+ pnBorder.place(4, 2, cmbPadZ);
+ pnBorder.place(5, 0, 3, 1, lblPad);
+ pnBorder.place(6, 0, 3, 1, lblApo);
+
+ JScrollPane scroll = new JScrollPane(pnBorder);
+ scroll.setBorder(BorderFactory.createEmptyBorder());
+ scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
- panel.add(control, BorderLayout.CENTER);
+ panel.setBorder(BorderFactory.createEtchedBorder());
+ panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
- Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
-
- cmbNormalization.addActionListener(this);
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
build = true;
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
- testInfo();
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
cmbPadXY.setSelectedIndex(0);
cmbPadZ.setSelectedIndex(0);
cmbApoXY.setSelectedIndex(0);
cmbApoZ.setSelectedIndex(0);
spnExtensionXY.set(0);
spnExtensionZ.set(0);
- cmbNormalization.setSelectedIndex(0);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
update();
return;
}
if (e.getSource() == getAction1Button()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getAction1Button().setEnabled(false);
getAction2Button().setEnabled(false);
- info.clear();
- info.append("p", "Test running...");
- info.clear();
- ArrayList<String> lines = new Deconvolution(Command.command()).checkImage();
- for (String line : lines)
- info.append("p", line);
- ArrayList<String> linesPSF = new Deconvolution(Command.command()).checkPSF();
- for (String line : linesPSF)
- info.append("p", line);
+ Deconvolution d = new Deconvolution("CheckImage", Command.command());
+ Apodization apo = d.getApodization();
+ if (apo == null) {
+ lblApo.setText("Error in Apodization");
+ return;
+ }
+ Padding pad = d.getPadding();
+ if (pad == null) {
+ lblPad.setText("Error in Padding");
+ return;
+ }
+ RealSignal x = d.openImage();
+ if (x == null) {
+ lblPad.setText("Error in input image");
+ lblApo.setText("Error in input image");
+ return;
+ }
+ Monitors m = Monitors.createDefaultMonitor();
+ RealSignal y = pad.pad(m, apo.apodize(m, x));
+
+ lblPad.setText(x.dimAsString() + " > " + y.dimAsString());
+ lblApo.setText(NumFormat.nice(x.getStats()[5]) + " > " + NumFormat.nice(y.getStats()[5]));
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
- testInfo();
update();
}
@Override
public void close() {
- cmbNormalization.removeActionListener(this);
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
}
- private void testInfo() {
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- if (build)
- info();
- }
- });
- thread.setPriority(Thread.MIN_PRIORITY);
- thread.start();
- }
-
- private Padding getPadding() {
- AbstractPadding padXY = Padding.getByName((String) cmbPadXY.getSelectedItem());
- AbstractPadding padZ = Padding.getByName((String) cmbPadZ.getSelectedItem());
- int extXY = spnExtensionXY.get();
- int extZ = spnExtensionZ.get();
- return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
- }
-
- private Apodization getApodization() {
- AbstractApodization apoXY = Apodization.getByName((String) cmbApoXY.getSelectedItem());
- AbstractApodization apoZ = Apodization.getByName((String) cmbApoZ.getSelectedItem());
- return new Apodization(apoXY, apoXY, apoZ);
- }
- private void info() {
- int nx = 600;
- int ny = 400;
- int nz = 100;
- RealSignal image = new Deconvolution(Command.command()).openImage();
- if (image != null) {
- nx = image.nx;
- ny = image.ny;
- nz = image.nz;
- }
- try {
- info.clear();
- }
- catch (Exception ex) {
- }
- int[] p = getPadding().pad(nx, ny, nz);
- String in = "[" + nx + " x" + ny + " x " + nz + "]";
- String out = "[" + p[0] + " x" + p[1] + " x " + p[2] + "]";
- String bin = NumFormat.bytes(nx * ny * nz * 4);
- String pout = NumFormat.bytes(p[0] * p[1] * p[2] * 4);
- if (info != null) {
- info.append("p", "Input size: " + in + " (" + bin + ")");
- info.append("p", "Padded size: " + out + " (" + pout + ")");
- double lost = getApodization().estimateLostEnergy(10);
- info.append("p", "Estimation of lost energy by apodization: " + (lost * 100) + "%");
- }
- }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
index 51b1bb8..f582a51 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
@@ -1,252 +1,245 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.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.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import deconvolution.Command;
-import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.tools.Files;
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 JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkConstraint;
private JCheckBox chkTime;
private JCheckBox chkItermax;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (chkConstraint.isSelected())
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("Time Limitation (s)");
chkItermax = new JCheckBox("Early Stopping");
chkConstraint = new JCheckBox("Constraint");
chkResidu = new JCheckBox("Residu Minimun");
chkReference = new JCheckBox("Reference");
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);
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, chkItermax);
pn.place(0, 1, txtIterations);
pn.place(1, 0, chkResidu);
pn.place(1, 1, txtResidu);
pn.place(4, 0, chkConstraint);
pn.place(4, 1, cmbConstraint);
pn.place(5, 0, chkTime);
pn.place(5, 1, txtTime);
pn.place(7, 0, chkReference);
pn.place(7, 1, txtReference);
pn.place(8, 0, "Ground-truth file");
pn.place(8, 1, bnBrowse);
- Border b1 = BorderFactory.createEtchedBorder();
- Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
- pn.setBorder(BorderFactory.createCompoundBorder(b1, b2));
-
JScrollPane scroll = new JScrollPane(pn);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
- panel.add(scroll, BorderLayout.NORTH);
-
-
+ panel.add(scroll, BorderLayout.CENTER);
+
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "constraint.enable", chkConstraint, false);
Config.register(getName(), "time.enable", chkTime, false);
Config.register(getName(), "itmax.enable", chkItermax, true);
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.value", cmbConstraint, "No");
chkItermax.setSelected(true);
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtTime.addKeyListener(this);
cmbConstraint.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
chkItermax.setSelected(true);
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkConstraint.isSelected() ? 1 : 0);
count += (chkTime.isSelected() ? 1 : 0);
count += (chkItermax.isSelected() ? 1 : 0);
setSynopsis("" + count + " stopping criteria");
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
- File file = Files.browseFile(deconvolution.getPath());
+ File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkTime.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkConstraint.setSelected(false);
chkTime.setSelected(false);
chkItermax.setSelected(true);
txtReference.setText("");
txtResidu.setText("0.01");
txtTime.setText("3600");
cmbConstraint.setSelectedIndex(0);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.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);
chkConstraint.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
index c8d4d57..7712ef0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
@@ -1,199 +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.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.component.GridPanel;
-import lab.component.HTMLPane;
-import lab.tools.NumFormat;
-import signal.Signal;
import deconvolution.Command;
-import deconvolution.Deconvolution;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
-import fft.AbstractFFTLibrary;
import fft.FFT;
+import lab.component.GridPanel;
+import lab.tools.NumFormat;
public class FFTModule extends AbstractModule implements ActionListener, ChangeListener {
- private HTMLPane info;
-
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbType;
private JComboBox<String> cmbSep;
private JComboBox<String> cmbEpsilon;
-
- private CustomizedTable table;
-
+ private JComboBox<String> cmbNormalization;
+ boolean init = false;
+
public FFTModule(boolean expanded) {
- super("Fourier", "", "", "Default", expanded);
+ super("Computation", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = "";
- if (cmbFFT.getSelectedIndex() != 0)
- cmd += " -fft " + (String) cmbFFT.getSelectedItem();
+ if (cmbNormalization.getSelectedIndex() != 0)
+ cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
+ if (cmbFFT.getSelectedIndex() != 0) {
+ cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
+ }
+ if (cmbEpsilon.getSelectedIndex() != 6)
+ cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
-
- ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
- columns.add(new CustomizedColumn("Name", String.class, 120, false));
- columns.add(new CustomizedColumn("Installed", String.class, 120, false));
- columns.add(new CustomizedColumn("Multithreadable", String.class, 120, false));
- columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
- table = new CustomizedTable(columns, true);
- table.setRowSelectionAllowed(false);
-
- info = new HTMLPane(100, 100);
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbType = new JComboBox<String>(new String[] { "float" });
cmbSep = new JComboBox<String>(new String[] { "XYZ" });
cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
cmbEpsilon.setSelectedItem("1E-6");
+ cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
+ cmbNormalization.addActionListener(this);
+ cmbNormalization.setSelectedIndex(0);
+ cmbNormalization.removeActionListener(this);
+
GridPanel pnNumeric = new GridPanel(false, 3);
- pnNumeric.place(3, 0, new JLabel("FFT Fourier Library"));
+ pnNumeric.place(1, 0, "PSF Normalization");
+ pnNumeric.place(1, 1, cmbNormalization);
+ pnNumeric.place(1, 2, "1, recommended");
+ pnNumeric.place(3, 0, new JLabel("FFT Library"));
pnNumeric.place(3, 1, cmbFFT);
- pnNumeric.place(6, 0, new JLabel("FFT Dimension"));
+ pnNumeric.place(3, 2, new JLabel("Fourier"));
+ pnNumeric.place(6, 0, new JLabel("FFT Processing"));
pnNumeric.place(6, 1, cmbSep);
- pnNumeric.place(7, 0, new JLabel("<html>Machine Epsilon &epsilon;</html>"));
+ pnNumeric.place(6, 2, new JLabel("Dimension Ordering"));
+
+ pnNumeric.place(7, 0, new JLabel("Machine Epsilon"));
pnNumeric.place(7, 1, cmbEpsilon);
-
- JScrollPane scroll2 = new JScrollPane(pnNumeric);
- scroll2.setBorder(BorderFactory.createEmptyBorder());
- scroll2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- scroll2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
-
- JPanel control = new JPanel(new BorderLayout());
- Border b1 = BorderFactory.createEtchedBorder();
- Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
-
- control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
- control.add(scroll2, BorderLayout.NORTH);
- control.add(info.getPane(), BorderLayout.CENTER);
- control.add(table.getPane(80, 80), BorderLayout.SOUTH);
+ pnNumeric.place(7, 2, new JLabel("<html>&epsilon;</html>"));
+
+ pnNumeric.place(8, 0, new JLabel("Data Type"));
+ pnNumeric.place(8, 1, cmbType);
+ pnNumeric.place(8, 2, new JLabel("(Only float)"));
+
+ JScrollPane scroll = new JScrollPane(pnNumeric);
+ scroll.setBorder(BorderFactory.createEmptyBorder());
+ scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
- panel.add(control, BorderLayout.CENTER);
+ panel.setBorder(BorderFactory.createEtchedBorder());
+ panel.add(scroll, BorderLayout.CENTER);
- Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
+ Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
Config.register(getName(), "dim", cmbSep, "XYZ");
-
+ Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
+
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
+ cmbSep.addActionListener(this);
cmbEpsilon.addActionListener(this);
-
+ cmbNormalization.addActionListener(this);
getAction1Button().addActionListener(this);
- getAction2Button().addActionListener(this);
- fillInstallation();
+ init = true;
return panel;
}
- private void fillInstallation() {
-
- ArrayList<AbstractFFTLibrary> libs = FFT.getRegisteredLibraries();
- for (AbstractFFTLibrary lib : libs) {
- String name = lib.getLibraryName();
- String installed = lib.isInstalled() ? " Yes" : "No";
- String multit = lib.isMultithreadable() ? " Yes" : "No";
- String location = lib.getLocation();
- table.append(new String[] { name, installed, multit, location });
- }
- AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
- info.clear();
- info.append("p", fftlib.getLicence());
- }
-
private void update() {
setCommand(getCommand());
- Signal.epsilon = NumFormat.parseNumber((String) cmbEpsilon.getSelectedItem(), 1e-6);
+ if (init)
+ setSynopsis("Norm " + cmbNormalization.getSelectedItem() + " " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
+System.out.println("" + e);
super.actionPerformed(e);
- if (e.getSource() == cmbFFT || e.getSource() == cmbSep) {
- AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
- info.clear();
- info.append("p", fftlib.getLicence());
- }
-
if (e.getSource() == getAction1Button()) {
- cmbFFT.removeActionListener(this);
- cmbType.removeActionListener(this);
- cmbEpsilon.removeActionListener(this);
cmbFFT.setSelectedIndex(0);
+ cmbSep.setSelectedIndex(0);
cmbType.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
- cmbFFT.addActionListener(this);
- cmbType.addActionListener(this);
- cmbEpsilon.addActionListener(this);
+ cmbNormalization.setSelectedIndex(0);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
- getAction2Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
+ cmbSep.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
+ cmbNormalization.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java b/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
index 3281aa1..7a9d389 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
@@ -1,102 +1,102 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
-import deconvolutionlab.dialog.LabDialog;
+import deconvolutionlab.dialog.LabPanel;
public class GroupedModulePanel extends JPanel {
private ArrayList<AbstractModule> modules;
- private LabDialog parent;
+ private LabPanel parent;
private Dimension min;
- public GroupedModulePanel(ArrayList<AbstractModule> modules, LabDialog parent) {
+ public GroupedModulePanel(ArrayList<AbstractModule> modules, LabPanel parent) {
this.modules = modules;
this.parent = parent;
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
int minWidth = 0;
int minHeight = 0;
for (AbstractModule mpn : modules) {
mpn.setMultipleModulePanel(this);
add(mpn);
Dimension dim = mpn.getCollapsedPanel().getPreferredSize();
minWidth = Math.max(minWidth, dim.width);
minHeight += dim.height;
}
min = new Dimension(minWidth, minHeight);
}
public Dimension getMinimumSize() {
return min;
}
public void organize() {
parent.sizeModule();
}
public ArrayList<AbstractModule> getModules() {
return modules;
}
public Dimension getVisibleSize(Dimension goal) {
int height = 0;
for (AbstractModule mpn : modules) {
height += mpn.getPreferredSize().height;
}
if (height > goal.height) {
return new Dimension(goal.width, height);
}
else {
ArrayList<AbstractModule> visibles = new ArrayList<AbstractModule>();
for (AbstractModule mpn : modules) {
if (mpn.isExpanded())
visibles.add(mpn);
}
if (visibles.size() > 0) {
int supp = (goal.height - height) / visibles.size();
for (AbstractModule mpn : modules) {
Dimension dim = mpn.getPreferredSize();
mpn.setPreferredSize(new Dimension(dim.width, dim.height + supp));
}
}
return new Dimension(goal.width, goal.height);
}
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index 9a47c62..388f51b 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,350 +1,351 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import deconvolution.Command;
import deconvolution.Deconvolution;
+import deconvolution.modules.ImageDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import deconvolutionlab.ImageSelector;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
- super("Image", "-image", "Active", "Show", expanded);
+ super("Image", "-image", (Lab.getPlatform() == Imaging.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, 5));
+ pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
- pn.add(bnPlatform);
+ if (Lab.getPlatform() == Imaging.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);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
+ 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(), "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) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
- file(deconvolution.getPath());
- }
- else if (e.getSource() == bnDirectory) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
- dir(deconvolution.getPath());
- }
+ 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", "" });
+ table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
- else if (e.getSource() == getAction2Button())
- display();
+ 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() {
- PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
- String name = selector.getSelectedImage();
- if (name != null)
- if (name != "")
- table.insert(new String[] { name, "platform", name, "" });
+ 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(), "" });
+ 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);
- dlg.setVisible(true);
+ Lab.setVisible(dlg, true);
+
if (dlg.wasCancel())
return;
- table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
+ 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, 1));
}
}
- dlg.setVisible(true);
+ 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(), "" });
+ 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()) {
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() {
+ private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- int row = table.getSelectedRow();
- RealSignal x = new Deconvolution(getCommand()).openImage();
- if (x != null)
- Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
- }
- });
- thread.setPriority(Thread.MIN_PRIORITY);
- thread.start();
+ Deconvolution deconvolution = new Deconvolution("ShowImage", getCommand());
+ if (stack) {
+ RealSignal x = deconvolution.openImage();
+ if (x != null)
+ Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
+ }
+ else {
+ new ImageDModule(deconvolution).show(table.getCell(row, 0));
+ }
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
index 6519392..04c1cd4 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
@@ -1,249 +1,253 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
-import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.Token;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolutionlab.Config;
import lab.component.HTMLPane;
public class LanguageModule extends AbstractModule implements ActionListener {
private HTMLPane language;
private JComboBox<String> cmb;
private JComboBox<String> gui;
private JTextField txt;
public LanguageModule(boolean expanded) {
super("Language", "", "", "", expanded);
}
+ public String getJobName() {
+ if (txt != null)
+ return txt.getText();
+ return "";
+ }
@Override
public JPanel buildExpandedPanel() {
language = new HTMLPane("Monaco", 100, 100);
cmb = new JComboBox<String>(new String[] { "Command line", "ImageJ Macro", "Java", "Matlab" });
gui = new JComboBox<String>(new String[] { "Run (Headless)", "Launch (with control panel)" });
txt = new JTextField("Job", 8);
JPanel pn = new JPanel(new BorderLayout());
pn.add(cmb, BorderLayout.WEST);
pn.add(txt, BorderLayout.CENTER);
pn.add(gui, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(language.getPane(), BorderLayout.CENTER);
cmb.addActionListener(this);
gui.addActionListener(this);
Config.register(getName(), "language", cmb, cmb.getItemAt(0));
Config.register(getName(), "headless", gui, gui.getItemAt(0));
Config.register(getName(), "job", txt, "Job");
language.clear();
return panel;
}
@Override
public void expand() {
super.expand();
update();
}
public void update() {
if (cmb.getSelectedIndex() == 0) {
language.clear();
String run = gui.getSelectedIndex() == 0 ? " Run " : " Launch ";
language.append("p", "java -jar DeconvolutionLab_2.jar " + run + Command.command());
language.append("p", "");
language.append("p", "java -cp JTransforms.jar:DeconvolutionLab_2.jar DeconvolutionLab2 "+ run + Command.command());
}
else if (cmb.getSelectedIndex() == 1) {
language.clear();
language.append("p", imagej(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 2) {
language.clear();
language.append("p", java(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 3) {
language.clear();
language.append("p", matlab());
}
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb)
update();
if (e.getSource() == gui)
update();
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
update();
}
@Override
public String getCommand() {
return "";
}
private String matlab() {
String job = txt.getText();
String script = "";
String cmd = Command.command();
- Deconvolution d = new Deconvolution(cmd);
+ Deconvolution d = new Deconvolution("Matlab", cmd);
String options = Command.extractOptions(cmd);
AbstractAlgorithm algo = d.getAlgo();
if (algo == null)
return "ERROR";
String s = algo.getShortname();
if (s.equalsIgnoreCase("lw+"))
s = "NNLW";
String param = algo.getParametersAsString();
script += p("% this function returns the deconvolved image as an 3D matrix");
script += p("% image is a 3D matrix containing the image");
script += p("% psf is a 3D matrix containing the PSF");
script += p("function result = " + job + "(image, psf)");
script += p1("% Install first DeconvolutionLab_2.jar into the java directory of Matlab");
script += p1("javaaddpath([matlabroot filesep 'java' filesep 'DeconvolutionLab_2.jar'])");
script += p1("% Run the deconvolution\n");
script += p1("result = DL2." + s + "(image, psf, " + param +" , '" + options +"');");
script += p("end");
return script;
}
private String imagej(boolean headless) {
String job = txt.getText();
String macro = p("// Job: " + job + " ");
macro += p("// Macro generated by DeconvolutionLab2 ");
macro += p("// " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()) + " ");
String param = p("parameters = \"\" ");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = "image = \" NOT DEFINED \" ";
String psf = "psf = \" NOT DEFINED \" ";
String algo = "algo = \" NOT DEFINED \" ";
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p("image = \" -image " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-psf"))
psf = p("psf = \" -psf " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-algorithm"))
algo = p("algorithm = \" -algorithm " + token.parameters.trim() + "\" ");
else
param += p("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\"");
}
String option = macro + image + psf + algo + param;
String cmd = "";
if (headless)
cmd = p("run(\"DeconvolutionLab2 Run\", image + psf + algorithm + parameters)");
else
cmd = p("run(\"DeconvolutionLab2 Launch\", image + psf + algorithm + parameters)");
return option + cmd;
}
private String java(boolean headless) {
String job = txt.getText();
String code = "";
code += p("import deconvolution.Deconvolution;");
code += p("import ij.plugin.PlugIn;");
code += p("");
code += p("public class DeconvolutionLab2_" + job + " implements PlugIn {");
code += p1("public DeconvolutionLab2_" + job + "() {");
String param = p2("String parameters = \"\";");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = p2("String image = \" NOT DEFINED \";");
String psf = p2("String psf = \" NOT DEFINED \";");
String algo = p2("String algo = \" NOT DEFINED \";");
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p2("String image = \" -image " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-psf"))
psf = p2("String psf = \" -psf " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-algorithm"))
algo = p2("String algorithm = \" -algorithm " + token.parameters.trim() + "\";");
else
param += p2("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\";");
}
code += image + psf + algo + param;
code += p2("new Deconvolution(image + psf + algorithm + parameters)");
code += p1("}");
code += p1("");
code += p1("@Override");
code += p1("public void run(String arg0) {");
code += p2(" new DeconvolutionLab2_" + job + "();");
code += p1("}");
code += p("}");
return code;
}
private String p(String content) {
return "<p>" + content + "</p>";
}
private String p1(String content) {
return "<p style=\"padding-left:10px\">" + content + "</p>";
}
private String p2(String content) {
return "<p style=\"padding-left:20px\">" + content + "</p>";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
index 8b381c8..6754279 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
@@ -1,251 +1,235 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.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 lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
+import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
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;
- private JButton bnStats;
- private JButton bnProfile;
public OutputModule(boolean expanded) {
super("Output", "", "", "Default", 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");
- bnStats = new JButton("\u2295 stats");
- bnProfile = new JButton("\u2295 profile");
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);
- pn.add(bnStats);
- pn.add(bnProfile);
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);
- bnStats.addActionListener(this);
- bnProfile.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;
- else if (e.getSource() == bnStats)
- view = View.STATS;
- else if (e.getSource() == bnProfile)
- view = View.PROFILE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
+ Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out == null)
System.out.println("Out is null");
else
table.insert(out.getAsString());
update();
}
if (e.getSource() == getAction1Button()) {
- int n = table.getRowCount();
- for (int i=0; i<n; i++)
- table.removeRow(0);
- String[] def = new String[] { "stack", "display", "intact", "float", "", "true", "false", "" };
- table.append(def);
+ 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);
- bnStats.removeActionListener(this);
- bnProfile.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index 405b479..efea6f0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
@@ -1,341 +1,338 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.Files;
-import signal.RealSignal;
-import signal.factory.SignalFactory;
import deconvolution.Command;
import deconvolution.Deconvolution;
+import deconvolution.modules.PSFDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import deconvolutionlab.ImageSelector;
+import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
-import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+import lab.tools.Files;
+import signal.RealSignal;
+import signal.factory.SignalFactory;
public class 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", "", "Show", 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);
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
- bnPlatform.addActionListener(this);
+ if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
+ bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
+ 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) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
- file(deconvolution.getPath());
- }
- else if (e.getSource() == bnDirectory) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
- dir(deconvolution.getPath());
- }
+ 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())
- display();
+ 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() {
- PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
- String name = selector.getSelectedImage();
- if (name != null)
- if (name != "")
- table.insert(new String[] {name, "platform", name, "" });
+ 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(), "" });
+ 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);
- dlg.setVisible(true);
+ Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
- table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
+ 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, 1));
}
}
- dlg.setVisible(true);
-
+ 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() {
+ private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- int row = table.getSelectedRow();
- RealSignal x = new Deconvolution(getCommand()).openPSF();
- if (x != null)
- Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
- }
- });
- thread.setPriority(Thread.MIN_PRIORITY);
- thread.start();
+ Deconvolution deconvolution = new Deconvolution("ShowPSF", getCommand());
+ if (stack) {
+ RealSignal x = deconvolution.openPSF();
+ if (x != null)
+ Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
+ }
+ else {
+ new PSFDModule(deconvolution).show(table.getCell(row, 0));
+ }
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
index 5128204..fe4faa3 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
@@ -1,73 +1,73 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import javax.swing.JPanel;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.SpinnerRangeInteger;
-import deconvolutionlab.Config;
public class PreferencesModule extends AbstractModule {
private SpinnerRangeInteger spnMaxItems;
public PreferencesModule(boolean expanded) {
super("Preferences", "", "", "", expanded);
}
@Override
public String getCommand() {
return "NO";
}
@Override
public JPanel buildExpandedPanel() {
spnMaxItems = new SpinnerRangeInteger(50, 1, 1000, 1);
JPanel panel = new JPanel(new BorderLayout());
GridPanel pn = new GridPanel(true);
pn.place(3, 0, "Maximum number of items in table");
pn.place(3, 1, spnMaxItems);
panel.add(pn, BorderLayout.NORTH);
Config.register(getName(), "maximum-items", spnMaxItems, 50);
return panel;
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
new file mode 100644
index 0000000..4cc44c0
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
@@ -0,0 +1,264 @@
+/*
+ * DeconvolutionLab2
+ *
+ * Conditions of use: You are free to use this software for research or
+ * educational purposes. In addition, we expect you to include adequate
+ * citations and acknowledgments whenever you present or publish results that
+ * are based on it.
+ *
+ * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
+ * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
+ * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
+ */
+
+/*
+ * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
+ *
+ * This file is part of DeconvolutionLab2 (DL2).
+ *
+ * DL2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * DL2. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package deconvolutionlab.modules;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+import lab.tools.Files;
+
+public class RunningModule extends AbstractModule implements MouseListener {
+
+ private CustomizedTable table;
+
+ private String[] valuesMonitor;
+ private String[] valuesVerbose;
+ private String[] valuesSystem;
+ private String[] valuesMultithreading;
+ private String[] valuesDisplay;
+ private String[] valuesStats;
+ private String[] valuesPath;
+
+ private JTextField txtMonitor;
+ private JTextField txtVerbose;
+ private JTextField txtSystem;
+ private JTextField txtMultithreading;
+ private JTextField txtDisplay;
+ private JTextField txtStats;
+ private JTextField txtPath;
+ private JTextField txtDirectory;
+
+ public RunningModule(boolean expanded) {
+ super("Running", "", "Default", "Browse", expanded);
+ }
+
+ @Override
+ public String getCommand() {
+ String cmd = "";
+ String p = txtPath.getText();
+ if (!p.equalsIgnoreCase(valuesPath[0]))
+ cmd += " -path " + txtDirectory.getText().toLowerCase();
+ if (!txtMonitor.getText().equalsIgnoreCase(valuesMonitor[0]))
+ cmd += " -monitor " + txtMonitor.getText().toLowerCase();
+ if (!txtVerbose.getText().equalsIgnoreCase(valuesVerbose[0]))
+ cmd += " -verbose " + txtVerbose.getText().toLowerCase();
+ if (!txtSystem.getText().equalsIgnoreCase(valuesSystem[0]))
+ cmd += " -system " + txtSystem.getText().toLowerCase();
+ if (!txtDisplay.getText().equalsIgnoreCase(valuesDisplay[0]))
+ cmd += " -display " + txtDisplay.getText().toLowerCase();
+ if (!txtStats.getText().equalsIgnoreCase(valuesStats[0]))
+ cmd += " -stats " + txtStats.getText().toLowerCase();
+ if (!txtMultithreading.getText().equalsIgnoreCase(valuesMultithreading[0]))
+ cmd += " -multithreading " + txtMultithreading.getText().toLowerCase();
+
+ return cmd;
+ }
+
+ @Override
+ public JPanel buildExpandedPanel() {
+
+ valuesPath = new String[] { "current", "specify" };
+ valuesMonitor = new String[] { "console table", "console", "table", "no" };
+ valuesStats = new String[] { "no", "show", "save", "show save" };
+ valuesVerbose = new String[] { "log", "quiet", "nute", "prolix" };
+ valuesSystem = new String[] { "yes", "no" };
+ valuesMultithreading = new String[] { "yes", "no" };
+ valuesDisplay = new String[] { "yes", "no" };
+
+ txtDirectory = new JTextField(System.getProperty("user.dir"));
+ txtPath = new JTextField(valuesPath[0]);
+ txtMonitor = new JTextField(valuesMonitor[0]);
+ txtStats = new JTextField(valuesStats[0]);
+ txtVerbose = new JTextField(valuesVerbose[0]);
+ txtSystem = new JTextField(valuesSystem[0]);
+ txtMultithreading = new JTextField(valuesMultithreading[0]);
+ txtDisplay = new JTextField(valuesDisplay[0]);
+
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Settings", String.class, 150, false));
+ columns.add(new CustomizedColumn("State", String.class, 100, false));
+ columns.add(new CustomizedColumn("Information", String.class, Constants.widthGUI - 250, true));
+ columns.add(new CustomizedColumn("", String.class, 100, "Change", "Change this setting"));
+ table = new CustomizedTable(columns, false);
+
+ table.getColumnModel().getColumn(3).setMaxWidth(140);
+ table.getColumnModel().getColumn(3).setMaxWidth(140);
+
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(table.getPane(100, 100), BorderLayout.CENTER);
+
+ Config.register(getName(), "Path", txtPath, valuesPath[0]);
+ Config.register(getName(), "Monitor", txtMonitor, valuesMonitor[0]);
+ Config.register(getName(), "Stats", txtStats, valuesStats[0]);
+ Config.register(getName(), "Verbose", txtVerbose, valuesVerbose[0]);
+ Config.register(getName(), "System", txtSystem, valuesSystem[0]);
+ Config.register(getName(), "Multithreading", txtMultithreading, valuesMultithreading[0]);
+ Config.register(getName(), "Display", txtDisplay, valuesDisplay[0]);
+ Config.register(getName(), "Directory", txtDirectory, System.getProperty("user.dir"));
+
+ getAction1Button().addActionListener(this);
+ getAction2Button().addActionListener(this);
+
+ table.addMouseListener(this);
+
+ return panel;
+ }
+
+ public void init() {
+ table.append(new String[] { "Path", txtPath.getText(), txtDirectory.getText(), "Change" });
+ table.append(new String[] { "Monitor", txtMonitor.getText(), "Monitor in table and in console", "Change" });
+ table.append(new String[] { "Stats", txtStats.getText(), "Compute stats (slow down)", "Change" });
+ table.append(new String[] { "Verbose", txtVerbose.getText(), "Level of messages in monitor", "Change" });
+ table.append(new String[] { "System", txtSystem.getText(), "Open the system window", "Change" });
+ table.append(new String[] { "Multithreading", txtMultithreading.getText(), "Activation of the multithreading", "Change" });
+ table.append(new String[] { "Display", txtDisplay.getText(), "Display result at the end", "Change" });
+ update();
+ }
+
+ public void update() {
+ setCommand(getCommand());
+ setSynopsis(txtDirectory.getText());
+ Command.command();
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ if (e.getSource() == getAction1Button()) {
+ for (int row = 0; row < table.getRowCount(); row++) {
+ if (table.getCell(row, 0).equalsIgnoreCase("path")) {
+ setDefault(row, valuesPath, txtPath);
+ txtDirectory.setText(System.getProperty("user.dir"));
+ table.setCell(0, 2, System.getProperty("user.dir"));
+ }
+ if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
+ setDefault(row, valuesMonitor, txtMonitor);
+ if (table.getCell(row, 0).equalsIgnoreCase("stats"))
+ setDefault(row, valuesStats, txtStats);
+ if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
+ setDefault(row, valuesVerbose, txtVerbose);
+ if (table.getCell(row, 0).equalsIgnoreCase("system"))
+ setDefault(row, valuesSystem, txtSystem);
+ if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
+ setDefault(row, valuesMultithreading, txtMultithreading);
+ if (table.getCell(row, 0).equalsIgnoreCase("display"))
+ setDefault(row, valuesDisplay, txtDisplay);
+ }
+ }
+ if (e.getSource() == getAction2Button()) {
+ File f = Files.browseDirectory(txtPath.getText());
+ if (f != null) {
+ txtDirectory.setText(f.getAbsolutePath());
+ txtPath.setText(valuesPath[1]);
+ table.setCell(0, 1, txtPath.getText());
+ table.setCell(0, 2, txtDirectory.getText());
+ }
+ }
+ update();
+ }
+
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ int row = table.getSelectedRow();
+ if (table.getSelectedColumn() == 3) {
+ if (table.getCell(row, 0).equalsIgnoreCase("path")) {
+ toggle(row, valuesPath, txtPath);
+ txtDirectory.setText(System.getProperty("user.dir"));
+ table.setCell(0, 2, System.getProperty("user.dir"));
+ }
+ if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
+ toggle(row, valuesMonitor, txtMonitor);
+ if (table.getCell(row, 0).equalsIgnoreCase("stats"))
+ toggle(row, valuesStats, txtStats);
+ if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
+ toggle(row, valuesVerbose, txtVerbose);
+ if (table.getCell(row, 0).equalsIgnoreCase("system"))
+ toggle(row, valuesSystem, txtSystem);
+ if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
+ toggle(row, valuesMultithreading, txtMultithreading);
+ if (table.getCell(row, 0).equalsIgnoreCase("display"))
+ toggle(row, valuesDisplay, txtDisplay);
+ }
+ update();
+ Command.command();
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ }
+
+ private void toggle(int row, String values[], JTextField txt) {
+ for (int i = 0; i < values.length; i++) {
+ if (table.getCell(row, 1).equalsIgnoreCase(values[i])) {
+ int k = i == values.length - 1 ? 0 : i + 1;
+ table.setCell(row, 1, values[k]);
+ txt.setText(values[k]);
+ return;
+ }
+ }
+ setDefault(row, values, txt);
+ }
+
+ private void setDefault(int row, String values[], JTextField txt) {
+ table.setCell(row, 1, values[0]);
+ txt.setText(values[0]);
+ }
+
+}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
index d78bf37..878a4de 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
@@ -1,196 +1,186 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import deconvolution.Command;
import deconvolutionlab.Config;
-import ij.IJ;
import lab.component.GridPanel;
-import lab.system.SystemPanel;
import lab.tools.Files;
public class WatcherModule extends AbstractModule implements ActionListener, KeyListener {
private JComboBox<String> cmbVerbose;
private JComboBox<String> cmbMonitor;
private JComboBox<String> cmbDisplay;
private JComboBox<String> cmbMultithreading;
private JComboBox<String> cmbPath;
private JTextField txtPath;
private JButton bnBrowse;
- private JButton bnSystem;
-
public WatcherModule(boolean expanded) {
super("Path & Watcher", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbPath.getSelectedIndex() != 0)
cmd += " -path " + txtPath.getText();
if (cmbMultithreading.getSelectedIndex() != 0)
cmd += " -" + (String)cmbMultithreading.getSelectedItem();
if (cmbDisplay.getSelectedIndex() != 0)
cmd += " -" + (String)cmbDisplay.getSelectedItem();
if (cmbMonitor.getSelectedIndex() != 0)
cmd += " -" + (String)cmbMonitor.getSelectedItem();
if (cmbVerbose.getSelectedIndex() != 0)
cmd += " -" + (String)cmbVerbose.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbVerbose = new JComboBox<String>(new String[] { "verbose log ", "verbose quiet ", "verbose prolix", "verbose mute" });
cmbDisplay = new JComboBox<String>(new String[] { "display final", "display no"});
cmbMonitor = new JComboBox<String>(new String[] { "monitor full", "monitor console", "monitor none"});
cmbMultithreading = new JComboBox<String>(new String[] { "multithreading enabled", "multithreading disabled"});
cmbPath = new JComboBox<String>(new String[] { "Current", "Specify"});
txtPath = new JTextField("", 30);
bnBrowse = new JButton("Browse");
- bnSystem = new JButton("System");
GridPanel pn1 = new GridPanel(true, 3);
pn1.place(0, 0, 2, 1, "Working directory");
pn1.place(1, 0, cmbPath);
pn1.place(1, 1, bnBrowse);
pn1.place(2, 0, 2, 1, txtPath);
GridPanel pn2 = new GridPanel(true, 3);
pn2.place(2, 0, cmbVerbose);
pn2.place(2, 1, cmbMonitor);
pn2.place(3, 0, cmbDisplay);
pn2.place(3, 1, cmbMultithreading);
- pn2.place(4, 1, bnSystem);
-
+
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(pn1);
panel.add(pn2);
String dir = System.getProperty("user.dir");
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
Config.register(getName(), "display", cmbDisplay, cmbDisplay.getItemAt(0));
Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
Config.register(getName(), "current", cmbPath, cmbPath.getItemAt(0));
Config.register(getName(), "path", txtPath, dir);
cmbPath.addActionListener(this);
txtPath.addKeyListener(this);
cmbVerbose.addActionListener(this);
cmbDisplay.addActionListener(this);
cmbMultithreading.addActionListener(this);
cmbMonitor.addActionListener(this);
bnBrowse.addActionListener(this);
- bnSystem.addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
if (cmbPath.getSelectedIndex() == 0) {
txtPath.setText(System.getProperty("user.dir"));
txtPath.setEnabled(false);
bnBrowse.setEnabled(false);
}
else {
txtPath.setEnabled(true);
bnBrowse.setEnabled(true);
}
setSynopsis(txtPath.getText());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
- if (e.getSource() == bnSystem) {
- SystemPanel.show(400, 400);
- }
- else if (e.getSource() == bnBrowse) {
+ if (e.getSource() == bnBrowse) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtPath.setText(f.getAbsolutePath());
}
}
else if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
}
update();
}
@Override
public void close() {
cmbVerbose.removeActionListener(this);
cmbDisplay.removeActionListener(this);
cmbMultithreading.removeActionListener(this);
cmbMonitor.removeActionListener(this);
cmbPath.removeActionListener(this);
txtPath.removeKeyListener(this);
bnBrowse.removeActionListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
index 21f4b31..382d599 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
@@ -1,82 +1,82 @@
/*
* 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.monitor;
-import lab.system.SystemUsage;
+import deconvolutionlab.system.SystemUsage;
import lab.tools.NumFormat;
public class Message {
private static long id = 0;
private double chrono;
private String mem;
private Verbose level;
private String message;
private double progress;
public Message(Verbose level, String message, double chrono, double progress) {
id = id+1;
this.chrono = chrono;
this.mem = SystemUsage.getMemoryMB();
this.message = message;
this.level = level;
this.progress = progress;
}
public long getID() {
return id;
}
public String getMessage() {
return message;
}
public Verbose getLevel() {
return level;
}
public double getProgress() {
return progress;
}
public String formatProgress() {
return NumFormat.time(chrono) + " \t " + message + " (" + progress + "%)";
}
public String formatTab() {
return level.name() + " \t " + NumFormat.time(chrono) + " \t " + mem + " \t " + message;
}
public String[] formatArray() {
return new String[] {NumFormat.time(chrono), mem, message};
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
index 51dc735..0e38608 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
@@ -1,133 +1,133 @@
/*
* 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.monitor;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableModel;
+import deconvolutionlab.system.SystemUsage;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
-import lab.system.SystemUsage;
import lab.tools.NumFormat;
public class RunningMonitor implements AbstractMonitor {
private CustomizedTable table;
private JPanel panel;
private double chrono = System.nanoTime();
private double peak = 0;
public RunningMonitor(int width, int height) {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Iteration", String.class, 60, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 4*100), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(40);
table.getColumnModel().getColumn(0).setMaxWidth(80);
table.getColumnModel().getColumn(1).setMinWidth(40);
table.getColumnModel().getColumn(1).setMaxWidth(80);
table.getColumnModel().getColumn(2).setMinWidth(40);
table.getColumnModel().getColumn(2).setMaxWidth(80);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JToolBar main = new JToolBar();
main.setFloatable(true);
main.setLayout(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public void reset() {
chrono = System.nanoTime();
peak = 0;
}
public JPanel getPanel() {
return panel;
}
public void show(String title) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
@Override
public void add(Message message) {
String msg = message.getMessage();
String iteration = "";
if (msg.startsWith("@")) {
String parts[] = msg.split(" ");
if (parts.length >= 1)
iteration = parts[0];
msg = msg.substring(parts[0].length(), msg.length()).trim();
}
String time = NumFormat.seconds(System.nanoTime()-chrono);
peak = Math.max(peak, SystemUsage.getHeapUsed());
String mem = NumFormat.bytes(peak);
String[] row = new String[] {time, mem, iteration, msg};
table.append(row);
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public String getName() {
return "running";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
index d4e4e5c..15ca443 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
@@ -1,179 +1,156 @@
/*
* 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.monitor;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
-import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
-import javax.swing.JToolBar;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
public class TableMonitor implements AbstractMonitor, ActionListener {
private CustomizedTable table;
private JButton bnClear = new JButton("Clear");
- private JButton bnProlix = new JButton("Prolix");
- private JButton bnVerbose = new JButton("verbose");
- private JButton bnQuiet = new JButton("Quiet");
- private JButton bnMute = new JButton("Mute");
private HashMap<Long, Color> colors = new HashMap<Long, Color>();
private JPanel panel;
-
- public TableMonitor(int width, int height) {
+ private String name;
+
+ public TableMonitor(String name, int width, int height) {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("#", Long.class, 60, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 3 * 60), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(60);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.getColumnModel().getColumn(1).setMaxWidth(100);
table.getColumnModel().getColumn(1).setMinWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMinWidth(100);
RowRenderer renderer = new RowRenderer();
for (int i = 0; i < 4; i++)
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
- /*
- JToolBar tool = new JToolBar();
- tool.setFloatable(false);
- tool.setLayout(new GridLayout(1, 3));
- tool.add(bnClear);
- tool.add(new JLabel(""));
- tool.add(new JLabel(""));
- tool.add(bnProlix);
- tool.add(bnVerbose);
- tool.add(bnQuiet);
- tool.add(bnMute);
- */
JPanel main = new JPanel(new BorderLayout());
- //main.add(tool, BorderLayout.NORTH);
main.add(scroll, BorderLayout.CENTER);
bnClear.addActionListener(this);
- bnVerbose.addActionListener(this);
- bnQuiet.addActionListener(this);
- bnProlix.addActionListener(this);
- bnMute.addActionListener(this);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public JPanel getPanel() {
return panel;
}
- public void show(String title) {
- JFrame frame = new JFrame(title);
+ public void show() {
+ JFrame frame = new JFrame(name);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public void add(Message message) {
String msg[] = message.formatArray();
int n = msg.length;
Object[] row = new Object[n + 1];
row[0] = message.getID();
for (int i = 0; i < n; i++)
row[i + 1] = msg[i];
table.append(row);
Verbose level = message.getLevel();
Color c = new Color(0, 0, 0);
if (level == Verbose.Prolix)
c = new Color(255, 0, 0);
else if (level == Verbose.Quiet)
c = new Color(200, 200, 0);
colors.put(new Long(message.getID()), c);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnClear) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
}
@Override
public String getName() {
- return "table";
+ return name;
}
class RowRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row >= 0) {
Long id = (Long) model.getValueAt(row, 0);
Color color = colors.get(id);
c.setForeground(color);
}
return c;
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
new file mode 100644
index 0000000..86b447e
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
@@ -0,0 +1,121 @@
+/*
+ * 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.system;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.util.HashMap;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
+import deconvolutionlab.Constants;
+import lab.component.CustomizedTable;
+
+public abstract class AbstractMeter extends JButton {
+
+ protected Color colorBackground = new Color(10, 10, 10, 30);
+ protected Color colorText = new Color(10, 10, 10);
+ protected Color colorHot = new Color(10, 10, 160, 30);
+
+ protected CustomizedTable table;
+ protected HashMap<String, Integer> features = new HashMap<String, Integer>();
+ protected boolean initialized = false;
+ protected String prefix = "\u25BA ";
+ protected boolean collapse = true;
+
+ public AbstractMeter() {
+ super("");
+ int w = (int)(Constants.widthGUI/3.2);
+ int h = 25;
+ setBorder(BorderFactory.createEtchedBorder());
+ setPreferredSize(new Dimension(w, h));
+ setMinimumSize(new Dimension(w, h));
+ table = new CustomizedTable(new String[] {"Tool", "Feature", "Value"}, false);
+ }
+
+ public boolean isExpanded() {
+ return !collapse;
+ }
+
+ public void collapse() {
+ collapse = true;
+ prefix = " \u25BA ";
+ }
+
+ public void expand() {
+ collapse = false;
+ prefix = " \u25BC ";
+ }
+
+ public JPanel getPanel(int width, int height) {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(table.getPane(width, height), BorderLayout.CENTER);
+ setDetail();
+ initialized = true;
+ return panel;
+ }
+
+ public abstract String getName();
+ public abstract void setDetail();
+
+ public void update() {
+ if (table == null)
+ return;
+
+ setDetail();
+ System.out.println("SetDetail" + getName());
+ }
+
+ protected void add(int i, String row[]) {
+ if (initialized) {
+ int r = features.get(row[0]);
+ if (i>=0 && i<table.getRowCount())
+ table.setCell(r, 1, row[1]);
+ }
+ else {
+ table.append(row);
+ features.put(row[0], i);
+ }
+ }
+
+
+ protected String split(String name) {
+ String func = name.substring(3);
+ return func.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
+ }
+
+
+
+}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
similarity index 69%
copy from DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
copy to DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
index d99963b..525acf3 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
@@ -1,50 +1,64 @@
/*
* 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.system;
+
+import java.awt.Graphics;
import java.io.File;
+import java.lang.management.ClassLoadingMXBean;
+import java.lang.management.ManagementFactory;
+
+import fft.FFT;
+import lab.tools.NumFormat;
+
+public class FFTMeter extends AbstractMeter {
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ g.setColor(colorText);
+ g.drawString(prefix + FFT.getFastestFFT().getLibraryName(), 10, 17);
+ }
-import deconvolutionlab.Config;
-import deconvolutionlab.Lab;
-import deconvolutionlab.Platform;
-import deconvolutionlab.dialog.LabDialog;
-import ij.IJ;
-import ij.plugin.PlugIn;
+ @Override
+ public void update() {
+ repaint();
+ }
-public class DeconvolutionLab2_Lab implements PlugIn {
+ @Override
+ public String getName() {
+ return "FFT";
+ }
@Override
- public void run(String arg) {
- Lab.getInstance(Platform.IMAGEJ);
- String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
- Config.getInstance(config);
- new LabDialog().setVisible(true);
+ public void setDetail() {
}
-}
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/lab/system/SystemHeap.java b/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
similarity index 50%
copy from DeconvolutionLab2/src/lab/system/SystemHeap.java
copy to DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
index 537956e..d636961 100644
--- a/DeconvolutionLab2/src/lab/system/SystemHeap.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
@@ -1,86 +1,91 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.system;
+package deconvolutionlab.system;
-import java.awt.Color;
-import java.awt.Dimension;
import java.awt.Graphics;
+import java.io.File;
+import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryUsage;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
import lab.tools.NumFormat;
-public class SystemHeap extends JLabel {
-
- private double peak;
-
- public SystemHeap() {
- super("");
- setBorder(BorderFactory.createEtchedBorder());
- setPreferredSize(new Dimension(200, 20));
- setMinimumSize(new Dimension(200, 20));
- setMaximumSize(new Dimension(200, 20));
- }
-
- public void reset() {
- peak = 0;
- }
-
+public class FileMeter extends AbstractMeter {
+
@Override
public void paintComponent(Graphics g) {
- MemoryUsage mem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
- double used = mem.getUsed();
- double maxi = mem.getMax();
- peak = Math.max(used, peak);
super.paintComponent(g);
+
+ double maxi = SystemUsage.getTotalSpace();
+ double used = maxi - SystemUsage.getAvailableSpace();
+ String space = NumFormat.bytes(used);
int w = getWidth();
- g.setColor(new Color(10, 10, 10, 30));
+ g.setColor(colorBackground);
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
- int posp = (int)Math.round(w*peak/maxi);
- String u = NumFormat.bytes(used);
- String m = NumFormat.bytes(maxi);
-
- g.setColor(new Color(10, 10, 160, 30));
+ g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
- g.fillRect(0, 0, posp, 30);
- g.setColor(new Color(160, 10, 10));
- g.drawString(u, 10, 13);
- //g.drawString(p, posp, 13);
- g.drawString(m, w-60, 13);
+
+ g.setColor(colorText);
+ g.drawString(prefix + space, 10, 17);
+ }
+
+ @Override
+ public void update() {
+ repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "File";
+ }
+
+ @Override
+ public void setDetail() {
+ File[] roots = File.listRoots();
+ int i=0;
+ add(i++, new String[] { "Properties", "java.class.path", System.getProperty("java.class.path") });
+ add(i++, new String[] { "Properties", "java.home", System.getProperty("java.home") });
+ add(i++, new String[] { "Properties", "user.dir", System.getProperty("user.dir") });
+ add(i++, new String[] { "Properties", "user.home", System.getProperty("user.home") });
+ add(i++, new String[] { "Properties", "user.name", System.getProperty("user.name") });
+
+ for (File root : roots) {
+ add(i++, new String[] { "FileSystem", "Root Path", root.getAbsolutePath() });
+ add(i++, new String[] { "FileSystem", "Total Space", NumFormat.bytes(root.getTotalSpace()) });
+ add(i++, new String[] { "FileSystem", "Usable Space", NumFormat.bytes(root.getUsableSpace()) });
+ }
+ ClassLoadingMXBean loader = ManagementFactory.getClassLoadingMXBean();
+ add(i++, new String[] { "ClassLoading", "Loaded Class", "" + loader.getLoadedClassCount() });
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
new file mode 100644
index 0000000..183c775
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
@@ -0,0 +1,79 @@
+/*
+ * 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.system;
+
+import java.awt.Graphics;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+
+import lab.tools.NumFormat;
+
+public class JavaMeter extends AbstractMeter {
+
+ @Override
+ public void paintComponent(Graphics g) {
+ g.setColor(colorText);
+ g.drawString(prefix + "Java "+ System.getProperty("java.version") , 10, 17);
+ }
+
+ @Override
+ public void update() {
+ repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "Java";
+ }
+
+ @Override
+ public void setDetail() {
+ int i = 0;
+ add(i++, new String[] { "Properties", "OS", System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") });
+ add(i++, new String[] { "Properties", "Java Version", System.getProperty("java.version") });
+
+ RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
+ add(i++, new String[] { "Runtime", "LibraryPath", rt.getLibraryPath() });
+ add(i++, new String[] { "Runtime", "Name", rt.getName() });
+ add(i++, new String[] { "Runtime", "VmVersion", rt.getVmVersion() });
+ for (int k = 0; k<rt.getInputArguments().size(); k++) {
+ String input = rt.getInputArguments().get(k);
+ add(i++, new String[] { "Runtime", "Input Arguments " + (k+1), input });
+ }
+
+ Runtime runt = Runtime.getRuntime();
+ add(i++, new String[] { "JVM", "Available processors", "" + runt.availableProcessors() });
+ add(i++, new String[] { "JVM", "Initial Memory (-Xms)", NumFormat.bytes(runt.freeMemory()) });
+ add(i++, new String[] { "JVM", "Maximum Memory (-Xmx)", NumFormat.bytes(runt.maxMemory()) });
+ add(i++, new String[] { "JVM", "Total Used Memory", NumFormat.bytes(runt.totalMemory()) });
+ }
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/lab/system/SystemHeap.java b/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
similarity index 59%
rename from DeconvolutionLab2/src/lab/system/SystemHeap.java
rename to DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
index 537956e..6c42d7a 100644
--- a/DeconvolutionLab2/src/lab/system/SystemHeap.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
@@ -1,86 +1,101 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.system;
+package deconvolutionlab.system;
+
-import java.awt.Color;
-import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-
import lab.tools.NumFormat;
-public class SystemHeap extends JLabel {
+public class MemoryMeter extends AbstractMeter {
private double peak;
- public SystemHeap() {
- super("");
- setBorder(BorderFactory.createEtchedBorder());
- setPreferredSize(new Dimension(200, 20));
- setMinimumSize(new Dimension(200, 20));
- setMaximumSize(new Dimension(200, 20));
- }
-
public void reset() {
peak = 0;
}
+ @Override
+ public void update() {
+ repaint();
+ }
+
@Override
public void paintComponent(Graphics g) {
MemoryUsage mem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
double used = mem.getUsed();
double maxi = mem.getMax();
peak = Math.max(used, peak);
super.paintComponent(g);
int w = getWidth();
- g.setColor(new Color(10, 10, 10, 30));
+ g.setColor(colorBackground);
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
int posp = (int)Math.round(w*peak/maxi);
String u = NumFormat.bytes(used);
- String m = NumFormat.bytes(maxi);
- g.setColor(new Color(10, 10, 160, 30));
+ g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
g.fillRect(0, 0, posp, 30);
- g.setColor(new Color(160, 10, 10));
- g.drawString(u, 10, 13);
- //g.drawString(p, posp, 13);
- g.drawString(m, w-60, 13);
+ g.setColor(colorText);
+ g.drawString(prefix + u, 10, 17);
+ }
+
+ @Override
+ public String getName() {
+ return "Memory";
+ }
+
+ @Override
+ public void setDetail() {
+ MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
+ MemoryUsage heapU = mem.getHeapMemoryUsage();
+ MemoryUsage nonhU = mem.getNonHeapMemoryUsage();
+ Runtime runt = Runtime.getRuntime();
+ int i = 0;
+ add(i++, new String[] { "JVM", "Initial Memory (-Xms)", NumFormat.bytes(runt.freeMemory()) });
+ add(i++, new String[] { "JVM", "Maximum Memory (-Xmx)", NumFormat.bytes(runt.maxMemory()) });
+ add(i++, new String[] { "JVM", "Total Used Memory", NumFormat.bytes(runt.totalMemory()) });
+
+ add(i++, new String[] { "Memory", "Heap Used", NumFormat.bytes(heapU.getUsed()) });
+ add(i++, new String[] { "Memory", "Heap Init", NumFormat.bytes(heapU.getInit()) });
+ add(i++, new String[] { "Memory", "Heap Max ", NumFormat.bytes(heapU.getMax()) });
+
+ add(i++, new String[] { "Memory", "NonHeap Used", NumFormat.bytes(nonhU.getUsed()) });
+ add(i++, new String[] { "Memory", "NonHeap Init", NumFormat.bytes(nonhU.getInit()) });
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/lab/system/SystemCPU.java b/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
similarity index 59%
rename from DeconvolutionLab2/src/lab/system/SystemCPU.java
rename to DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
index 531e509..9ea7da4 100644
--- a/DeconvolutionLab2/src/lab/system/SystemCPU.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
@@ -1,100 +1,104 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.system;
+package deconvolutionlab.system;
import java.awt.Color;
-import java.awt.Dimension;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
+import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
+import lab.tools.NumFormat;
-import deconvolutionlab.Constants;
-
-public class SystemCPU extends JLabel {
-
- private double peak;
-
- public SystemCPU() {
- super("");
- setBorder(BorderFactory.createEtchedBorder());
- setPreferredSize(new Dimension(200, 20));
- setMinimumSize(new Dimension(200, 20));
- setMaximumSize(new Dimension(200, 20));
- }
-
- public void reset() {
- peak = 0;
- }
+public class ProcessorMeter extends AbstractMeter {
+
+ @Override
+ public void update() {
+ repaint();
+ }
@Override
public void paintComponent(Graphics g) {
- OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- double l = 20;
- for (Method method : os.getClass().getDeclaredMethods()) {
- method.setAccessible(true);
- if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) {
- try {
- if (method.getName().contains("ProcessCpuLoad") )
-
- l = Double.parseDouble(method.invoke(os).toString());
- }
- catch (Exception e) {}
- }
- }
-
-
- double used = l;
+ double used = SystemUsage.getLoad();
double maxi = 100;
- peak = Math.max(used, peak);
super.paintComponent(g);
int w = getWidth();
g.setColor(new Color(10, 10, 10, 30));
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
- int posp = (int)Math.round(w*peak/maxi);
- String u = String.format("%3.3f", used);
+ String u = String.format("%3.3f", used);
- g.setColor(new Color(10, 10, 160, 30));
+ g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
- g.fillRect(0, 0, posp, 30);
- g.setColor(new Color(160, 10, 10));
- g.drawString(u + "%", 10, 13);
- g.drawString("100%", w-50, 13);
+ g.setColor(colorText);
+ g.drawString(prefix + u + "%", 10, 17);
+ }
+
+ @Override
+ public String getName() {
+ return "Processor";
}
+
+ @Override
+ public void setDetail() {
+ Runtime runt = Runtime.getRuntime();
+ int i = 0;
+ RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
+ add(i++, new String[] { "JVM", "Available processors", "" + runt.availableProcessors() });
+ add(i++, new String[] { "Runtime", "Uptime", "" + NumFormat.time(rt.getUptime()*1e6) });
+ OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
+ for (Method method : os.getClass().getDeclaredMethods()) {
+ method.setAccessible(true);
+ if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) {
+ try {
+ String name = split(method.getName());
+ if (name.contains("Size"))
+ add(i++, new String[] { "OS", name, NumFormat.bytes(Double.parseDouble(method.invoke(os).toString())) });
+ else if (name.contains("Time"))
+ add(i++, new String[] { "OS", name, NumFormat.time(Double.parseDouble(method.invoke(os).toString())) });
+ else if (name.contains("Load"))
+ add(i++, new String[] { "OS", name, NumFormat.nice(100 * Double.parseDouble(method.invoke(os).toString()))+"%" });
+ else
+ add(i++, new String[] { "OS", name, "" + method.invoke(os).toString() });
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+ }
+
+
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java b/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
similarity index 73%
rename from DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java
rename to DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
index 279a9de..f09eabf 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
@@ -1,39 +1,60 @@
/*
* 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;
+package deconvolutionlab.system;
-public abstract class PlatformImageSelector {
+import java.awt.Graphics;
- public abstract String getSelectedImage();
+import signal.SignalCollector;
- public abstract boolean isSelectable();
-}
+public class SignalMeter extends AbstractMeter {
+
+ @Override
+ public void paintComponent(Graphics g) {
+ g.setColor(colorText);
+ g.drawString(prefix + SignalCollector.sumarize(), 10, 17);
+ }
+
+ @Override
+ public void update() {
+ repaint();
+ }
+
+ @Override
+ public String getName() {
+ return "Signals";
+ }
+
+ @Override
+ public void setDetail() {
+
+ }
+}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
new file mode 100644
index 0000000..8595898
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
@@ -0,0 +1,285 @@
+/*
+ * 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.system;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.util.ArrayList;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
+import fft.FFTPanel;
+import lab.component.PanelImage;
+import lab.tools.NumFormat;
+import signal.SignalCollector;
+
+public class SystemInfo extends JDialog implements WindowListener, ActionListener, MouseListener {
+
+ private JPanel cards;
+
+ private String[] rates = new String[] { "1 s.", "0.5 s.", "0.2 s.", "0.1 s.", "10 s.", "5 s.", "2 s." };
+ private JButton bnRate = new JButton("1 s.");
+ private JButton bnClear = new JButton("Clear");
+
+ private Timer timer = new Timer();
+ private TimerTask updater = new Updater();
+
+ private MemoryMeter memory;
+ private ProcessorMeter processor;
+ private SignalMeter signal;
+ private FFTMeter fft;
+ private JavaMeter java;
+ private FileMeter file;
+
+ private int width = Constants.widthGUI;
+
+ private static SystemInfo instance;
+ private int rate = 0;
+
+ private ArrayList<AbstractMeter> meters = new ArrayList<AbstractMeter>();
+
+ public static void activate() {
+ if (instance == null) {
+ instance = new SystemInfo();
+ instance.setVisible(true);
+ Config.registerFrame("System", "Frame", instance);
+ return;
+ }
+ if (!instance.isVisible())
+ instance.setVisible(true);
+ instance.toFront();
+ }
+
+ public static void close() {
+ if (instance == null)
+ return;
+ if (instance.isVisible())
+ instance.dispose();
+ }
+
+ private SystemInfo() {
+ super(new JFrame(), "DeconvolutionLab2 System");
+
+ memory = new MemoryMeter();
+ processor = new ProcessorMeter();
+ signal = new SignalMeter();
+ fft = new FFTMeter();
+ java = new JavaMeter();
+ file = new FileMeter();
+ meters.add(memory);
+ meters.add(processor);
+ meters.add(signal);
+ meters.add(fft);
+ meters.add(java);
+ meters.add(file);
+
+ // Panel meters on top
+ JPanel meters = new JPanel(new GridLayout(2, 3));
+ meters.add(file);
+ meters.add(memory);
+ meters.add(processor);
+ meters.add(java);
+ meters.add(signal);
+ meters.add(fft);
+
+ bnClear.setToolTipText("Clear all the entries");
+ bnRate.setToolTipText("Choose the rate of refreshing the information");
+ JPanel pan = new JPanel(new GridLayout(2, 1));
+ pan.add(bnRate);
+ pan.add(bnClear);
+
+ restart();
+
+
+ // Panel Compact
+ PanelImage pnCompact = new PanelImage("celegans.jpg");
+ pnCompact.setPreferredSize(new Dimension(width, 20));
+
+ // Panel cards, compact is visible
+ cards = new JPanel(new CardLayout());
+ cards.add("collapse", pnCompact);
+ cards.add(signal.getName(), SignalCollector.getPanel(width, 200));
+ cards.add(memory.getName(), memory.getPanel(width, 200));
+ cards.add(processor.getName(), processor.getPanel(width, 200));
+ cards.add(fft.getName(), new FFTPanel(width, 200));
+ cards.add(java.getName(), java.getPanel(width, 200));
+ cards.add(file.getName(), file.getPanel(width, 200));
+
+ cards.setVisible(false);
+ JPanel top = new JPanel(new BorderLayout());
+ top.add(meters, BorderLayout.CENTER);
+ top.add(pan, BorderLayout.EAST);
+
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(top, BorderLayout.NORTH);
+ panel.add(cards, BorderLayout.CENTER);
+
+ getContentPane().add(panel);
+ bnClear.addActionListener(this);
+ signal.addMouseListener(this);
+ memory.addMouseListener(this);
+ processor.addMouseListener(this);
+ java.addMouseListener(this);
+ file.addMouseListener(this);
+ fft.addMouseListener(this);
+ bnRate.addActionListener(this);
+ setMinimumSize(new Dimension(width, 70));
+ pack();
+ bnClear.setEnabled(signal.isExpanded());
+ Rectangle rect = Config.getDialog("System.Frame");
+ if (rect.x > 0 && rect.y > 0)
+ setLocation(rect.x, rect.y);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ if (e.getSource() == bnRate) {
+ rate++;
+ if (rate >= rates.length)
+ rate = 0;
+ bnRate.setText(rates[rate]);
+ restart();
+ }
+
+ if (e.getSource() == bnClear)
+ SignalCollector.clear();
+
+ pack();
+ }
+
+ public void update() {
+ for(AbstractMeter meter : meters)
+ meter.update();
+ }
+
+ public void restart() {
+ long refreshTime = (long) (NumFormat.parseNumber(bnRate.getText(), 1) * 1000);
+
+ if (updater != null) {
+ updater.cancel();
+ updater = null;
+ }
+ updater = new Updater();
+ timer.schedule(updater, 0, refreshTime);
+ }
+
+ private class Updater extends TimerTask {
+ @Override
+ public void run() {
+ update();
+ }
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getSource() instanceof AbstractMeter) {
+ AbstractMeter meter = (AbstractMeter) e.getSource();
+ if (meter.isExpanded()) {
+ meter.collapse();
+ cards.setVisible(false);
+ }
+ else for(AbstractMeter m : meters) {
+ if (m.isExpanded())
+ m.collapse();
+ meter.expand();
+ cards.setVisible(true);
+ }
+ ((CardLayout) (cards.getLayout())).show(cards, meter.getName());
+ pack();
+ }
+ bnClear.setEnabled(signal.isExpanded());
+ }
+
+ @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 windowOpened(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ timer.cancel();
+ timer = 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) {
+ }
+}
diff --git a/DeconvolutionLab2/src/lab/system/SystemUsage.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
similarity index 82%
rename from DeconvolutionLab2/src/lab/system/SystemUsage.java
rename to DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
index 958850b..89e5b6b 100644
--- a/DeconvolutionLab2/src/lab/system/SystemUsage.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
@@ -1,109 +1,121 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.system;
+package deconvolutionlab.system;
+import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
import lab.tools.NumFormat;
public class SystemUsage {
public static String getMemoryMB() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- double c = 1.0/ (1024.0*1024.0);
+ double c = 1.0 / (1024.0 * 1024.0);
double heap = mem.getHeapMemoryUsage().getUsed() * c;
return String.format("%6.1fMb ", heap);
}
-
+
public String getMemoryUsage() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- double c = 1.0/ (1024.0*1024.0);
+ double c = 1.0 / (1024.0 * 1024.0);
double heap = mem.getHeapMemoryUsage().getUsed() * c;
double nonheap = mem.getNonHeapMemoryUsage().getUsed() * c;
return String.format("Heap:%6.1fMb NonHeap:%6.1fMb ", heap, nonheap);
}
public static String getMemory() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
String heap = NumFormat.bytes(mem.getHeapMemoryUsage().getUsed());
- String max = NumFormat.bytes(mem.getHeapMemoryUsage().getMax());
+ String max = NumFormat.bytes(mem.getHeapMemoryUsage().getMax());
return heap + "/" + max;
}
-
+
public static String getCores() {
String load = "" + Runtime.getRuntime().availableProcessors() + " cores";
return load;
}
public static double getHeapUsed() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
return mem.getHeapMemoryUsage().getUsed();
}
public static double getNonHeapUsed() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
return mem.getNonHeapMemoryUsage().getUsed();
}
public static double[] getHeap() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
double u = mem.getHeapMemoryUsage().getUsed();
double m = mem.getHeapMemoryUsage().getMax();
double i = mem.getHeapMemoryUsage().getInit();
- return new double[] {i, u, m};
+ return new double[] { i, u, m };
}
public static String getNonHeap() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- double c = 1.0/ (1024.0*1024.0);
+ double c = 1.0 / (1024.0 * 1024.0);
double u = mem.getNonHeapMemoryUsage().getUsed() * c;
double m = mem.getNonHeapMemoryUsage().getMax() * c;
double i = mem.getNonHeapMemoryUsage().getMax() * c;
return String.format("u=%3.2f m=%3.2f i=%3.2f Mb", u, m, i);
}
-
- public static String getLoad() {
- String load = "" + Runtime.getRuntime().availableProcessors() + " cores";
+
+ public static double getLoad() {
try {
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- double l = os.getSystemLoadAverage();
- load += " | Average Load:" + String.format("%3.1f ", l*100) + " | ";
- }
- catch(Exception ex) {
+ return os.getSystemLoadAverage();
}
- return load;
+ catch (Exception ex) {
+ }
+ return 0;
}
-
+ public static double getAvailableSpace() {
+ File[] roots = File.listRoots();
+ for(File root : roots)
+ return root.getUsableSpace();
+ return 0;
+ }
+
+ public static double getTotalSpace() {
+ File[] roots = File.listRoots();
+ for(File root : roots)
+ return root.getTotalSpace();
+ return 0;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/AbstractFFT.java b/DeconvolutionLab2/src/fft/AbstractFFT.java
index 691c2d4..271bdb7 100644
--- a/DeconvolutionLab2/src/fft/AbstractFFT.java
+++ b/DeconvolutionLab2/src/fft/AbstractFFT.java
@@ -1,101 +1,101 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package fft;
import deconvolutionlab.monitor.Monitors;
import signal.ComplexSignal;
import signal.RealSignal;
public abstract class AbstractFFT {
protected int nx = 2;
protected int ny = 2;
protected int nz = 2;
protected Separability sep;
public AbstractFFT(Separability sep) {
this.sep = sep;
}
public Separability getSeparability() {
return sep;
}
public void init(Monitors monitors, int nx, int ny, int nz) {
this.nx = nx;
this.ny = ny;
this.nz = nz;
monitors.log(getName() + " initialized for [" + nx + "x" + ny + "x" + nz + "]");
}
public abstract void transformInternal(RealSignal xInput, ComplexSignal XAllocated);
public abstract void inverseInternal(ComplexSignal XInput, RealSignal xAllocated);
public ComplexSignal transform(RealSignal x, ComplexSignal XAllocated) {
if (XAllocated == null)
- XAllocated = new ComplexSignal(nx, ny, nz);
+ XAllocated = new ComplexSignal("fft(" + x.name + ")", nx, ny, nz);
transformInternal(x, XAllocated);
return XAllocated;
}
public ComplexSignal transform(RealSignal x) {
- ComplexSignal X = new ComplexSignal(nx, ny, nz);
+ ComplexSignal X = new ComplexSignal("fft(" + x.name + ")", nx, ny, nz);
transformInternal(x, X);
return X;
}
public RealSignal inverse(ComplexSignal X, RealSignal xAllocated) {
if (xAllocated == null)
- xAllocated = new RealSignal(nx, ny, nz);
+ xAllocated = new RealSignal("ifft(" + X.name + ")", nx, ny, nz);
inverseInternal(X, xAllocated);
return xAllocated;
}
public RealSignal inverse(ComplexSignal X) {
- RealSignal x = new RealSignal(nx, ny, nz);
+ RealSignal x = new RealSignal("ifft(" + X.name + ")", nx, ny, nz);
inverseInternal(X, x);
return x;
}
public abstract String getName();
public int getSizeX() {
return nx;
}
public int getSizeY() {
return ny;
}
public int getSizeZ() {
return nz;
}
}
diff --git a/DeconvolutionLab2/src/fft/FFT.java b/DeconvolutionLab2/src/fft/FFT.java
index dc3ed84..70c0d95 100644
--- a/DeconvolutionLab2/src/fft/FFT.java
+++ b/DeconvolutionLab2/src/fft/FFT.java
@@ -1,144 +1,155 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package fft;
import java.util.ArrayList;
import deconvolutionlab.monitor.Monitors;
import fft.academic.Academic;
import fft.academic.AcademicLibrary;
import fft.fftw.FFTW3D;
import fft.fftw.FFTWLibrary;
import fft.jtransforms.JTransforms;
import fft.jtransforms.JTransformsLibrary;
public class FFT {
private static ArrayList<AbstractFFTLibrary> libraries = new ArrayList<AbstractFFTLibrary>();
private static ArrayList<AbstractFFTLibrary> registers = new ArrayList<AbstractFFTLibrary>();
static {
Monitors monitors = Monitors.createDefaultMonitor();
AcademicLibrary academic = new AcademicLibrary();
if (academic.isInstalled()) {
libraries.add(academic);
monitors.log("AcademicFFT Added");
}
else {
monitors.log("AcademicFFT not found");
}
JTransformsLibrary jtransform = new JTransformsLibrary();
if (jtransform.isInstalled()) {
libraries.add(jtransform);
monitors.log("JTransforms Added");
}
else {
monitors.log("JTransforms not found");
}
FFTWLibrary jfftw = new FFTWLibrary(monitors);
if (jfftw.isInstalled()) {
libraries.add(jfftw);
monitors.log("FFTW Added");
}
else {
monitors.log("FFTW not found");
- }
-
+ }
registers.add(academic);
registers.add(jtransform);
registers.add(jfftw);
}
public static ArrayList<AbstractFFTLibrary> getRegisteredLibraries() {
return registers;
}
public static ArrayList<AbstractFFTLibrary> getInstalledLibraries() {
return libraries;
}
+ public static AbstractFFTLibrary getFastestFFT() {
+ for (int i = 0; i < libraries.size(); i++)
+ if (libraries.get(i).getLibraryName().equals("FFTW2"))
+ return libraries.get(i);
+ for (int i = 0; i < libraries.size(); i++)
+ if (libraries.get(i).getLibraryName().equals("JTransforms"))
+ return libraries.get(i);
+ return libraries.get(0);
+ }
+
public static String[] getLibrariesAsArray() {
- String[] libs = new String[libraries.size()];
+ String[] libs = new String[libraries.size()+1];
+ libs[0] = "Fastest";
for (int i = 0; i < libraries.size(); i++)
- libs[i] = libraries.get(i).getLibraryName();
+ libs[i+1] = libraries.get(i).getLibraryName();
return libs;
}
public static AbstractFFT createFFT(Monitors monitors, AbstractFFTLibrary fftlib, int nx, int ny, int nz) {
String name = fftlib.getLibraryName().toLowerCase();
AbstractFFT fft = null;
String n = name.trim().toLowerCase();
if (n.equals("academic")) {
fft = new Academic();
fft.init(monitors, nx, ny, nz);
return fft;
}
if (n.equals("jtransforms")) {
fft = new JTransforms();
fft.init(monitors, nx, ny, nz);
return fft;
}
if (n.equals("fftw2")) {
fft = new FFTW3D();
fft.init(monitors, nx, ny, nz);
return fft;
}
return createDefaultFFT(monitors, nx, ny, nz);
}
public static AbstractFFTLibrary getLibraryByName(String name) {
+ if (name.equalsIgnoreCase("fastest"))
+ return getFastestFFT();
for (AbstractFFTLibrary library : getInstalledLibraries())
if (library.getLibraryName().equals(name))
return library;
return new AcademicLibrary();
}
-
public static AbstractFFT createDefaultFFT(Monitors monitors, int nx, int ny, int nz) {
AbstractFFT fft = new Academic();
fft.init(monitors, nx, ny, nz);
return fft;
}
public static String getLicence(String name) {
for (AbstractFFTLibrary lib : getInstalledLibraries()) {
for (AbstractFFT fft : lib.getFFTs())
if (name.equals(fft.getName()))
return lib.getLicence();
}
return "Unknown FFT library";
}
}
diff --git a/DeconvolutionLab2/src/fft/FFTPanel.java b/DeconvolutionLab2/src/fft/FFTPanel.java
new file mode 100644
index 0000000..1c50c45
--- /dev/null
+++ b/DeconvolutionLab2/src/fft/FFTPanel.java
@@ -0,0 +1,86 @@
+package fft;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.ArrayList;
+
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+import lab.component.HTMLPane;
+import lab.tools.NumFormat;
+import signal.Operations;
+
+public class FFTPanel extends JPanel implements MouseListener {
+
+ private HTMLPane info;
+ private CustomizedTable table;
+ private ArrayList<AbstractFFTLibrary> libs;
+
+ public FFTPanel(int w, int h) {
+ super(new BorderLayout());
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Name", String.class, 120, false));
+ columns.add(new CustomizedColumn("Installed", String.class, 120, false));
+ columns.add(new CustomizedColumn("Multithreadable", String.class, 120, false));
+ columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
+ table = new CustomizedTable(columns, true);
+ table.setRowSelectionAllowed(true);
+ table.addMouseListener(this);
+ libs = FFT.getRegisteredLibraries();
+ for (AbstractFFTLibrary lib : libs) {
+ String name = lib.getLibraryName();
+ String installed = lib.isInstalled() ? "Yes" : "No";
+ String multit = lib.isMultithreadable() ? "Yes" : "No";
+ String location = lib.getLocation();
+ table.append(new String[] { name, installed, multit, location });
+ }
+ info = new HTMLPane(w, h-100);
+
+ JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getPane(w, 100), info.getPane());
+ split.setDividerLocation(0.5);
+ add(split, BorderLayout.CENTER);
+ table.setRowSelectionInterval(0, 0);
+ info.clear();
+ info.append("p", libs.get(0).getLicence());
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ int i = table.getSelectedRow();
+ if (i<0)
+ return;
+ if (i>=libs.size())
+ return;
+ info.clear();
+ info.append("p", libs.get(i).getLicence());
+ }
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/DeconvolutionLab2/src/imagej/IJImageSelector.java b/DeconvolutionLab2/src/imagej/IJImageSelector.java
deleted file mode 100644
index 14e6f6f..0000000
--- a/DeconvolutionLab2/src/imagej/IJImageSelector.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package imagej;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.BorderFactory;
-import javax.swing.DefaultListModel;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.ListSelectionModel;
-
-import deconvolutionlab.PlatformImageSelector;
-import ij.ImagePlus;
-import ij.WindowManager;
-import ij.gui.GUI;
-
-public class IJImageSelector extends PlatformImageSelector {
-
- @Override
- public boolean isSelectable() {
- return true;
- }
-
- @Override
- public String getSelectedImage() {
- Dialog dialog = new Dialog();
- dialog.setVisible(true);
- if (dialog.wasCancel())
- return "";
- return dialog.getName();
- }
-
- public class Dialog extends JDialog implements ActionListener, WindowListener {
-
- private JList<String> list;
- private JButton bnOK = new JButton("OK");
- private JButton bnCancel = new JButton("Cancel");
- private boolean cancel = false;
- private String name = "";
-
- public Dialog() {
- super(new JFrame(), "Image Selection");
-
- JPanel bn = new JPanel(new GridLayout(1, 2));
- bn.add(bnCancel);
- bn.add(bnOK);
-
- JPanel panel = new JPanel(new BorderLayout());
- int[] ids = WindowManager.getIDList();
-
- if (ids != null) {
- DefaultListModel listModel = new DefaultListModel();
- list = new JList(listModel);
- for (int id : ids) {
- ImagePlus idp = WindowManager.getImage(id);
- if (idp != null) {
- ((DefaultListModel) listModel).addElement(idp.getTitle());
- }
- }
- list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- JScrollPane listScroller = new JScrollPane(list);
- listScroller.setPreferredSize(new Dimension(250, 80));
- panel.add(listScroller, BorderLayout.CENTER);
- }
- else {
- panel.add(new JLabel("No open images."));
- }
- panel.add(bn, BorderLayout.SOUTH);
- panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- bnOK.addActionListener(this);
- bnCancel.addActionListener(this);
- add(panel);
- pack();
- addWindowListener(this);
- GUI.center(this);
- setModal(true);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- bnOK.removeActionListener(this);
- bnCancel.removeActionListener(this);
- if (e.getSource() == bnCancel) {
- cancel = true;
- name = "";
- dispose();
- return;
- }
- else if (e.getSource() == bnOK) {
- cancel = false;
- name = (String) list.getSelectedValue();
- dispose();
- }
- }
-
- public String getName() {
- return name;
- }
-
- public boolean wasCancel() {
- return cancel;
- }
-
- @Override
- public void windowOpened(WindowEvent e) {
- }
-
- @Override
- public void windowClosing(WindowEvent e) {
- dispose();
- cancel = true;
- name = "";
- return;
- }
-
- @Override
- public void windowClosed(WindowEvent e) {
- }
-
- @Override
- public void windowIconified(WindowEvent e) {
- }
-
- @Override
- public void windowDeiconified(WindowEvent e) {
- }
-
- @Override
- public void windowActivated(WindowEvent e) {
- }
-
- @Override
- public void windowDeactivated(WindowEvent e) {
- }
- }
-
-}
diff --git a/DeconvolutionLab2/src/imagej/IJImager.java b/DeconvolutionLab2/src/imagej/IJImager.java
index ac47161..88caaaf 100644
--- a/DeconvolutionLab2/src/imagej/IJImager.java
+++ b/DeconvolutionLab2/src/imagej/IJImager.java
@@ -1,222 +1,348 @@
/*
* 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 imagej;
-import java.util.HashMap;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
-import deconvolutionlab.PlatformImager;
-import deconvolutionlab.PlatformImager.ContainerImage;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.ListSelectionModel;
+
+import deconvolutionlab.Imaging;
import ij.ImagePlus;
import ij.ImageStack;
import ij.WindowManager;
+import ij.gui.GUI;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-public class IJImager extends PlatformImager {
+public class IJImager extends Imaging {
+
+ @Override
+ public Platform getPlatform() {
+ return Imaging.Platform.IMAGEJ;
+ }
+
+ @Override
+ public void setVisible(JDialog dialog, boolean modal) {
+ if (modal) {
+ dialog.setModal(modal);
+ GUI.center(dialog);
+ }
+ dialog.pack();
+ dialog.setVisible(true);
+ }
public static RealSignal create(ImagePlus imp) {
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
- RealSignal signal = new RealSignal(nx, ny, nz);
+ RealSignal signal = new RealSignal("ij-" + imp.getTitle(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
}
@Override
public RealSignal create() {
return build(WindowManager.getCurrentImage());
}
@Override
public RealSignal create(String name) {
ImagePlus imp = null;
if (name.equalsIgnoreCase("active"))
imp = WindowManager.getCurrentImage();
else
imp = WindowManager.getImage(name);
if (imp == null)
imp = WindowManager.getCurrentImage();
return build(imp);
}
@Override
public RealSignal open(String filename) {
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
return build(imp);
}
@Override
- public void show(RealSignal signal, String title) {
- show(signal, title, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void show(RealSignal signal, String title, PlatformImager.Type type) {
- show(signal, title, type, signal.nz / 2);
- }
-
- @Override
- public void show(RealSignal signal, String title, PlatformImager.Type type, int z) {
+ public void show(RealSignal signal, String title, Imaging.Type type, int z) {
ImagePlus imp = build(signal, type);
if (imp != null) {
imp.setTitle(title);
int nz = imp.getStackSize();
imp.show();
imp.setSlice(Math.max(1, Math.min(nz, z)));
imp.getProcessor().resetMinAndMax();
}
}
public ContainerImage createContainer(String title) {
return new ContainerImage();
}
-
- @Override
- public void append(ContainerImage container, RealSignal signal, String title) {
- append(container, signal, title, PlatformImager.Type.FLOAT);
- }
@Override
- public void append(ContainerImage container, RealSignal signal, String title, PlatformImager.Type type) { ImagePlus cont = (ImagePlus) container.object;
+ public void append(ContainerImage container, RealSignal signal, String title, Imaging.Type type) { ImagePlus cont = (ImagePlus) container.object;
if (container.object == null) {
ImageStack stack = new ImageStack(signal.nx, signal.ny);
stack.addSlice(build(signal, type).getProcessor());
stack.addSlice(build(signal, type).getProcessor());
container.object = new ImagePlus(title, stack);
((ImagePlus)container.object).show();
}
else {
cont.getStack().addSlice(build(signal, type).getProcessor());
cont.setSlice(cont.getStack().getSize());
cont.updateAndDraw();
cont.getProcessor().resetMinAndMax();
}
}
@Override
- public void save(RealSignal signal, String filename) {
- save(signal, filename, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void save(RealSignal signal, String filename, PlatformImager.Type type) {
+ public void save(RealSignal signal, String filename, Imaging.Type type) {
ImagePlus imp = build(signal, type);
if (imp != null) {
if (imp.getStackSize() == 1) {
new FileSaver(imp).saveAsTiff(filename);
}
else {
new FileSaver(imp).saveAsTiffStack(filename);
}
}
}
- @Override
- public void show(ComplexSignal signal, String title) {
- show(signal, title, ComplexComponent.MODULE);
- }
-
@Override
public void show(ComplexSignal signal, String title, ComplexComponent complex) {
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
switch (complex) {
case REAL:
plane = signal.getRealXY(k);
break;
case IMAGINARY:
plane = signal.getImagXY(k);
break;
case MODULE:
plane = signal.getModuleXY(k);
break;
default:
plane = signal.getModuleXY_dB(k);
}
stack.addSlice(new FloatProcessor(signal.nx, signal.ny, plane));
}
new ImagePlus(title, stack).show();
}
private RealSignal build(ImagePlus imp) {
if (imp == null)
return null;
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
- RealSignal signal = new RealSignal(nx, ny, nz);
+ RealSignal signal = new RealSignal("ij-" + imp.getTitle(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
}
- private ImagePlus build(RealSignal signal, PlatformImager.Type type) {
+ private ImagePlus build(RealSignal signal, Imaging.Type type) {
if (signal == null)
return null;
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
ImageProcessor ip = new FloatProcessor(signal.nx, signal.ny, signal.getXY(k));
switch (type) {
case BYTE:
stack.addSlice(ip.convertToByteProcessor(false));
break;
case SHORT:
stack.addSlice(ip.convertToShortProcessor(false));
break;
case FLOAT:
stack.addSlice(ip);
default:
break;
}
}
return new ImagePlus("", stack);
}
@Override
public String getName() {
return "ImageJ";
}
+
+ @Override
+ public boolean isSelectable() {
+ return true;
+ }
+
+ @Override
+ public String getSelectedImage() {
+ Dialog dialog = new Dialog();
+ dialog.setVisible(true);
+ if (dialog.wasCancel())
+ return "";
+ return dialog.getName();
+ }
+
+ public class Dialog extends JDialog implements ActionListener, WindowListener {
+
+ private JList<String> list;
+ private JButton bnOK = new JButton("OK");
+ private JButton bnCancel = new JButton("Cancel");
+ private boolean cancel = false;
+ private String name = "";
+
+ public Dialog() {
+ super(new JFrame(), "Image Selection");
+
+ JPanel bn = new JPanel(new GridLayout(1, 2));
+ bn.add(bnCancel);
+ bn.add(bnOK);
+
+ JPanel panel = new JPanel(new BorderLayout());
+ int[] ids = WindowManager.getIDList();
+
+ if (ids != null) {
+ DefaultListModel listModel = new DefaultListModel();
+ list = new JList(listModel);
+ for (int id : ids) {
+ ImagePlus idp = WindowManager.getImage(id);
+ if (idp != null) {
+ ((DefaultListModel) listModel).addElement(idp.getTitle());
+ }
+ }
+ list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ JScrollPane listScroller = new JScrollPane(list);
+ listScroller.setPreferredSize(new Dimension(250, 80));
+ panel.add(listScroller, BorderLayout.CENTER);
+ }
+ else {
+ panel.add(new JLabel("No open images."));
+ }
+ panel.add(bn, BorderLayout.SOUTH);
+ panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ bnOK.addActionListener(this);
+ bnCancel.addActionListener(this);
+ add(panel);
+ pack();
+ addWindowListener(this);
+ GUI.center(this);
+ setModal(true);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ bnOK.removeActionListener(this);
+ bnCancel.removeActionListener(this);
+ if (e.getSource() == bnCancel) {
+ cancel = true;
+ name = "";
+ dispose();
+ return;
+ }
+ else if (e.getSource() == bnOK) {
+ cancel = false;
+ name = (String) list.getSelectedValue();
+ dispose();
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean wasCancel() {
+ return cancel;
+ }
+
+ @Override
+ public void windowOpened(WindowEvent e) {
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ dispose();
+ cancel = true;
+ name = "";
+ return;
+ }
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ }
+
+ @Override
+ public void windowIconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ @Override
+ public void windowActivated(WindowEvent e) {
+ }
+
+ @Override
+ public void windowDeactivated(WindowEvent e) {
+ }
+ }
+
}
diff --git a/DeconvolutionLab2/src/lab/component/BorderToggledButton.java b/DeconvolutionLab2/src/lab/component/BorderToggledButton.java
new file mode 100644
index 0000000..06a7f7d
--- /dev/null
+++ b/DeconvolutionLab2/src/lab/component/BorderToggledButton.java
@@ -0,0 +1,22 @@
+package lab.component;
+
+import java.awt.Insets;
+
+import javax.swing.JButton;
+
+public class BorderToggledButton extends JButton {
+
+ private String text = "";
+ public BorderToggledButton(String text) {
+ super(text);
+ this.text = text;
+ setMargin(new Insets(1, 1, 1, 1));
+ }
+
+ public void setSelected(boolean selected) {
+ if (selected)
+ setText("<html><b>" + text + "</b></html>");
+ else
+ setText(text);
+ }
+}
diff --git a/DeconvolutionLab2/src/lab/component/CustomizedTable.java b/DeconvolutionLab2/src/lab/component/CustomizedTable.java
index ae489e7..635144c 100644
--- a/DeconvolutionLab2/src/lab/component/CustomizedTable.java
+++ b/DeconvolutionLab2/src/lab/component/CustomizedTable.java
@@ -1,285 +1,298 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package lab.component;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.Insets;
import java.awt.Rectangle;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
public class CustomizedTable extends JTable {
private JScrollPane pane = null;
private ArrayList<CustomizedColumn> columns;
public CustomizedTable(String headers[], boolean sortable) {
ArrayList<CustomizedColumn> colums = new ArrayList<CustomizedColumn>();
for (int i = 0; i < headers.length; i++)
colums.add(new CustomizedColumn(headers[i], String.class, 150, false));
create(colums);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
public CustomizedTable(ArrayList<CustomizedColumn> columns, boolean sortable) {
create(columns);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
private void create(ArrayList<CustomizedColumn> column) {
columns = column;
DefaultTableModel model = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int col) {
return columns.get(col).editable;
}
@Override
public Class<?> getColumnClass(int col) {
return columns.get(col).classe;
}
};
setModel(model);
int n = columns.size();
String headers[] = new String[n];
for (int col = 0; col < n; col++)
headers[col] = columns.get(col).header;
model.setColumnIdentifiers(headers);
setFillsViewportHeight(true);
for (int col = 0; col < n; col++) {
TableColumn tc = getColumnModel().getColumn(col);
tc.setPreferredWidth(columns.get(col).width);
if (columns.get(col).choices != null) {
JComboBox<String> cmb = new JComboBox<String>();
for (String p : columns.get(col).choices) {
cmb.addItem(p);
cmb.setToolTipText(columns.get(col).tooltip);
tc.setCellEditor(new DefaultCellEditor(cmb));
}
}
if (columns.get(col).button != null) {
ButtonRenderer bn = new ButtonRenderer();
bn.setToolTipText(columns.get(col).tooltip);
tc.setCellRenderer(bn);
}
}
getTableHeader().setReorderingAllowed(false);
}
public void setPreferredSize(int width, int height) {
if (pane != null)
pane.setPreferredSize(new Dimension(width, height));
}
public void removeRow(int row) {
if (row >= 0 && row < getRowCount())
((DefaultTableModel) getModel()).removeRow(row);
}
+ public void removeRows() {
+ while(getRowCount() > 0)
+ ((DefaultTableModel) getModel()).removeRow(0);
+ }
+
public String[] getRow(int row) {
if (row >= 0) {
int ncol = getColumnCount();
String items[] = new String[ncol];
for (int col = 0; col < ncol; col++)
items[col] = (String) getModel().getValueAt(row, col);
return items;
}
return new String[1];
}
public String getCell(int row, int col) {
- if (row >= 0) {
+ if (row >= 0 && col >= 0) {
return (String) getModel().getValueAt(row, col);
}
return "";
}
+
+ public void setCell(int row, int col, String value) {
+ if (row >= 0 && col >= 0) {
+ getModel().setValueAt(value, row, col);
+ }
+ }
public String getRowCSV(int row, String seperator) {
if (row >= 0) {
int ncol = getColumnCount();
String items = "";
for (int col = 0; col < ncol - 1; col++) {
if ((String) getModel().getValueAt(row, col) == null)
items += "" + seperator;
else
items += (String) getModel().getValueAt(row, col) + seperator;
}
if (ncol >= 1)
items += (String) getModel().getValueAt(row, ncol - 1);
return items;
}
return "";
}
public void saveCSV(String filename) {
File file = new File(filename);
try {
BufferedWriter buffer = new BufferedWriter(new FileWriter(file));
int nrows = getRowCount();
int ncols = getColumnCount();
String row = "";
for (int c = 0; c < columns.size(); c++)
row += columns.get(c).header + (c == columns.size() - 1 ? "" : ", ");
buffer.write(row + "\n");
for (int r = 0; r < nrows; r++) {
row = "";
for (int c = 0; c < ncols; c++)
row += this.getCell(r, c) + (c == ncols - 1 ? "" : ", ");
buffer.write(row + "\n");
}
buffer.close();
}
catch (IOException ex) {
}
}
public String getSelectedAtColumn(int col) {
int row = getSelectedRow();
if (row >= 0)
return (String) getModel().getValueAt(row, col);
else
return "";
}
public void setSelectedAtColumn(int col, String selection) {
int nrows = this.getRowCount();
for (int i = 0; i < nrows; i++) {
String name = (String) getModel().getValueAt(i, col);
if (name.equals(selection))
this.setRowSelectionInterval(i, i + 1);
}
}
public void append(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.addRow(row);
i = getRowCount() - 1;
if (i >= 0) {
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
}
catch (Exception e) {
}
repaint();
}
public void insert(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.insertRow(0, row);
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
catch (Exception e) {
}
repaint();
}
@Override
public int getSelectedRow() {
int row = super.getSelectedRow();
if (row < 0) {
if (getRowCount() > 0) {
setRowSelectionInterval(0, 0);
row = super.getSelectedRow();
}
return row;
}
return row;
}
public void update(ArrayList<String[]> data) {
DefaultTableModel model = (DefaultTableModel) getModel();
model.getDataVector().removeAllElements();
for (String[] row : data)
model.addRow(row);
repaint();
}
public JScrollPane getPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
pane = new JScrollPane(this);
return pane;
}
public JScrollPane getMinimumPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setMinimumSize(new Dimension(width, height));
setShowVerticalLines(true);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
return new JScrollPane(this);
}
public JFrame show(String title, int w, int h) {
JFrame frame = new JFrame(title);
frame.add(getPane(w, h));
frame.pack();
frame.setVisible(true);
return frame;
}
public class ButtonRenderer extends JButton implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- setText(columns.get(column).button);
+ setText((String)value);
+ setMargin(new Insets(1, 1, 1, 1));
return this;
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/JPanelImage.java b/DeconvolutionLab2/src/lab/component/JPanelImage.java
index 6c57814..595da29 100644
--- a/DeconvolutionLab2/src/lab/component/JPanelImage.java
+++ b/DeconvolutionLab2/src/lab/component/JPanelImage.java
@@ -1,67 +1,82 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package lab.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
+import java.awt.image.BufferedImage;
import javax.swing.JPanel;
/**
* This class extends the JPanel to create grid panel given the possibility to
* place Java components in an organized manner in the dialog box.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class JPanelImage extends JPanel {
private Image image;
+ public JPanelImage() {
+ super();
+ }
+ public JPanelImage(BufferedImage img) {
+ super();
+ image = img;
+ }
+
public JPanelImage(String filename) {
super();
image = ImageLoader.get(filename);
}
+ public void setImage(BufferedImage image) {
+ this.image = image;
+ repaint();
+ }
+
+
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/PanelImage.java b/DeconvolutionLab2/src/lab/component/PanelImage.java
index a0229c7..88fb6be 100644
--- a/DeconvolutionLab2/src/lab/component/PanelImage.java
+++ b/DeconvolutionLab2/src/lab/component/PanelImage.java
@@ -1,45 +1,53 @@
package lab.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
+import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class PanelImage extends JPanel {
private Image image;
private int w = -1;
private int h = -1;
public PanelImage(String filename) {
super();
image = ImageLoader.get(filename);
}
+
+ public PanelImage(int w, int h) {
+ super();
+ image = null;
+ this.w = w;
+ this.h = h;
+ }
public PanelImage(String filename, int w, int h) {
super();
image = ImageLoader.get(filename);
this.w = w;
this.h = h;
}
-
+
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
if (w < 0)
- g.drawImage(image, getWidth(), 0, getWidth(), getHeight(), null);
+ g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
else {
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(image, (getWidth()-w)/2, 0, w, h, null);
}
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/lab/system/SystemBar.java b/DeconvolutionLab2/src/lab/system/SystemBar.java
deleted file mode 100644
index 939516c..0000000
--- a/DeconvolutionLab2/src/lab/system/SystemBar.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package lab.system;
-
-import java.awt.BorderLayout;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.BoxLayout;
-import javax.swing.JToolBar;
-
-public class SystemBar extends JToolBar {
-
- private Timer timer = new Timer();
- private TimerTask updater = new Updater();
-
- private SystemHeap heap;
- private SystemCPU load;
-
- public SystemBar(int refreshTime) {
- super("System Bar");
- setFloatable(false);
- heap = new SystemHeap();
- load = new SystemCPU();
- restart(refreshTime);
- setLayout(new BorderLayout());
- add(heap, BorderLayout.CENTER);
- add(load, BorderLayout.EAST);
- }
-
- public void update() {
- heap.repaint();
- load.repaint();
- }
-
- public void restart(int refreshTime) {
- if (updater != null) {
- updater.cancel();
- updater = null;
- }
- updater = new Updater();
- timer.schedule(updater, 0, refreshTime);
- }
-
- public void close() {
- timer.cancel();
- timer = null;
- }
-
- private class Updater extends TimerTask {
- @Override
- public void run() {
- update();
- }
- }
-
-}
diff --git a/DeconvolutionLab2/src/lab/system/SystemPanel.java b/DeconvolutionLab2/src/lab/system/SystemPanel.java
deleted file mode 100644
index e2a5c04..0000000
--- a/DeconvolutionLab2/src/lab/system/SystemPanel.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package lab.system;
-
-import java.awt.BorderLayout;
-import java.awt.FlowLayout;
-import java.io.File;
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.MemoryUsage;
-import java.lang.management.OperatingSystemMXBean;
-import java.lang.management.RuntimeMXBean;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import lab.component.CustomizedTable;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
-
-public class SystemPanel extends JPanel implements ChangeListener {
-
- private CustomizedTable table;
- private TimerTask updater = new Updater();
- private Timer timer;
- private SpinnerRangeInteger spnRefresh;
- private int refreshTime = 1000;
-
- public SystemPanel(int refreshTime) {
- super(new BorderLayout());
- this.refreshTime = refreshTime;
- spnRefresh = new SpinnerRangeInteger(refreshTime, 1, 360000, 100);
- table = new CustomizedTable(new String[] { "Manager", "Feature", "Value" }, false);
- table.update(getFeatures());
- table.setFillsViewportHeight(true);
- JPanel pn = new JPanel(new FlowLayout());
- pn.add(new JLabel("Refresh time"));
- pn.add(spnRefresh);
- pn.add(new JLabel("ms"));
- JScrollPane scroll = new JScrollPane(table);
- scroll.setVisible(true);
- add(pn, BorderLayout.NORTH);
- add(scroll, BorderLayout.CENTER);
- timer = new Timer();
- timer.schedule(updater, 1, refreshTime);
- spnRefresh.addChangeListener(this);
- }
-
- public static void show(int w, int h) {
- JFrame frame = new JFrame("System Info");
- frame.add(new SystemPanel(1000));
- frame.pack();
- frame.setVisible(true);
- }
-
- @Override
- public void stateChanged(ChangeEvent e) {
- if (e.getSource() == spnRefresh)
- restart(spnRefresh.get());
- }
-
- public void restart(int refreshTime) {
- this.refreshTime = refreshTime;
- if (updater != null) {
- updater.cancel();
- updater = null;
- }
- updater = new Updater();
- timer.schedule(updater, 0, refreshTime);
- }
-
- private class Updater extends TimerTask {
- @Override
- public void run() {
- if (table != null) {
- table.update(getFeatures());
- }
- }
- }
-
- public int getSystemTime() {
- return refreshTime;
- }
-
- public ArrayList<String[]> getFeatures() {
-
- ArrayList<String[]> features = new ArrayList<String[]>();
- String f = "";
- features.add(new String[] { "Properties", "OS", "" + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") });
- features.add(new String[] { "Properties", "Java Version", "" + System.getProperty("java.version") });
- f = "java.class.path";
- features.add(new String[] { "Properties", f, "" + System.getProperty(f) });
- f = "java.home";
- features.add(new String[] { "Properties", f, "" + System.getProperty(f) });
- f = "user.dir";
- features.add(new String[] { "Properties", f, "" + System.getProperty(f) });
- f = "user.home";
- features.add(new String[] { "Properties", f, "" + System.getProperty(f) });
- f = "user.name";
- features.add(new String[] { "Properties", f, "" + System.getProperty(f) });
-
- Runtime runt = Runtime.getRuntime();
- features.add(new String[] { "JVM", "Available processors", "" + runt.availableProcessors() });
- features.add(new String[] { "JVM", "Initial Memory (-Xms)", NumFormat.bytes(runt.freeMemory()) });
- features.add(new String[] { "JVM", "Maximum Memory (-Xmx)", NumFormat.bytes(runt.maxMemory()) });
- features.add(new String[] { "JVM", "Total Used Memory", NumFormat.bytes(runt.totalMemory()) });
-
- MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- MemoryUsage heapU = mem.getHeapMemoryUsage();
- MemoryUsage nonhU = mem.getNonHeapMemoryUsage();
-
- features.add(new String[] { "Memory", "Heap Used", NumFormat.bytes(heapU.getUsed()) });
- features.add(new String[] { "Memory", "Heap Init", NumFormat.bytes(heapU.getInit()) });
- features.add(new String[] { "Memory", "Heap Max ", NumFormat.bytes(heapU.getMax()) });
-
- features.add(new String[] { "Memory", "NonHeap Used", NumFormat.bytes(nonhU.getUsed()) });
- features.add(new String[] { "Memory", "NonHeap Init", NumFormat.bytes(nonhU.getInit()) });
- features.add(new String[] { "Memory", "NonHeap Max ", NumFormat.bytes(nonhU.getMax()) });
-
- RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
- features.add(new String[] { "Runtime", "Library Path", rt.getLibraryPath() });
- features.add(new String[] { "Runtime", "Uptime", "" + NumFormat.time(rt.getUptime()) });
- features.add(new String[] { "Runtime", "Name", rt.getName() });
- features.add(new String[] { "Runtime", "Vm Version", rt.getVmVersion() });
- for (String input : rt.getInputArguments())
- features.add(new String[] { "Runtime", "Input Arguments", input });
-
- File[] roots = File.listRoots();
- for (File root : roots) {
- features.add(new String[] { "FileSystem", "Root Path", root.getAbsolutePath() });
- features.add(new String[] { "FileSystem", "Total Space", NumFormat.bytes(root.getTotalSpace()) });
- features.add(new String[] { "FileSystem", "Usable Space", NumFormat.bytes(root.getUsableSpace()) });
- }
-
- ClassLoadingMXBean loader = ManagementFactory.getClassLoadingMXBean();
-
- features.add(new String[] { "ClassLoading", "Loaded Class", "" + loader.getLoadedClassCount() });
-
- OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- for (Method method : os.getClass().getDeclaredMethods()) {
- method.setAccessible(true);
- if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) {
- try {
- String name = split(method.getName());
- features.add(new String[] { "OS", name, "" + method.invoke(os).toString() });
- }
- catch (Exception e) {
- }
- }
- }
- return features;
- }
-
- private static String split(String name) {
- String func = name.substring(3);
- return func.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
- }
-
-}
diff --git a/DeconvolutionLab2/src/lab/tools/NumFormat.java b/DeconvolutionLab2/src/lab/tools/NumFormat.java
index 6f1956c..01cfca4 100644
--- a/DeconvolutionLab2/src/lab/tools/NumFormat.java
+++ b/DeconvolutionLab2/src/lab/tools/NumFormat.java
@@ -1,174 +1,174 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package lab.tools;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NumFormat {
public static String[] floatRepresentation(double a) {
double[] base = { 10, 5, 3, 2 };
double min = Double.MAX_VALUE;
double mantisse = 0;
double exp = 1;
for (int i = 0; i < base.length; i++) {
double p = Math.log(a) / Math.log(base[i]);
double e = roundToNumberOfSignificantDigits(p, 3);
double b = Math.pow(base[i], e);
if (Math.abs(a-b) < min) {
mantisse = base[i];
exp = e;
min = Math.abs(a-b);
}
}
return new String[] { "" + mantisse, "" + exp };
}
public static double roundToNumberOfSignificantDigits(double num, int n) {
double maxPowerOfTen = Math.floor(Math.log10(Double.MAX_VALUE));
if (num == 0) {
return 0;
}
final double d = Math.ceil(Math.log10(num < 0 ? -num : num));
final int power = n - (int) d;
double firstMagnitudeFactor = 1.0;
double secondMagnitudeFactor = 1.0;
if (power > maxPowerOfTen) {
firstMagnitudeFactor = Math.pow(10.0, maxPowerOfTen);
secondMagnitudeFactor = Math.pow(10.0, (double) power - maxPowerOfTen);
}
else {
firstMagnitudeFactor = Math.pow(10.0, (double) power);
}
double toBeRounded = num * firstMagnitudeFactor;
toBeRounded *= secondMagnitudeFactor;
final long shifted = Math.round(toBeRounded);
double rounded = ((double) shifted) / firstMagnitudeFactor;
rounded /= secondMagnitudeFactor;
return rounded;
}
public static double parseNumber(String line, double def) {
double[] numbers = parseNumbers(line);
if (numbers.length >= 1)
return numbers[0];
else
return def;
}
public static double[] parseNumbers(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static String nice(double a) {
double b = Math.abs(a);
String n = a < 0 ? "-" : " ";
if (a == 0)
return "0.0";
if (b > 3000.0)
return String.format(n + "%6.3E", b);
if (b > 300.0)
return String.format(n + "%4.1f", b);
if (b > 30.0)
return String.format(n + "%3.2f", b);
if (b > 3.0)
return String.format(n + "%2.4f", b);
if (b > 0.003)
return String.format(n + "%1.4f", b);
return String.format(n + "%6.3E", b).trim();
}
public static String seconds(double ns) {
return String.format("%5.1f s", ns * 1e-9);
}
public static String time(double ns) {
if (ns < 3000.0)
return String.format("%3.2f ns", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f us", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f ms", ns);
ns *= 0.001;
if (ns < 3600.0 * 3)
return String.format("%3.2f s", ns);
ns /= 3600;
return String.format("%3.2f h", ns);
}
public static String bytes(double bytes) {
if (bytes < 3000)
- return String.format("%3.0f b", bytes);
+ return String.format("%3.0f", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Kb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Mb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Gb", bytes);
bytes /= 1024.0;
return String.format("%3.1f Tb", bytes);
}
public static String toPercent(String value) {
try {
return toPercent(Double.parseDouble(value));
}
catch (Exception ex) {
}
return value;
}
public static String toPercent(double value) {
return String.format("%5.3f", value * 100) + "%";
}
}
diff --git a/DeconvolutionLab2/src/matlab/Converter.java b/DeconvolutionLab2/src/matlab/Converter.java
index 79fca95..f1091c5 100644
--- a/DeconvolutionLab2/src/matlab/Converter.java
+++ b/DeconvolutionLab2/src/matlab/Converter.java
@@ -1,553 +1,553 @@
package matlab;
import ij.ImagePlus;
import ij.ImageStack;
import ij.process.ByteProcessor;
import ij.process.ColorProcessor;
import ij.process.FloatProcessor;
import ij.process.ShortProcessor;
import signal.RealSignal;
public class Converter {
public static boolean verbose;
/**
* Get an image.
*
* @param imageplus image
* @return an N x M array representing the input image
*/
public static Object get(ImagePlus imageplus) {
if (imageplus == null)
return null;
int width = imageplus.getWidth();
int height = imageplus.getHeight();
int stackSize = imageplus.getStackSize();
int counter = 0;
ImageStack imagestack = imageplus.getStack();
switch (imageplus.getType()) {
case ImagePlus.COLOR_256: {
;
}
case ImagePlus.GRAY8: {
short[][][] is = new short[height][width][stackSize];
for (int sz = 0; sz < stackSize; sz++) {
ByteProcessor byteprocessor = (ByteProcessor) imagestack.getProcessor(sz + 1);
byte[] pixels = (byte[]) byteprocessor.getPixels();
counter = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
is[h][w][sz] = (short)(pixels[counter]&0xff);
w++;
counter++;
}
counter = ++h * width;
}
}
return is;
}
case ImagePlus.GRAY16: {
int[][][] is = new int[height][width][stackSize];
for (int sz = 0; sz < stackSize; sz++) {
counter = 0;
ShortProcessor shortprocessor = (ShortProcessor) imagestack.getProcessor(sz + 1);
short[] spixels = (short[]) shortprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
is[h][w][sz] = (int)(spixels[counter]&0xffff);
w++;
counter++;
}
counter = ++h * width;
}
}
return is;
}
case ImagePlus.GRAY32: {
double[][][] fs = new double[height][width][stackSize];
for (int sz = 0; sz < stackSize; sz++) {
FloatProcessor floatprocessor = (FloatProcessor) imagestack.getProcessor(sz + 1);
float[] fpixels = (float[]) floatprocessor.getPixels();
counter = 0;
int i = 0;
while (i < height) {
int j = 0;
while (j < width) {
fs[i][j][sz] = (double) fpixels[counter];
j++;
counter++;
}
counter = ++i * width;
}
}
return fs;
}
case ImagePlus.COLOR_RGB: {
if (stackSize == 1) {
short[][][] is = new short[height][width][3];
ColorProcessor colorprocessor = (ColorProcessor) imagestack.getProcessor(1);
byte[] red = new byte[width * height];
byte[] green = new byte[width * height];
byte[] blue = new byte[width * height];
colorprocessor.getRGB(red, green, blue);
counter = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
is[h][w][0] = (short)(red[counter]&0xff);
is[h][w][1] = (short)(green[counter]&0xff);
is[h][w][2] = (short)(blue[counter]&0xff);
w++;
counter++;
}
counter = ++h * width;
}
return is;
}
short[][][][] is = new short[height][width][stackSize][3];
for (int sz = 0; sz < stackSize; sz++) {
ColorProcessor colorprocessor = (ColorProcessor) imagestack.getProcessor(sz + 1);
byte[] red = new byte[width * height];
byte[] green = new byte[width * height];
byte[] blue = new byte[width * height];
colorprocessor.getRGB(red, green, blue);
counter = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
is[h][w][sz][0] = (short)red[counter];
is[h][w][sz][1] = (short)green[counter];
is[h][w][sz][2] = (short)blue[counter];
w++;
counter++;
}
counter = ++h * width;
}
}
return is;
}
default:
System.out.println("MIJ Error message: Unknow type of volumes.");
return null;
}
}
/**
* Create a new image in ImageJ from a Matlab variable with a specified
* title.
*
* This method try to create a image (ImagePlus of ImageJ) from a Matlab's
* variable which should be an 2D or 3D array The recognize type are byte,
* short, int, float and double. The dimensionality of the 2 (image) or 3
* (stack of images)
*
* @param title
* title of the new image
* @param object
* Matlab variable
* @param showImage
* Whether to display the newly created image or not
* @return the resulting ImagePlus instance
*/
public static ImagePlus createImage(String title, Object object, boolean showImage) {
ImagePlus imp = null;
int i = 0;
if (object instanceof byte[][]) {
byte[][] is = (byte[][]) object;
int height = is.length;
int width = is[0].length;
ByteProcessor byteprocessor = new ByteProcessor(width, height);
byte[] bp = (byte[]) byteprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
bp[i] = is[h][w];
w++;
i++;
}
i = ++h * width;
}
imp = new ImagePlus(title, byteprocessor);
}
else if (object instanceof short[][]) {
short[][] is = (short[][]) object;
int height = is.length;
int width = is[0].length;
ShortProcessor shortprocessor = new ShortProcessor(width, height);
short[] sp = (short[]) shortprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
sp[i] = is[h][w];
w++;
i++;
}
i = ++h * width;
}
imp = new ImagePlus(title, shortprocessor);
}
else if (object instanceof int[][]) {
if (verbose)
System.out.println("MIJ warning message: Loss of precision: convert int 32-bit to short 16-bit");
int[][] is = (int[][]) object;
int height = is.length;
int width = is[0].length;
ShortProcessor shortprocessor = new ShortProcessor(width, height);
short[] sp = (short[]) shortprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
sp[i] = (short) is[h][w];
w++;
i++;
}
i = ++h * width;
}
imp = new ImagePlus(title, shortprocessor);
}
else if (object instanceof float[][]) {
float[][] fs = (float[][]) object;
int height = fs.length;
int width = fs[0].length;
FloatProcessor floatprocessor = new FloatProcessor(width, height);
float[] fp = (float[]) floatprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
fp[i] = fs[h][w];
w++;
i++;
}
i = ++h * width;
}
floatprocessor.resetMinAndMax();
imp = new ImagePlus(title, floatprocessor);
}
else if (object instanceof double[][]) {
if (verbose)
System.out.println("MIJ warning message: Loss of precision: convert double 32-bit to float 32-bit");
double[][] ds = (double[][]) object;
int height = ds.length;
int width = ds[0].length;
FloatProcessor floatprocessor = new FloatProcessor(width, height);
float[] fp = (float[]) floatprocessor.getPixels();
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
fp[i] = (float) ds[h][w];
w++;
i++;
}
i = ++h * width;
}
floatprocessor.resetMinAndMax();
imp = new ImagePlus(title, floatprocessor);
}
else if (object instanceof byte[][][]) {
byte[][][] is = (byte[][][]) object;
int height = is.length;
int width = is[0].length;
int stackSize = is[0][0].length;
ImageStack imagestack = new ImageStack(width, height);
for (int sz = 0; sz < stackSize; sz++) {
ByteProcessor byteprocessor = new ByteProcessor(width, height);
byte[] bp = (byte[]) byteprocessor.getPixels();
i = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
bp[i] = is[h][w][sz];
w++;
i++;
}
i = ++h * width;
}
imagestack.addSlice("", byteprocessor);
}
imp = new ImagePlus(title, imagestack);
}
else if (object instanceof short[][][]) {
short[][][] is = (short[][][]) object;
int height = is.length;
int width = is[0].length;
int stackSize = is[0][0].length;
ImageStack imagestack = new ImageStack(width, height);
for (int sz = 0; sz < stackSize; sz++) {
ShortProcessor shortprocessor = new ShortProcessor(width, height);
short[] sp = (short[]) shortprocessor.getPixels();
i = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
sp[i] = is[h][w][sz];
w++;
i++;
}
i = ++h * width;
}
imagestack.addSlice("", shortprocessor);
}
imp = new ImagePlus(title, imagestack);
}
else if (object instanceof int[][][]) {
if (verbose)
System.out.println("MIJ warning message: Loss of precision: convert int 32 bits to short 16 bits");
int[][][] is = (int[][][]) object;
int height = is.length;
int width = is[0].length;
int stackSize = is[0][0].length;
ImageStack imagestack = new ImageStack(width, height);
for (int sz = 0; sz < stackSize; sz++) {
ShortProcessor shortprocessor = new ShortProcessor(width, height);
short[] sp = (short[]) shortprocessor.getPixels();
i = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
sp[i] = (short) is[h][w][sz];
w++;
i++;
}
i = ++h * width;
}
if (sz == 0)
shortprocessor.resetMinAndMax();
imagestack.addSlice("", shortprocessor);
}
imp = new ImagePlus(title, imagestack);
}
else if (object instanceof float[][][]) {
float[][][] fs = (float[][][]) object;
int height = fs.length;
int width = fs[0].length;
int stackSize = fs[0][0].length;
ImageStack imagestack = new ImageStack(width, height);
for (int sz = 0; sz < stackSize; sz++) {
FloatProcessor floatprocessor = new FloatProcessor(width, height);
float[] fp = (float[]) floatprocessor.getPixels();
i = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
fp[i] = fs[h][w][sz];
w++;
i++;
}
i = ++h * width;
}
if (sz == 0)
floatprocessor.resetMinAndMax();
imagestack.addSlice("", floatprocessor);
}
imp = new ImagePlus(title, imagestack);
}
else if (object instanceof double[][][]) {
if (verbose)
System.out.println("MIJ warning message: Loss of precision: convert double 32-bit to float 32-bit");
double[][][] ds = (double[][][]) object;
int height = ds.length;
int width = ds[0].length;
int stackSize = ds[0][0].length;
ImageStack imagestack = new ImageStack(width, height);
for (int sz = 0; sz < stackSize; sz++) {
FloatProcessor floatprocessor = new FloatProcessor(width, height);
float[] fp = (float[]) floatprocessor.getPixels();
i = 0;
int h = 0;
while (h < height) {
int w = 0;
while (w < width) {
fp[i] = (float) ds[h][w][sz];
w++;
i++;
}
i = ++h * width;
}
if (sz == 0)
floatprocessor.resetMinAndMax();
imagestack.addSlice("", floatprocessor);
}
imp = new ImagePlus(title, imagestack);
}
else {
System.out.println("MIJ Error message: Unknow type of images or volumes.");
return null;
}
if (showImage) {
imp.show();
imp.updateAndDraw();
}
return imp;
}
/**
* Create a new RealSignal from a Matlab variable with a specified
* title.
*/
public static RealSignal createRealSignal(Object object) {
RealSignal signal = null;
if (object instanceof byte[][]) {
byte[][] data = (byte[][]) object;
int h = data.length;
int w = data[0].length;
- signal = new RealSignal(h, w, 1);
+ signal = new RealSignal("Matlab-byte2D", h, w, 1);
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[0][i+j*h]= data[i][j];
return signal;
}
if (object instanceof short[][]) {
short[][] data = (short[][]) object;
int h = data.length;
int w = data[0].length;
- signal = new RealSignal(h, w, 1);
+ signal = new RealSignal("Matlab-short2D", h, w, 1);
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[0][i+j*h]= data[i][j];
return signal;
}
if (object instanceof int[][]) {
int[][] data = (int[][]) object;
int h = data.length;
int w = data[0].length;
- signal = new RealSignal(h, w, 1);
+ signal = new RealSignal("Matlab-int2D", h, w, 1);
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[0][i+j*h]= data[i][j];
return signal;
}
if (object instanceof float[][]) {
float[][] data = (float[][]) object;
int h = data.length;
int w = data[0].length;
- signal = new RealSignal(h, w, 1);
+ signal = new RealSignal("Matlab-float3D", h, w, 1);
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[0][i+j*h]= data[i][j];
return signal;
}
if (object instanceof double[][]) {
double[][] data = (double[][]) object;
int h = data.length;
int w = data[0].length;
- signal = new RealSignal(h, w, 1);
+ signal = new RealSignal("Matlab-double2D", h, w, 1);
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[0][i+j*h]= (float)data[i][j];
return signal;
}
if (object instanceof byte[][][]) {
byte[][][] data = (byte[][][]) object;
int h = data.length;
int w = data[0].length;
int d = data[0][0].length;
- signal = new RealSignal(h, w, d);
+ signal = new RealSignal("Matlab-byte3D", h, w, d);
for(int k=0; k<d; k++)
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[k][i+j*h]= (float)data[i][j][k];
return signal;
}
if (object instanceof short[][][]) {
short[][][] data = (short[][][]) object;
int h = data.length;
int w = data[0].length;
int d = data[0][0].length;
- signal = new RealSignal(h, w, d);
+ signal = new RealSignal("Matlab-short3D", h, w, d);
for(int k=0; k<d; k++)
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[k][i+j*h]= (float)data[i][j][k];
return signal;
}
if (object instanceof int[][][]) {
int[][][] data = (int[][][]) object;
int h = data.length;
int w = data[0].length;
int d = data[0][0].length;
- signal = new RealSignal(h, w, d);
+ signal = new RealSignal("Matlab-int3D", h, w, d);
for(int k=0; k<d; k++)
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[k][i+j*h]= (float)data[i][j][k];
return signal;
}
if (object instanceof float[][][]) {
float[][][] data = (float[][][]) object;
int h = data.length;
int w = data[0].length;
int d = data[0][0].length;
- signal = new RealSignal(h, w, d);
+ signal = new RealSignal("Matlab-float3D", h, w, d);
for(int k=0; k<d; k++)
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[k][i+j*h]= data[i][j][k];
return signal;
}
if (object instanceof double[][][]) {
double[][][] data = (double[][][]) object;
int h = data.length;
int w = data[0].length;
int d = data[0][0].length;
- signal = new RealSignal(h, w, d);
+ signal = new RealSignal("Matlab-double3D", h, w, d);
for(int k=0; k<d; k++)
for(int i=0; i<h; i++)
for(int j=0; j<w; j++)
signal.data[k][i+j*h]= (float)data[i][j][k];
return signal;
}
return null;
}
public static Object createObject(RealSignal signal) {
if (signal == null)
return null;
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
double[][][] object = new double[ny][nx][nz];
for(int k=0; k<nz; k++)
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++)
object[j][i][k] = signal.data[k][i+j*nx];
return object;
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/DeconvolutionLabIcyFrame.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/DeconvolutionLabIcyFrame.java
new file mode 100644
index 0000000..277e4f8
--- /dev/null
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/DeconvolutionLabIcyFrame.java
@@ -0,0 +1,111 @@
+package plugins.sage.deconvolutionlab;
+
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+
+import javax.swing.JButton;
+
+import deconvolution.DeconvolutionDialog;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
+import deconvolutionlab.dialog.LabPanel;
+import icy.gui.frame.IcyFrame;
+import icy.gui.frame.IcyFrameEvent;
+import icy.gui.frame.IcyFrameListener;
+
+public class DeconvolutionLabIcyFrame extends IcyFrame implements ComponentListener, IcyFrameListener, ActionListener {
+
+ private LabPanel panel = null;
+ private JButton bnClose = new JButton("Close");
+
+ public DeconvolutionLabIcyFrame() {
+ super(Constants.name);
+ panel = new LabPanel(bnClose);
+ getContentPane().add(panel);
+ pack();
+ addFrameListener(this);
+ toFront();
+ addToDesktopPane();
+ setVisible(true);
+ setResizable(true);
+ bnClose.addActionListener(this);
+ addComponentListener(this);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == bnClose) {
+ panel.close();
+ dispose();
+ return;
+ }
+ }
+
+ @Override
+ public void icyFrameOpened(IcyFrameEvent e) {
+ System.out.println("not yet implemented " + e);
+ }
+
+ @Override
+ public void icyFrameClosing(IcyFrameEvent e) {
+ panel.close();
+ Config.store();
+ dispose();
+ }
+
+ @Override
+ public void icyFrameClosed(IcyFrameEvent e) {
+ }
+
+ @Override
+ public void icyFrameIconified(IcyFrameEvent e) {
+ }
+
+ @Override
+ public void icyFrameDeiconified(IcyFrameEvent e) {
+ panel.sizeModule();
+ }
+
+ @Override
+ public void icyFrameActivated(IcyFrameEvent e) {
+ panel.sizeModule();
+ }
+
+ @Override
+ public void icyFrameDeactivated(IcyFrameEvent e) {
+ }
+
+ @Override
+ public void icyFrameInternalized(IcyFrameEvent e) {
+ panel.sizeModule();
+ }
+
+ @Override
+ public void icyFrameExternalized(IcyFrameEvent e) {
+ panel.sizeModule();
+ }
+ @Override
+ public void componentResized(ComponentEvent e) {
+ panel.sizeModule();
+ }
+
+ @Override
+ public void componentMoved(ComponentEvent e) {
+ Point p = this.getLocation();
+ p.x += this.getWidth();
+ DeconvolutionDialog.setLocationLaunch(p);
+ }
+
+ @Override
+ public void componentShown(ComponentEvent e) {
+ panel.sizeModule();
+ }
+
+ @Override
+ public void componentHidden(ComponentEvent e) {
+ }
+
+}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
index ed6ebb2..4d5690b 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
@@ -1,45 +1,48 @@
/*
* 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 plugins.sage.deconvolutionlab;
-import icy.gui.dialog.MessageDialog;
+import java.io.File;
+
+import deconvolutionlab.Imaging;
+import deconvolutionlab.Lab;
import icy.plugin.abstract_.PluginActionable;
public class Deconvolutionlab2 extends PluginActionable {
@Override
public void run() {
- // TODO Auto-generated by Icy4Eclipse
- MessageDialog.showDialog("deconvolutionlab2 is working fine !");
+ Lab.init(Imaging.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ new DeconvolutionLabIcyFrame();
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImageSelector.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImageSelector.java
deleted file mode 100644
index eb09961..0000000
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImageSelector.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package plugins.sage.deconvolutionlab;
-
-import deconvolutionlab.PlatformImageSelector;
-
-public class IcyImageSelector extends PlatformImageSelector {
-
- @Override
- public String getSelectedImage() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean isSelectable() {
- return false;
- }
-
-}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
index db2a17c..e441366 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
@@ -1,210 +1,216 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package plugins.sage.deconvolutionlab;
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.swing.JDialog;
+
+import deconvolutionlab.Imaging;
import icy.file.Saver;
+import icy.gui.frame.IcyFrame;
import icy.image.IcyBufferedImage;
import icy.imagej.ImageJUtil;
import icy.main.Icy;
import icy.sequence.Sequence;
import icy.type.DataType;
import icy.type.collection.array.Array1DUtil;
import ij.ImagePlus;
import ij.io.Opener;
-
-import java.io.File;
-import java.util.ArrayList;
-
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-import deconvolutionlab.PlatformImager;
-import deconvolutionlab.monitor.Monitors;
-public class IcyImager extends PlatformImager {
+public class IcyImager extends Imaging {
+
+ @Override
+ public Platform getPlatform() {
+ return Imaging.Platform.ICY;
+ }
+ @Override
+ public void setVisible(JDialog dialog, boolean modal) {
+ IcyFrame icf = new IcyFrame();
+ icf.setTitle(dialog.getTitle());
+ dialog.setModal(modal);
+ icf.add(dialog.getContentPane());
+ icf.toFront();
+ icf.addToDesktopPane();
+ icf.setVisible(true);
+ }
public static RealSignal create(Sequence seq) {
int nx = seq.getSizeX();
int ny = seq.getSizeY();
int nz = seq.getSizeZ();
- RealSignal signal = new RealSignal(nx, ny, nz);
+ RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
@Override
public RealSignal create() {
return build(Icy.getMainInterface().getActiveSequence());
}
@Override
public RealSignal create(String name) {
ArrayList<Sequence> sequences = Icy.getMainInterface().getSequences(name);
for(Sequence sequence : sequences)
if (sequence.getName().equals(name))
return build(sequence);
return null;
}
@Override
public RealSignal open(String filename) {
//File file = new File(filename);
//return build(Loader.loadSequence(file, 0, false));
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
Sequence seq = ImageJUtil.convertToIcySequence(imp, null);
return build(seq);
}
- @Override
- public void show(RealSignal signal, String title) {
- show(signal, title, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void show(RealSignal signal, String title, PlatformImager.Type type) {
- Sequence sequence = build(signal, type);
- Icy.getMainInterface().addSequence(sequence);
- }
-
@Override
public void show(ComplexSignal signal, String title, ComplexComponent complex) {
Sequence sequence = new Sequence();
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
switch(complex) {
case REAL: plane = signal.getRealXY(k); break;
case IMAGINARY: plane = signal.getImagXY(k); break;
case MODULE: plane = signal.getModuleXY(k); break;
default: plane = signal.getModuleXY_dB(k);
}
IcyBufferedImage image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.FLOAT);
Array1DUtil.floatArrayToSafeArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, k, image);
}
sequence.setName(title);
Icy.getMainInterface().addSequence(sequence);
}
@Override
- public void save(RealSignal signal, String filename) {
- save(signal, filename, PlatformImager.Type.FLOAT);
- }
-
- @Override
- public void save(RealSignal signal, String filename, PlatformImager.Type type) {
+ public void save(RealSignal signal, String filename, Imaging.Type type) {
Sequence sequence = build(signal, type);
File file = new File(filename);
Saver.save(sequence, file, false, true);
}
- private RealSignal build(Sequence sequence) {
- int nx = sequence.getSizeX();
- int ny = sequence.getSizeY();
- int nz = sequence.getSizeZ();
- RealSignal signal = new RealSignal(nx, ny, nz);
+ private RealSignal build(Sequence seq) {
+ int nx = seq.getSizeX();
+ int ny = seq.getSizeY();
+ int nz = seq.getSizeZ();
+ RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
- Array1DUtil.arrayToFloatArray(sequence.getDataXY(0, k, 0), pixels, sequence.isSignedDataType());
+ Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
- private Sequence build(RealSignal signal, PlatformImager.Type type) {
+ private Sequence build(RealSignal signal, Imaging.Type type) {
+ int nx = signal.nx;
+ int ny = signal.ny;
+ int nz = signal.nz;
Sequence sequence = new Sequence();
- for (int k = 0; k < signal.nz; k++) {
- float[] plane = signal.getXY(k);
- IcyBufferedImage image = null;
- switch(type) {
- case BYTE:
- byte[] b = Array1DUtil.arrayToByteArray(plane);
- image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.BYTE);
- Array1DUtil.byteArrayToArray(b, image.getDataXY(0), image.isSignedDataType());
- break;
- case SHORT:
- short[] s = Array1DUtil.arrayToShortArray(plane, false);
- image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.SHORT);
- Array1DUtil.shortArrayToArray(s, image.getDataXY(0), image.isSignedDataType());
- break;
- default:
- image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.FLOAT);
- Array1DUtil.floatArrayToArray(signal.data[k], image.getDataXY(0));
- break;
+ for (int z = 0; z < nz; z++) {
+ if (type == Imaging.Type.SHORT) {
+ short[] plane = Array1DUtil.arrayToShortArray(signal.data[z], false);
+ IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.USHORT);
+ Array1DUtil.shortArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
+ image.dataChanged();
+ sequence.setImage(0, z, image);
}
- image.dataChanged();
- sequence.setImage(0, k, image);
+ else if (type == Imaging.Type.BYTE) {
+ byte[] plane = Array1DUtil.arrayToByteArray(signal.data[z]);
+ IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.UBYTE);
+ Array1DUtil.byteArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
+ image.dataChanged();
+ sequence.setImage(0, z, image);
+ }
+ else {
+ IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.FLOAT);
+ Array1DUtil.floatArrayToSafeArray(signal.data[z], image.getDataXY(0), image.isSignedDataType());
+ image.dataChanged();
+ sequence.setImage(0, z, image);
+ }
+
}
return sequence;
}
+
@Override
public String getName() {
return "Icy";
}
- @Override
- public void show(RealSignal signal, String title, Type type, int z) {
- // TODO Auto-generated method stub
- }
-
- @Override
- public void show(ComplexSignal signal, String title) {
- // TODO Auto-generated method stub
- }
-
@Override
public ContainerImage createContainer(String title) {
// TODO Auto-generated method stub
return null;
}
+
@Override
- public void append(ContainerImage container, RealSignal signal, String title) {
+ public void append(ContainerImage container, RealSignal signal, String title, Type type) {
// TODO Auto-generated method stub
}
@Override
- public void append(ContainerImage container, RealSignal signal, String title, Type type) {
- // TODO Auto-generated method stub
-
+ public void show(RealSignal signal, String title, Type type, int z) {
+ Sequence sequence = build(signal, type);
+ sequence.setName(title);
+ Icy.getMainInterface().addSequence(sequence);
}
+ @Override
+ public String getSelectedImage() {
+ return null;
+ }
+
+ @Override
+ public boolean isSelectable() {
+ return false;
+ }
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java
new file mode 100644
index 0000000..d6feda5
--- /dev/null
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java
@@ -0,0 +1,29 @@
+package plugins.sage.deconvolutionlab;
+
+import java.io.File;
+
+import deconvolutionlab.Imaging;
+import deconvolutionlab.Lab;
+import deconvolutionlab.Output.View;
+import deconvolutionlab.dialog.OutputDialog;
+import icy.gui.frame.IcyFrame;
+import icy.plugin.abstract_.PluginActionable;
+
+public class Test extends PluginActionable {
+
+ @Override
+ public void run() {
+
+ Lab.init(Imaging.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ IcyFrame icf = new IcyFrame();
+ icf.add(new OutputDialog(View.FIGURE).getContentPane());
+ icf.pack();
+ icf.toFront();
+ icf.addToDesktopPane();
+ icf.setVisible(true);
+ //icf.setResizable(true);
+
+
+ }
+
+}
diff --git a/DeconvolutionLab2/src/signal/Assessment.java b/DeconvolutionLab2/src/signal/Assessment.java
index 5797a9d..81c4c9a 100644
--- a/DeconvolutionLab2/src/signal/Assessment.java
+++ b/DeconvolutionLab2/src/signal/Assessment.java
@@ -1,87 +1,87 @@
/*
* 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 signal;
public class Assessment {
public static double snr(RealSignal test, RealSignal ref) {
double measures[] = measure(test, ref);
return measures[0];
}
public static double psnr(RealSignal test, RealSignal ref) {
double measures[] = measure(test, ref);
return measures[1];
}
public static double rmse(RealSignal test, RealSignal ref) {
double measures[] = measure(test, ref);
return measures[3];
}
public static double relativeResidu(RealSignal test, RealSignal ref) {
double measures[] = measure(test, ref);
- return measures[3] / Math.max(measures[2], RealSignal.epsilon);
+ return measures[3] / Math.max(measures[2], Operations.epsilon);
}
/**
*
* @param test RealSignal
* @param ref RealSignal
* @return an array of double containing
*/
private static double[] measure(RealSignal test, RealSignal ref) {
int nxy = Math.min(test.nx * test.ny, ref.nx * ref.ny);
int nz = Math.min(test.nz, ref.nz);
double max = -Double.MAX_VALUE;
double sref = 0.0;
double rmse = 0.0;
double a = 0.0;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
a = ref.data[k][i] ;
if (max < a)
max = a;
sref += a * a;
rmse += (a-test.data[k][i]) * (a-test.data[k][i]);
}
sref = Math.sqrt(sref / (nz*nxy));
rmse = Math.sqrt(rmse / (nz*nxy));
if (rmse <= 0)
return new double[] {Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, sref, rmse, max};
else
return new double[] {20*Math.log10(sref/rmse), 20*Math.log10(max/rmse), sref, rmse, max};
}
}
diff --git a/DeconvolutionLab2/src/signal/ComplexSignal.java b/DeconvolutionLab2/src/signal/ComplexSignal.java
index ef57629..b796774 100644
--- a/DeconvolutionLab2/src/signal/ComplexSignal.java
+++ b/DeconvolutionLab2/src/signal/ComplexSignal.java
@@ -1,609 +1,633 @@
/*
* 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 signal;
-import deconvolutionlab.Lab;
+public class ComplexSignal extends Signal implements SignalListener {
-public class ComplexSignal extends Signal {
+ public ComplexSignal(String name, int nx, int ny, int nz) {
+ super(name, nx, ny, nz);
+ int step = Math.max(1, nz/SignalCollector.NOTIFICATION_RATE);
+ this.data = new float[nz][];
+ notify(name, 0);
+ for(int k=0; k<nz; k++) {
+ data[k] = new float[nx * ny * 2];
+ if (k % step == 0)
+ notify(name, k*100.0/nz);
+ }
+ notify(name, 100);
+ SignalCollector.alloc(name, nx, ny, ny, true);
+ }
- public ComplexSignal(int nx, int ny, int nz) {
- allocateComplexSignal(nx, ny, nz);
+ @Override
+ public void notify(String name, double progress) {
+ SignalCollector.setProgress(progress);
}
- public ComplexSignal(RealSignal real) {
- allocateComplexSignal(real.nx, real.ny, real.nz);
+ @Override
+ public void finalize() {
+ data = null;
+ System.gc();
+ SignalCollector.free(name, nx, ny, ny, true);
+ }
+
+ public void set(RealSignal real) {
for(int k=0; k<nz; k++) {
float[] s = data[k];
float[] r = real.getXY(k);
for(int i=0; i<nx*ny; i++) {
s[2*i] = r[i];
}
}
}
- public ComplexSignal(RealSignal real, RealSignal imag) {
- allocateComplexSignal(real.nx, real.ny, real.nz);
+ public void set(RealSignal real, RealSignal imag) {
for(int k=0; k<nz; k++) {
float[] s = data[k];
float[] re = real.getXY(k);
float[] im = imag.getXY(k);
for(int i=0; i<nx*ny; i++) {
s[2*i] = re[i];
s[2*i+1] = im[i];
}
}
}
public void divide(ComplexSignal denominator) {
float a1, a2, b1, b2, mag;
- float epsilon2 = (float)(epsilon*epsilon);
+ float epsilon2 = (float)(Operations.epsilon*Operations.epsilon);
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = data[k][i];
b1 = data[k][i+1];
a2 = denominator.data[k][i];
b2 = denominator.data[k][i+1];
mag = a2*a2 + b2*b2;
if (mag >= epsilon2) {
data[k][i] = (a1*a2 + b1*b2) / mag;
data[k][i+1] = (b1*a2 - a1*b2) / mag;
}
else {
data[k][i] = (a1*a2 + b1*b2) / epsilon2;
data[k][i+1] = (b1*a2 - a1*b2) / epsilon2;
}
}
}
public double[][][] getReal3DArrayAsDouble() {
double[][][] ar = new double[nx][ny][nz];
for(int k=0; k<nz; k++) {
float[] s = data[k];
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++) {
ar[i][j][k] = s[2*(i+j*nx)];
}
}
return ar;
}
public double[][][] getImag3DArrayAsDouble() {
double[][][] ar = new double[nx][ny][nz];
for(int k=0; k<nz; k++) {
float[] s = data[k];
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++) {
ar[i][j][k] = s[2*(i+j*nx)+1];
}
}
return ar;
}
public void set3DArrayAsDouble(double[][][] real, double imag[][][]) {
for(int k=0; k<nz; k++) {
float[] s = data[k];
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++) {
s[2*(i+j*nx)] = (float)real[i][j][k];
s[2*(i+j*nx)+1] = (float)imag[i][j][k];
}
}
}
- public void times(float factor) {
+ public ComplexSignal times(float factor) {
int nxy = nx * ny * 2;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
- data[k][i] *= factor;
+ data[k][i] *= factor;
+ return this;
}
- public void plus(float real, float imag) {
+ public ComplexSignal plus(float real, float imag) {
int nxy = nx * ny * 2;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i+=2) {
data[k][i] += real;
data[k][i+1] += imag;
}
+ return this;
}
- public void times(ComplexSignal factor) {
+ public ComplexSignal times(ComplexSignal factor) {
float a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = data[k][i];
b1 = data[k][i+1];
a2 = factor.data[k][i];
b2 = factor.data[k][i+1];
data[k][i] = a1*a2 - b1*b2;
data[k][i+1] = a1*b2 + a2*b1;
}
+ return this;
}
// this <- Ht * this
public void timesConjugate(ComplexSignal H) {
float a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = data[k][i];
b1 = data[k][i+1];
a2 = H.data[k][i];
b2 = -H.data[k][i+1];
data[k][i] = a1*a2 - b1*b2;
data[k][i+1] = a1*b2 + a2*b1;
}
}
public void plus(ComplexSignal term) {
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
data[k][i] += term.data[k][i];
data[k][i+1] += term.data[k][i+1];
}
}
public void minus(ComplexSignal term) {
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
data[k][i] -= term.data[k][i];
data[k][i+1] -= term.data[k][i+1];
}
}
public void conjugate() {
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2)
data[k][i+1] = -data[k][i+1];
}
public float[] getValue(int i, int j, int k) {
return new float[] {data[k][2*(j*nx+i)], data[k][2*(j*nx+i)+1]};
}
public void setValue(int i, int j, int k, float[] value) {
data[k][2*(j*nx+i)] = value[0];
data[k][2*(j*nx+i)+1] = value[1];
}
public float[] getInterleaveXYZ() {
int nxy = nx*ny*2;
float[] interleave = new float[nz*nxy];
for (int k = 0; k < nz; k++)
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = 2*(k*nx*ny + j*nx + i);
interleave[index] = data[k][(i+j*nx)*2];
interleave[index + 1] = data[k][(i+j*nx)*2+1];
}
return interleave;
}
public void setInterleaveXYZ(float[] interleave) {
int nxy = nx * ny * 2;
this.data = new float[nz][nxy];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
for (int k = 0; k < nz; k++) {
int index = 2*(k*nx*ny + j*nx + i);
data[k][(i+j*nx)*2] = interleave[index];
data[k][(i+j*nx)*2 + 1] = interleave[index+1];
}
}
public RealSignal getRealSignal() {
- RealSignal real = new RealSignal(nx, ny, nz);
+ String n = "real(" + name + ")";
+ RealSignal real = new RealSignal(n, nx, ny, nz);
int nxy = nx * ny;
for (int k = 0; k < nz; k++) {
float[] r = real.getXY(k);
for (int i = 0; i < nxy; i++)
r[i] = data[k][2*i];
}
return real;
}
public RealSignal getImagSignal() {
- RealSignal real = new RealSignal(nx, ny, nz);
+ String n = "imag(" + name + ")";
+ RealSignal real = new RealSignal(n, nx, ny, nz);
int nxy = nx * ny;
for (int k = 0; k < nz; k++) {
float[] r = real.getXY(k);
for (int i = 0; i < nxy; i++)
r[i] = data[k][2*i+1];
}
return real;
}
public RealSignal getModule() {
- RealSignal module = new RealSignal(nx, ny, nz);
+ String n = "mod(" + name + ")";
+ RealSignal module = new RealSignal(n, nx, ny, nz);
for (int k = 0; k < nz; k++)
module.setXY(k, getModuleXY(k));
return module;
}
public float[] getModuleXY(int k) {
float[] m = new float[nx*ny];
for (int i = 0; i < nx * ny; i++)
m[i] = data[k][2*i]*data[k][2*i] + data[k][2*i+1]*data[k][2*i+1];
return m;
}
public float[] getModuleXY_dB(int k) {
float[] m = new float[nx*ny];
for (int i = 0; i < nx * ny; i++)
m[i] = (float)(10f*Math.log10(data[k][2*i]*data[k][2*i] + data[k][2*i+1]*data[k][2*i+1]));
return m;
}
public ComplexSignal duplicate() {
- ComplexSignal out = new ComplexSignal(nx, ny, nz);
+ ComplexSignal out = new ComplexSignal("copy(" + name + ")", nx, ny, nz);
int nxy = nx * ny * 2;
for (int k = 0; k < nz; k++)
System.arraycopy(data[k], 0, out.data[k], 0, nxy);
return out;
}
public ComplexSignal replicate() {
- return new ComplexSignal(nx, ny, nz);
+ return new ComplexSignal(">" + name, nx, ny, nz);
}
public float getEnergy() {
int nxy = nx * ny;
float energy = 0.f;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
energy += modulus(k, i);
return energy;
}
private float modulus(int k, int index) {
int i = index * 2;
return (float)Math.sqrt(data[k][i] * data[k][i] + data[k][i + 1] * data[k][i + 1]);
}
public float[] getRealXYZ() {
float[] real = new float[nx*ny*nz];
int nxy = nx * ny;
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + nx*j;
for (int k = 0; k < nz; k++)
real[k*nxy + index] = data[k][2*index];
}
return real;
}
public float[] getImagXYZ() {
float[] imag = new float[nx*ny*nz];
int nxy = nx * ny;
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + nx*j;
for (int k = 0; k < nz; k++)
imag[k*nxy + index] = data[k][2*index+1];
}
return imag;
}
public void setXYZ(float[] real, float[] imag) {
int nxy = nx * ny;
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + nx*j;
for (int k = 0; k < nz; k++) {
data[k][2*index] = real[k*nxy + index];
data[k][2*index+1] = imag[k*nxy + index];
}
}
}
public float[] getInterleaveZ(int i, int j) {
float line[] = new float[nz*2];
int index = 2 * (i + j * nx);
for (int k = 0; k < nz; k++) {
line[2*k] = data[k][index];
line[2*k+1] = data[k][index+1];
}
return line;
}
public float[] getRealZ(int i, int j) {
float line[] = new float[nz];
int index = 2 * (i + j * nx);
for (int k = 0; k < nz; k++)
line[k] = data[k][index];
return line;
}
public float[] getImagZ(int i, int j) {
float line[] = new float[nz];
int index = 2 * (i + j * nx) + 1;
for (int k = 0; k < nz; k++)
line[k] = data[k][index];
return line;
}
public float[] getRealY(int i, int k) {
float line[] = new float[ny];
for (int j = 0; j < ny; j++)
line[j] = data[k][2 * (i + j * nx)];
return line;
}
public float[] getImagY(int i, int k) {
float line[] = new float[ny];
for (int j = 0; j < ny; j++)
line[j] = data[k][2 * (i + j * nx) + 1];
return line;
}
public float[] getRealX(int j, int k) {
float line[] = new float[nx];
for (int i = 0; i < nx; i++)
line[i] = data[k][2 * (i + j * nx)];
return line;
}
public float[] getImagX(int j, int k) {
float line[] = new float[nx];
for (int i = 0; i < nx; i++)
line[i] = data[k][2 * (i + j * nx) + 1];
return line;
}
public float[] getInterleaveXY(int k) {
float slice[] = new float[nx*ny*2];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = 2*(i + j * nx);
slice[index] = data[k][index];
slice[index + 1] = data[k][index + 1];
}
return slice;
}
public float[] getInterleaveYX(int k) {
float slice[] = new float[nx*ny*2];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = 2*(j + i * ny);
slice[index] = data[k][index];
slice[index + 1] = data[k][index + 1];
}
return slice;
}
public float[] getRealXY(int k) {
float slice[] = new float[nx*ny];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + j * nx;
slice[index] = data[k][2*index];
}
return slice;
}
public float[] getImagXY(int k) {
float slice[] = new float[nx*ny];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
slice[i + j * nx] = data[k][2 * (i + j * nx)+1];
return slice;
}
public void setInterleaveZ(int i, int j, float line[]) {
int index = 2 * (i + j * nx);
for (int k = 0; k < nz; k++) {
data[k][index] = line[2*k];
data[k][index+1] = line[2*k+1];
}
}
public void setRealZ(int i, int j, float line[]) {
int index = 2 * (i + j * nx);
for (int k = 0; k < nz; k++)
data[k][index] = line[k];
}
public void setImagZ(int i, int j, float line[]) {
int index = 2 * (i + j * nx) + 1;
for (int k = 0; k < nz; k++)
data[k][index] = line[k];
}
public void setRealX(int j, int k, float line[]) {
for (int i = 0; i < nx; i++)
data[k][2 * (i + j * nx)] = line[i];
}
public void setImagX(int j, int k, float line[]) {
for (int i = 0; i < nx; i++)
data[k][2 * (i + j * nx) + 1] = line[i];
}
public void setRealY(int i, int k, float line[]) {
for (int j = 0; j < ny; j++)
data[k][2 * (i + j * nx)] = line[j];
}
public void setImagY(int i, int k, float line[]) {
for (int j = 0; j < ny; j++)
data[k][2 * (i + j * nx) + 1] = line[j];
}
public void setInterleaveXY(int k, float slice[]) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
data[k][2 * (i + j * nx)] = slice[2*(i + j * nx)];
data[k][2 * (i + j * nx) + 1] = slice[2*(i + j * nx) + 1];
}
}
public void setInterleaveYX(int k, float slice[]) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
data[k][2 * (i + j * nx)] = slice[2*(j + i * ny)];
data[k][2 * (i + j * nx) + 1] = slice[2*(j + i * ny) + 1];
}
}
public void setRealXY(int k, float slice[]) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
data[k][2 * (i + j * nx)] = slice[i + j * nx];
}
public void setImagXY(int k, float slice[]) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
data[k][2 * (i + j * nx)+1] = slice[i + j * nx];
}
public float[] getRealY(int i, int k, int imag) {
float line[] = new float[ny];
int off = 2 * i + imag;
for (int j = 0; j < ny; j++)
line[j] = data[k][2 * j * nx + off];
return line;
}
public void swap() {
int hx = nx / 2;
int hy = ny / 2;
int hz = nz / 2;
if (nx > 1) {
float rx[] = new float[nx];
float ix[] = new float[nx];
for (int j = 0; j < ny; j++)
for (int k = 0; k < nz; k++) {
float real[] = getRealX(j, k);
float imag[] = getImagX(j, k);
for (int i = 0; i < hx; i++) {
rx[i] = real[i + hx];
rx[i + hx] = real[i];
ix[i] = imag[i + hx];
ix[i + hx] = imag[i];
}
setRealX(j, k, rx);
setImagX(j, k, ix);
}
}
if (ny > 1) {
float ry[] = new float[ny];
float iy[] = new float[ny];
for (int i = 0; i < nx; i++)
for (int k = 0; k < nz; k++) {
float real[] = getRealY(i, k);
float imag[] = getImagY(i, k);
for (int j = 0; j < hy; j++) {
ry[j] = real[j + hy];
ry[j + hy] = real[j];
iy[j] = imag[j + hy];
iy[j + hy] = imag[j];
}
setRealY(i, k, ry);
setImagY(i, k, iy);
}
}
if (nz > 1) {
float rz[] = new float[nz];
float iz[] = new float[nz];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
float real[] = getRealZ(i, j);
float imag[] = getImagZ(i, j);
for (int k = 0; k < hz; k++) {
rz[k] = real[k + hz];
rz[k + hz] = real[k];
iz[k] = imag[k + hz];
iz[k + hz] = imag[k];
}
setRealZ(i, j, rz);
setImagZ(i, j, iz);
}
}
}
public void circularShift() {
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++) {
setImagZ(i, j, rotate(getImagZ(i, j)));
setRealZ(i, j, rotate(getRealZ(i, j)));
}
for(int i=0; i<nx; i++)
for(int k=0; k<nz; k++) {
setImagY(i, k, rotate(getImagY(i, k)));
setRealY(i, k, rotate(getRealY(i, k)));
}
for(int j=0; j<ny; j++)
for(int k=0; k<nz; k++) {
setImagX(j, k, rotate(getImagX(j, k)));
setRealX(j, k, rotate(getRealX(j, k)));
}
}
private float[] rotate(float[] buffer) {
int len = buffer.length;
if (len <= 1)
return buffer;
int count = 0;
int offset = 0;
int start = len / 2;
while (count < len) {
int index = offset;
float tmp = buffer[index];
int index2 = (start + index) % len;
while (index2 != offset) {
buffer[index] = buffer[index2];
count++;
index = index2;
index2 = (start + index) % len;
}
buffer[index] = tmp;
count++;
offset++;
}
return buffer;
}
@Override
public String toString() {
return "Complex Signal [" + nx + ", " + ny + ", " + nz + "]";
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/signal/Operations.java b/DeconvolutionLab2/src/signal/Operations.java
index 4f10788..5e3bbe2 100644
--- a/DeconvolutionLab2/src/signal/Operations.java
+++ b/DeconvolutionLab2/src/signal/Operations.java
@@ -1,322 +1,342 @@
/*
* 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 signal;
public class Operations {
+ public static double epsilon = 1e-6;
+
public static RealSignal log(RealSignal s) {
+ String name = "log(" + s.name + ")";
int nx = s.nx;
int ny = s.ny;
int nz = s.nz;
int nxy = nx * ny;
- RealSignal log = new RealSignal(nx, ny, nz);
+ RealSignal log = new RealSignal(name, nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i++) {
log.data[k][i] = (float) Math.log(s.data[k][i]);
}
return log;
}
- public static void divide(RealSignal numerator, RealSignal denominator, RealSignal output) {
+ public static void divide(RealSignal numerator, RealSignal denominator, RealSignal output) {
+ String name = numerator.name + "/" + denominator.name;
if (output == null)
- output = new RealSignal(numerator.nx, numerator.ny, numerator.nz);
- double epsilon = Signal.epsilon;
+ output = new RealSignal(name, numerator.nx, numerator.ny, numerator.nz);
int nxy = numerator.nx * numerator.ny;
for(int k=0; k<numerator.nz; k++)
for(int i=0; i< nxy; i++) {
if (denominator.data[k][i] < epsilon)
output.data[k][i] = 0.0f;
else
output.data[k][i] = numerator.data[k][i] / denominator.data[k][i];
}
}
public static RealSignal divide(RealSignal numerator, RealSignal denominator) {
- RealSignal output = new RealSignal(numerator.nx, numerator.ny, numerator.nz);
+ String name = numerator.name + "/" + denominator.name;
+ RealSignal output = new RealSignal(name, numerator.nx, numerator.ny, numerator.nz);
divide(numerator, denominator, output);
return output;
}
public static ComplexSignal conjugate(ComplexSignal s) {
+ String name = "conj(" + s.name + ")";
int nx = s.nx;
int ny = s.ny;
int nz = s.nz;
int nxy = nx * ny * 2;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
result.data[k][i] = s.data[k][i];
result.data[k][i+1] = -s.data[k][i+1];
}
return result;
}
public static void multiply(ComplexSignal a, ComplexSignal b, ComplexSignal output) {
+ String name = a.name + "*" + b.name;
if (output == null)
- output = new ComplexSignal(a.nx, a.ny, a.nz);
+ output = new ComplexSignal(name, a.nx, a.ny, a.nz);
int nx = a.nx;
int ny = a.ny;
int nz = a.nz;
double ar, ai, br, bi;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
ar = a.data[k][i];
ai = a.data[k][i+1];
br = b.data[k][i];
bi = b.data[k][i+1];
output.data[k][i] = (float)(ar*br - ai*bi);
output.data[k][i+1] = (float)(ar*bi + br*ai);
}
}
public static ComplexSignal multiply(ComplexSignal a, ComplexSignal b) {
- ComplexSignal output = new ComplexSignal(a.nx, a.ny, a.nz);
+ String name = a.name + "*" + b.name;
+ ComplexSignal output = new ComplexSignal(name, a.nx, a.ny, a.nz);
multiply(a, b, output);
return output;
}
public static ComplexSignal multiplyConjugate(ComplexSignal aConjugate, ComplexSignal b) {
- ComplexSignal output = new ComplexSignal(b.nx, b.ny, b.nz);
+ String name = aConjugate.name + "* *" + b.name;
+ ComplexSignal output = new ComplexSignal(name, b.nx, b.ny, b.nz);
multiplyConjugate(aConjugate, b, output);
return output;
}
public static void multiplyConjugate(ComplexSignal aConjugate, ComplexSignal b, ComplexSignal output) {
+ String name = aConjugate.name + "* *" + b.name;
if (output == null)
- output = new ComplexSignal(b.nx, b.ny, b.nz);
+ output = new ComplexSignal(name, b.nx, b.ny, b.nz);
int nx = b.nx;
int ny = b.ny;
int nz = b.nz;
double a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = aConjugate.data[k][i];
b1 = -aConjugate.data[k][i+1];
a2 = b.data[k][i];
b2 = b.data[k][i+1];
output.data[k][i] = (float)(a1*a2 - b1*b2);
output.data[k][i+1] = (float)(a1*b2 + a2*b1);
}
}
public static ComplexSignal multiply(double w, ComplexSignal a, ComplexSignal b) {
+ String name = a.name + "* w *" + b.name;
int nx = a.nx;
int ny = a.ny;
int nz = a.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = a.data[k][i];
b1 = a.data[k][i+1];
a2 = b.data[k][i];
b2 = b.data[k][i+1];
result.data[k][i] = (float)(w*(a1*a2 - b1*b2));
result.data[k][i+1] = (float)(w*(a1*b2 + a2*b1));
}
return result;
}
public static ComplexSignal multiplyConjugate(double w, ComplexSignal aConjugate, ComplexSignal b) {
+ String name = aConjugate.name + "* * w *" + b.name;
int nx = b.nx;
int ny = b.ny;
int nz = b.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = aConjugate.data[k][i];
b1 = -aConjugate.data[k][i+1];
a2 = b.data[k][i];
b2 = b.data[k][i+1];
result.data[k][i] = (float)(w*(a1*a2 - b1*b2));
result.data[k][i+1] = (float)(w*(a1*b2 + a2*b1));
}
return result;
}
public static ComplexSignal divideStabilized(ComplexSignal numerator, ComplexSignal denominator) {
+ String name = numerator.name + " / " + denominator.name;
int nx = numerator.nx;
int ny = numerator.ny;
int nz = numerator.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a1, a2, b1, b2, mag;
int nxy = nx * ny * 2;
- double epsilon = Signal.epsilon;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = numerator.data[k][i];
b1 = numerator.data[k][i+1];
a2 = denominator.data[k][i];
b2 = denominator.data[k][i+1];
mag = Math.max(epsilon, a2*a2 + b2*b2);
result.data[k][i] = (float)((a1*a2 + b1*b2) / mag);
result.data[k][i+1] = (float)((b1*a2 - a1*b2) / mag);
}
return result;
}
public static ComplexSignal divideNotStabilized(ComplexSignal numerator, ComplexSignal denominator) {
+ String name = numerator.name + " /0/ " + denominator.name;
int nx = numerator.nx;
int ny = numerator.ny;
int nz = numerator.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a1, a2, b1, b2;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a1 = numerator.data[k][i];
b1 = numerator.data[k][i+1];
a2 = denominator.data[k][i];
b2 = denominator.data[k][i+1];
double mag = a2*a2 + b2*b2;
result.data[k][i] = (float)((a1*a2 + b1*b2) / mag);
result.data[k][i+1] = (float)((b1*a2 - a1*b2) / mag);
}
return result;
}
public static ComplexSignal add(ComplexSignal s1, ComplexSignal s2) {
+ String name = s1.name + " + " + s2.name;
int nx = s1.nx;
int ny = s1.ny;
int nz = s1.nz;
int nxy = nx * ny * 2;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i<nxy; i++)
result.data[k][i] = s1.data[k][i] + s2.data[k][i];
return result;
}
public static ComplexSignal subtract(ComplexSignal s1, ComplexSignal s2) {
+ String name = s1.name + " - " + s2.name;
int nx = s1.nx;
int ny = s1.ny;
int nz = s1.nz;
int nxy = nx * ny * 2;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i<nxy; i++)
result.data[k][i] = s1.data[k][i] - s2.data[k][i];
return result;
}
public static void subtract(RealSignal s1, RealSignal s2, RealSignal output) {
+ String name = s1.name + " - " + s2.name;
if (output == null)
- output = new RealSignal(s1.nx, s1.ny, s1.nz);
+ output = new RealSignal(name, s1.nx, s1.ny, s1.nz);
int nxy = s1.nx * s1.ny;
for(int k=0; k<s1.nz; k++)
for(int i=0; i<nxy; i++)
output.data[k][i] = s1.data[k][i] - s2.data[k][i];
}
public static RealSignal subtract(RealSignal s1, RealSignal s2) {
- RealSignal output = new RealSignal(s1.nx, s1.ny, s1.nz);
+ String name = s1.name + " - " + s2.name;
+ RealSignal output = new RealSignal(name, s1.nx, s1.ny, s1.nz);
subtract(s1, s2, output);
return output;
}
public static ComplexSignal computeHtH(double w, ComplexSignal h) {
+ String name = " w * HtH( " + h.name + ")";
int nx = h.nx;
int ny = h.ny;
int nz = h.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a, b;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a = h.data[k][i];
b = h.data[k][i+1];
result.data[k][i] = (float)(w*(a*a + b*b));
//result.data[k][i+1] = 0f;
}
return result;
}
// I - gamma * Ht * H
public static ComplexSignal delta(double w, ComplexSignal h) {
+ String name = " w * Delta2( " + h.name + ")";
int nx = h.nx;
int ny = h.ny;
int nz = h.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a, b;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a = h.data[k][i];
b = h.data[k][i+1];
result.data[k][i] = (float)(1.0 - w*(a*a + b*b));
//result.data[k][i+1] = 0f;
}
return result;
}
// I - gamma * H
public static ComplexSignal delta1(double w, ComplexSignal h) {
+ String name = " w * Delta1( " + h.name + ")";
int nx = h.nx;
int ny = h.ny;
int nz = h.nz;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
double a, b;
int nxy = nx * ny * 2;
for(int k=0; k<nz; k++)
for(int i=0; i< nxy; i+=2) {
a = h.data[k][i];
b = h.data[k][i+1];
result.data[k][i] = (float)(1.0 - w*a);
result.data[k][i+1] = (float)(- w*b);
}
return result;
}
public static ComplexSignal multiply(double factor, ComplexSignal s) {
+ String name = " w * ( " + s.name + ")";
int nx = s.nx;
int ny = s.ny;
int nz = s.nz;
int nxy = nx * ny * 2;
- ComplexSignal result = new ComplexSignal(nx, ny, nz);
+ ComplexSignal result = new ComplexSignal(name, nx, ny, nz);
for(int k=0; k<nz; k++)
for(int i=0; i<nxy; i++)
result.data[k][i] = (float)(factor * s.data[k][i]);
return result;
}
public static RealSignal circularShift(RealSignal signal) {
RealSignal out = signal.duplicate();
out.circular();
return out;
}
}
diff --git a/DeconvolutionLab2/src/signal/RealSignal.java b/DeconvolutionLab2/src/signal/RealSignal.java
index 6e1b120..2cbe86b 100644
--- a/DeconvolutionLab2/src/signal/RealSignal.java
+++ b/DeconvolutionLab2/src/signal/RealSignal.java
@@ -1,602 +1,657 @@
/*
* 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 signal;
-import deconvolutionlab.monitor.Monitors;
+import java.awt.Image;
+import java.awt.image.BufferedImage;
-public class RealSignal extends Signal {
+import deconvolutionlab.monitor.Monitors;
+public class RealSignal extends Signal implements SignalListener {
- public RealSignal(int nx, int ny, int nz) {
- allocateRealSignal(nx, ny, nz, true);
+ public RealSignal(String name, int nx, int ny, int nz) {
+ super(name, nx, ny, nz);
+ this.data = new float[nz][];
+ int step = Math.max(1, nz / SignalCollector.NOTIFICATION_RATE);
+ notify(name, 0);
+ for (int k = 0; k < nz; k++) {
+ data[k] = new float[nx * ny];
+ if (k % step == 0)
+ notify(name, k * 100.0 / nz);
+ }
+ notify(name, 100);
+ SignalCollector.alloc(name, nx, ny, ny, false);
+ this.addSignalListener(this);
}
- public RealSignal(int nx, int ny, int nz, boolean incMemory) {
- allocateRealSignal(nx, ny, nz, incMemory);
+ @Override
+ public void notify(String name, double progress) {
+ SignalCollector.setProgress(progress);
}
- public RealSignal(int nx, int ny, int nz, float data[]) {
- allocateRealSignal(nx, ny, nz, true);
- setXYZ(data);
+ @Override
+ public void finalize() {
+ data = null;
+ System.gc();
+ SignalCollector.free(name, nx, ny, ny, false);
}
public void copy(RealSignal source) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] = source.data[k][i];
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = source.data[k][i];
+ }
}
-
+
public void setSignal(RealSignal signal) {
int sx = signal.nx;
int mx = Math.min(nx, signal.nx);
int my = Math.min(ny, signal.ny);
int mz = Math.min(nz, signal.nz);
for (int i = 0; i < mx; i++)
- for (int j = 0; j < my; j++)
- for (int k = 0; k < mz; k++)
- data[k][i+nx*j] = signal.data[k][i+sx*j];
+ for (int j = 0; j < my; j++)
+ for (int k = 0; k < mz; k++)
+ data[k][i + nx * j] = signal.data[k][i + sx * j];
}
public void getSignal(RealSignal signal) {
int sx = signal.nx;
int mx = Math.min(nx, signal.nx);
int my = Math.min(ny, signal.ny);
int mz = Math.min(nz, signal.nz);
for (int i = 0; i < mx; i++)
- for (int j = 0; j < my; j++)
- for (int k = 0; k < mz; k++)
- signal.data[k][i+sx*j] = data[k][i+nx*j];
+ for (int j = 0; j < my; j++)
+ for (int k = 0; k < mz; k++)
+ signal.data[k][i + sx * j] = data[k][i + nx * j];
}
/**
* Applies a soft threshold (in-place processing)
+ *
* @param inferiorLimit
* @param superiorLimit
* @return the instance of the calling object
*/
public RealSignal thresholdSoft(float inferiorLimit, float superiorLimit) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- if (data[k][i] <= inferiorLimit)
- data[k][i] += inferiorLimit;
- else if (data[k][i] >= superiorLimit)
- data[k][i] -= superiorLimit;
- else
- data[k][i] = 0f;
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ if (data[k][i] <= inferiorLimit)
+ data[k][i] += inferiorLimit;
+ else if (data[k][i] >= superiorLimit)
+ data[k][i] -= superiorLimit;
+ else
+ data[k][i] = 0f;
+ }
return this;
}
/**
* Multiplies by a signal pixelwise (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal times(RealSignal factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] *= factor.data[k][i];
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] *= factor.data[k][i];
+ }
return this;
}
-
+
/**
* Multiplies by a scalar factor (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal times(float factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] *= factor;
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] *= factor;
+ }
return this;
}
/**
* Adds a signal pixelwise (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal plus(RealSignal factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] += factor.data[k][i];
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] += factor.data[k][i];
+ }
return this;
}
-
+
/**
* Subtracts by a signal pixelwise (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal minus(RealSignal factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] -= factor.data[k][i];
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] -= factor.data[k][i];
+ }
return this;
}
/**
* Adds a scalar term (in-place processing)
+ *
* @param term
* @return the instance of the calling object
*/
public RealSignal plus(float term) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] += term;
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] += term;
+ }
return this;
}
/**
- * Takes the maximum (in-place processing)
+ * Takes the maximum (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal max(RealSignal factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] = Math.max(data[k][i], factor.data[k][i]);
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = Math.max(data[k][i], factor.data[k][i]);
+ }
return this;
}
-
+
/**
- * Takes the minimum (in-place processing)
+ * Takes the minimum (in-place processing)
+ *
* @param factor
* @return the instance of the calling object
*/
public RealSignal min(RealSignal factor) {
int nxy = nx * ny;
- for(int k=0; k<nz; k++)
- for(int i=0; i< nxy; i++) {
- data[k][i] = Math.min(data[k][i], factor.data[k][i]);
- }
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = Math.min(data[k][i], factor.data[k][i]);
+ }
return this;
}
public double[][][] get3DArrayAsDouble() {
double[][][] ar = new double[nx][ny][nz];
for (int k = 0; k < nz; k++) {
float[] s = data[k];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
ar[i][j][k] = s[i + j * nx];
}
}
return ar;
}
public void set3DArrayAsDouble(double[][][] real) {
for (int k = 0; k < nz; k++) {
float[] s = data[k];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
s[i + j * nx] = (float) real[i][j][k];
}
}
}
public RealSignal duplicate() {
- RealSignal out = new RealSignal(nx, ny, nz);
+ RealSignal out = new RealSignal("copy(" + name + ")", nx, ny, nz);
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
System.arraycopy(data[k], 0, out.data[k], 0, nxy);
return out;
}
public float getEnergy() {
int nxy = nx * ny;
float energy = 0.f;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
energy += data[k][i];
return energy;
}
public float[] getStats() {
int nxy = nx * ny;
float min = Float.MAX_VALUE;
float max = -Float.MAX_VALUE;
double norm1 = 0.0;
double norm2 = 0.0;
double mean = 0.0;
-
+
for (int k = 0; k < nz; k++)
- for (int i = 0; i < nxy; i++) {
- float v = data[k][i];
- max = Math.max(max, v);
- min = Math.min(min, v);
- mean += v;
- norm1 += (v > 0 ? v : -v);
- norm2 += v*v;
- }
- mean = mean / (nz*nxy);
- norm1 = norm1 / (nz*nxy);
- norm2 = Math.sqrt(norm2 / (nz*nxy));
+ for (int i = 0; i < nxy; i++) {
+ float v = data[k][i];
+ max = Math.max(max, v);
+ min = Math.min(min, v);
+ mean += v;
+ norm1 += (v > 0 ? v : -v);
+ norm2 += v * v;
+ }
+ mean = mean / (nz * nxy);
+ norm1 = norm1 / (nz * nxy);
+ norm2 = Math.sqrt(norm2 / (nz * nxy));
double stdev = 0.0;
for (int k = 0; k < nz; k++)
- for (int i = 0; i < nxy; i++) {
- stdev += (data[k][i]-mean)*(data[k][i]-mean);
- }
- stdev = Math.sqrt(stdev / (nz*nxy));
- return new float[] {(float)mean, min, max, (float)stdev, (float)norm1, (float)norm2};
+ for (int i = 0; i < nxy; i++) {
+ stdev += (data[k][i] - mean) * (data[k][i] - mean);
+ }
+ stdev = Math.sqrt(stdev / (nz * nxy));
+ return new float[] { (float) mean, min, max, (float) stdev, (float) norm1, (float) norm2 };
}
public float[] getExtrema() {
int nxy = nx * ny;
float min = Float.MAX_VALUE;
float max = -Float.MAX_VALUE;
-
+
for (int k = 0; k < nz; k++)
- for (int i = 0; i < nxy; i++) {
- float v = data[k][i];
- max = Math.max(max, v);
- min = Math.min(min, v);
- }
- return new float[] {min, max};
+ for (int i = 0; i < nxy; i++) {
+ float v = data[k][i];
+ max = Math.max(max, v);
+ min = Math.min(min, v);
+ }
+ return new float[] { min, max };
}
public RealSignal normalize(double to) {
if (to == 0)
return this;
int nxy = nx * ny;
float sum = 0f;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
sum += data[k][i];
if (sum != 0f) {
double r = to / sum;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
data[k][i] *= r;
}
return this;
}
-
+
public void setSlice(int z, RealSignal slice) {
int mx = slice.nx;
int my = slice.ny;
for (int j = 0; j < Math.min(ny, my); j++)
- for (int i = 0; i < Math.min(nx, mx); i++)
- data[z][i + nx * j] = slice.data[0][i + mx * j];
+ for (int i = 0; i < Math.min(nx, mx); i++)
+ data[z][i + nx * j] = slice.data[0][i + mx * j];
}
-
+
public RealSignal getSlice(int z) {
- RealSignal slice = new RealSignal(nx, ny, 1);
- for (int j = 0; j < nx*ny; j++)
+ RealSignal slice = new RealSignal(name + "_z=" + z, nx, ny, 1);
+ for (int j = 0; j < nx * ny; j++)
slice.data[0][j] = data[z][j];
return slice;
}
-
+
public void multiply(double factor) {
for (int k = 0; k < nz; k++)
for (int i = 0; i < nx * ny; i++)
data[k][i] *= factor;
}
public float[] getInterleaveXYZAtReal() {
float[] interleave = new float[2 * nz * nx * ny];
for (int k = 0; k < nz; k++)
- for (int j = 0; j < ny; j++)
- for (int i = 0; i < nx; i++)
- interleave[2 * (k * nx * ny + j * nx + i)] = data[k][i + j * nx];
+ for (int j = 0; j < ny; j++)
+ for (int i = 0; i < nx; i++)
+ interleave[2 * (k * nx * ny + j * nx + i)] = data[k][i + j * nx];
return interleave;
}
public void setInterleaveXYZAtReal(float[] interleave) {
for (int k = 0; k < nz; k++)
- for (int j = 0; j < ny; j++)
- for (int i = 0; i < nx; i++)
- data[k][i + nx * j] = interleave[(k * nx * ny + j * nx + i) * 2];
+ for (int j = 0; j < ny; j++)
+ for (int i = 0; i < nx; i++)
+ data[k][i + nx * j] = interleave[(k * nx * ny + j * nx + i) * 2];
}
public float[] getInterleaveXYAtReal(int k) {
float real[] = new float[nx * ny * 2];
for (int i = 0; i < nx; i++)
- for (int j = 0; j < ny; j++) {
- int index = i + j * nx;
- real[2 * index] = data[k][index];
- }
+ for (int j = 0; j < ny; j++) {
+ int index = i + j * nx;
+ real[2 * index] = data[k][index];
+ }
return real;
}
-
+
public void setInterleaveXYAtReal(int k, float real[]) {
for (int i = 0; i < nx; i++)
- for (int j = 0; j < ny; j++) {
- int index = i + j * nx;
- data[k][index] = real[2 * index];
- }
+ for (int j = 0; j < ny; j++) {
+ int index = i + j * nx;
+ data[k][index] = real[2 * index];
+ }
}
public float[] getXYZ() {
int nxy = nx * ny;
float[] d = new float[nz * nx * ny];
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
d[k * nxy + i] = data[k][i];
return d;
}
public void setXYZ(float[] data) {
- if (nx*ny*nz != data.length)
+ if (nx * ny * nz != data.length)
return;
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
- this.data[k][i] = data[k * nxy + i];
+ this.data[k][i] = data[k * nxy + i];
}
public float[] getXY(int k) {
return data[k];
}
public void setXY(int k, float slice[]) {
data[k] = slice;
}
public float[] getX(int j, int k) {
float line[] = new float[nx];
for (int i = 0; i < nx; i++)
line[i] = data[k][i + j * nx];
return line;
}
public float[] getZ(int i, int j) {
float line[] = new float[nz];
int index = i + j * nx;
for (int k = 0; k < nz; k++)
line[k] = data[k][index];
return line;
}
public float[] getY(int i, int k) {
float line[] = new float[ny];
for (int j = 0; j < ny; j++)
line[j] = data[k][i + j * nx];
return line;
}
public void setX(int j, int k, float line[]) {
for (int i = 0; i < nx; i++)
data[k][i + j * nx] = line[i];
}
public void setY(int i, int k, float line[]) {
for (int j = 0; j < ny; j++)
data[k][i + j * nx] = line[j];
}
-
+
public void setZ(int i, int j, float line[]) {
int index = i + j * nx;
for (int k = 0; k < nz; k++)
data[k][index] = line[k];
}
public void clip(float min, float max) {
for (int k = 0; k < nz; k++)
for (int j = 0; j < ny * nx; j++)
if (data[k][j] < min)
data[k][j] = min;
else if (data[k][j] > max)
data[k][j] = max;
}
-
+
public void fill(float constant) {
for (int k = 0; k < nz; k++)
- for (int j = 0; j < ny * nx; j++)
- data[k][j] = constant;
+ for (int j = 0; j < ny * nx; j++)
+ data[k][j] = constant;
}
-
public RealSignal changeSizeAs(RealSignal model) {
- return size(model.nx, model.ny, model.nz);
+ return size(model.nx, model.ny, model.nz);
}
public RealSignal size(int mx, int my, int mz) {
+ String n = "resize(" + name + ")";
+
int ox = (mx - nx) / 2;
int oy = (my - ny) / 2;
- int oz = (mz - nz) / 2;
- RealSignal signal = new RealSignal(mx, my, mz);
- int vx = Math.min(nx, mx);
- int vy = Math.min(ny, my);
- int vz = Math.min(nz, mz);
+ int oz = (mz - nz) / 2;
+ RealSignal signal = new RealSignal(n, mx, my, mz);
+ int vx = Math.min(nx, mx);
+ int vy = Math.min(ny, my);
+ int vz = Math.min(nz, mz);
for (int k = 0; k < vz; k++)
for (int j = 0; j < vy; j++)
for (int i = 0; i < vx; i++) {
int pi = ox >= 0 ? i + ox : i;
int qi = ox >= 0 ? i : i - ox;
int pj = oy >= 0 ? j + oy : j;
int qj = oy >= 0 ? j : j - oy;
int pk = oz >= 0 ? k + oz : k;
int qk = oz >= 0 ? k : k - oz;
signal.data[pk][pi + pj * mx] = data[qk][qi + qj * nx];
}
return signal;
}
+ public BufferedImage createPreviewMIPZ() {
+ RealSignal mip = createMIPZ();
+ mip.rescale(Monitors.createDefaultMonitor());
+ BufferedImage img = new BufferedImage(nx, ny, BufferedImage.TYPE_INT_ARGB);
+ int alpha = (255 << 24);
+ for (int i = 0; i < nx; i++)
+ for (int j = 0; j < ny; j++) {
+ int v = (int)data[0][i + j * nx];
+ img.setRGB(i, j, alpha | (v << 16) | (v << 8) | v);
+ }
+ return img;
+ }
+
public RealSignal createOrthoview() {
- return createOrthoview(nx/2, ny/2, nz/2);
+ return createOrthoview(nx / 2, ny / 2, nz / 2);
}
-
+
public RealSignal createOrthoview(int hx, int hy, int hz) {
+ String n = "ortho(" + name + ")";
+
int vx = nx + nz;
int vy = ny + nz;
- RealSignal view = new RealSignal(vx, vy, 1);
- hx = Math.min(nx-1, Math.max(0, hx));
- hy = Math.min(ny-1, Math.max(0, hy));
- hz = Math.min(nz-1, Math.max(0, hz));
+ RealSignal view = new RealSignal(n, vx, vy, 1);
+ hx = Math.min(nx - 1, Math.max(0, hx));
+ hy = Math.min(ny - 1, Math.max(0, hy));
+ hz = Math.min(nz - 1, Math.max(0, hz));
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
view.data[0][x + vx * y] = data[hz][x + nx * y];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++)
view.data[0][nx + z + vx * y] = data[z][hx + nx * y];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++)
view.data[0][x + vx * (ny + z)] = data[z][x + nx * hy];
return view;
}
-
+
public RealSignal createFigure(int hx, int hy, int hz) {
+ String n = "figure(" + name + ")";
int vx = nx + nz + 4;
int vy = ny + 2;
float max = this.getExtrema()[1];
- RealSignal view = new RealSignal(vx, vy, 1);
- for (int i = 0; i < vx*vy; i++)
+ RealSignal view = new RealSignal(n, vx, vy, 1);
+ for (int i = 0; i < vx * vy; i++)
view.data[0][i] = max;
-
- hx = Math.min(nx-1, Math.max(0, hx));
- hy = Math.min(ny-1, Math.max(0, hy));
- hz = Math.min(nz-1, Math.max(0, hz));
+
+ hx = Math.min(nx - 1, Math.max(0, hx));
+ hy = Math.min(ny - 1, Math.max(0, hy));
+ hz = Math.min(nz - 1, Math.max(0, hz));
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
- view.data[0][x+1 + vx * (y+1)] = data[hz][x + nx * y];
+ view.data[0][x + 1 + vx * (y + 1)] = data[hz][x + nx * y];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++)
- view.data[0][nx + 3 + z + vx * (y+1)] = data[z][hx + nx * y];
+ view.data[0][nx + 3 + z + vx * (y + 1)] = data[z][hx + nx * y];
return view;
}
-
public RealSignal createMIP() {
+ String n = "mip(" + name + ")";
+
int vx = nx + nz + 1;
int vy = ny + nz + 1;
- RealSignal view = new RealSignal(vx, vy, 1);
+ RealSignal view = new RealSignal(n, vx, vy, 1);
for (int x = 0; x < nx; x++)
- for (int y = 0; y < ny; y++)
- for (int k = 0; k < nz; k++) {
- int index = x + vx * y;
- view.data[0][index] = Math.max(view.data[0][index], data[k][x + nx * y]);
- }
+ for (int y = 0; y < ny; y++)
+ for (int k = 0; k < nz; k++) {
+ int index = x + vx * y;
+ view.data[0][index] = Math.max(view.data[0][index], data[k][x + nx * y]);
+ }
for (int z = 0; z < nz; z++)
- for (int y = 0; y < ny; y++)
- for (int x = 0; x < nx; x++) {
- int index = nx + 1 + z + vx * y;
- view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
- }
+ for (int y = 0; y < ny; y++)
+ for (int x = 0; x < nx; x++) {
+ int index = nx + 1 + z + vx * y;
+ view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
+ }
for (int z = 0; z < nz; z++)
+ for (int x = 0; x < nx; x++)
+ for (int y = 0; y < ny; y++) {
+ int index = x + vx * (ny + 1 + z);
+ view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
+ }
+ return view;
+ }
+
+ public RealSignal createMIPZ() {
+ String n = "mipz(" + name + ")";
+ RealSignal view = new RealSignal(n, nx, ny, 1);
for (int x = 0; x < nx; x++)
- for (int y = 0; y < ny; y++) {
- int index = x + vx * (ny + 1 + z);
- view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
- }
+ for (int y = 0; y < ny; y++) {
+ int index = x + nx * y;
+ for (int k = 0; k < nz; k++) {
+ view.data[0][index] = Math.max(view.data[0][index], data[k][x + nx * y]);
+ }
+ }
return view;
}
public RealSignal createMontage() {
+ String n = "planar(" + name + ")";
int nr = (int) Math.sqrt(nz);
int nc = (int) Math.ceil(nz / nr) + 1;
int w = nx * nr;
int h = ny * nc;
- RealSignal view = new RealSignal(w, h, 1, false);
+ RealSignal view = new RealSignal(n, w, h, 1);
for (int k = 0; k < nz; k++) {
int col = k % nr;
int row = k / nr;
- int offx = col*nx;
- int offy = row*ny;
+ int offx = col * nx;
+ int offy = row * ny;
for (int x = 0; x < nx; x++)
- for (int y = 0; y < ny; y++)
- view.data[0][x + offx + w*(y + offy)] = data[k][x + nx * y];
+ for (int y = 0; y < ny; y++)
+ view.data[0][x + offx + w * (y + offy)] = data[k][x + nx * y];
}
return view;
}
-
+
public RealSignal circular() {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
setZ(i, j, rotate(getZ(i, j)));
for (int i = 0; i < nx; i++)
for (int k = 0; k < nz; k++)
setY(i, k, rotate(getY(i, k)));
for (int j = 0; j < ny; j++)
for (int k = 0; k < nz; k++)
setX(j, k, rotate(getX(j, k)));
return this;
}
-
- public RealSignal rescale(Monitors monitors) {
+
+ public RealSignal rescale(Monitors monitors) {
new Constraint(monitors).rescaled(this, 0, 255);
return this;
}
public float[] rotate(float[] buffer) {
int len = buffer.length;
if (len <= 1)
return buffer;
int count = 0;
int offset = 0;
int start = len / 2;
while (count < len) {
int index = offset;
float tmp = buffer[index];
int index2 = (start + index) % len;
while (index2 != offset) {
buffer[index] = buffer[index2];
count++;
index = index2;
index2 = (start + index) % len;
}
buffer[index] = tmp;
count++;
offset++;
}
return buffer;
}
-
+
@Override
public String toString() {
return "Real Signal [" + nx + ", " + ny + ", " + nz + "]";
}
}
diff --git a/DeconvolutionLab2/src/signal/Signal.java b/DeconvolutionLab2/src/signal/Signal.java
index 2de3807..6aa8f68 100644
--- a/DeconvolutionLab2/src/signal/Signal.java
+++ b/DeconvolutionLab2/src/signal/Signal.java
@@ -1,73 +1,66 @@
/*
* 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 signal;
+import java.util.ArrayList;
+
public class Signal {
public int nx = 0;
public int ny;
public int nz;
public float data[][];
-
- public static double bytes = 0;
-
- public static double epsilon = 1e-6;
+ public String name = "untitled";
- public String dimAsString() {
- return nx + "x" + ny + "x" + nz + " ";
- }
+ private ArrayList<SignalListener> listeners = new ArrayList<SignalListener>();
- public void allocateRealSignal(int nx, int ny, int nz, boolean incMemory) {
+ public Signal(String name, int nx, int ny, int nz) {
+ this.name = name;
this.nx = nx;
this.ny = ny;
this.nz = nz;
- Signal.bytes += (incMemory ? nx * ny * nz * 4 : 0);
- this.data = new float[nz][nx * ny];
+ }
+
+ public String dimAsString() {
+ return nx + "x" + ny + "x" + nz + " ";
}
- public void allocateRealSignal(int nx, int ny, int nz) {
- this.nx = nx;
- this.ny = ny;
- this.nz = nz;
- Signal.bytes += nx * ny * nz * 4;
- this.data = new float[nz][nx * ny];
+ public void addSignalListener(SignalListener listener) {
+ listeners.add(listener);
}
-
- public void allocateComplexSignal(int nx, int ny, int nz) {
- this.nx = nx;
- this.ny = ny;
- this.nz = nz;
- Signal.bytes += 2 * nx * ny * nz * 4;
- this.data = new float[nz][nx * ny * 2];
+
+ public void notify(String name, double progress) {
+ for(SignalListener listener : listeners)
+ listener.notify(name, progress);
}
-
+
}
diff --git a/DeconvolutionLab2/src/signal/SignalCollector.java b/DeconvolutionLab2/src/signal/SignalCollector.java
new file mode 100644
index 0000000..672e2fd
--- /dev/null
+++ b/DeconvolutionLab2/src/signal/SignalCollector.java
@@ -0,0 +1,109 @@
+package signal;
+
+import java.util.ArrayList;
+
+import javax.swing.JScrollPane;
+
+import deconvolutionlab.system.SystemUsage;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+import lab.tools.NumFormat;
+
+public class SignalCollector {
+
+ private static long bytesReal = 0;
+ private static int countReal = 0;
+ private static long bytesComplex = 0;
+ private static int countComplex = 0;
+ private static double chrono = 0;
+ private static CustomizedTable table;
+ private static double progress = 0;
+
+ protected final static int NOTIFICATION_RATE = 25;
+
+ static {
+ bytesReal = 0;
+ countReal = 0;
+ bytesComplex = 0;
+ countComplex = 0;
+ chrono = System.nanoTime();
+
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Time", String.class, 100, false));
+ columns.add(new CustomizedColumn("Name", String.class, 600, false));
+ columns.add(new CustomizedColumn("Dimension", String.class, 60, false));
+ columns.add(new CustomizedColumn("Count", String.class, 100, false));
+ columns.add(new CustomizedColumn("Total", String.class, 100, false));
+ columns.add(new CustomizedColumn("Memory", String.class, 100, false));
+ table = new CustomizedTable(columns, true);
+ table.getColumnModel().getColumn(4).setMaxWidth(100);
+ table.getColumnModel().getColumn(4).setMinWidth(100);
+ }
+
+ public static JScrollPane getPanel(int w, int h) {
+ return table.getPane(w, h);
+ }
+
+ public static String sumarize() {
+ String r = "Signals: " + NumFormat.bytes(bytesReal + bytesComplex);
+ return r;
+ }
+
+ public static void clear() {
+ table.removeRows();
+ }
+
+ public static double getProgress() {
+ return progress;
+ }
+
+ public static void setProgress(double p) {
+ progress = p;
+ }
+
+ public static void marker(String name) {
+ String t = NumFormat.time(System.nanoTime()-chrono);
+ String m = NumFormat.bytes(SystemUsage.getHeapUsed());
+ String row[] = {t, name, "", "", "", m};
+ table.append(row);
+ }
+
+ public static void alloc(String name, int nx, int ny, int nz, boolean complex) {
+ long b = nx * ny * nz * 4 * (complex ? 2 : 1);
+ if (complex) {
+ bytesComplex += b;
+ countComplex++;
+ }
+ else {
+ bytesReal += b;
+ countReal++;
+ }
+ String m = NumFormat.bytes(SystemUsage.getHeapUsed());
+ String t = NumFormat.time(System.nanoTime()-chrono);
+ String dim = "" + nx + "x" + ny + "x" + nz;
+ String c = "" + (countReal + countComplex);
+ String a = NumFormat.bytes(bytesReal + bytesComplex);
+ String row[] = {t, name, dim, c, a, m};
+ table.append(row);
+ }
+
+ public static void free(String name, int nx, int ny, int nz, boolean complex) {
+ long b = nx * ny * nz * 4 * (complex ? 2 : 1);
+ if (complex) {
+ bytesComplex -= b;
+ countComplex--;
+ }
+ else {
+ bytesReal -= b;
+ countReal--;
+ }
+ String m = NumFormat.bytes(SystemUsage.getHeapUsed());
+ String t = NumFormat.time(System.nanoTime()-chrono);
+ String dim = "" + nx + "x" + ny + "x" + nz;
+ String c = "" + (countReal + countComplex);
+ String a = NumFormat.bytes(bytesReal + bytesComplex);
+ String row[] = {t, name, dim, c, a, m};
+ table.append(row);
+ }
+
+}
diff --git a/DeconvolutionLab2/src/signal/SignalListener.java b/DeconvolutionLab2/src/signal/SignalListener.java
new file mode 100644
index 0000000..3d1cdc5
--- /dev/null
+++ b/DeconvolutionLab2/src/signal/SignalListener.java
@@ -0,0 +1,6 @@
+package signal;
+
+public interface SignalListener {
+
+ public void notify(String name, double progress);
+}
diff --git a/DeconvolutionLab2/src/signal/apodization/Apodization.java b/DeconvolutionLab2/src/signal/apodization/Apodization.java
index bccbc0b..0af3223 100644
--- a/DeconvolutionLab2/src/signal/apodization/Apodization.java
+++ b/DeconvolutionLab2/src/signal/apodization/Apodization.java
@@ -1,169 +1,169 @@
/*
* 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 signal.apodization;
import java.util.ArrayList;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.Constant;
public class Apodization {
private AbstractApodization apoX = getDefault();
private AbstractApodization apoY = getDefault();
private AbstractApodization apoZ = getDefault();
public Apodization() {
apoX = new UniformApodization();
apoY = new UniformApodization();
apoZ = new UniformApodization();
}
public Apodization(AbstractApodization apoX, AbstractApodization apoY, AbstractApodization apoZ) {
this.apoX = apoX;
this.apoY = apoY;
this.apoZ = apoZ;
}
public Apodization(String nameX, String nameY, String nameZ) {
for(AbstractApodization apo : getApodizations()) {
if (apo.getName().equals(nameX))
apoX = apo;
if (apo.getName().equals(nameY))
apoY = apo;
if (apo.getName().equals(nameZ))
apoZ = apo;
if (apo.getShortname().equals(nameX))
apoX = apo;
if (apo.getShortname().equals(nameY))
apoY = apo;
if (apo.getShortname().equals(nameZ))
apoZ = apo;
}
}
public static ArrayList<AbstractApodization> getApodizations() {
ArrayList<AbstractApodization> apos = new ArrayList<AbstractApodization>();
apos.add(new UniformApodization());
apos.add(new HammingApodization());
apos.add(new HannApodization());
apos.add(new RaisedCosineApodization(1));
apos.add(new TukeyApodization(0.5));
apos.add(new WelchApodization());
return apos;
}
public static ArrayList<String> getApodizationsName() {
ArrayList<AbstractApodization> apos = getApodizations();
ArrayList<String> names = new ArrayList<String>();
for(AbstractApodization apo : apos)
names.add(apo.getName());
return names;
}
public static String[] getApodizationsAsArray() {
ArrayList<AbstractApodization> apos = getApodizations();
String names[] = new String[apos.size()];
for(int i=0; i<apos.size(); i++)
names[i] = apos.get(i).getName();
return names;
}
public static AbstractApodization getByName(String name) {
ArrayList<AbstractApodization> apos = getApodizations();
for(AbstractApodization apo : apos)
if (name.equals(apo.getName()))
return apo;
return getDefault();
}
public static AbstractApodization getByShortname(String name) {
ArrayList<AbstractApodization> apos = getApodizations();
for(AbstractApodization apo : apos)
if (name.equals(apo.getShortname()))
return apo;
return getDefault();
}
public static AbstractApodization getDefault() {
return new UniformApodization();
}
public double estimateLostEnergy(int size) {
RealSignal in = new Constant().intensity(0, 1).generate(size, size, size);
double ein = size * size * size;
double eout = apodize(Monitors.createDefaultMonitor(), in).getEnergy();
return 1.0 - (ein - eout) / ein;
}
public RealSignal apodize(Monitors monitors, RealSignal input) {
if (apoX instanceof UniformApodization &&
apoY instanceof UniformApodization &&
apoZ instanceof UniformApodization) {
return input;
}
if (monitors != null)
monitors.log("Apodization (" + apoX.getName() + ", " + apoY.getName() + ", " + apoZ.getName() + ")");
-
- RealSignal out = new RealSignal(input.nx, input.ny, input.nz);
+ String name = " apo( " + input.name + ")";
+ RealSignal out = new RealSignal(name, input.nx, input.ny, input.nz);
for(int i=0; i<input.nx; i++) {
double cx = apoX.apodize(i, input.nx);
for(int j=0; j<input.ny; j++) {
double cy = apoY.apodize(j, input.ny);
int index = i + input.nx*j;
for(int k=0; k<input.nz; k++) {
double cz = apoZ.apodize(k, input.nz);
out.data[k][index] = (float)(cx * cy * cz * input.data[k][index]);
}
}
}
return out;
}
@Override
public String toString() {
String s = "";
s += "lateral (XY)";
if (apoX instanceof UniformApodization)
s += " keep unchanged";
else
s+= " " + apoX.getName();
s += ", axial (Z)";
if (apoZ instanceof UniformApodization)
s += " keep unchanged";
else
s+= " " + apoZ.getName();
return s;
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/MotionBlur.java b/DeconvolutionLab2/src/signal/factory/MotionBlur.java
index 0bb21bc..61042fa 100644
--- a/DeconvolutionLab2/src/signal/factory/MotionBlur.java
+++ b/DeconvolutionLab2/src/signal/factory/MotionBlur.java
@@ -1,92 +1,93 @@
/*
* 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 signal.factory;
+import signal.Operations;
import signal.RealSignal;
import signal.Signal;
public class MotionBlur extends SignalFactory {
private double sigma = 3.0;
private double direction = 30.0;
private double elongation = 3.0;
public MotionBlur(double sigma, double direction, double elongation) {
super(new double[] { sigma, direction, elongation });
}
@Override
public String getName() {
return "MotionBlur";
}
@Override
public String[] getParametersName() {
return new String[] { "Sigma", "Direction", "Elongation" };
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.sigma = parameters[0];
if (parameters.length >= 2)
this.direction = parameters[1];
if (parameters.length >= 3)
this.elongation = parameters[2];
}
@Override
public double[] getParameters() {
return new double[] { sigma, direction, elongation };
}
@Override
public void fill(RealSignal signal) {
double K1 = 0.5 / (sigma * sigma);
double K2 = 0.5 / (sigma * sigma * elongation * elongation);
double cosa = Math.cos(Math.toRadians(direction));
double sina = Math.sin(Math.toRadians(direction));
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
double dx = (x - xc);
double dy = (y - yc);
- double M = (dx * cosa + dy * sina) / Math.max(dx * dx + dy * dy, Signal.epsilon);
+ double M = (dx * cosa + dy * sina) / Math.max(dx * dx + dy * dy, Operations.epsilon);
M = (1.0 - 1.0 / (1.0 + Math.exp(-M / elongation)));
double r2 = (x - xc) * (x - xc) + (y - yc) * (y - yc);
for (int z = 0; z < nz; z++) {
signal.data[z][x + nx * y] = (float) ((amplitude - background) * M * Math.exp(0) + background);
}
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/SignalFactory.java b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
index c7f0fae..9a1275e 100644
--- a/DeconvolutionLab2/src/signal/factory/SignalFactory.java
+++ b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
@@ -1,210 +1,210 @@
/*
* 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 signal.factory;
import java.util.ArrayList;
import javax.swing.SwingWorker;
import signal.RealSignal;
public abstract class SignalFactory {
protected double fractXC = 0.5;
protected double fractYC = 0.5;
protected double fractZC = 0.5;
protected double background = 0.0;
protected double amplitude = 1.0;
protected double xc;
protected double yc;
protected double zc;
protected int nx;
protected int ny;
protected int nz;
public SignalFactory() {
}
public SignalFactory(double[] parameters) {
setParameters(parameters);
}
public static SignalFactory get(String name) {
ArrayList<SignalFactory> list = getAll();
for (SignalFactory factory : list) {
if (factory.getName().equals(name))
return factory;
}
return null;
}
public static ArrayList<String> getAllName() {
ArrayList<String> list = new ArrayList<String>();
for (SignalFactory factory : getAll()) {
list.add(factory.getName());
}
return list;
}
public static ArrayList<SignalFactory> getAll() {
ArrayList<SignalFactory> list = new ArrayList<SignalFactory>();
list.add(new AirySimulated(1));
list.add(new Astigmatism(3, 0.2));
list.add(new Constant());
list.add(new Cross(1, 1, 30));
list.add(new Cube(10 ,1));
list.add(new Defocus(3, 10, 10));
list.add(new DoG(3, 4));
list.add(new DoubleHelix(3, 10, 10));
list.add(new Gaussian(3, 3, 3));
list.add(new GridSpots(3, 1, 10));
list.add(new Impulse());
//list.add(new MotionBlur(3, 30, 3));
list.add(new Ramp(1, 0, 0));
list.add(new RandomLines(3));
list.add(new Sinc(3, 3, 3));
list.add(new Sphere(10, 1));
list.add(new Torus(10));
return list;
}
public static ArrayList<SignalFactory> getImages() {
ArrayList<SignalFactory> list = new ArrayList<SignalFactory>();
list.add(new Cube(10, 1));
list.add(new Sphere(10, 1));
list.add(new GridSpots(3, 1, 10));
list.add(new Constant());
list.add(new Cross(1, 1, 30));
list.add(new DoG(3, 4));
list.add(new Gaussian(3, 3, 3));
list.add(new Impulse());
list.add(new Ramp(1, 0, 0));
list.add(new RandomLines(3));
list.add(new Torus(10));
return list;
}
public static ArrayList<SignalFactory> getPSF() {
ArrayList<SignalFactory> list = new ArrayList<SignalFactory>();
list.add(new AirySimulated(1));
list.add(new Astigmatism(3, 0.2));
list.add(new Cross(3, 1, 10));
list.add(new Cube(10, 1));
list.add(new Defocus(3, 10, 10));
list.add(new DoG(3, 4));
list.add(new DoubleHelix(3, 10, 10));
list.add(new Gaussian(3, 3, 3));
//list.add(new MotionBlur(3, 30, 3));
list.add(new Impulse());
list.add(new Sinc(3, 3, 3));
list.add(new Sphere(10, 1));
list.add(new RandomLines(3));
list.add(new Torus(10));
return list;
}
public static SignalFactory getFactoryByName(String name) {
ArrayList<SignalFactory> list = getAll();
for (SignalFactory factory : list)
if (name.toLowerCase().equals(factory.getName().toLowerCase())) {
return factory;
}
return null;
}
public SignalFactory center(double fractXC, double fractYC, double fractZC) {
this.fractXC = fractXC;
this.fractYC = fractYC;
this.fractZC = fractZC;
return this;
}
public SignalFactory intensity(double background, double amplitude) {
this.background = background;
this.amplitude = amplitude;
return this;
}
public String params() {
String name[] = getParametersName();
double params[] = getParameters();
if (params.length == 1)
return name[0] + "=" + params[0];
else if (params.length == 2)
return name[0] + "=" + params[0] + " " + name[1] + "=" + params[1];
else
return name[0] + "=" + params[0] + " " + name[1] + "=" + params[2] + " " + name[2] + "=" + params[2];
}
public RealSignal generate(int nx, int ny, int nz) {
this.nx = nx;
this.ny = ny;
this.nz = nz;
xc = fractXC * nx;
yc = fractYC * ny;
zc = fractZC * nz;
- RealSignal signal = new RealSignal(nx, ny, nz);
+ RealSignal signal = new RealSignal(getName(), nx, ny, nz);
fill(signal);
return signal;
}
public abstract String getName();
public abstract void setParameters(double[] parameters);
public abstract double[] getParameters();
public abstract String[] getParametersName();
public abstract void fill(RealSignal signal);
public class Worker extends SwingWorker<RealSignal, String> {
private RealSignal signal;
public boolean done=false;
public Worker(RealSignal signal) {
this.signal = signal;
done = false;
}
protected RealSignal doInBackground() throws Exception {
fill(signal);
done = true;
return signal;
}
protected void done() {
done = true;
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Sinc.java b/DeconvolutionLab2/src/signal/factory/Sinc.java
index f0d811e..7adf5f8 100644
--- a/DeconvolutionLab2/src/signal/factory/Sinc.java
+++ b/DeconvolutionLab2/src/signal/factory/Sinc.java
@@ -1,90 +1,91 @@
/*
* 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 signal.factory;
import deconvolutionlab.Lab;
+import signal.Operations;
import signal.RealSignal;
public class Sinc extends SignalFactory {
private double periodX = 3.0;
private double periodY = 3.0;
private double periodZ = 3.0;
public Sinc(double periodX, double periodY, double periodZ) {
super(new double[] {periodX, periodY, periodZ});
}
@Override
public String getName() {
return "Sinc";
}
@Override
public String[] getParametersName() {
return new String[] {"Period X", "Period Y", "Period Z"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.periodX = parameters[0];
if (parameters.length >= 2)
this.periodY = parameters[1];
if (parameters.length >= 3)
this.periodZ = parameters[2];
}
@Override
public double[] getParameters() {
return new double[] {periodX, periodY, periodZ};
}
@Override
public void fill(RealSignal signal) {
double KX = 1. / (periodX*periodX);
double KY = 1. / (periodY*periodY);
double KZ = 1. / (periodZ*periodZ);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
double r = Math.sqrt(KX*(x-xc)*(x-xc) + KY*(y-yc)*(y-yc) + KZ*(z-zc)*(z-zc));
double v = 1.0;
- if (r > RealSignal.epsilon)
+ if (r > Operations.epsilon)
v = Math.sin(r) / r;
signal.data[z][x+nx*y] = (float)((amplitude-background) * v + background);
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java b/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
index 6cda8b9..00ef89e 100644
--- a/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
+++ b/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
@@ -1,151 +1,151 @@
/*
* 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 signal.factory.complex;
import signal.ComplexSignal;
public class ComplexSignalFactory {
public static ComplexSignal gaussian(int nx, int ny, int nz, double sigma) {
double K = sigma * sigma / 2.0;
int xsize = nx / 2;
int ysize = ny / 2;
int zsize = nz / 2;
float[][][] function = new float[xsize + 1][ysize + 1][zsize + 1];
double wx, wy, wz, wr;
for (int z = 0; z <= zsize; z++)
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++) {
wx = Math.PI * x / xsize;
wy = Math.PI * y / ysize;
wz = Math.PI * z / ysize;
wr = Math.sqrt(wx * wx + wy * wy + wz * wz);
function[x][y][z] = (float) Math.exp(-wr * wr * K);
}
- return createHermitian(nx, ny, nz, function);
+ return createHermitian("Gaussian", nx, ny, nz, function);
}
public static ComplexSignal identity(int nx, int ny, int nz) {
int xsize = nx / 2;
int ysize = ny / 2;
int zsize = nz / 2;
float[][][] function = new float[xsize + 1][ysize + 1][zsize + 1];
for (int z = 0; z <= zsize; z++)
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++)
function[x][y][z] = 1.0f;
- return createHermitian(nx, ny, nz, function);
+ return createHermitian("Identity", nx, ny, nz, function);
}
public static ComplexSignal laplacian(int nx, int ny, int nz) {
int xsize = nx / 2;
int ysize = ny / 2;
int zsize = nz / 2;
float[][][] function = new float[xsize + 1][ysize + 1][zsize + 1];
double wx, wy, wz;
for (int z = 0; z <= zsize; z++)
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++) {
wx = Math.PI * x / xsize;
wy = Math.PI * y / ysize;
wz = Math.PI * z / ysize;
function[x][y][z] = (float) ((wx * wx + wy * wy + wz * wz));
}
- return createHermitian(nx, ny, nz, function);
+ return createHermitian("Laplacian", nx, ny, nz, function);
}
public static ComplexSignal airySimulated(int nx, int ny, int nz, double mu) {
int xsize = nx / 2;
int ysize = ny / 2;
int zsize = nz / 2;
double K = ysize/2;
float[][][] function = new float[xsize + 1][ysize + 1][zsize + 1];
double wx, wy, wz, wr;
for (int z = 0; z <= zsize; z++)
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++) {
wx = Math.PI * x / xsize;
wy = Math.PI * y / ysize;
wz = Math.PI * z / ysize;
wr = Math.sqrt(wx * wx + wy * wy + wz*wz);
function[x][y][z] =
(float) (1.0 - 1.0 / (1.0 + Math.exp(-K * (wr - mu)))
+ 1.0 / (1.0 + Math.exp(-K * (wr - 0.6 * mu)))
- 1.0 / (1.0 + Math.exp(-K * (wr - 0.4 * mu))));
}
- return createHermitian(nx, ny, nz, function);
+ return createHermitian("Airy", nx, ny, nz, function);
}
- public static ComplexSignal createHermitian(int nx, int ny, int nz, float[][][] firstQuadrant) {
- ComplexSignal signal = new ComplexSignal(nx, ny, nz);
+ public static ComplexSignal createHermitian(String name, int nx, int ny, int nz, float[][][] firstQuadrant) {
+ ComplexSignal signal = new ComplexSignal(name, nx, ny, nz);
int xsize = firstQuadrant.length - 1;
int ysize = firstQuadrant[0].length - 1;
int zsize = firstQuadrant[0][0].length - 1;
if (xsize >= 1 && ysize >= 1 && zsize >= 1) {
for (int z = 0; z <= zsize; z++)
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++) {
signal.data[z][2 * (x + nx * y)] = firstQuadrant[x][y][z];
}
for (int z = 0; z < zsize; z++)
for (int y = 0; y < ysize; y++)
for (int x = 0; x < xsize; x++) {
int a = nx - 1 - x;
int b = nx * (ny - 1 - y);
signal.data[z][2 * (a + nx * y)] = firstQuadrant[x + 1][y][z];
signal.data[z][2 * (a + b)] = firstQuadrant[x + 1][y + 1][z];
signal.data[z][2 * (x + b)] = firstQuadrant[x][y + 1][z];
int c = nz - 1 - z;
signal.data[c][2 * (x + nx * y)] = firstQuadrant[x][y][z + 1];
signal.data[c][2 * (a + nx * y)] = firstQuadrant[x + 1][y][z + 1];
signal.data[c][2 * (a + b)] = firstQuadrant[x + 1][y + 1][z + 1];
signal.data[c][2 * (x + b)] = firstQuadrant[x][y + 1][z + 1];
}
}
if (zsize == 0) {
for (int y = 0; y <= ysize; y++)
for (int x = 0; x <= xsize; x++) {
signal.data[0][2 * (x + nx * y)] = firstQuadrant[x][y][0];
}
for (int y = 0; y < ysize; y++)
for (int x = 0; x < xsize; x++) {
int a = nx - 1 - x;
int b = nx * (ny - 1 - y);
signal.data[0][2 * (a + nx * y)] = firstQuadrant[x + 1][y][0];
signal.data[0][2 * (a + b)] = firstQuadrant[x + 1][y + 1][0];
signal.data[0][2 * (x + b)] = firstQuadrant[x][y + 1][0];
}
}
return signal;
}
}
diff --git a/DeconvolutionLab2/src/signal/padding/Padding.java b/DeconvolutionLab2/src/signal/padding/Padding.java
index 413f447..090a66c 100644
--- a/DeconvolutionLab2/src/signal/padding/Padding.java
+++ b/DeconvolutionLab2/src/signal/padding/Padding.java
@@ -1,250 +1,254 @@
/*
* 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 signal.padding;
import java.util.ArrayList;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
public class Padding {
private AbstractPadding padX = getDefault();
private AbstractPadding padY = getDefault();
private AbstractPadding padZ = getDefault();
private int minExtensionX = 0;
private int minExtensionY = 0;
private int minExtensionZ = 0;
private int nx = -1;
private int ny = -1;
private int nz = -1;
public Padding() {
padX = new NoPadding();
padY = new NoPadding();
padZ = new NoPadding();
this.minExtensionX = 0;
this.minExtensionY = 0;
this.minExtensionZ = 0;
}
public Padding(int minExtensionX, int minExtensionY, int minExtensionZ) {
padX = new NoPadding();
padY = new NoPadding();
padZ = new NoPadding();
this.minExtensionX = minExtensionX;
this.minExtensionY = minExtensionY;
this.minExtensionZ = minExtensionZ;
}
public Padding(AbstractPadding padX, AbstractPadding padY, AbstractPadding padZ, int minExtensionX, int minExtensionY, int minExtensionZ) {
this.padX = padX;
this.padY = padY;
this.padZ = padZ;
this.minExtensionX = minExtensionX;
this.minExtensionY = minExtensionY;
this.minExtensionZ = minExtensionZ;
}
public Padding(AbstractPadding pad, int extension) {
this.padX = pad;
this.padY = pad;
this.padZ = pad;
this.minExtensionX = extension;
this.minExtensionY = extension;
this.minExtensionZ = extension;
}
public Padding(String nameX, String nameY, String nameZ, int minExtensionX, int minExtensionY, int minExtensionZ) {
for(AbstractPadding pad : getPaddings()) {
if (pad.getName().equals(nameX))
padX = pad;
if (pad.getName().equals(nameY))
padY = pad;
if (pad.getName().equals(nameZ))
padZ = pad;
if (pad.getShortname().equals(nameX))
padX = pad;
if (pad.getShortname().equals(nameY))
padY = pad;
if (pad.getShortname().equals(nameZ))
padZ = pad;
this.minExtensionX = minExtensionX;
this.minExtensionY = minExtensionY;
this.minExtensionZ = minExtensionZ;
}
}
public static ArrayList<AbstractPadding> getPaddings() {
ArrayList<AbstractPadding> pads = new ArrayList<AbstractPadding>();
pads.add(new NoPadding());
pads.add(new Multiple2Padding());
pads.add(new Power2Padding());
pads.add(new Multiple23Padding());
pads.add(new Multiple235Padding());
return pads;
}
public static ArrayList<String> getPaddingsName() {
ArrayList<AbstractPadding> pads = getPaddings();
ArrayList<String> names = new ArrayList<String>();
for(AbstractPadding pad : pads)
names.add(pad.getName());
return names;
}
public static String[] getPaddingsAsArray() {
ArrayList<AbstractPadding> pads = getPaddings();
String names[] = new String[pads.size()];
for(int i=0; i<pads.size(); i++)
names[i] = pads.get(i).getName();
return names;
}
public static AbstractPadding getByName(String name) {
ArrayList<AbstractPadding> pads = getPaddings();
for(AbstractPadding pad : pads)
if (name.equals(pad.getName()))
return pad;
return getDefault();
}
public static AbstractPadding getByShortname(String name) {
ArrayList<AbstractPadding> pads = getPaddings();
for(AbstractPadding pad : pads)
if (name.equals(pad.getShortname()))
return pad;
return getDefault();
}
public static AbstractPadding getDefault() {
return new NoPadding();
}
public int[] pad(int nx, int ny, int nz) {
return new int[] { padX.padding(nx+minExtensionX), padY.padding(ny+minExtensionY), padZ.padding(nz+minExtensionZ)};
}
public RealSignal pad(Monitors monitors, RealSignal input) {
if (padX instanceof NoPadding && padY instanceof NoPadding &&
padZ instanceof NoPadding && (minExtensionX + minExtensionY + minExtensionZ == 0)) {
nx = ny = nz = -1;
return input.duplicate();
}
nx = input.nx;
ny = input.ny;
nz = input.nz;
int lx = padX.padding(nx+minExtensionX);
int ly = padY.padding(ny+minExtensionY);
int lz = padZ.padding(nz+minExtensionZ);
monitors.log("Padding to (" + lx + ", " + ly + ", " + lz + ")");
if (lx == nx)
if (ly == ny)
if (lz == nz)
return input.duplicate();
int ox = (lx - nx) / 2;
int oy = (ly - ny) / 2;
int oz = (lz - nz) / 2;
- RealSignal large = new RealSignal(lx, ly, lz);
+ String name = " pad( " + input.name + ")";
+
+ RealSignal large = new RealSignal(name, lx, ly, lz);
for(int k=0; k<nz; k++) {
float in[] = input.data[k];
float lpix[] = large.data[k+oz];
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++)
lpix[(i+ox) + lx*(j+oy)] = in[i + nx*j];
}
return large;
}
public RealSignal crop(Monitors monitors, RealSignal large) {
if (nx == -1 || ny == -1 || nz == -1) {
return large;
}
int lx = large.nx;
int ly = large.ny;
int lz = large.nz;
int ox = (lx - nx) / 2;
int oy = (ly - ny) / 2;
int oz = (lz - nz) / 2;
if (lx == nx)
if (ly == ny)
if (lz == nz)
return large;
- RealSignal output = new RealSignal(nx, ny, nz);
+ String name = " crop( " + large.name + ")";
+
+ RealSignal output = new RealSignal(name, nx, ny, nz);
monitors.log("Cropping to (" + nx + ", " + ny + ", " + nz + ")");
for(int k=0; k<nz; k++) {
float lpix[] = large.data[k+oz];
float out[] = output.data[k];
for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++)
out[i + nx*j] = lpix[(i+ox) + lx*(j+oy)];
}
return output;
}
@Override
public String toString() {
String s = "";
s += "lateral (XY)";
if (padX instanceof NoPadding) {
if (minExtensionX == 0)
s += " no padding";
else
s += " extension of " + minExtensionX;
}
else {
s += " enforced to " + padX.getName();
}
s += ", axial (Z)";
if (padZ instanceof NoPadding) {
if (minExtensionZ == 0)
s += " no padding";
else
s += " extension of " + minExtensionZ;
}
else {
s += " enforced to " + padZ.getName();
}
return s;
}
}
diff --git a/DeconvolutionLab2/src/wavelets/AbstractWavelets.java b/DeconvolutionLab2/src/wavelets/AbstractWavelets.java
index 701f738..34bc83d 100644
--- a/DeconvolutionLab2/src/wavelets/AbstractWavelets.java
+++ b/DeconvolutionLab2/src/wavelets/AbstractWavelets.java
@@ -1,112 +1,114 @@
/*
* 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 wavelets;
import signal.RealSignal;
public abstract class AbstractWavelets {
protected int scales;
public AbstractWavelets() {
this.scales = 3;
}
public AbstractWavelets(int scales) {
this.scales = scales;
}
-
public abstract void setScale(int scale);
public abstract RealSignal analysis1(RealSignal in);
public abstract RealSignal synthesis1(RealSignal in);
public abstract String getName();
public abstract String getDocumentation();
public int getScales() {
return scales;
}
public void shrinkage(float threshold, RealSignal in, RealSignal out, RealSignal buffer) {
analysis(in, buffer);
buffer.thresholdSoft(-threshold, threshold);
synthesis(buffer, out);
}
public void analysis(RealSignal in, RealSignal out) {
+ String name = "w(" + in.name + ")";
+
if (out == null)
- out = new RealSignal(in.nx, in.ny, in.nz);
+ out = new RealSignal(name, in.nx, in.ny, in.nz);
int nxfine = in.nx;
int nyfine = in.ny;
int nzfine = in.nz;
int nx = nxfine;
int ny = nyfine;
int nz = nzfine;
for ( int i=0; i<scales; i++) {
- RealSignal sub = new RealSignal(nx, ny, nz, false);
+ RealSignal sub = new RealSignal("sub" + i, nx, ny, nz);
if (i==0)
in.getSignal(sub);
else
out.getSignal(sub);
sub = analysis1(sub);
out.setSignal(sub);
nx = Math.max(1, nx / 2);
ny = Math.max(1, ny / 2);
nz = Math.max(1, nz / 2);
}
}
public void synthesis(RealSignal in, RealSignal out) {
+ String name = "iw(" + in.name + ")";
if (out == null)
- out = new RealSignal(in.nx, in.ny, in.nz);
+ out = new RealSignal(name, in.nx, in.ny, in.nz);
int div = (int)Math.pow(2.0, (double)(scales-1));
int nxcoarse = Math.max(1, in.nx / div);
int nycoarse = Math.max(1, in.ny / div);
int nzcoarse = Math.max(1, in.nz / div);
int nx = nxcoarse;
int ny = nycoarse;
int nz = nzcoarse;
out.copy(in);
for ( int i=0; i<scales; i++) {
- RealSignal sub = new RealSignal(nx, ny, nz, false);
+ RealSignal sub = new RealSignal("sub" + i, nx, ny, nz);
out.getSignal(sub);
sub = synthesis1(sub);
out.setSignal(sub);
nx = nx * 2;
ny = ny * 2;
if (nz > 1)
nz = nz * 2;
}
}
}
diff --git a/DeconvolutionLab2/src/wavelets/haar/HaarWavelets.java b/DeconvolutionLab2/src/wavelets/haar/HaarWavelets.java
index bbb6ed5..62c5232 100644
--- a/DeconvolutionLab2/src/wavelets/haar/HaarWavelets.java
+++ b/DeconvolutionLab2/src/wavelets/haar/HaarWavelets.java
@@ -1,153 +1,156 @@
/*
* 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 wavelets.haar;
import signal.RealSignal;
import wavelets.AbstractWavelets;
public class HaarWavelets extends AbstractWavelets {
private double q = Math.sqrt(2);
public HaarWavelets(int scales) {
super(scales);
}
@Override
public void setScale(int scale) {
this.scales = scale;
}
@Override
public String getName() {
return "Haar";
}
@Override
public String getDocumentation() {
return "Haar Wavelets";
}
@Override
public RealSignal analysis1(RealSignal in) {
+ String name = "w(" + in.name + ")";
int nx = in.nx;
int ny = in.ny;
int nz = in.nz;
- RealSignal out = new RealSignal(nx, ny, nz, false);
+ RealSignal out = new RealSignal(name, nx, ny, nz);
float ux[] = new float[nx];
float vx[] = new float[nx];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++) {
ux = in.getX(y, z);
split(ux, vx);
out.setX(y, z, vx);
}
float uy[] = new float[ny];
float vy[] = new float[ny];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++) {
uy = out.getY(x, z);
split(uy, vy);
out.setY(x, z, vy);
}
if (nz > 1) {
float uz[] = new float[nz];
float vz[] = new float[nz];
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
uz = out.getZ(x, y);
split(uz, vz);
out.setZ(x, y, vz);
}
}
return out;
}
@Override
public RealSignal synthesis1(RealSignal in) {
+ String name = "iw(" + in.name + ")";
+
int nx = in.nx;
int ny = in.ny;
int nz = in.nz;
- RealSignal out = new RealSignal(nx, ny, nz, false);
+ RealSignal out = new RealSignal(name, nx, ny, nz);
float ux[] = new float[nx];
float vx[] = new float[nx];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++) {
ux = in.getX(y, z);
merge(ux, vx);
out.setX(y, z, vx);
}
float uy[] = new float[ny];
float vy[] = new float[ny];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++) {
uy = out.getY(x, z);
merge(uy, vy);
out.setY(x, z, vy);
}
if (nz > 1) {
float uz[] = new float[nz];
float vz[] = new float[nz];
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
uz = out.getZ(x, y);
merge(uz, vz);
out.setZ(x, y, vz);
}
}
return out;
}
private void split(float vin[], float vout[]) {
int n2 = vin.length / 2;
int j;
for (int i = 0; i < n2; i++) {
j = 2 * i;
vout[i] = (float) ((vin[j] + vin[j + 1]) / q);
vout[i + n2] = (float) ((vin[j] - vin[j + 1]) / q);
}
}
private void merge(float vin[], float vout[]) {
int n2 = vin.length / 2;
for (int i = 0; i < n2; i++) {
vout[2 * i] = (float) ((vin[i] + vin[i + n2]) / q);
vout[2 * i + 1] = (float) ((vin[i] - vin[i + n2]) / q);
}
}
}
diff --git a/DeconvolutionLab2/src/wavelets/spline/SplineWaveletsTool.java b/DeconvolutionLab2/src/wavelets/spline/SplineWaveletsTool.java
index a86324d..b574ba1 100644
--- a/DeconvolutionLab2/src/wavelets/spline/SplineWaveletsTool.java
+++ b/DeconvolutionLab2/src/wavelets/spline/SplineWaveletsTool.java
@@ -1,262 +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 wavelets.spline;
import signal.RealSignal;
public class SplineWaveletsTool {
private SplineFilter filters;
public SplineWaveletsTool(int scale, int order) {
this.filters = new SplineFilter(order);
}
public RealSignal analysis1(RealSignal in) {
+ String name = "w(" + in.name + ")";
+
int nx = in.nx;
int ny = in.ny;
int nz = in.nz;
- RealSignal out = new RealSignal(nx, ny, nz, false);
+ RealSignal out = new RealSignal(name, nx, ny, nz);
float ux[] = new float[nx];
float vx[] = new float[nx];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++) {
ux = in.getX(y, z);
splitMirror(ux, vx, filters.h, filters.g);
out.setX(y, z, vx);
}
float uy[] = new float[ny];
float vy[] = new float[ny];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++) {
uy = out.getY(x, z);
splitMirror(uy, vy, filters.h, filters.g);
out.setY(x, z, vy);
}
if (nz > 1) {
float uz[] = new float[nz];
float vz[] = new float[nz];
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
uz = out.getZ(x, y);
splitMirror(uz, vz, filters.h, filters.g);
out.setZ(x, y, vz);
}
}
return out;
}
public RealSignal synthesis1(RealSignal in) {
+ String name = "iw(" + in.name + ")";
int nx = in.nx;
int ny = in.ny;
int nz = in.nz;
- RealSignal out = new RealSignal(nx, ny, nz, false);
+ RealSignal out = new RealSignal(name, nx, ny, nz);
float ux[] = new float[nx];
float vx[] = new float[nx];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++) {
ux = in.getX(y, z);
mergeMirror(ux, vx, filters.h, filters.g);
out.setX(y, z, vx);
}
float uy[] = new float[ny];
float vy[] = new float[ny];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++) {
uy = out.getY(x, z);
mergeMirror(uy, vy, filters.h, filters.g);
out.setY(x, z, vy);
}
if (nz > 1) {
float uz[] = new float[nz];
float vz[] = new float[nz];
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
uz = out.getZ(x, y);
mergeMirror(uz, vz, filters.h, filters.g);
out.setZ(x, y, vz);
}
}
return out;
}
private void splitMirror(float vin[], float vout[], double h[], double g[]) {
int n = vin.length;
int n2 = n / 2;
int nh = h.length;
int ng = g.length;
double pix;
int j, k, j1, j2;
int period = 2 * n - 2; // period for mirror boundary conditions
for (int i = 0; i < n2; i++) {
j = i * 2;
pix = vin[j] * h[0];
for (k = 1; k < nh; k++) { // Low pass part
j1 = j - k;
if (j1 < 0) { // Mirror conditions
while (j1 < 0)
j1 += period; // Periodize
if (j1 >= n)
j1 = period - j1; // Symmetrize
}
j2 = j + k;
if (j2 >= n) { // Mirror conditions
while (j2 >= n)
j2 -= period; // Periodize
if (j2 < 0)
j2 = -j2; // Symmetrize
}
pix = pix + h[k] * (vin[j1] + vin[j2]);
}
vout[i] = (float) pix;
j = j + 1;
pix = vin[j] * g[0]; // High pass part
for (k = 1; k < ng; k++) {
j1 = j - k;
if (j1 < 0) { // Mirror conditions
while (j1 < 0)
j1 += period; // Periodize
if (j1 >= n)
j1 = period - j1; // Symmetrize
}
j2 = j + k;
if (j2 >= n) { // Mirror conditions
while (j2 >= n)
j2 -= period; // Periodize
if (j2 < 0)
j2 = -j2; // Symmetrize
}
pix = pix + g[k] * (vin[j1] + vin[j2]);
}
vout[i + n2] = (float) pix;
}
}
static private void mergeMirror(float vin[], float vout[], double h[], double g[]) {
int n = vin.length;
int n2 = n / 2;
int nh = h.length;
int ng = g.length;
double pix1, pix2;
int j, k, kk, i1, i2;
int k01 = (nh / 2) * 2 - 1;
int k02 = (ng / 2) * 2 - 1;
int period = 2 * n2 - 1; // period for mirror boundary conditions
for (int i = 0; i < n2; i++) {
j = 2 * i;
pix1 = h[0] * vin[i];
for (k = 2; k < nh; k += 2) {
i1 = i - (k / 2);
if (i1 < 0) {
i1 = (-i1) % period;
if (i1 >= n2)
i1 = period - i1;
}
i2 = i + (k / 2);
if (i2 > n2 - 1) {
i2 = i2 % period;
if (i2 >= n2)
i2 = period - i2;
}
pix1 = pix1 + h[k] * (vin[i1] + vin[i2]);
}
pix2 = 0.;
for (k = -k02; k < ng; k += 2) {
kk = Math.abs(k);
i1 = i + (k - 1) / 2;
if (i1 < 0) {
i1 = (-i1 - 1) % period;
if (i1 >= n2)
i1 = period - 1 - i1;
}
if (i1 >= n2) {
i1 = i1 % period;
if (i1 >= n2)
i1 = period - 1 - i1;
}
pix2 = pix2 + g[kk] * vin[i1 + n2];
}
vout[j] = (float) (pix1 + pix2);
j = j + 1;
pix1 = 0.;
for (k = -k01; k < nh; k += 2) {
kk = Math.abs(k);
i1 = i + (k + 1) / 2;
if (i1 < 0) {
i1 = (-i1) % period;
if (i1 >= n2)
i1 = period - i1;
}
if (i1 >= n2) {
i1 = (i1) % period;
if (i1 >= n2)
i1 = period - i1;
}
pix1 = pix1 + h[kk] * vin[i1];
}
pix2 = g[0] * vin[i + n2];
for (k = 2; k < ng; k += 2) {
i1 = i - (k / 2);
if (i1 < 0) {
i1 = (-i1 - 1) % period;
if (i1 >= n2)
i1 = period - 1 - i1;
}
i2 = i + (k / 2);
if (i2 > n2 - 1) {
i2 = i2 % period;
if (i2 >= n2)
i2 = period - 1 - i2;
}
pix2 = pix2 + g[k] * (vin[i1 + n2] + vin[i2 + n2]);
}
vout[j] = (float) (pix1 + pix2);
}
}
}

Event Timeline