Page MenuHomec4science

No OneTemporary

File Metadata

Created
Wed, Dec 18, 18:04
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/DeconvolutionLab2.config b/DeconvolutionLab2.config
new file mode 100644
index 0000000..67086af
--- /dev/null
+++ b/DeconvolutionLab2.config
@@ -0,0 +1,58 @@
+#DeconvolutionLab2 [Beta 2]
+#DeconvolutionLab2 [Beta 2]
+#Sun Feb 26 14:32:31 CET 2017
+Algorithm.I.gaussian.mean=0.0
+Algorithm.I.gaussian.stdev=1.0
+Algorithm.I.iterations=10
+Algorithm.I.poisson=0.0
+Algorithm.I.reg=0.1
+Algorithm.I.scale=3
+Algorithm.I.step=1.0
+Algorithm.I.wavelets=Haar
+Algorithm.algorithm=Regularized Inverse Filter [RIF | LRIF]
+Border.apoxy=Uniform
+Border.apoz=Uniform
+Border.extxy=0
+Border.extz=0
+Border.padxy=None
+Border.padz=None
+Computation.dim=XYZ
+Computation.epsilon=1E-6
+Computation.fft=Fastest
+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=false
+Controller.residu.value=0.01
+Controller.time.enable=false
+Controller.time.value=3600
+DeconvolutionLab.DeconvolutionDialog.location.h=400
+DeconvolutionLab.DeconvolutionDialog.location.w=600
+DeconvolutionLab.DeconvolutionDialog.location.x=802
+DeconvolutionLab.DeconvolutionDialog.location.y=266
+DeconvolutionLab.MainDialog.location.h=511
+DeconvolutionLab.MainDialog.location.w=593
+DeconvolutionLab.MainDialog.location.x=181
+DeconvolutionLab.MainDialog.location.y=298
+Image.image.row0=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;
+Image.image.selected=Cell7.tif;file;/Users/dsage/Desktop/Maria Azevedo/Cell7.tif;
+Language.headless=Run (Headless)
+Language.job=Job
+Language.language=Command line
+PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
+PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;
+Running.Directory=/Users/dsage/git/deconvolution
+Running.Display=yes
+Running.Monitor=console table
+Running.Multithreading=yes
+Running.Path=current
+Running.Stats=no
+Running.System=yes
+Running.Verbose=log
+System.Frame.location.h=313
+System.Frame.location.w=637
+System.Frame.location.x=0
+System.Frame.location.y=23
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index cab7984..192c0b8 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,80 +1,89 @@
#DeconvolutionLab2 [Beta 2]
#DeconvolutionLab2 [Beta 2]
-#Sun Mar 26 18:45:42 CEST 2017
+#Thu Apr 20 22:35:15 CEST 2017
Algorithm.BVLS.iterations=10
Algorithm.BVLS.step=1.0
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=1.000E-18
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
-Algorithm.algorithm=Regularized Inverse Filter
+Algorithm.algorithm=Richardson-Lucy
Border.apoxy=Hamming
Border.apoz=Uniform
-Border.extxy=1
+Border.extxy=6
Border.extz=0
Border.padxy=None
Border.padz=None
-Computation.dim=XYZ
+Computation.display=yes
Computation.epsilon=1E-6
Computation.fft=Fastest
+Computation.multithreading=yes
Computation.normalization=1
-Controller.constraint.enable=false
-Controller.constraint.value=no
-Controller.itmax.enable=true
+Computation.system=no
+Controller.constraint=no
+Controller.monitor=console
Controller.reference.enable=false
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.value=0.01
+Controller.stats=show
Controller.time.enable=false
-Controller.time.value=3600
-DeconvolutionLab.MainDialog.location.h=780
+Controller.time.value=1
+Controller.verbose=log
+DeconvolutionLab.MainDialog.location.h=626
DeconvolutionLab.MainDialog.location.w=500
-DeconvolutionLab.MainDialog.location.x=141
-DeconvolutionLab.MainDialog.location.y=51
-Image.image.row0=active;platform;active;\u232B
-Image.image.row1=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
-Image.image.row2=Applications;directory;/users/dsage/Applications;\u232B
-Image.image.row3=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
-Image.image.row4=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
-Image.image.selected=active;platform;active;\u232B
+DeconvolutionLab.MainDialog.location.x=896
+DeconvolutionLab.MainDialog.location.y=23
+Image.image.row0=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row10=Applications;directory;/users/dsage/Applications;\u232B
+Image.image.row11=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.row12=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
+Image.image.row1=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
+Image.image.row2=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row3=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row4=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
+Image.image.row5=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row6=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row7=RandomLines;synthetic;RandomLines 100.0 size 128 128 32 intensity 255.0 ;\u232B
+Image.image.row8=active;platform;active;\u232B
+Image.image.row9=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.selected=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
Language.headless=Run (Headless)
Language.job=Job
Language.language=Java
-Output.output.row0=ortho;OR2;;;;\u2713;\u2713;\u232B
-Output.output.selected=ortho;OR2;;;;\u2713;\u2713;\u232B
-PSF.psf.row0=Chrome Apps.localized;directory;/users/dsage/applications/Chrome Apps.localized;\u232B
-PSF.psf.row1=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
-PSF.psf.selected=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
-Running.Directory=/Users/dsage/Applications
-Running.Display=no
-Running.Monitor=console table
-Running.Multithreading=yes
+Output.output.row0=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
+Output.output.selected=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
+PSF.psf.row0=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
+PSF.psf.row1=Sinc;synthetic;Sinc 3.0 3.0 3.0 size 100 128 200 intensity 255.0 ;null
+PSF.psf.selected=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
+Path.current=Current
+Path.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
+Running.Directory=/Users/dsage/git/deconvolution/DeconvolutionLab2
+Running.Monitor=table
Running.Path=specify
-Running.Stats=show
-Running.System=no
-Running.Verbose=log
+Running.Verbose=quiet
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index c512b7d..21ed668 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,51 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="DeconvolutionLab2" default="build" basedir=".">
<property name="imagej" location="${user.home}/Desktop/ImageJ/plugins" />
<property name="fiji" location="${user.home}/Desktop/Fiji-deconv.app/plugins" />
<property name="matlab" location="/Applications/MATLAB_R2014b.app/java/" />
<property name="doc" location="${user.home}/Desktop/doc/" />
<property name="javadoc.header" value="&lt;h3&gt;DeconvolutionLab2&lt;/h3&gt;&#09;v1.0" />
<property name="javadoc.footer" value="&lt;h4&gt;DeconvolutionLab2&lt;/h4&gt;&#09;&lt;script&gt; var tStamp=new Date(); document.write(tStamp.toUTCString()); &lt;/script&gt;" />
<property name="javadoc.bottom" value='Copyright &amp;copy; &lt;script&gt; var currYear=new Date(); document.write(currYear.getFullYear()); &lt;/script&gt;, Biomedical Imaging Group, EPFL, Lausanne, Switzerland. All rights reserved.' />
<target name="build">
<mkdir dir="${doc}" />
<mkdir dir="bin" />
<copy todir="bin">
<fileset dir="ij">
</fileset>
</copy>
<copy file="plugins.config" toDir="bin" />
<zip destfile="../DeconvolutionLab2-src.zip" basedir="src" />
<zip destfile="../DeconvolutionLab2-cls.zip" basedir="bin" />
<jar destfile="../DeconvolutionLab_2.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="DeconvolutionLab2" />
<attribute name="Class-Path" value="ij.jar jtransforms.jar" />
</manifest>
</jar>
<javadoc destdir="${doc}"
author="true"
version="true"
overview="${basedir}/overview.html"
windowtitle="DeconvolutionLab2">
<fileset dir="src">
<include name="**/*.java" />
<exclude name="**/fft/**" />
<exclude name="**/jfftw/**" />
</fileset>
<header><![CDATA[${javadoc.header}]]></header>
<footer><![CDATA[${javadoc.footer}]]></footer>
<bottom><![CDATA[${javadoc.bottom}]]></bottom>
-
</javadoc>
<copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
<copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
-
<copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
</target>
</project>
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index e854461..cdfffc5 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.java
@@ -1,133 +1,130 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Imager.Platform;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2 {
public static String ack = Constants.name + " " + Constants.version + " " + Constants.copyright;
public static void main(String arg[]) {
System.out.println(ack);
Lab.init(Platform.STANDALONE);
if (arg.length == 0) {
System.out.println("Starting lab");
lab(arg);
return;
}
String flag = arg[0].trim().toLowerCase();
if (flag.equalsIgnoreCase("help")) {
System.out.println("Starting help");
help();
return;
}
else if (flag.equalsIgnoreCase("lab")) {
System.out.println("Starting lab");
lab(arg);
}
else if (flag.equalsIgnoreCase("fft")) {
System.out.println("Starting fft");
Lab.checkFFT(Monitors.createDefaultMonitor());
}
else if (flag.equalsIgnoreCase("run")) {
System.out.println("Starting run");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Run", cmd, Deconvolution.Finish.KILL).deconvolve();
}
else if (flag.equalsIgnoreCase("launch")) {
System.out.println("Starting launch");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Launch", cmd, Deconvolution.Finish.KILL).launch();
}
else
System.out.println("" + flag + " command not found");
}
private static void lab(String arg[]) {
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
if (arg.length >= 2) {
String filename = arg[1].trim();
File file = new File(filename);
if (file.exists())
if (file.isFile())
if (file.canRead())
config = filename;
}
Lab.init(Platform.STANDALONE, config);
LabDialog dialog = new LabDialog();
dialog.setVisible(true);
}
public static void help() {
System.out.println("More info:" + Constants.url);
System.out.println("Syntax:");
System.out.println("java -jar DeconvolutionLab_2.jar lab");
System.out.println("java -jar DeconvolutionLab_2.jar run {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar launch {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar fft");
System.out.println("java -jar DeconvolutionLab_2.jar info");
System.out.println("java -jar DeconvolutionLab_2.jar help");
System.out.println("{command} is the full command line for running a deconvolution");
System.out.println("Keywords of {command}: ");
for (String keyword : Command.keywords)
System.out.println("\t" + keyword);
-
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
Lab.init(Imager.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
new Deconvolution("CommandLine", cmd).deconvolve();
}
-
-
}
diff --git a/DeconvolutionLab2/src/Display_FactorySignals.java b/DeconvolutionLab2/src/Display_FactorySignals.java
new file mode 100644
index 0000000..57e2c07
--- /dev/null
+++ b/DeconvolutionLab2/src/Display_FactorySignals.java
@@ -0,0 +1,254 @@
+import java.io.File;
+import java.util.ArrayList;
+
+import bilib.table.CustomizedTable;
+import bilib.tools.Files;
+import deconvolution.algorithm.Convolution;
+import deconvolutionlab.Lab;
+import deconvolutionlab.monitor.Monitors;
+import fft.AbstractFFT;
+import fft.FFT;
+import ij.plugin.PlugIn;
+import signal.ComplexSignal;
+import signal.RealSignal;
+import signal.factory.SignalFactory;
+import signal.factory.Sphere;
+import signal.factory.complex.ComplexSignalFactory;
+
+public class Display_FactorySignals implements PlugIn {
+
+ private String path = Files.getDesktop() + File.separator + "Deconvolution" + File.separator + "Signals" + File.separator;
+
+ @Override
+ public void run(String arg0) {
+ }
+
+ public static void main(String arg[]) {
+ new Display_FactorySignals();
+ }
+
+ public Display_FactorySignals() {
+ new File(path).mkdir();
+ int nx = 128;
+ int ny = 96;
+ int nz = 100;
+
+ ArrayList<SignalFactory> factories = SignalFactory.getAll();
+ RealSignal image = new Sphere(20, 0.5).generate(nx, ny, nz);
+ Monitors monitors = Monitors.createDefaultMonitor();
+ CustomizedTable table = new CustomizedTable(new String[] {"Name", "mean", "min", "max"}, true);
+ table.show("Stats", 500, 500);
+ for(SignalFactory factory : factories) {
+ RealSignal psf = factory.intensity(133).generate(nx, ny, nz);
+ Lab.show(psf);
+ float s[] = psf.getStats();
+ table.append(new String[] {factory.getName(), ""+s[0], ""+s[1], ""+s[2]});
+ Lab.showOrthoview(psf);
+ Lab.save(monitors, psf, path + psf.name + ".tif");
+ Lab.save(monitors, psf.createMIP(), path + "mip-" + psf.name + ".tif");
+ Lab.save(monitors, psf.createOrthoview(), path + "ortho-" + psf.name + ".tif");
+ Convolution convolution = new Convolution();
+ RealSignal a = convolution.run(image, psf);
+ Lab.showMIP(monitors, a, "conv " + factory.getName());
+ Lab.save(monitors, a, path + "conv-"+psf.name + ".tif");
+ Lab.save(monitors, a.createMIP(), path + "conv-mip-" + psf.name + ".tif");
+ Lab.save(monitors, a.createOrthoview(), path + "conv-ortho-" + psf.name + ".tif");
+ }
+ }
+
+ public void d() {
+ int nx = 150;
+ int ny = 128;
+ int nz = 100;
+ int xsize = nx / 2;
+ int ysize = ny / 2;
+ int zsize = nz / 2;
+ double wx, wy, wz;
+ RealSignal psf = new RealSignal("psf", nx, ny, nz);
+ AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, 1);
+ double pupil = 10;
+ double defocus = 10;
+ double wave = 2;
+
+ double defocusTop = 2.0*Math.PI / (defocus*defocus*pupil);
+ double defocusCen = 2.0*Math.PI / pupil;
+
+ for (int z = 0; z <= zsize; z++) {
+ float[][][] real = new float[xsize + 1][ysize + 1][1];
+ float[][][] imag = new float[xsize + 1][ysize + 1][1];
+ wz = wave*(z-zsize)*2.0*Math.PI / zsize;
+ double cosz = Math.cos(wz);
+ double sinz = Math.sin(wz);
+ double fcz = z * Math.abs(defocusTop-defocusCen) / zsize+ defocusTop;
+ for (int y = 0; y <= ysize; y++)
+ for (int x = 0; x <= xsize; x++) {
+ wx = Math.PI * x / xsize;
+ wy = Math.PI * y / ysize;
+ double g = wy*wy+wx*wx >= fcz*fcz ? 0 : 1;
+ real[x][y][0] = (float) (g * cosz);
+ imag[x][y][0] = (float) (g * sinz);
+ }
+ ComplexSignal c = ComplexSignalFactory.createHermitian(""+z, nx, ny, 1, real, imag);
+ RealSignal pz = fft.inverse(c).circular();
+
+ //pz.plus(1);
+ //pz.normalize(1);
+ psf.setXY(z, pz.getXY(0));
+ psf.setXY(nz-1-z, pz.duplicate().getXY(0));
+ }
+ //psf = new Gaussian(3,4,4).generate(nx, ny, nz);
+ float min = psf.getExtrema()[0];
+ psf.minus(min);
+ float max = psf.getExtrema()[1];
+ psf.times(1/max);
+ float aft[] = psf.getExtrema();
+ System.out.println(" // " + aft[0] + " // " + aft[1]);
+ psf.normalize(1);
+ Lab.show(psf);
+ Lab.showOrthoview(psf);
+ Lab.save(Monitors.createDefaultMonitor(), psf, "psfdiffraction.tif");
+ /*
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, nz);
+ ComplexSignal otf = fft.transform(psf);
+ Lab.show(otf.getModule().circular().log());
+ Lab.showOrthoview(otf.getModule().circular().log());
+
+
+ RealSignal r = new Cube(30, 1).generate(nx, ny, nz);
+ RealSignal a = new Convolution().run(r, psf);
+ Lab.showOrthoview(a);
+ */
+ }
+ public void c() {
+ int nx = 128;
+ int ny = 128;
+ int nz = 128;
+ RealSignal otf = new RealSignal("psf", nx, ny, nz);
+
+ int cx = nx/2;
+ int cy = ny/2;
+ int cz = nz/2;
+ double pi = Math.PI;
+ double periodTop = 5;
+ double periodCenter = 15;
+ double attenuation = 10;
+ double aperture = 60;
+ double apernorm = (2.0*aperture)/(nx+ny);
+ double diag = Math.sqrt(nx*nx+ny*ny+nz*nz);
+ double step = (periodCenter-periodTop)/nz;
+ for(int i=0; i<nx; i++)
+ for(int j=0; j<ny; j++) {
+ double r = Math.sqrt((i-cx)*(i-cx)+(j-cy)*(j-cy));
+ for(int k=0; k<nx; k++) {
+ double z = Math.abs(k-cz);
+ double p = Math.sqrt(r*r + z*z)/diag;
+ double period = Math.max(1, periodCenter-step*z);
+ double sz = apernorm*z + period*0.25;
+ double s1 = 1.0 / (1.0+Math.exp(-(r+sz)));
+ double s2 = 1.0 / (1.0+Math.exp(-(r-sz)));
+ double s = Math.cos(2*pi*(r-apernorm*z)/period);
+ double g = (attenuation*p+1);
+ otf.data[k][i+j*nx] = (float)((s1-s2)*s*s/g);
+ }
+ }
+ Lab.show(otf);
+ Lab.showOrthoview(otf, "out", cx, cy, cz);
+ float[] stats = otf.getStats();
+ for(float s : stats)
+ System.out.println("" + s);
+
+ AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, nz);
+ ComplexSignal psf = fft.transform(otf);
+ float[] stats1 = psf.getModule().getStats();
+ for(float s : stats1)
+ System.out.println("PSF " + s);
+ Lab.show(psf.getModule().circular().log());
+ Lab.showOrthoview(psf.getModule().circular().log(), "out", cx, cy, cz);
+ }
+
+ public void b() {
+ int nx = 128;
+ int ny = 128;
+ int nz = 128;
+ RealSignal otf = new RealSignal("psf", nx, ny, nz);
+
+ int cx = nx/2;
+ int cy = ny/2;
+ int cz = nz/2;
+
+ for(int i=0; i<nx; i++)
+ for(int j=0; j<ny; j++) {
+ double r = Math.sqrt((i-cx)*(i-cx)+(j-cy)*(j-cy));
+ for(int k=0; k<nx; k++) {
+ double df = Math.abs(k-cz);
+ double dd = df - 6;
+ double sig = 3 + df * 0.2;
+ double sigd = 0.1 + dd * 0.2;
+ double norm = 1.0 / (Math.PI*sig*sig);
+ double g = norm * Math.exp(-r*r/(2.0*sig*sig));
+ double gd = (dd < 0 ? 0 : norm * Math.exp(-r*r/(2*sigd*sigd)));
+ otf.data[k][i+j*nx] = (float)(g-gd); //(Math.exp(-r*0.1));
+ }
+ }
+ Lab.show(otf);
+ Lab.showOrthoview(otf, "out", cx, cy, cz);
+
+ float[] stats = otf.getStats();
+ for(float s : stats)
+ System.out.println("" + s);
+
+ AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, nz);
+ ComplexSignal psf = fft.transform(otf);
+ float[] stats1 = psf.getModule().getStats();
+ for(float s : stats1)
+ System.out.println("PSF " + s);
+ Lab.show(Monitors.createDefaultMonitor(), psf.getModule().circular(), "psf");
+ }
+
+ public void va() {
+ int nx = 128;
+ int ny = 128;
+ int nz = 128;
+ RealSignal otf = new RealSignal("psf", nx, ny, nz);
+
+ int cx = nx/2;
+ int cy = ny/2;
+ int cz = nz/2;
+ double p = 1.3;
+ for(int i=0; i<nx; i++)
+ for(int j=0; j<ny; j++) {
+ double d = Math.sqrt((i-cx)*(i-cx) + (j-cy)*(j-cy));
+ double v = (p-Math.exp(-d*0.1));
+ for(int k=0; k<nx; k++) {
+ double dz = ((double)Math.abs(k-cz))/nz;
+ double g = Math.exp(-dz*dz*2*nx);
+ double vz = g*v*Math.cos(d*Math.PI*2/nx);
+ if (vz > 0) {
+ double r = Math.sqrt((i-cx)*(i-cx) + (j-cy)*(j-cy) + (k-cz)*(k-cz));
+ if (r < cx)
+ otf.data[k][i+j*nx] = (float)vz; //(Math.exp(-r*0.1));
+
+ }
+ }
+ }
+ Lab.show(otf);
+ Lab.showOrthoview(otf, "out", cx, cy, cz);
+
+ float[] stats = otf.getStats();
+ for(float s : stats)
+ System.out.println("" + s);
+
+ AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, nz);
+ ComplexSignal psf = fft.transform(otf);
+ float[] stats1 = psf.getModule().getStats();
+ for(float s : stats1)
+ System.out.println("PSF " + s);
+ Lab.show(Monitors.createDefaultMonitor(), psf.getModule().circular(), "psf");
+
+ }
+
+}
diff --git a/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java b/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
index 5e1b91e..18997b6 100644
--- a/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
+++ b/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
@@ -1,22 +1,51 @@
+/*
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
+ *
+ * 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.
+ */
+
+/*
+ * 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 bilib.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/bilib/component/GridPanel.java b/DeconvolutionLab2/src/bilib/component/GridPanel.java
index 0f89435..f0fec94 100644
--- a/DeconvolutionLab2/src/bilib/component/GridPanel.java
+++ b/DeconvolutionLab2/src/bilib/component/GridPanel.java
@@ -1,200 +1,198 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
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 GridPanel extends JPanel {
private static final long serialVersionUID = 1L;
private GridBagLayout layout = new GridBagLayout();
private GridBagConstraints constraint = new GridBagConstraints();
private int defaultSpace = 3;
/**
* Constructor.
*/
public GridPanel() {
super();
setLayout(layout);
setBorder(BorderFactory.createEtchedBorder());
}
/**
* Constructor.
*/
public GridPanel(int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
}
/**
* Constructor.
*/
public GridPanel(boolean border) {
super();
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
}
/**
* Constructor.
*/
public GridPanel(String title) {
super();
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
}
/**
* Constructor.
*/
public GridPanel(boolean border, int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
}
/**
* Constructor.
*/
public GridPanel(String title, int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
}
/**
* Specify the defaultSpace.
*/
public void setSpace(int defaultSpace) {
this.defaultSpace = defaultSpace;
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, String label) {
place(row, col, 1, 1, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, String label) {
place(row, col, 1, 1, space, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, String label) {
place(row, col, width, height, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, JComponent comp) {
place(row, col, 1, 1, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, JComponent comp) {
place(row, col, 1, 1, space, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, JComponent comp) {
place(row, col, width, height, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int space, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(space, space, space, space);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int spaceHorizontal, int spaceVertical, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(spaceVertical, spaceHorizontal, spaceHorizontal, spaceVertical);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/GridToolbar.java b/DeconvolutionLab2/src/bilib/component/GridToolbar.java
index 721e775..d37aa43 100644
--- a/DeconvolutionLab2/src/bilib/component/GridToolbar.java
+++ b/DeconvolutionLab2/src/bilib/component/GridToolbar.java
@@ -1,246 +1,244 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JToolBar;
/**
* This class extends the JToolbar 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 GridToolbar extends JToolBar {
private GridBagLayout layout = new GridBagLayout();
private GridBagConstraints constraint = new GridBagConstraints();
private int defaultSpace = 3;
/**
* Constructor.
*/
public GridToolbar() {
super("Control");
setLayout(layout);
setBorder(BorderFactory.createEtchedBorder());
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border) {
super("Control");
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(String title) {
super(title);
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(int defaultSpace) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, int defaultSpace) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, int defaultSpace, boolean floatable) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, boolean floatable) {
super("Control");
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(String title, boolean floatable) {
super(title);
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(int defaultSpace, boolean floatable) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(String title, int defaultSpace) {
super(title);
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(String title, int defaultSpace, boolean floatable) {
super(title);
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(floatable);
}
/**
* Specify the defaultSpace.
*/
public void setSpace(int defaultSpace) {
this.defaultSpace = defaultSpace;
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, String label) {
place(row, col, 1, 1, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, String label) {
place(row, col, 1, 1, space, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, String label) {
place(row, col, width, height, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, JComponent comp) {
place(row, col, 1, 1, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, JComponent comp) {
place(row, col, 1, 1, space, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, JComponent comp) {
place(row, col, width, height, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int space, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(space, space, space, space);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/HTMLPane.java b/DeconvolutionLab2/src/bilib/component/HTMLPane.java
index 49a0c9e..db5e904 100644
--- a/DeconvolutionLab2/src/bilib/component/HTMLPane.java
+++ b/DeconvolutionLab2/src/bilib/component/HTMLPane.java
@@ -1,141 +1,139 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import java.awt.Dimension;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
/**
* This class extends the Java JEditorPane to make a easy to use panel to
* display HTML information.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class HTMLPane extends JEditorPane {
private String html = "";
private String header = "";
private String footer = "";
private Dimension dim;
private String font = "verdana";
private String color = "#222222";
private String background = "#f8f8f8";
public HTMLPane() {
create();
}
public HTMLPane(String font) {
this.font = font;
create();
}
public HTMLPane(int width, int height) {
this.dim = new Dimension(width, height);
create();
}
public HTMLPane(String font, int width, int height) {
this.font = font;
this.dim = new Dimension(width, height);
create();
}
public HTMLPane(String font, String color, String background, int width, int height) {
this.font = font;
this.dim = new Dimension(width, height);
this.color = color;
this.background = background;
create();
}
@Override
public String getText() {
Document doc = this.getDocument();
try {
return doc.getText(0, doc.getLength());
}
catch (BadLocationException e) {
e.printStackTrace();
return getText();
}
}
public void clear() {
html = "";
append("");
}
private void create() {
header += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n";
header += "<html><head>\n";
header += "<style>body {background-color:" + background + "; color:" + color + "; font-family: " + font + ";margin:4px}</style>\n";
header += "<style>h1 {color:#555555; font-size:1.0em; font-weight:bold; padding:1px; margin:1px;}</style>\n";
header += "<style>h2 {color:#333333; font-size:0.9em; font-weight:bold; padding:1px; margin:1px;}</style>\n";
header += "<style>h3 {color:#000000; font-size:0.9em; font-weight:italic; padding:1px; margin:1px;}</style>\n";
header += "<style>p {color:" + color + "; font-size:0.9em; padding:1px; margin:0px;}</style>\n";
header += "</head>\n";
header += "<body>\n";
footer += "</body></html>\n";
setEditable(false);
setContentType("text/html; charset=ISO-8859-1");
}
public void append(String content) {
html += content;
setText(header + html + footer);
if (dim != null) {
setPreferredSize(dim);
}
setCaretPosition(0);
}
public void append(String tag, String content) {
html += "<" + tag + ">" + content + "</" + tag + ">";
setText(header + html + footer);
if (dim != null) {
setPreferredSize(dim);
}
setCaretPosition(0);
}
public JScrollPane getPane() {
JScrollPane scroll = new JScrollPane(this, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setPreferredSize(dim);
return scroll;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/PanelImage.java b/DeconvolutionLab2/src/bilib/component/PanelImage.java
index 304113f..2abb46a 100644
--- a/DeconvolutionLab2/src/bilib/component/PanelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/PanelImage.java
@@ -1,64 +1,92 @@
+/*
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
+ *
+ * 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.
+ */
+
+/*
+ * 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 bilib.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
-
import javax.swing.JPanel;
-import deconvolutionlab.splash.ImageLoader;
+import resources.ImageLoader;
public class PanelImage extends JPanel {
private Image image;
private int w = -1;
private int h = -1;
public PanelImage() {
super();
}
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;
}
public void setImage(BufferedImage image) {
this.image = image;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
if (w < 0)
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/bilib/component/SpinnerRangeDouble.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
index 73a1401..74e1fd0 100644
--- a/DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
@@ -1,197 +1,195 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* double. It handles double type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeDouble extends JSpinner {
private SpinnerNumberModel model;
private double defValue;
private double minValue;
private double maxValue;
private double incValue;
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(double minValue, double maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
double value = get();
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Double def = new Double(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(double incValue) {
this.incValue = incValue;
Double def = (Double) getModel().getValue();
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public double getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(double value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Double(value));
}
/**
* Return the value with clipping the value in the range [min..max].
*/
public double get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
double ii = i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
double ii = i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
double ii = i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0.0;
}
public double getRangeMaximum() {
return maxValue;
}
public double getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
index 0d59520..a211630 100644
--- a/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
@@ -1,197 +1,195 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* float. It handles float type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeFloat extends JSpinner {
private SpinnerNumberModel model;
private float defValue;
private float minValue;
private float maxValue;
private float incValue;
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Float def = new Float(defValue);
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
this.model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Float def = new Float(defValue);
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(float minValue, float maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
float value = get();
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Float def = new Float(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(float incValue) {
this.incValue = incValue;
Float def = (Float) getModel().getValue();
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public float getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(float value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Float(value));
}
/**
* Return the value without clipping the value in the range [min..max].
*/
public float get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
float ii = (float) i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
float ii = (float) i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
float ii = i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0f;
}
public float getRangeMaximum() {
return maxValue;
}
public float getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
index 9c5558c..a258627 100644
--- a/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
@@ -1,196 +1,194 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* integer. It handles int type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeInteger extends JSpinner {
private SpinnerNumberModel model;
private int defValue;
private int minValue;
private int maxValue;
private int incValue;
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(format.length());
}
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(int minValue, int maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
int value = get();
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Integer def = new Integer(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(int incValue) {
this.incValue = incValue;
Integer def = (Integer) getModel().getValue();
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public int getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(int value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Integer(value));
}
/**
* Return the value without clipping the value in the range [min..max].
*/
public int get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
int ii = i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
int ii = (int) i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
int ii = (int) i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0;
}
public int getRangeMaximum() {
return maxValue;
}
public int getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java b/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
index 43fc093..df3c3fd 100644
--- a/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
+++ b/DeconvolutionLab2/src/bilib/table/CustomizedColumn.java
@@ -1,67 +1,65 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.table;
public class CustomizedColumn {
public Class<?> classe;
public String header;
public int width;
public boolean editable;
public String[] choices; // Combobox
public String button; // Button
public String tooltip;
public CustomizedColumn(String header, Class<?> classe, int width, boolean editable) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = editable;
}
public CustomizedColumn(String header, Class<?> classe, int width, String[] choices, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = true;
this.choices = choices;
this.tooltip = tooltip;
}
public CustomizedColumn(String header, Class<?> classe, int width, String button, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = false;
this.button = button;
this.tooltip = tooltip;
}
}
diff --git a/DeconvolutionLab2/src/bilib/table/CustomizedTable.java b/DeconvolutionLab2/src/bilib/table/CustomizedTable.java
index ae916d9..c1a2859 100644
--- a/DeconvolutionLab2/src/bilib/table/CustomizedTable.java
+++ b/DeconvolutionLab2/src/bilib/table/CustomizedTable.java
@@ -1,298 +1,296 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.table;
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 && 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((String)value);
setMargin(new Insets(1, 1, 1, 1));
return this;
}
}
}
diff --git a/DeconvolutionLab2/src/bilib/tools/Bessel.java b/DeconvolutionLab2/src/bilib/tools/Bessel.java
new file mode 100644
index 0000000..50ca2fe
--- /dev/null
+++ b/DeconvolutionLab2/src/bilib/tools/Bessel.java
@@ -0,0 +1,79 @@
+/*
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
+ *
+ * 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.
+ */
+
+/*
+ * 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 bilib.tools;
+
+public class Bessel {
+
+ // Returns the Bessel function J0(x) for any real x. Adapted from Computer
+ // Approximations by Hart 1978.
+ public static double J0(double x) {
+ double ax, z;
+ double xx, y, ans, ans1, ans2;
+ if ((ax = Math.abs(x)) < 8.0) {
+ y = x * x;
+ ans1 = 57568490574.0 + y * (-13362590354.0 + y * (651619640.7 + y * (-11214424.18 + y * (77392.33017 + y * (-184.9052456)))));
+ ans2 = 57568490411.0 + y * (1029532985.0 + y * (9494680.718 + y * (59272.64853 + y * (267.8532712 + y * 1.0))));
+ ans = ans1 / ans2;
+ }
+ else {
+ z = 8.0 / ax;
+ y = z * z;
+ xx = ax - 0.785398164;
+ ans1 = 1.0 + y * (-0.1098628627e-2 + y * (0.2734510407e-4 + y * (-0.2073370639e-5 + y * 0.2093887211e-6)));
+ ans2 = -0.1562499995e-1 + y * (0.1430488765e-3 + y * (-0.6911147651e-5 + y * (0.7621095161e-6 - y * 0.934945152e-7)));
+ ans = Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
+ }
+ return ans;
+ }
+
+ // Returns the Bessel function J1(x) for any real x. Adapted from Computer
+ // Approximations by Hart 1978.
+ public static double J1(double x) {
+ double ax, z;
+ double xx, y, ans, ans1, ans2;
+ if ((ax = Math.abs(x)) < 8.0) {
+ y = x * x;
+ ans1 = x * (72362614232.0 + y * (-7895059235.0 + y * (242396853.1 + y * (-2972611.439 + y * (15704.48260 + y * (-30.16036606))))));
+ ans2 = 144725228442.0 + y * (2300535178.0 + y * (18583304.74 + y * (99447.43394 + y * (376.9991397 + y * 1.0))));
+ ans = ans1 / ans2;
+ }
+ else {
+ z = 8.0 / ax;
+ y = z * z;
+ xx = ax - 2.356194491;
+ ans1 = 1.0 + y * (0.183105e-2 + y * (-0.3516396496e-4 + y * (0.2457520174e-5 + y * (-0.240337019e-6))));
+ ans2 = 0.04687499995 + y * (-0.2002690873e-3 + y * (0.8449199096e-5 + y * (-0.88228987e-6 + y * 0.105787412e-6)));
+ ans = Math.sqrt(0.636619772 / ax) * (Math.cos(xx) * ans1 - z * Math.sin(xx) * ans2);
+ if (x < 0.0)
+ ans = -ans;
+ }
+ return ans;
+ }
+
+}
diff --git a/DeconvolutionLab2/src/bilib/tools/Files.java b/DeconvolutionLab2/src/bilib/tools/Files.java
index 423081a..f337d83 100644
--- a/DeconvolutionLab2/src/bilib/tools/Files.java
+++ b/DeconvolutionLab2/src/bilib/tools/Files.java
@@ -1,71 +1,79 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.tools;
import java.io.File;
import javax.swing.JFileChooser;
+import javax.swing.filechooser.FileSystemView;
public class Files {
+ public static String getHome() {
+ return FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath();
+
+ }
+
+ public static String getDesktop() {
+ return getHome() + File.separator + "Desktop";
+ }
+
public static File browseFile(String path) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
File dir = new File(path);
if (dir.exists())
fc.setCurrentDirectory(dir);
int ret = fc.showOpenDialog(null);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = new File(fc.getSelectedFile().getAbsolutePath());
if (file.exists())
return file;
}
return null;
}
public static File browseDirectory(String path) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
File dir = new File(path);
if (dir.exists())
fc.setCurrentDirectory(dir);
int ret = fc.showOpenDialog(null);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = new File(fc.getSelectedFile().getAbsolutePath());
if (file.exists())
return file;
}
return null;
}
}
diff --git a/DeconvolutionLab2/src/bilib/tools/NumFormat.java b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
index 912a246..65235c1 100644
--- a/DeconvolutionLab2/src/bilib/tools/NumFormat.java
+++ b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
@@ -1,129 +1,135 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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 bilib.tools;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NumFormat {
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[] parseNumbersAfter(String keyword, String line) {
+ String parts[] = line.trim().toLowerCase().split(keyword.toLowerCase());
+ if (parts.length == 2)
+ return parseNumbers(parts[1]);
+ else
+ return new double[0];
+ }
+
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 ? "-" : " ";
+ 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", 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/bilib/tools/WebBrowser.java b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
index e516788..ad9655f 100644
--- a/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
+++ b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
@@ -1,61 +1,90 @@
/*
* 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/>.
*/
+/*
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
+ *
+ * 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.
+ */
+
+/*
+ * 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 bilib.tools;
import java.awt.Desktop;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class WebBrowser {
public static boolean open(String url) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL(url).toURI());
return true;
}
catch (Exception e) {
e.printStackTrace();
}
}
JFrame frame = new JFrame("Help");
JLabel lbl = new JLabel(url);
frame.add(lbl);
frame.pack();
frame.setVisible(true);
return false;
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
index 198952e..0bbc747 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
@@ -1,123 +1,123 @@
/*
* 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 course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
+import bilib.tools.Files;
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 root = Files.getDesktop() + 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("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("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("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("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("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("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("run", noisy + psf + rl).deconvolve();
new File(res + "RL-ITER/I.tif").delete();
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("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 e82fddb..441d0b4 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
@@ -1,138 +1,138 @@
/*
* 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 course;
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);
+ RealSignal im = new Cube(22, .1).intensity(100).center(0.25, 0.00, 0.05).generate(nx, ny, nz);
+ RealSignal i0 = new Cube(22, .1).intensity(100).center(0.25, 0.05, 0.05).generate(nx, ny, nz);
+ RealSignal i1 = new Cube(22, .1).intensity(100).center(0.25, 0.10, 0.05).generate(nx, ny, nz);
+ RealSignal i2 = new Cube(22, .1).intensity(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);
+ RealSignal g = new Gaussian(10, 10, 10).intensity(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("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("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("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("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("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("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("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("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("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("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("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("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("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("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_Noise.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
index 4672d13..a2c2354 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
@@ -1,98 +1,98 @@
/*
* 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 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);
+ RealSignal im = new Cube(50, 0.25).intensity(100).center(0.2, 0.5, 0).generate(nx, ny, nz);
+ RealSignal i1 = new Cube(50, 0.25).intensity(70).center(0.4, 0.5, 0).generate(nx, ny, nz);
+ RealSignal i2 = new Cube(50, 0.25).intensity(40).center(0.6, 0.5, 0).generate(nx, ny, nz);
+ RealSignal i3 = new Cube(50, 0.25).intensity(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("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("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("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 5c1b8f5..8f2e87e 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Piecewise.java
@@ -1,116 +1,116 @@
/*
* 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 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);
+ RealSignal x = new Constant().intensity(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));
+ x.plus(new Cube(size, 0.1).intensity(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("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("run", ground + psf + algo).deconvolve();
algo = " -algorithm NIF -out ortho NIF " + paramout;
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("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 2aaefc6..72a1933 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
@@ -1,107 +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 course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
+import deconvolution.Stats;
+import deconvolution.algorithm.Controller;
+import deconvolution.algorithm.Convolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
-import signal.factory.GridSpots;
+import signal.factory.Airy;
+import signal.factory.CubeSphericalBeads;
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;
+ int ny = 120;
+ int nz = 122;
+ int spacing = 12;
+ int border = 6;
- 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");
+ RealSignal x = new CubeSphericalBeads(4, 0.1, spacing, border).intensity(400).generate(nx, ny, nz);
+ //RealSignal x = new Sphere(30, 1).generate(nx, ny, nz);
+ //RealSignal x = new Constant().intensity(0, 255).generate(nx, ny, nz);
+ //Lab.show(monitors, x, "reference");
+ //Lab.showOrthoview(x);
+ //Lab.showMIP(x);
+ //Lab.save(monitors, x, res + "ref.tif");
+
+ //RealSignal h = new Gaussian(3, 3, 1).generate(nx, ny, nz);
+ RealSignal h = new Airy(100, 50, 0.5, 0.1).generate(nx, ny, nz);
+ Lab.show(monitors, h, "psf");
+ Lab.showOrthoview(h);
+ Lab.showMIP(h);
+ Lab.save(monitors, h, res + "psf.tif");
+ Lab.save(monitors, h.createOrthoview(), res + "psfo.tif");
+ Lab.save(monitors, h.createMIP(), res + "psfp.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 param = " -reference " + res + "ref.tif -stats show -display no -monitor no -system no";
+ String conv = " -image file " + res + "conv.tif ";
+ String ref = " -image file " + res + "ref.tif ";
+ String psf = " -psf file " + res + "psf.tif ";
+
+ Controller controller = new Controller();
+ controller.setSystem(true);
+ controller.setReference(res + "ref.tif");
+ controller.setStatsMode(Stats.Mode.SHOW);
- String paramout = " intact float (" + spacing + "," + spacing + "," + spacing + ")";
+ Convolution convo = new Convolution();
+ convo.setController(controller);
+ RealSignal y = convo.run(x, h);
+ Lab.show(y);
+ /*
+ algo = " -algorithm NIF -out mip NIFp ";
+ new Deconvolution("nif", conv + psf + algo + param).deconvolve();
+/*
+// algo = " -algorithm TRIF 10e-5 -pad NO NO 0 32 -out mip trifppad -out ortho trifopad ";
+// new Deconvolution("trif", conv + psf + algo + param).deconvolve();
+
+ algo = " -algorithm TRIF 10e-5 -out mip TRIFo ";
+ new Deconvolution("trif", conv + psf + algo + param).deconvolve();
- algo = " -algorithm CONV -out stats @3 PR -out stack PR -out ortho PRo ";
- new Deconvolution("run", ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve();
+ algo = " -algorithm TRIF 10e-5 -pad NO NO 100 100 -out mip TRIFoapo ";
+ new Deconvolution("TRIF apo", conv + psf + algo + param).deconvolve();
- algo = " -algorithm SIM 0 1.5 0 -out stats @3 SIM -out stack signal -out ortho SIGNALo ";
- new Deconvolution("run", ground + psf + algo).deconvolve();
- algo = " -algorithm NIF -out ortho NIF " + paramout;
- new Deconvolution("run", signal + psf + algo).deconvolve();
+// algo = " -algorithm TRIF 10e-4 -pad NO NO 0 20 -out mip trif_ppad -out ortho trif_opad";
+// new Deconvolution("trif", conv + psf + algo + param).deconvolve();
+
+ //algo = " -algorithm TRIF 10e-6 -out mip trif_p -out ortho trif_o -stats show";
+ //new Deconvolution("trif", conv + psf + algo + param).deconvolve();
+ /*
+ for(int i=-8; i<=-2; i+=20) {
+ algo = " -algorithm TRIF " + Math.pow(10, i) + " -out mip nifp" + i + " -out ortho nifo" + i + " -stats show";
+ new Deconvolution("trif", conv + psf + algo + param).deconvolve();
+ }
+
+ algo = " -algorithm SIM 0 1 0 -out ortho simo -system no -monitor no";
+ new Deconvolution("run", ref + psf + algo).deconvolve();
+
+ algo = " -algorithm NIF -out ortho nifo -system -monitor";
+ 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("run", signal + psf + algo).deconvolve();
}
-
- algo = " -algorithm LW+ 305 1 -out stats @3 LW+ nosave -out ortho @25 LW+/LW+" + paramout;
+ algo = " -algorithm LW+ 30 1 -out stats @3 LW+ nosave -out ortho @s5 LW+/LW+" + paramout;
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_MemoryFootprint.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
index 6bc3659..aa43077 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
@@ -1,103 +1,103 @@
/*
* 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 course;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import ij.plugin.PlugIn;
import signal.SignalCollector;
public class DeconvolutionLab2_MemoryFootprint implements PlugIn {
public DeconvolutionLab2_MemoryFootprint() {
CustomizedTable table = new CustomizedTable(new String[] { "Name", "Algo", "Optimized", "Time", "Energy", "Peak Count", "Peak Bytes", "End Count", "End Byte", "Ratio" }, true);
table.show("Memory Footprint", 1100, 300);
run(table, "CONV");
run(table, "FISTA 10 1 1");
run(table, "ICTM 10 1 0.1");
run(table, "I");
run(table, "ISTA 10 1 1");
run(table, "LW 10 1");
run(table, "LLS 10 1");
run(table, "NLLS 10 1");
run(table, "NIF");
run(table, "DIV");
run(table, "RIF 1");
run(table, "RL 10");
run(table, "RLTV 10 1");
run(table, "SIM 1 1 1");
run(table, "BVLS 10 1");
run(table, "TM 10 1 0.1");
run(table, "TRIF 1");
run(table, "VC 10 1");
}
private void run(CustomizedTable table, String cmd) {
int nx = 64;
int ny = 32;
int nz = 12;
String size = " size " + nx + " " + ny + " " + nz;
String image = " -image synthetic Cross 110 0 1 1 80.0 " + size;
String psf = " -psf synthetic Double-Helix 100 0 3 10 10 " + size;
for (int i = 0; i <= 1; i++) {
SignalCollector.resetSignals();
SignalCollector.clear();
Deconvolution d = new Deconvolution("noise", " -algorithm " + cmd + psf + image + " -display no");
boolean optimized = i == 1;
- d.getAlgo().setOptimizedMemoryFootprint(optimized);
- String n = d.getAlgo().getName();
+ d.getAlgorithm().setOptimizedMemoryFootprint(optimized);
+ String n = d.getAlgorithm().getName();
double chrono = System.nanoTime();
d.run();
String energy = "" + d.getOutput().getEnergy();
String time = NumFormat.time(System.nanoTime() - chrono);
int cp = SignalCollector.getCountPeakSignals();
int cs = SignalCollector.getCountSignals();
long bp = SignalCollector.getBytesPeakSignals();
long bs = SignalCollector.getBytesSignals();
double ratio = (bp + bs) / (nx * ny * nz * 4);
table.append(new String[] { n, cmd, "" + optimized, time, energy, "" + cp, NumFormat.bytes(bp), "" + cs, NumFormat.bytes(bs), NumFormat.nice(ratio) });
}
}
public static void main(String arg[]) {
new DeconvolutionLab2_MemoryFootprint();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_MemoryFootprint();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index fbf999e..8dc0a8e 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,456 +1,425 @@
/*
* 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 bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
+import deconvolutionlab.Constants;
import deconvolutionlab.Output;
-import deconvolutionlab.OutputCollection;
import deconvolutionlab.Output.View;
-import deconvolutionlab.modules.AbstractModule;
-import deconvolutionlab.modules.CommandModule;
+import deconvolutionlab.module.AbstractModule;
+import deconvolutionlab.module.CommandModule;
+import deconvolutionlab.monitor.ConsoleMonitor;
+import deconvolutionlab.monitor.Monitors;
+import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import fft.AbstractFFT;
-import fft.AbstractFFTLibrary;
import fft.FFT;
import signal.Constraint;
import signal.Operations;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
import wavelets.Wavelets;
public class Command {
public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-system", "-stats", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft", "-epsilon" };
private static AbstractModule modules[];
private static CommandModule command;
public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
return cmd;
}
-
- public static void decode(String command, Deconvolution deconvolution) {
-
- AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
- boolean flagSystem = true;
- boolean flagDisplay = true;
- boolean flagMultithreading = true;
- int monitor = 3;
- int stats = 0;
- 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.getFastestFFT();
+ public static Controller decodeController(String command) {
+
+ Controller controller = new Controller();
+
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;
+ controller.setPath(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);
+ controller.setMonitors(decodeMonitors(token.parameters));
+
+ if (token.keyword.equalsIgnoreCase("-verbose"))
+ controller.setVerbose(Verbose.getByName(token.parameters));
- if (token.keyword.equalsIgnoreCase("-display"))
- flagDisplay = decodeDisplay(token);
-
- if (token.keyword.equalsIgnoreCase("-multithreading"))
- flagMultithreading = decodeMultithreading(token);
+ if (token.keyword.equalsIgnoreCase("-system"))
+ controller.setSystem(decodeBoolean(token.parameters));
- if (token.keyword.equalsIgnoreCase("-verbose"))
- verbose = Verbose.getByName(token.parameters);
+ if (token.keyword.equalsIgnoreCase("-multithreading"))
+ controller.setMultithreading(decodeBoolean(token.parameters));
- if (token.keyword.equalsIgnoreCase("-fft"))
- fft = FFT.getLibraryByName(token.parameters);
+ if (token.keyword.equalsIgnoreCase("-display"))
+ controller.setDisplayFinal(decodeBoolean(token.parameters));
+
+ if (token.keyword.equalsIgnoreCase("-stats"))
+ controller.setStats(decodeStats(token));
- if (token.keyword.equalsIgnoreCase("-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);
-
+ controller.setConstraint(decodeConstraint(token));
+
if (token.keyword.equalsIgnoreCase("-time"))
- decodeController(token, controller);
-
+ controller.setTimeLimit(decodeTimeLimit(token));
+
if (token.keyword.equalsIgnoreCase("-residu"))
- decodeController(token, controller);
-
+ controller.setResiduMin(decodeResidu(token));
+
if (token.keyword.equalsIgnoreCase("-reference"))
- decodeController(token, controller);
+ controller.setReference(token.parameters);
+
+ if (token.keyword.equalsIgnoreCase("-pad"))
+ controller.setPadding(decodePadding(token));
+
+ if (token.keyword.equalsIgnoreCase("-apo"))
+ controller.setApodization(decodeApodization(token));
+
+ if (token.keyword.equalsIgnoreCase("-norm"))
+ controller.setNormalizationPSF(decodeNormalization(token));
+
+ if (token.keyword.equalsIgnoreCase("-epsilon"))
+ Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
+
+ if (token.keyword.equalsIgnoreCase("-fft"))
+ controller.setFFT(FFT.getLibraryByName(token.parameters).getDefaultFFT());
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equals("-out")) {
Output out = decodeOut(token);
if (out != null)
- outs.add(out);
+ controller.addOutput(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);
+ return controller;
}
-
+
+ public static AbstractAlgorithm decodeAlgorithm(String command) {
+ AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
+ ArrayList<Token> tokens = parse(command);
+ for (Token token : tokens) {
+ if (token.keyword.equalsIgnoreCase("-algorithm"))
+ algo = Command.decodeAlgorithm(token);
+ }
+ return algo;
+ }
+
/**
* This methods first segments the command line, then create all the tokens
* of the command line
*
* @param command
* Command line
* @return the list of tokens extracted from the command line
*/
public static ArrayList<Token> parse(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
ArrayList<Token> tokens = new ArrayList<Token>();
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
Token token = new Token(keyword, command, begin, end);
tokens.add(token);
}
return tokens;
}
public static Token extract(String command, String keyword) {
ArrayList<Token> tokens = parse(command);
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase(keyword))
return token;
return (Token) null;
}
public static double[] parseNumeric(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static ArrayList<CommandSegment> findSegment(String command, String keyword) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
String regex = "(?<!\\w)" + keyword + "(?!\\w)";
if (command == null)
return segments;
Matcher matcher = Pattern.compile(regex).matcher(command);
while (matcher.find()) {
segments.add(new CommandSegment(keyword, matcher.start()));
}
return segments;
}
public static String extractOptions(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
String options = "";
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
if (keyword != "-image" && keyword != "-psf" && keyword != "-algorithm")
options += keyword + " " + command.substring(begin, end);
}
return options;
}
- public static AbstractAlgorithm decodeAlgorithm(Token token, Controller controller) {
-
+ public static AbstractAlgorithm decodeAlgorithm(Token token) {
String option = token.option;
-
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
double params[] = parseNumeric(token.parameters);
+
if (params != null) {
algo.setParameters(params);
- if (algo.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()));
return out;
}
- public static void decodeController(Token token, Controller controller) {
- String line = token.parameters;
- if (token.parameters.startsWith("@")) {
- String parts[] = token.parameters.split(" ");
- if (parts.length >= 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 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) {
+ public static Stats 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;
+ for (String p : parts) {
+ if (p.startsWith("no") || p.equals("false") || p.equals("0"))
+ return new Stats(Stats.Mode.NO);
if (p.equals("1"))
- return 1;
+ return new Stats(Stats.Mode.SHOW);
if (p.equals("2"))
- return 2;
+ return new Stats(Stats.Mode.SAVE);
if (p.equals("3"))
- return 3;
+ return new Stats(Stats.Mode.SHOWSAVE);
if (p.equals("show"))
m += 1;
if (p.equals("save"))
m += 2;
}
- return m;
- }
+ if (m==1)
+ return new Stats(Stats.Mode.SHOW);
+ if (m==2)
+ return new Stats(Stats.Mode.SAVE);
+ if (m==3)
+ return new Stats(Stats.Mode.SHOWSAVE);
+ return new Stats(Stats.Mode.NO);
- public static 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) {
+ public static Constraint.Mode decodeConstraint(Token token) {
String p = token.parameters.toLowerCase();
+ if (p.startsWith("non"))
+ return Constraint.Mode.NONNEGATIVE;
if (p.startsWith("no"))
- return false;
+ return Constraint.Mode.NO;
+ if (p.startsWith("clip"))
+ return Constraint.Mode.CLIPPED;
if (p.equals("0"))
- return false;
- if (p.equals("false"))
- return false;
- return true;
+ return Constraint.Mode.NO;
+ return Constraint.Mode.NO;
}
- 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 double decodeResidu(Token token) {
+ if (token.parameters.toLowerCase().endsWith("no"))
+ return -1;
+ else
+ return NumFormat.parseNumber(token.parameters, 1);
+ }
+
+ public static double decodeTimeLimit(Token token) {
+ if (token.parameters.toLowerCase().endsWith("no"))
+ return -1;
+ else
+ return NumFormat.parseNumber(token.parameters, 1);
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
- 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);
+ int extXY = 0;
if (ext.length > 0)
extXY = (int) Math.round(ext[0]);
+ int extZ = 0;
if (ext.length > 1)
extZ = (int) Math.round(ext[1]);
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
public static Apodization decodeApodization(Token token) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
String[] parts = token.parameters.trim().split(" ");
if (parts.length >= 1)
apoXY = Apodization.getByShortname(parts[0].trim());
if (parts.length >= 2)
apoZ = Apodization.getByShortname(parts[1].trim());
return new Apodization(apoXY, apoXY, apoZ);
}
-
+
public static String getPath() {
command();
ArrayList<Token> tokens = parse(command.getCommand());
String path = System.getProperty("user.dir");
-
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
path = token.parameters;
return path;
}
-
-
+
+ public static Monitors decodeMonitors(String cmd) {
+ String parts[] = cmd.toLowerCase().split(" ");
+ Monitors monitors = new Monitors();
+ for (String p : parts) {
+ if (p.equals("0") || p.startsWith("no"))
+ monitors.clear();
+ if (p.equals("1") || p.startsWith("console"))
+ monitors.add(new ConsoleMonitor());
+ if (p.equals("2"))
+ monitors.add(new TableMonitor("Monitor", Constants.widthGUI, 240));
+ if (p.equals("3")) {
+ monitors.add(new ConsoleMonitor());
+ monitors.add(new TableMonitor("Monitor", Constants.widthGUI, 240));
+ }
+ if (p.equals("console"))
+ monitors.add(new ConsoleMonitor());
+ if (p.equals("table"))
+ monitors.add(new TableMonitor("Monitor", Constants.widthGUI, 240));
+ }
+ return monitors;
+ }
+
+ public static boolean decodeBoolean(String cmd) {
+ String p = cmd.toLowerCase();
+ if (p.startsWith("no"))
+ return false;
+ if (p.equals("0"))
+ return false;
+ if (p.equals("false"))
+ return false;
+ if (p.startsWith("dis"))
+ return false;
+ return true;
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolution/CommandSegment.java b/DeconvolutionLab2/src/deconvolution/CommandSegment.java
index 4738201..f261cf8 100644
--- a/DeconvolutionLab2/src/deconvolution/CommandSegment.java
+++ b/DeconvolutionLab2/src/deconvolution/CommandSegment.java
@@ -1,17 +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 deconvolution;
public class CommandSegment implements Comparable<CommandSegment> {
public String keyword;
public int index = 0;
public CommandSegment(String keyword, int index) {
this.keyword = keyword;
this.index = index;
}
@Override
public int compareTo(CommandSegment o) {
return index > o.index ? 1 : -1;
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 35cce6f..d6076c5 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,595 +1,393 @@
/*
* 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 bilib.tools.NumFormat;
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.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
-import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.system.SystemInfo;
-import fft.AbstractFFTLibrary;
import signal.RealSignal;
import signal.SignalCollector;
-import signal.apodization.Apodization;
-import signal.factory.SignalFactory;
-import signal.padding.Padding;
+/**
+ * This class is the main class to run deconvolution with or without user interface.
+ *
+ * All the parameters are given in the command line (String variable command).
+ *
+ * @author Daniel Sage
+ *
+ */
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
- public AbstractAlgorithm algo = null;
-
- private String path;
- public double norm = 1.0;
- public Padding pad = new Padding();
- public 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;
-
- public Monitors monitors = new Monitors();
-
+ private AbstractAlgorithm algo = null;
+ private Controller controller = new Controller();
private String command = "";
- private boolean live = false;
-
private Features report = new Features();
-
private String name = "";
-
- private ArrayList<DeconvolutionListener> listeners = new ArrayList<DeconvolutionListener>();
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
-
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
- private TableStats tableStats;
-
public Deconvolution(String name, String command) {
- this.name = name;
+ this.name = name;
this.finish = Finish.DIE;
setCommand(command);
- tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
- tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
}
public void setCommand(String command) {
this.command = command;
- Command.decode(command, this);
+ controller = Command.decodeController(command);
+ algo = Command.decodeAlgorithm(command);
+ algo.setController(controller);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortnames()[0];
- live = false;
}
- /**
- * This method runs the deconvolution without graphical user interface.
- *
- * @param exit
- * System.exit call is true
- */
+ public RealSignal deconvolve() {
+ return deconvolve(image, psf);
+ }
+
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
- runDeconvolve();
- return deconvolvedImage;
- }
+ for(AbstractMonitor monitor : controller.getMonitors())
+ if (monitor instanceof TableMonitor)
+ Lab.setVisible(((TableMonitor)monitor).getPanel(), "Monitor of " + name, 10, 10);
- public RealSignal deconvolve() {
- this.image = null;
- this.psf = null;
- runDeconvolve();
- return deconvolvedImage;
- }
-
- /**
- * This method runs the deconvolution without graphical user interface.
- *
- * @param exit
- * System.exit call is true
- */
- private void runDeconvolve() {
- if ((flagMonitor & 2) == 2) {
- TableMonitor tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
- monitors.add(tableMonitor);
- Lab.setVisible(tableMonitor.getPanel(), "Monitor of " + name, 10, 10);
- }
-
- if ((flagMonitor & 1) == 1)
- monitors.add(new ConsoleMonitor());
-
- if ((flagStats & 1) == 1) {
- Lab.setVisible(tableStats.getPanel(), "Stats of " + name, 50, 50);
- }
-
- if (fft == null) {
+ if (controller.getFFT() == null) {
run();
- return;
+ return deconvolvedImage;
}
-
- if (!fft.isMultithreadable()) {
+
+ if (!controller.getFFT().isMultithreadable()) {
run();
- return;
+ return deconvolvedImage;
}
- if (flagMultithreading) {
+ if (controller.isMultithreading()) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
- }
-
+ }
+ return deconvolvedImage;
}
/**
* This method runs the deconvolution with a graphical user interface.
- *
- * @param job
- * Name of the job of deconvolution
*/
public void launch() {
- monitors = new Monitors();
TableMonitor tableMonitor = null;
- if ((flagMonitor & 2) == 2) {
- tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
- monitors.add(tableMonitor);
- }
- if ((flagMonitor & 1) == 1)
- monitors.add(new ConsoleMonitor());
- if (flagStats == 0) {
- tableStats = null;
- }
-
- dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this, tableMonitor, tableStats);
- monitors.add(new StatusMonitor(dialog.getProgressBar()));
+ for(AbstractMonitor monitor : controller.getMonitors())
+ if (monitor instanceof TableMonitor)
+ tableMonitor = (TableMonitor)monitor;
+
+ dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this, tableMonitor, controller.getStats());
+ controller.getMonitors().add(new StatusMonitor(dialog.getProgressBar()));
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
-
- if (flagSystem)
+ Monitors monitors = controller.getMonitors();
+
+ if (controller.isSystem())
SystemInfo.activate();
- for (DeconvolutionListener listener : listeners)
- listener.started();
-
- live = true;
- if (monitors != null)
- monitors.setVerbose(verbose);
+ report.add("Path", controller.toStringPath());
- report.add("Path", checkPath(path));
- monitors.log("Path: " + checkPath(path));
-
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
- monitors.log("PSF: " + psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
- Controller controller = algo.getController();
- if (controller == null) {
- monitors.error("Controller: not valid");
- if (finish == Finish.KILL)
- System.exit(-104);
- return;
- }
-
- 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("FFT", controller.getFFT().getName());
report.add("Algorithm", algo.getName());
- algo.setController(controller);
-
- algo.setFFT(fft);
- algo.setMonitors(monitors);
-
- deconvolvedImage = algo.run(image, psf, pad, apo, norm);
- live = false;
- for (DeconvolutionListener listener : listeners)
- listener.finish();
+ algo.setController(controller);
+ deconvolvedImage = algo.run(image, psf, controller.getStats());
report.add("End", NumFormat.time(System.nanoTime() - chrono));
- if (flagDisplay)
+ if (controller.isDisplayFinal())
Lab.show(monitors, deconvolvedImage, "Result of " + algo.getShortnames()[0]);
if (finish == Finish.KILL) {
System.out.println("End");
System.exit(0);
}
if (finish == Finish.DIE)
die();
}
-
public void close() {
if (dialog != null)
dialog.dispose();
SignalCollector.free(image);
SignalCollector.free(psf);
SignalCollector.free(deconvolvedImage);
algo = null;
image = null;
psf = null;
deconvolvedImage = null;
- monitors = null;
System.gc();
}
-
+
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
-
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
Token image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
-
+ double norm = controller.getNormalizationPSF();
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReference());
features.add("Constraint", controller.getConstraintAsString());
- features.add("Padding", pad.toString());
- features.add("Apodization", apo.toString());
- features.add("FFT", fft == null ? "null" : fft.getLibraryName());
+ features.add("Padding", controller.getPadding().toString());
+ features.add("Apodization", controller.getApodization().toString());
+ features.add("FFT", controller.getFFT() == null ? "null" : controller.getFFT().getName());
}
- features.add("Path", path);
-
- String monitor = "";
- if (flagMonitor == 0)
- monitor = "no ";
- if (flagMonitor == 1)
- monitor = "console (" + verbose.name().toLowerCase() + ")";
- if (flagMonitor == 2)
- monitor = "table (" + verbose.name().toLowerCase() + ")";
- if (flagMonitor == 3)
- monitor = "console table (" + verbose.name().toLowerCase() + ")";
- String stats = "";
- if (flagStats == 0)
- stats = "no ";
- if (flagStats == 1)
- stats = "show ";
- if (flagStats == 2)
- stats = "save ";
- if (flagStats == 3)
- 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)
- features.add("Output", "not valid");
- else
- for (Output out : outs)
- features.add("Output " + out.getName(), out.toString());
+ features.add("Path", controller.getPath());
+
+ features.add("Monitor", controller.toStringMonitor());
+ if (controller.getStats() != null)
+ features.add("Stats", controller.getStats().toStringStats());
+ features.add("Running", controller.toStringRunning());
+
+ for (Output out : controller.getOuts())
+ features.add("Output " + out.getName(), out.toString());
return features;
}
-
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
- features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi*4));
- features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
+ features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi * 4));
+ features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
- features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
+ features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
-
- public boolean isLive() {
- return live;
- }
public void abort() {
- live = false;
algo.getController().abort();
}
- 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;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
- image = createRealSignal(monitors, arg, cmd, path);
+ image = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return image;
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
- psf = createRealSignal(monitors, arg, cmd, path);
+ psf = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return psf;
}
private static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
if (arg.equalsIgnoreCase("synthetic")) {
signal = Lab.createSynthetic(monitors, cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = Lab.getImage(monitors, cmd);
}
-
+
if (arg.equalsIgnoreCase("file")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.openFile(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.openFile(monitors, cmd);
}
}
}
-
+
if (arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
}
return signal;
}
- public void addDeconvolutionListener(DeconvolutionListener listener) {
- listeners.add(listener);
- }
-
- public OutputCollection getOuts() {
- return outs;
- }
-
- public void setAlgorithm(AbstractAlgorithm algo, Controller controller) {
+ public void setAlgorithm(AbstractAlgorithm algo) {
this.algo = algo;
- if (algo != null && controller != null) {
- algo.setController(controller);
- }
}
- public AbstractAlgorithm getAlgo() {
+ public AbstractAlgorithm getAlgorithm() {
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 setController(Controller controller) {
+ this.controller = controller;
}
- public void setPadding(Padding pad) {
- this.pad = pad;
- }
-
- public Padding getPadding() {
- return pad;
+ public Controller getController() {
+ return controller;
}
public RealSignal getOutput() {
return deconvolvedImage;
}
public RealSignal getImage() {
return image;
}
public RealSignal getPSF() {
return psf;
}
public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
-
- public 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 Monitors getMonitors() {
+ return controller.getMonitors();
}
public String getCommand() {
return command;
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index c99c3d4..86340c8 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,379 +1,374 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JToolBar;
import bilib.component.BorderToggledButton;
import bilib.component.PanelImage;
-import deconvolution.modules.AlgorithmDModule;
-import deconvolution.modules.ImageDModule;
-import deconvolution.modules.PSFDModule;
-import deconvolution.modules.RecapDModule;
-import deconvolution.modules.ReportDModule;
+import deconvolution.capsule.AlgorithmCapsule;
+import deconvolution.capsule.ImageCapsule;
+import deconvolution.capsule.PSFCapsule;
+import deconvolution.capsule.RecapCapsule;
+import deconvolution.capsule.ReportCapsule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
-import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
public class DeconvolutionDialog extends JDialog implements WindowListener, ActionListener, Runnable {
public enum State {
NOTDEFINED, READY, RUN, FINISH
};
public enum Module {
ALL, RECAP, IMAGE, PSF, ALGO
};
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 Thread thread = null;
private Deconvolution deconvolution;
private JProgressBar progress = new JProgressBar();
public static Point location = new Point(0, 0);
private JPanel cards = new JPanel(new CardLayout());
private boolean flagMonitor = false;
private boolean flagStats = false;
- private ImageDModule image;
- private PSFDModule psf;
- private RecapDModule recap;
- private AlgorithmDModule algorithm;
- private ReportDModule report;
+ private ImageCapsule image;
+ private PSFCapsule psf;
+ private RecapCapsule recap;
+ private AlgorithmCapsule algorithm;
+ private ReportCapsule report;
- private TableStats tableStats;
private TableMonitor tableMonitor;
- public DeconvolutionDialog(Module module, Deconvolution deconvolution, TableMonitor tableMonitor, TableStats tableStats) {
+ public DeconvolutionDialog(Module module, Deconvolution deconvolution, TableMonitor tableMonitor, Stats stats) {
super(new JFrame(), deconvolution.getName());
this.deconvolution = deconvolution;
this.tableMonitor = tableMonitor;
- this.tableStats = tableStats;
- image = new ImageDModule(deconvolution);
- psf = new PSFDModule(deconvolution);
- recap = new RecapDModule(deconvolution);
- algorithm = new AlgorithmDModule(deconvolution);
- report = new ReportDModule(deconvolution);
+ image = new ImageCapsule(deconvolution);
+ psf = new PSFCapsule(deconvolution);
+ recap = new RecapCapsule(deconvolution);
+ algorithm = new AlgorithmCapsule(deconvolution);
+ report = new ReportCapsule(deconvolution);
// Panel status bar on bottom
progress.setAlignmentX(JLabel.CENTER_ALIGNMENT);
progress.setBorder(BorderFactory.createLoweredBevelBorder());
JToolBar statusBar = new JToolBar();
statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
statusBar.setFloatable(false);
statusBar.setLayout(new BorderLayout());
statusBar.add(bnHelp, BorderLayout.WEST);
statusBar.add(progress, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
// Panel bottom
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
// Panel buttons
if (module == Module.ALL) {
PanelImage buttons = new PanelImage("celegans.jpg");
buttons.setLayout(new FlowLayout());
buttons.setBorder(BorderFactory.createEtchedBorder());
buttons.add(bnReset);
buttons.add(bnStop);
buttons.add(bnStart);
bottom.add(buttons);
}
bottom.add(statusBar);
// Panel Image
cards.add(recap.getName(), recap.getPane());
cards.add(image.getName(), image.getPane());
cards.add(psf.getName(), psf.getPane());
cards.add(algorithm.getName(), algorithm.getPane());
cards.add(report.getName(), report.getPane());
if (tableMonitor != null)
cards.add("Monitor", tableMonitor.getPanel());
- if (tableStats != null)
- cards.add("Stats", tableStats.getPanel());
+ if (stats != null)
+ cards.add("Stats", stats.getPanel());
// Panel Main
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(cards, BorderLayout.CENTER);
panel.add(bottom, BorderLayout.SOUTH);
// Panel tool with all buttons
if (module == Module.ALL) {
JToolBar tool = new JToolBar();
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 6));
tool.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tool.add(bnRecap);
tool.add(bnImage);
tool.add(bnPSF);
tool.add(bnAlgo);
if (tableMonitor != null)
tool.add(bnMonitor);
- if (tableStats != null)
+ if (stats != null)
tool.add(bnStats);
tool.add(bnReport);
panel.add(tool, BorderLayout.NORTH);
}
add(panel);
bnReset.addActionListener(this);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnStop.addActionListener(this);
bnHelp.addActionListener(this);
bnImage.addActionListener(this);
bnPSF.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
if (tableMonitor != null)
bnMonitor.addActionListener(this);
- if (tableStats != null)
+ if (stats != null)
bnStats.addActionListener(this);
bnReport.addActionListener(this);
this.addWindowListener(this);
setMinimumSize(new Dimension(Constants.widthGUI, 400));
setPreferredSize(new Dimension(Constants.widthGUI, 400));
pack();
Config.registerFrame("DeconvolutionLab", "DeconvolutionDialog", this);
Rectangle rect = Config.getDialog("DeconvolutionLab.DeconvolutionDialog");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
bnStop.setEnabled(false);
if (module == Module.ALL) {
toggle(bnRecap);
recap.update();
}
if (module == Module.IMAGE) {
toggle(bnImage);
- deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
+ deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
image.update();
}
if (module == Module.PSF) {
toggle(bnPSF);
- deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
+ deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
psf.update();
}
if (module == Module.ALGO) {
toggle(bnAlgo);
- deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
+ deconvolution.getMonitors().add(new StatusMonitor(getProgressBar()));
algorithm.update();
}
if (module == Module.RECAP) {
toggle(bnRecap);
recap.update();
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
if (flagMonitor)
toggle(bnMonitor);
else if (flagStats)
toggle(bnStats);
if (thread == null) {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnStop) {
toggle(bnReport);
if (deconvolution != null)
deconvolution.abort();
}
else if (e.getSource() == bnImage) {
toggle(bnImage);
image.update();
}
else if (e.getSource() == bnPSF) {
toggle(bnPSF);
psf.update();
}
else if (e.getSource() == bnAlgo) {
toggle(bnAlgo);
algorithm.update();
}
else if (e.getSource() == bnRecap) {
toggle(bnRecap);
recap.update();
}
else if (e.getSource() == bnReport) {
toggle(bnReport);
report.update();
}
else if (e.getSource() == bnReset) {
toggle(bnRecap);
if (tableMonitor != null)
tableMonitor.clear();
- if (tableStats != null)
- tableStats.clear();
bnStart.setEnabled(true);
}
else if (e.getSource() == bnQuit) {
deconvolution.close();
deconvolution = null;
dispose();
}
else if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnMonitor)
toggle(bnMonitor);
else if (e.getSource() == bnStats)
toggle(bnStats);
}
@Override
public void run() {
bnRecap.setEnabled(false);
bnImage.setEnabled(false);
bnPSF.setEnabled(false);
bnAlgo.setEnabled(false);
bnStart.setEnabled(false);
bnStop.setEnabled(true);
deconvolution.setCommand(recap.getCommand());
deconvolution.run();
toggle(bnReport);
bnStop.setEnabled(false);
report.update();
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
thread = null;
}
public static void setLocationLaunch(Point l) {
location = l;
}
private void toggle(BorderToggledButton bn) {
((CardLayout) (cards.getLayout())).show(cards, bn.getText());
bnRecap.setSelected(false);
bnImage.setSelected(false);
bnPSF.setSelected(false);
bnAlgo.setSelected(false);
bnMonitor.setSelected(false);
bnStats.setSelected(false);
bnReport.setSelected(false);
bn.setSelected(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
deconvolution.close();
deconvolution = null;
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
public JProgressBar getProgressBar() {
return progress;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionListener.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionListener.java
deleted file mode 100644
index fe4542b..0000000
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionListener.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package deconvolution;
-
-public interface DeconvolutionListener {
-
- public abstract void started();
- public abstract void finish();
-}
diff --git a/DeconvolutionLab2/src/deconvolution/Features.java b/DeconvolutionLab2/src/deconvolution/Features.java
index 23f2a0c..ab814dd 100644
--- a/DeconvolutionLab2/src/deconvolution/Features.java
+++ b/DeconvolutionLab2/src/deconvolution/Features.java
@@ -1,16 +1,47 @@
+/*
+ * 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;
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/RegularizationPanel.java b/DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
index d1f116d..ce04632 100644
--- a/DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/RegularizationPanel.java
@@ -1,83 +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 deconvolution;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Hashtable;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import bilib.tools.NumFormat;
public class RegularizationPanel extends JPanel {
private JSlider slider = new JSlider();
private JTextField txt = new JTextField(10);
private double base = Math.pow(10, 1. / 3.0);
private double logbase = Math.log(base);
public RegularizationPanel(double value) {
setLayout(new BorderLayout());
slider.setMinimum(-54);
slider.setMaximum(30);
slider.setPreferredSize(new Dimension(200, 40));
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
Hashtable<Integer, JLabel> labels = new Hashtable<Integer, JLabel>();
JLabel lbl0 = new JLabel("Off");
JLabel lbl1 = new JLabel("Low");
JLabel lbl2 = new JLabel("High");
JLabel lbl4 = new JLabel("1E-6");
JLabel lbl5 = new JLabel("1.0");
java.awt.Font font = lbl1.getFont();
java.awt.Font small = new java.awt.Font(font.getFamily(), font.getStyle(), font.getSize() - 3);
lbl0.setFont(small);
lbl1.setFont(small);
lbl2.setFont(small);
lbl4.setFont(small);
lbl5.setFont(small);
labels.put(-54, lbl0);
labels.put(-36, lbl1);
labels.put(-18, lbl4);
labels.put(0, lbl5);
labels.put(27, lbl2);
slider.setMinorTickSpacing(3);
// js.setSnapToTicks(true);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.setMajorTickSpacing(9);
slider.setLabelTable(labels);
add(new JLabel("<html>Reg. &lambda;</html>"), BorderLayout.WEST);
add(slider, BorderLayout.CENTER);
add(txt, BorderLayout.EAST);
}
public JSlider getSlider() {
return slider;
}
public JTextField getText() {
return txt;
}
public void updateFromSlider() {
double d = Math.pow(base, slider.getValue());
d = Math.min(d, Math.pow(base, slider.getMaximum()));
d = Math.max(d, Math.pow(base, slider.getMinimum()));
txt.setText(NumFormat.nice(d));
}
public void updateFromText() {
String typed = txt.getText();
double value = NumFormat.parseNumber(typed, 1);
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
}
public double getValue() {
return Math.pow(base, slider.getValue());
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Stats.java b/DeconvolutionLab2/src/deconvolution/Stats.java
new file mode 100644
index 0000000..a753b08
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/Stats.java
@@ -0,0 +1,159 @@
+/*
+ * DeconvolutionLab2
+ *
+ * Conditions of use: You are free to use this software for research or
+ * educational purposes. In addition, we expect you to include adequate
+ * citations and acknowledgments whenever you present or publish results that
+ * are based on it.
+ *
+ * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
+ * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
+ * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
+ */
+
+/*
+ * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
+ *
+ * This file is part of DeconvolutionLab2 (DL2).
+ *
+ * DL2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * DL2. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package deconvolution;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.io.File;
+import java.util.ArrayList;
+
+import javax.swing.BorderFactory;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import bilib.table.CustomizedColumn;
+import bilib.table.CustomizedTable;
+import bilib.tools.NumFormat;
+import deconvolutionlab.Constants;
+import deconvolutionlab.Lab;
+import deconvolutionlab.monitor.Monitors;
+import deconvolutionlab.system.SystemUsage;
+import signal.RealSignal;
+import signal.SignalCollector;
+
+public class Stats {
+
+ public enum Mode {NO, SHOW, SAVE, SHOWSAVE};
+
+ private CustomizedTable table;
+ private float[] statsInput;
+ private Mode mode;
+
+ public Stats(Mode mode) {
+ this.mode = mode;
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
+ columns.add(new CustomizedColumn("Mean", String.class, 100, false));
+ columns.add(new CustomizedColumn("Minimum", String.class, 100, false));
+ columns.add(new CustomizedColumn("Maximum", String.class, 100, false));
+ columns.add(new CustomizedColumn("Stdev", String.class, 100, false));
+ columns.add(new CustomizedColumn("Energy", String.class, 100, false));
+ columns.add(new CustomizedColumn("Time", String.class, 100, false));
+ columns.add(new CustomizedColumn("Memory", String.class, 100, false));
+ columns.add(new CustomizedColumn("Signal", String.class, 100, false));
+ columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
+ columns.add(new CustomizedColumn("SNR", String.class, 100, false));
+ columns.add(new CustomizedColumn("Residu", String.class, 100, false));
+ table = new CustomizedTable(columns, true);
+ }
+
+ public void show() {
+ if (mode == Mode.SHOW || mode == Mode.SHOWSAVE) {
+ JFrame frame = new JFrame("Stats");
+ frame.getContentPane().add(getPanel());
+ frame.pack();
+ Lab.setVisible(frame);
+ }
+ }
+
+ public void save(Monitors monitors, String path) {
+ if (mode == Mode.SAVE || mode == Mode.SHOWSAVE) {
+ String filename = path + File.separator + "stats.csv";
+ monitors.log("Stats save " + filename);
+ table.saveCSV(filename);
+ }
+
+ }
+
+ public void addInput(RealSignal x) {
+ statsInput = x.getStats();
+ table.append(compute(x, 0, "", "", "", ""));
+ }
+
+ public void add(RealSignal x, int iterations) {
+ table.append(compute(x, iterations, "", "", "", ""));
+ }
+
+ public void add(RealSignal x, int iterations, String time, String psnr, String snr, String residu) {
+ table.append(compute(x, iterations, time, psnr, snr, residu));
+ }
+
+ public String[] compute(RealSignal x, int iterations, String time, String psnr, String snr, String residu) {
+ float params[] = null;
+ if (x != null)
+ params = x.getStats();
+ String[] row = new String[12];
+ row[0] = "" + iterations;
+ row[1] = (params == null ? "-" : "" + params[0]);
+ row[2] = (params == null ? "-" : "" + params[1]);
+ row[3] = (params == null ? "-" : "" + params[2]);
+ row[4] = (params == null ? "-" : "" + params[3]);
+ row[5] = (params == null ? "-" : "" + params[5]);
+ row[6] = time;
+ row[7] = NumFormat.bytes(SystemUsage.getHeapUsed());
+ row[8] = SignalCollector.sumarize();
+ row[9] = psnr;
+ row[10] = snr;
+ row[11] = residu;
+
+ return row;
+ }
+
+ public JPanel getPanel() {
+ JScrollPane scroll = new JScrollPane(table);
+ scroll.setPreferredSize(new Dimension(Constants.widthGUI, 400));
+ JPanel panel = new JPanel(new BorderLayout());
+ panel = new JPanel(new BorderLayout());
+ panel.add(scroll);
+ panel.setBorder(BorderFactory.createEtchedBorder());
+ return panel;
+ }
+
+ public String toStringStats() {
+ if (mode == Mode.SHOW)
+ return "show";
+ if (mode == Mode.SAVE)
+ return "save";
+ if (mode == Mode.SHOWSAVE)
+ return "show and save";
+ return "no";
+ }
+
+ public Mode getMode() {
+ return mode;
+ }
+ public float[] getStatsInput() {
+ return statsInput;
+ }
+
+}
diff --git a/DeconvolutionLab2/src/deconvolution/Token.java b/DeconvolutionLab2/src/deconvolution/Token.java
index c556f42..3b1cc05 100644
--- a/DeconvolutionLab2/src/deconvolution/Token.java
+++ b/DeconvolutionLab2/src/deconvolution/Token.java
@@ -1,53 +1,86 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolution;
+/*
+ * 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() : "";
+ try {
+ this.parameters = command.substring(begin, end).trim();
+ String arg[] = parameters.split(" ");
+ option = arg.length >= 1 ? arg[0].trim() : "";
+ }
+ catch(Exception ex) {
+ option = "";
+ }
}
@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 ebafedf..b24857d 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,269 +1,398 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
+import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import bilib.tools.NumFormat;
+import deconvolution.Stats;
+import deconvolutionlab.Output;
import deconvolutionlab.monitor.Monitors;
+import deconvolutionlab.monitor.Verbose;
import fft.AbstractFFT;
-import fft.AbstractFFTLibrary;
import fft.FFT;
-import signal.Operations;
+import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h;
- /**
- * The controller takes the control of the algorithm, in particular to do
- * some operations at the starting, at every iteration and at the end.
- */
- protected Controller controller;
-
- /** This is the FFT used. */
- protected AbstractFFT fft ;
-
- protected Monitors monitors;
- protected AbstractFFTLibrary fftlib;
protected boolean threaded;
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint;
+ protected int iterMax = 0;
+
+ protected AbstractFFT fft;
+ protected Controller controller;
+
public AbstractAlgorithm() {
- this.controller = new Controller();
- monitors = Monitors.createDefaultMonitor();
- fftlib = FFT.getFastestFFT();
+ setController(new Controller());
optimizedMemoryFootprint = true;
threaded = true;
+ fft = FFT.getFastestFFT().getDefaultFFT();
+ }
+
+ public AbstractAlgorithm(Controller controller) {
+ this.controller = controller;
+ optimizedMemoryFootprint = true;
+ threaded = true;
+ fft = FFT.getFastestFFT().getDefaultFFT();
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract String[] getShortnames();
-
public abstract double getMemoryFootprintRatio();
-
public abstract int getComplexityNumberofFFT();
-
public abstract boolean isRegularized();
-
public abstract boolean isStepControllable();
-
public abstract boolean isIterative();
-
public abstract boolean isWaveletsBased();
-
public abstract void setParameters(double[] params);
-
public abstract double getRegularizationFactor();
-
public abstract double getStepFactor();
-
public abstract double[] getParameters();
-
public abstract double[] getDefaultParameters();
public RealSignal run(RealSignal image, RealSignal psf) {
- return run(image, psf, new Padding(), new Apodization(), 1);
+ return run(image, psf, new Stats(Stats.Mode.NO));
}
- public RealSignal run(RealSignal image, RealSignal psf, Padding pad, Apodization apo) {
- return run(image, psf, pad, apo, 1);
- }
-
- public RealSignal run(RealSignal image, RealSignal psf, Padding pad, Apodization apo, double norm) {
+ public RealSignal run(RealSignal image, RealSignal psf, Stats stats) {
+ Padding pad = controller.getPadding();
+ Apodization apo = controller.getApodization();
+ double norm = controller.getNormalizationPSF();
+
+ fft = controller.getFFT();
+ controller.setIterationsMax(iterMax);
if (image == null)
return null;
+
if (psf == null)
return null;
-
- 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);
-
+
+ // Prepare the controller and the outputs
+
+ Monitors monitors = controller.getMonitors();
+ monitors.setVerbose(controller.getVerbose());
+ monitors.log("Path: " + controller.toStringPath());
+ monitors.log("Algorithm: " + getName());
+
+ // Prepare the signal and the PSF
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
-
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
- String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
+ String iterations = (isIterative() ? iterMax + " iterations" : "direct");
+
+ controller.setIterationsMax(iterMax);
+
monitors.log(getShortnames()[0] + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
- controller.start(y);
-
+
+ controller.start(y, stats);
h.circular();
- if (fft == null)
- fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
- else
- fft.init(monitors, y.nx, y.ny, y.nz);
+
+ // FFT
+ fft.init(monitors, y.nx, y.ny, y.nz);
+ controller.setFFT(fft);
+
monitors.log(getShortnames()[0] + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortnames()[0] + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
- x.setName("x");
- controller.finish(x);
- monitors.log(getName() + " is finished");
SignalCollector.free(y);
SignalCollector.free(h);
-
+ x.setName("x");
RealSignal result = pad.crop(monitors, x);
+
+ controller.finish(result);
+ monitors.log(getName() + " is finished");
+
SignalCollector.free(x);
result.setName("Output of " + this.getShortnames()[0]);
return result;
}
- public Monitors getMonitors() {
- return monitors;
- }
-
- public void setMonitors(Monitors monitors) {
- this.monitors = monitors;
- }
-
- public AbstractFFT getFFT() {
- return fft;
- }
-
- public void setFFT(AbstractFFT fft) {
- this.fft = fft;
- }
-
- public void setFFT(AbstractFFTLibrary fftlib) {
- this.fftlib = fftlib;
+ public void setController(Controller controller) {
+ this.controller = controller;
}
public Controller getController() {
return controller;
}
- public void setController(Controller controller) {
- this.controller = controller;
+ public int getIterationsMax() {
+ return iterMax;
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
- s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
+ s += (isIterative() ? ", " + iterMax + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for (int i = 0; i < p.length; i++)
if (i == p.length - 1)
param += p[i];
else
param += p[i] + ", ";
return param;
}
+
+
+ public AbstractFFT getFFT() {
+ return controller.getFFT();
+ }
+
+ public void setFFT(AbstractFFT fft) {
+ this.fft = fft;
+ controller.setFFT(fft);
+ }
+
+ public String getPath() {
+ return controller.getPath();
+ }
+
+ public void setPath(String path) {
+ controller.setPath(path);
+ }
+
+ public boolean isSystem() {
+ return controller.isSystem();
+ }
+
+ public void setSystem(boolean system) {
+ controller.setSystem(system);
+ }
+
+ public boolean isMultithreading() {
+ return controller.isMultithreading();
+ }
+
+ public void setMultithreading(boolean multithreading) {
+ controller.setMultithreading(multithreading);
+ }
+
+ public boolean isDisplayFinal() {
+ return controller.isDisplayFinal();
+ }
+
+ public void setDisplayFinal(boolean displayFinal) {
+ controller.setDisplayFinal(displayFinal);
+ }
+
+ public double getNormalizationPSF() {
+ return controller.getNormalizationPSF();
+ }
+
+ public void setNormalizationPSF(double normalizationPSF) {
+ controller.setNormalizationPSF(normalizationPSF);
+ }
+
+ public double getEpsilon() {
+ return controller.getEpsilon();
+ }
+
+ public void setEpsilon(double epsilon) {
+ controller.setEpsilon(epsilon);
+ }
+
+ public Padding getPadding() {
+ return controller.getPadding();
+ }
+
+ public void setPadding(Padding padding) {
+ controller.setPadding(padding);
+ }
+
+ public Apodization getApodization() {
+ return controller.getApodization();
+ }
+
+ public void setApodization(Apodization apodization) {
+ controller.setApodization(apodization);
+ }
+
+ public Monitors getMonitors() {
+ return controller.getMonitors();
+ }
+
+ public void setMonitors(Monitors monitors) {
+ controller.setMonitors(monitors);
+ }
+
+ public Verbose getVerbose() {
+ return controller.getVerbose();
+ }
+
+ public void setVerbose(Verbose verbose) {
+ controller.setVerbose(verbose);
+ }
+
+ public Constraint.Mode getConstraint() {
+ return controller.getConstraint();
+ }
+
+ public void setConstraint(Constraint.Mode constraint) {
+ controller.setConstraint(constraint);
+ }
+
+ public Stats getStats() {
+ return controller.getStats();
+ }
+
+ public void setStats(Stats stats) {
+ controller.setStats(stats);
+ }
+
+ public double getResiduMin() {
+ return controller.getResiduMin();
+ }
+
+ public void setResiduMin(double residuMin) {
+ controller.setResiduMin(residuMin);
+ }
+
+ public double getTimeLimit() {
+ return controller.getTimeLimit();
+ }
+
+ public void setTimeLimit(double timeLimit) {
+ controller.setTimeLimit(timeLimit);
+ }
+
+ public String getReference() {
+ return controller.getReference();
+ }
+
+ public void setReference(String reference) {
+ controller.setReference(reference);
+ }
+
+ public ArrayList<Output> getOuts() {
+ return controller.getOuts();
+ }
+
+ public void setOuts(ArrayList<Output> outs) {
+ controller.setOuts(outs);
+ }
+
+ public void addOutput(Output out) {
+ controller.addOutput(out);
+ }
+
+
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index e1bc26b..5701561 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,353 +1,638 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
+import java.io.File;
+import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
-import deconvolutionlab.OutputCollection;
-import deconvolutionlab.TableStats;
+import deconvolution.Stats;
+import deconvolutionlab.Constants;
+import deconvolutionlab.Output;
+import deconvolutionlab.monitor.AbstractMonitor;
+import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
+import deconvolutionlab.monitor.TableMonitor;
+import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFT;
import fft.FFT;
import signal.Assessment;
import signal.ComplexSignal;
import signal.Constraint;
import signal.RealSignal;
-import signal.SignalCollector;
+import signal.apodization.Apodization;
+import signal.padding.Padding;
/**
- * This is an important class to manage all the common task
- * of the algorithm.
- * The method start() is called before at the starting of the
- * algorithm.
- * The method ends() is called at the end of every iterations
- * for the iterative algorithm. It returns true if one the
- * stopping criteria is true.
- * The method finish() is called when the algorithm is completely
- * terminated.
+ * This is an important class to manage all the common task of the algorithm.
+ * The method start() is called before at the starting of the algorithm. The
+ * method ends() is called at the end of every iterations for the iterative
+ * algorithm. It returns true if one the stopping criteria is true. The method
+ * finish() is called when the algorithm is completely terminated.
*
- * @author sage
+ * @author Daniel Sage
*
*/
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 path;
+ private boolean system;
+ private boolean multithreading;
+ private boolean displayFinal;
+ private double normalizationPSF;
+ private double epsilon;
+
+ private Padding padding;
+ private Apodization apodization;
+ private ArrayList<Output> outs;
+ private Stats stats;
+ private Constraint.Mode constraintMode;
+ private double residuMin;
+ private double timeLimit;
+ private String reference;
+ private Monitors monitors;
+ private Verbose verbose;
+ private AbstractFFT fft;
+
+ private int iterationsMax = 100;
+
+ private boolean doResidu = false;
+ private boolean doTime = false;
+ private boolean doReference = false;
+ private boolean doConstraint = false;
+ private boolean abort = false;
+
+ private double timeStarting = 0;
+ private double memoryStarting = 0;
+ private double residu = Double.MAX_VALUE;
+ private int iterations = 0;
+ private double memoryPeak = 0;
+ private double snr = 0;
+ private double psnr = 0;
+
private RealSignal refImage;
private RealSignal prevImage;
private RealSignal x;
-
- private Timer timer;
- private AbstractFFT fft;
-
- private TableStats tableStats;
- private float[] statsInput;
- private Monitors monitors = new Monitors();
+ private Timer timer;
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;
+ timeStarting = System.nanoTime();
+
+ setPath(System.getProperty("user.dir"));
+ setSystem(true);
+ setMultithreading(true);
+ setDisplayFinal(true);
+ setFFT(FFT.getFastestFFT().getDefaultFFT());
+ setNormalizationPSF(1);
+ setEpsilon(1e-6);
+ setPadding(new Padding());
+ setApodization(new Apodization());
+
+ monitors = new Monitors();
+ monitors.add(new ConsoleMonitor());
+ monitors.add(new TableMonitor("Monitor", Constants.widthGUI, 240));
+
+ setVerbose(Verbose.Log);
+ setStats(new Stats(Stats.Mode.NO));
+ setConstraint(Constraint.Mode.NO);
+ setResiduMin(-1);
+ setTimeLimit(-1);
+ setReference("");
+ setOuts(new ArrayList<Output>());
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
- public int getIterationMax() {
- return iterationsMax;
- }
-
- public void setIterationMax(int iterationsMax) {
+ public void setIterationsMax(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 boolean needSpatialComputation() {
return doConstraint || doResidu || doReference;
}
-
- public void start(RealSignal x) {
+
+ /**
+ * Call one time at the beginning of the algorithms
+ *
+ * @param x
+ * the input signal
+ */
+ public void start(RealSignal x, Stats stats) {
this.x = x;
- statsInput = x.getStats();
- if (tableStats != null)
- tableStats.nextStats(monitors, stats());
+ this.stats = stats;
+
+ stats.show();
+ stats.addInput(x);
+
iterations = 0;
timer = new Timer();
timer.schedule(new Updater(), 0, 100);
timeStarting = System.nanoTime();
memoryStarting = SystemUsage.getHeapUsed();
if (doConstraint && x != null)
Constraint.setModel(x);
if (doReference) {
- refImage = new Deconvolution("Reference", "-image file " + referenceName).openImage();
+ refImage = new Deconvolution("Reference", "-image file " + reference).openImage();
if (refImage == null)
- monitors.error("Impossible to load the reference image " + referenceName);
+ monitors.error("Impossible to load the reference image " + reference);
else
monitors.log("Reference image loaded");
}
+ for (Output out : outs)
+ out.executeStarting(monitors, x, this);
- if (outs != null)
- outs.executeStarting(monitors, x, this);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
- boolean out = outs == null ? false : outs.hasShow(iterations);
+
+ boolean out = false;
+ for (Output output : outs)
+ out = out | output.is(iterations);
if (doConstraint || doResidu || doReference || out) {
if (fft == null)
fft = FFT.createDefaultFFT(monitors, X.nx, X.ny, X.nz);
x = fft.inverse(X, x);
return ends(x);
}
return ends((RealSignal) null);
}
public boolean ends(RealSignal x) {
this.x = x;
if (doConstraint || doResidu || doReference)
compute(iterations, x, doConstraint, doResidu, doReference);
- if (outs != null)
- outs.executeIterative(monitors, x, this, iterations);
+ for (Output out : outs)
+ out.executeIterative(monitors, x, this, iterations);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
- double timeElapsed = getTimeNano();
+ double timeElapsed = getTimeSecond();
boolean stopIter = (iterations >= iterationsMax);
- boolean stopTime = doTime && (timeElapsed >= timeMax);
+ boolean stopTime = doTime && (timeElapsed >= timeLimit);
boolean stopResd = doResidu && (residu <= residuMin);
monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed));
- if (tableStats != null)
- tableStats.nextStats(monitors, stats());
-
+ addStats();
+
String prefix = "Stopped>> by ";
if (abort)
monitors.log(prefix + "abort");
if (stopIter)
monitors.log(prefix + "iteration " + iterations + " > " + iterationsMax);
if (stopTime)
- monitors.log(prefix + "time " + timeElapsed + " > " + timeMax);
+ monitors.log(prefix + "time " + timeElapsed + " > " + timeLimit);
if (stopResd)
monitors.log(prefix + "residu " + NumFormat.nice(residu) + " < " + NumFormat.nice(residuMin));
return abort | stopIter | stopTime | stopResd;
}
public void finish(RealSignal x) {
this.x = x;
boolean ref = doReference;
boolean con = doConstraint;
boolean res = doResidu;
if (con || res || ref)
compute(iterations, x, con, res, ref);
- if (tableStats != null)
- tableStats.lastStats(monitors, stats());
-
- if (outs != null)
- outs.executeFinal(monitors, x, this);
+ addStats();
+ stats.save(monitors, path);
+
+ for (Output out : outs)
+ out.executeFinal(monitors, x, this);
monitors.log("Time: " + NumFormat.seconds(getTimeNano()) + " Peak:" + getMemoryAsString());
if (timer != null)
timer.cancel();
}
private void compute(int iterations, RealSignal x, boolean con, boolean res, boolean ref) {
if (x == null)
return;
- if (con && constraint != null)
- new Constraint(monitors).apply(x, constraint);
+ if (con && constraintMode != null)
+ new Constraint(monitors).apply(x, constraintMode);
if (ref && refImage != null) {
String s = "";
psnr = Assessment.psnr(x, refImage);
snr = Assessment.snr(x, refImage);
s += " PSNR: " + NumFormat.nice(psnr);
s += " SNR: " + NumFormat.nice(snr);
monitors.log("@" + iterations + " " + s);
}
residu = Double.MAX_VALUE;
if (res && prevImage != null) {
residu = Assessment.relativeResidu(x, prevImage);
prevImage = x.duplicate();
monitors.log("@" + iterations + " Residu: " + NumFormat.nice(residu));
}
}
- public String[] stats() {
- if (tableStats == null)
- return null;
- float params[] = null;
- if (x != null)
- params = x.getStats();
- String[] row = new String[12];
- row[0] = "" + iterations;
- row[1] = (params == null ? "-" : "" + params[0]);
- row[2] = (params == null ? "-" : "" + params[1]);
- row[3] = (params == null ? "-" : "" + params[2]);
- row[4] = (params == null ? "-" : "" + params[3]);
- row[5] = (params == null ? "-" : "" + params[5]);
- row[6] = NumFormat.seconds(getTimeNano());
- row[7] = NumFormat.bytes(SystemUsage.getHeapUsed());
- row[8] = SignalCollector.sumarize();
- row[9] = doReference ? NumFormat.nice(psnr) : "n/a";
- row[10] = doReference ? NumFormat.nice(snr) : "n/a";
- row[11] = doResidu ? NumFormat.nice(residu) : "n/a";
- return row;
+ private void addStats() {
+ String pnsrText = doReference ? NumFormat.nice(psnr) : "n/a";
+ String snrText = doReference ? NumFormat.nice(snr) : "n/a";
+ String residuText = doResidu ? NumFormat.nice(residu) : "n/a";
+
+ stats.add(x, iterations, NumFormat.seconds(getTimeNano()), pnsrText, snrText, residuText);
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
-
- public Constraint.Mode getConstraint() {
- return constraint;
- }
-
- public String getReference() {
- return doReference ? referenceName : "no ground-truth";
+
+ public double getTimeSecond() {
+ return (System.nanoTime() - timeStarting) * 1e-9;
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
- if (constraint == null)
+ if (constraintMode == null)
return "null";
- return constraint.name().toLowerCase();
+ return constraintMode.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" + ", ";
+ String stop = algo.isIterative() ? "iterations limit=" + algo.getIterationsMax() + ", " : "direct, ";
+ stop += doTime ? ", time limit=" + NumFormat.nice(timeLimit * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
- public 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());
}
+ public AbstractFFT getFFT() {
+ return fft;
+ }
+
+ /**
+ * @return the path
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * @param path
+ * the path to set
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * @return the system
+ */
+ public boolean isSystem() {
+ return system;
+ }
+
+ /**
+ * @param system
+ * the system to set
+ */
+ public void setSystem(boolean system) {
+ this.system = system;
+ }
+
+ /**
+ * @return the multithreading
+ */
+ public boolean isMultithreading() {
+ return multithreading;
+ }
+
+ /**
+ * @param multithreading
+ * the multithreading to set
+ */
+ public void setMultithreading(boolean multithreading) {
+ this.multithreading = multithreading;
+ }
+
+ /**
+ * @return the displayFinal
+ */
+ public boolean isDisplayFinal() {
+ return displayFinal;
+ }
+
+ /**
+ * @param displayFinal
+ * the displayFinal to set
+ */
+ public void setDisplayFinal(boolean displayFinal) {
+ this.displayFinal = displayFinal;
+ }
+
+ /**
+ * @return the normalizationPSF
+ */
+ public double getNormalizationPSF() {
+ return normalizationPSF;
+ }
+
+ /**
+ * @param normalizationPSF
+ * the normalizationPSF to set
+ */
+ public void setNormalizationPSF(double normalizationPSF) {
+ this.normalizationPSF = normalizationPSF;
+ }
+
+ /**
+ * @return the epsilon
+ */
+ public double getEpsilon() {
+ return epsilon;
+ }
+
+ /**
+ * @param epsilon
+ * the epsilon to set
+ */
+ public void setEpsilon(double epsilon) {
+ this.epsilon = epsilon;
+ }
+
+ /**
+ * @return the padding
+ */
+ public Padding getPadding() {
+ return padding;
+ }
+
+ /**
+ * @param padding
+ * the padding to set
+ */
+ public void setPadding(Padding padding) {
+ this.padding = padding;
+ }
+
+ /**
+ * @return the apodization
+ */
+ public Apodization getApodization() {
+ return apodization;
+ }
+
+ /**
+ * @param apodization
+ * the apodization to set
+ */
+ public void setApodization(Apodization apodization) {
+ this.apodization = apodization;
+ }
+
+ /**
+ * @return the monitors
+ */
+ public Monitors getMonitors() {
+ return monitors;
+ }
+
+ /**
+ * @param monitors
+ * the monitors to set
+ */
+ public void setMonitors(Monitors monitors) {
+ this.monitors = monitors;
+ }
+
+ /**
+ * @return the verbose
+ */
+ public Verbose getVerbose() {
+ return verbose;
+ }
+
+ /**
+ * @param verbose
+ * the verbose to set
+ */
+ public void setVerbose(Verbose verbose) {
+ this.verbose = verbose;
+ }
+
+ public Constraint.Mode getConstraint() {
+ return constraintMode;
+ }
+
+ public void setConstraint(Constraint.Mode constraintMode) {
+ doConstraint = constraintMode != Constraint.Mode.NO;
+ this.constraintMode = constraintMode;
+ }
+
+ /**
+ * @return the stats
+ */
+ public Stats getStats() {
+ return stats;
+ }
+
+ /**
+ * @param stats
+ * the stats to set
+ */
+ public void setStats(Stats stats) {
+ this.stats = stats;
+ }
+
+ /**
+ * @return the residuMin
+ */
+ public double getResiduMin() {
+ return residuMin;
+ }
+
+ /**
+ * @param residuMin
+ * the residuMin to set
+ */
+ public void setResiduMin(double residuMin) {
+ doResidu = residuMin > 0;
+ this.residuMin = residuMin;
+ }
+
+ /**
+ * @return the timeLimit
+ */
+ public double getTimeLimit() {
+ return timeLimit;
+ }
+
+ /**
+ * @param timeLimit
+ * the timeLimit to set
+ */
+ public void setTimeLimit(double timeLimit) {
+ doTime = timeLimit > 0;
+ this.timeLimit = timeLimit;
+ }
+
+ /**
+ * @return the reference
+ */
+ public String getReference() {
+ return reference;
+ }
+
+ /**
+ * @param reference
+ * the reference to set
+ */
+ public void setReference(String reference) {
+ doReference = false;
+ if (reference == null)
+ return;
+ if (reference.equals(""))
+ return;
+ doReference = true;
+ this.reference = reference;
+ }
+
+ /**
+ * @return the outs
+ */
+ public ArrayList<Output> getOuts() {
+ return outs;
+ }
+
+ /**
+ * @param outs
+ * the outs to set
+ */
+ public void setOuts(ArrayList<Output> outs) {
+ this.outs = outs;
+ }
+
+ public void addOutput(Output out) {
+ this.outs.add(out);
+ }
+
+ public String toStringMonitor() {
+ String s = "[" + verbose.name().toLowerCase() + "] ";
+ for (AbstractMonitor monitor : monitors) {
+ s += "" + monitor.getName() + " ";
+ }
+ return s;
+ }
+
+ /**
+ * @return the stats
+ */
+ public Stats.Mode getStatsMode() {
+ return stats.getMode();
+ }
+
+ /**
+ * @param stats
+ * the stats to set
+ */
+ public void setStatsMode(Stats.Mode mode) {
+ this.stats = new Stats(mode);
+ }
+
+ public String toStringRunning() {
+ String s = "";
+ s += "system " + (system ? "shown" : "hidden ");
+ s += ", multithreading " + (multithreading ? "on" : "off ");
+ s += ", display final " + (displayFinal ? "on " : "off ");
+ return s;
+ }
+
+ public String toStringPath() {
+ File dir = new File(path);
+ if (dir.exists()) {
+ if (dir.isDirectory()) {
+ if (dir.canWrite())
+ return path + " (writable)";
+ else
+ return path + " (non-writable)";
+ }
+ else {
+ return path + " (non-directory)";
+ }
+ }
+ else {
+ return path + " (not-valid)";
+ }
+ }
+
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java b/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java
index 2454d9f..bbb5e4b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java
@@ -1,188 +1,188 @@
/*
* 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;
import signal.SignalCollector;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class FISTA extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
private double lambda = 0.1;
private String waveletsName = "Haar";
private int scale = 3;
- public FISTA(int iter, double gamma, double lambda, String waveletsName, int scale) {
+ public FISTA(int iterMax, double gamma, double lambda, String waveletsName, int scale) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
this.lambda = lambda;
this.waveletsName = waveletsName;
this.scale = scale;
}
@Override
public RealSignal call() throws Exception {
AbstractWavelets wavelets = Wavelets.getWaveletsByName(waveletsName);
wavelets.setScale(scale);
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(Y);
SignalCollector.free(H);
ComplexSignal Z = G.duplicate();
RealSignal x = fft.inverse(G);
RealSignal s = x.duplicate();
RealSignal z = x.duplicate();
RealSignal xprev = fft.inverse(G);
float pk1 = 1f;
float pk0 = 1f;
float threshold = (float) (lambda * gamma * 0.5);
RealSignal buffer = y.duplicate();
while (!controller.ends(x)) {
fft.transform(s, Z);
Z.times(A);
Z.plus(G);
fft.inverse(Z, z);
wavelets.shrinkage(threshold, z, x, buffer);
pk0 = pk1;
pk1 = (1f + (float) Math.sqrt(1f + 4f * pk0 * pk0)) * 0.5f;
update(xprev, x, (pk0 - 1f) / pk1, s);
}
SignalCollector.free(A);
SignalCollector.free(Z);
SignalCollector.free(G);
SignalCollector.free(s);
SignalCollector.free(z);
SignalCollector.free(xprev);
SignalCollector.free(buffer);
return x;
}
public void update(RealSignal xprev, RealSignal x, double w, RealSignal s) {
int nxy = x.nx * x.ny;
for (int k = 0; k < x.nz; k++)
for (int i = 0; i < nxy; i++) {
float vx = x.data[k][i];
s.data[k][i] = (float) (vx + w * (vx - xprev.data[k][i]));
xprev.data[k][i] = vx;
}
}
@Override
public String getName() {
return "Fast Iterative Shrinkage-Thresholding";
}
@Override
public String[] getShortnames() {
return new String[] {"FISTA"};
}
@Override
public int getComplexityNumberofFFT() {
- return 4 + 4 * controller.getIterationMax();
+ return 4 + 4 * iterMax;
}
@Override
public double getMemoryFootprintRatio() {
return 15.0;
}
@Override
public boolean isRegularized() {
return true;
}
@Override
public boolean isStepControllable() {
return true;
}
@Override
public boolean isIterative() {
return true;
}
@Override
public boolean isWaveletsBased() {
return true;
}
@Override
public void setWavelets(String waveletsName) {
this.waveletsName = waveletsName;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
- controller.setIterationMax((int) Math.round(params[0]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float) params[1];
if (params.length > 2)
lambda = (float) params[2];
if (params.length > 3)
scale = (int) params[3];
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10, 1, 0.1 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax(), gamma, lambda };
+ return new double[] { iterMax, gamma, lambda };
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java b/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
index 1f051ab..0e13a33 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
@@ -1,153 +1,153 @@
/*
* 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.Constraint;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
import signal.factory.complex.ComplexSignalFactory;
public class ICTM extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
private double lambda = 1.0;
- public ICTM(int iter, double gamma, double lambda) {
+ public ICTM(int iterMax, double gamma, double lambda) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
controller.setConstraint(Constraint.Mode.NONNEGATIVE);
this.gamma = gamma;
this.lambda = lambda;
}
@Override
public RealSignal call() throws Exception {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal L = ComplexSignalFactory.laplacian(Y.nx, Y.ny, Y.nz);
ComplexSignal L2 = Operations.multiplyConjugate(lambda * gamma, L, L);
SignalCollector.free(L);
A.minus(L2);
SignalCollector.free(L2);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(H);
SignalCollector.free(Y);
ComplexSignal X = G.duplicate();
controller.setConstraint(Constraint.Mode.NONNEGATIVE);
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(A);
SignalCollector.free(G);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public String getName() {
return "Iterative Contraint Tikhonov-Miller";
}
@Override
public String[] getShortnames() {
return new String[] {"ICTM"};
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + controller.getIterationMax() * 2;
+ return 3 + iterMax * 2;
}
@Override
public double getMemoryFootprintRatio() {
return 10.0;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float) params[1];
if (params.length > 2)
lambda = (float) params[2];
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10, 1, 0.1 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax(), gamma, lambda };
+ return new double[] { iterMax, gamma, lambda };
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ISTA.java b/DeconvolutionLab2/src/deconvolution/algorithm/ISTA.java
index e041133..a81998b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ISTA.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ISTA.java
@@ -1,180 +1,180 @@
/*
* 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;
import signal.SignalCollector;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class ISTA extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
private double lambda = 1.0;
private String waveletsName = "Haar";
private int scale = 3;
- public ISTA(int iter, double gamma, double lambda, String waveletsName, int scale) {
+ public ISTA(int iterMax, double gamma, double lambda, String waveletsName, int scale) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
this.lambda = lambda;
this.waveletsName = waveletsName;
this.scale = scale;
}
@Override
public RealSignal call() throws Exception {
AbstractWavelets wavelets = Wavelets.getWaveletsByName(waveletsName);
wavelets.setScale(scale);
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(Y);
SignalCollector.free(H);
ComplexSignal Z = G.duplicate();
RealSignal x = fft.inverse(G);
RealSignal z = x.duplicate();
float threshold = (float)(lambda*gamma*0.5);
RealSignal buffer = y.duplicate();
while(!controller.ends(x)) {
fft.transform(x, Z);
Z.times(A);
Z.plus(G);
fft.inverse(Z, z);
wavelets.shrinkage(threshold, z, x, buffer);
}
SignalCollector.free(A);
SignalCollector.free(Z);
SignalCollector.free(G);
SignalCollector.free(z);
SignalCollector.free(buffer);
return x;
}
public void update(RealSignal xprev, RealSignal x, double w, RealSignal s) {
int nxy = x.nx * x.ny;
for(int k=0; k<x.nz; k++)
for(int i=0; i< nxy; i++) {
float vx = x.data[k][i];
s.data[k][i] = (float)(vx + w*(vx - xprev.data[k][i]));
xprev.data[k][i] = vx;
}
}
@Override
public String getName() {
return "Iterative Shrinkage-Thresholding";
}
@Override
public String[] getShortnames() {
return new String[] {"ISTA"};
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + 4 * controller.getIterationMax();
+ return 3 + 4 * iterMax;
}
@Override
public double getMemoryFootprintRatio() {
return 13.0;
}
@Override
public boolean isRegularized() {
return true;
}
@Override
public boolean isStepControllable() {
return true;
}
@Override
public boolean isIterative() {
return true;
}
@Override
public boolean isWaveletsBased() {
return true;
}
@Override
public void setWavelets(String waveletsName) {
this.waveletsName = waveletsName;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
- controller.setIterationMax((int)Math.round(params[0]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float)params[1];
if (params.length > 2)
lambda = (float)params[2];
if (params.length > 3)
scale = (int)params[3];
}
@Override
public double[] getDefaultParameters() {
return new double[] {10, 1, 0.1};
}
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax(), gamma, lambda};
+ return new double[] {iterMax, gamma, lambda};
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java b/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
index 9592e83..b737e30 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
@@ -1,147 +1,147 @@
/*
* 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;
import signal.SignalCollector;
public class Landweber extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
- public Landweber(int iter, double gamma) {
+ public Landweber(int iterMax, double gamma) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
}
@Override
// Landweber algorithm
// X(n+1) = X(n) + g*H*(Y-H*X(n))
// => X(n+1) = X(n) - g*H*H*X(n) + g*H*Y
// => X(n+1) = X(n) * (I-g*H*H) + g*H*Y
// => pre-compute: A = (I-g*H*H) and G = g*H*Y
// => Iteration : X(n+1) = X(n) * A + G with F(0) = G
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(Y);
SignalCollector.free(H);
ComplexSignal X = G.duplicate();
X.setName("X");
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(A);
SignalCollector.free(G);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public String getName() {
return "Landweber";
}
@Override
public String[] getShortnames() {
return new String[] {"LW", "LLS"};
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + (controller.needSpatialComputation() ? 2 * controller.getIterationMax() : 0);
+ return 3 + (controller.needSpatialComputation() ? 2 * iterMax : 0);
}
@Override
public double getMemoryFootprintRatio() {
return 9.0;
}
@Override
public boolean isRegularized() {
return false;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float) params[1];
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10, 1 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax(), gamma };
+ return new double[] { iterMax, gamma };
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
index 1110ba6..90fcda7 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
@@ -1,149 +1,149 @@
/*
* 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.Constraint;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
public class LandweberPositivity extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
- public LandweberPositivity(int iter, double gamma) {
+ public LandweberPositivity(int iterMax, double gamma) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
controller.setConstraint(Constraint.Mode.NONNEGATIVE);
this.gamma = gamma;
}
@Override
// Landweber algorithm
// X(n+1) = X(n) + g*H*(Y-H*X(n))
// => X(n+1) = X(n) - g*H*H*X(n) + g*H*Y
// => X(n+1) = X(n) * (I-g*H*H) + g*H*Y
// => pre-compute: A = (I-g*H*H) and G = g*H*Y
// => Iteration : X(n+1) = X(n) * A + G with F(0) = G
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
ComplexSignal X = G.duplicate();
controller.setConstraint(Constraint.Mode.NONNEGATIVE);
SignalCollector.free(Y);
SignalCollector.free(H);
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(A);
SignalCollector.free(G);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public String getName() {
return "Non-Negative Least-Square";
}
@Override
public String[] getShortnames() {
return new String[] {"NNLS", "LW+"};
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + controller.getIterationMax() * 2;
+ return 3 + iterMax * 2;
}
@Override
public double getMemoryFootprintRatio() {
return 10.0;
}
@Override
public boolean isRegularized() {
return false;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float) params[1];
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10, 1 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax(), gamma };
+ return new double[] { iterMax, gamma };
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
index bf806d6..4dcd0e8 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
@@ -1,123 +1,123 @@
/*
* 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;
import signal.SignalCollector;
public class NonStabilizedDivision extends AbstractAlgorithm implements Callable<RealSignal> {
public NonStabilizedDivision() {
super();
}
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = Operations.divideNotStabilized(Y, H);
SignalCollector.free(Y);
SignalCollector.free(H);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public String getName() {
- return "Non Stablized Division [DIV]";
+ return "Non Stablized Division";
}
@Override
public String[] getShortnames() {
return new String[] {"DIV"};
}
@Override
public int getComplexityNumberofFFT() {
return 3;
}
@Override
public double getMemoryFootprintRatio() {
return 8.0;
}
@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) {
}
@Override
public double[] getDefaultParameters() {
return new double[] {};
}
@Override
public double[] getParameters() {
return new double[] {};
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
index 3d149e8..4a25f4b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
@@ -1,141 +1,141 @@
/*
* 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;
import signal.SignalCollector;
public class RichardsonLucy extends AbstractAlgorithm implements Callable<RealSignal> {
public RichardsonLucy(int iter) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
}
// x(k+1) = x(k) *. Hconj * ( y /. H x(k))
@Override
public RealSignal call() {
ComplexSignal H = fft.transform(h);
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);
}
SignalCollector.free(H);
SignalCollector.free(p);
SignalCollector.free(u);
SignalCollector.free(U);
return x;
}
@Override
public String getName() {
return "Richardson-Lucy";
}
@Override
public String[] getShortnames() {
return new String[] {"RL"};
}
@Override
public int getComplexityNumberofFFT() {
- return 1 + 5 * controller.getIterationMax();
+ return 1 + 5 * iterMax;
}
@Override
public double getMemoryFootprintRatio() {
return 9.0;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax() };
+ return new double[] { iterMax };
}
@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 479af1c..18e9e25 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTV.java
@@ -1,235 +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 deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
public class RichardsonLucyTV extends AbstractAlgorithm implements Callable<RealSignal> {
private double lambda = 0.1;
- public RichardsonLucyTV(int iter, double lambda) {
+ public RichardsonLucyTV(int iterMax, double lambda) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
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("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);
}
SignalCollector.free(H);
SignalCollector.free(U);
SignalCollector.free(ggx);
SignalCollector.free(ggy);
SignalCollector.free(ggz);
SignalCollector.free(tv);
SignalCollector.free(u);
SignalCollector.free(p);
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));
}
}
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) 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 int getComplexityNumberofFFT() {
- return 1 + 7 * controller.getIterationMax();
+ return 1 + 7 * iterMax;
}
@Override
public String getName() {
return "Richardson-Lucy Total Variation";
}
@Override
public String[] getShortnames() {
return new String[] {"RLTV"};
}
@Override
public double getMemoryFootprintRatio() {
return 13.0;
}
@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]));
+ iterMax = (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};
+ return new double[] {iterMax, lambda};
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return 0.0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/StarkParker.java b/DeconvolutionLab2/src/deconvolution/algorithm/StarkParker.java
index 794d5c2..eaa4476 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/StarkParker.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/StarkParker.java
@@ -1,148 +1,148 @@
/*
* 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.Constraint;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
public class StarkParker extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
- public StarkParker(int iter, double gamma) {
+ public StarkParker(int iterMax, double gamma) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
}
@Override
// Landweber algorithm
// X(n+1) = X(n) + g*H*(Y-H*X(n))
// => X(n+1) = X(n) - g*H*H*X(n) + g*H*Y
// => X(n+1) = X(n) * (I-g*H*H) + g*H*Y
// => pre-compute: A = (I-g*H*H) and G = g*H*Y
// => Iteration : X(n+1) = X(n) * A + G with F(0) = G
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(H);
SignalCollector.free(Y);
ComplexSignal X = G.duplicate();
controller.setConstraint(Constraint.Mode.CLIPPED);
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(A);
SignalCollector.free(G);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public String getName() {
return "Bounded-Variable Least Squares";
}
@Override
public String[] getShortnames() {
return new String[] {"BVLS", "SP"};
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + controller.getIterationMax() * 2;
+ return 3 + iterMax * 2;
}
@Override
public double getMemoryFootprintRatio() {
return 9.0;
}
@Override
public boolean isRegularized() {
return false;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float) params[1];
}
@Override
public double[] getDefaultParameters() {
return new double[] { 10, 1 };
}
@Override
public double[] getParameters() {
- return new double[] { controller.getIterationMax(), gamma };
+ return new double[] { iterMax, gamma };
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMiller.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMiller.java
index 350c3e2..ab67126 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMiller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMiller.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 deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
import signal.factory.complex.ComplexSignalFactory;
public class TikhonovMiller extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
private double lambda = 1.0;
- public TikhonovMiller(int iter, double gamma, double lambda) {
+ public TikhonovMiller(int iterMax, double gamma, double lambda) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
this.lambda = lambda;
}
@Override
public RealSignal call() throws Exception {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta(gamma, H);
ComplexSignal L = ComplexSignalFactory.laplacian(Y.nx, Y.ny, Y.nz);
ComplexSignal L2 = Operations.multiplyConjugate(lambda*gamma, L, L);
SignalCollector.free(L);
A.minus(L2);
SignalCollector.free(L2);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
SignalCollector.free(H);
SignalCollector.free(Y);
ComplexSignal X = G.duplicate();
while(!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(A);
SignalCollector.free(G);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + (controller.needSpatialComputation() ? 2 * controller.getIterationMax() : 0);
+ return 3 + (controller.needSpatialComputation() ? 2 * iterMax : 0);
}
@Override
public String getName() {
return "Tikhonov-Miller";
}
@Override
public String[] getShortnames() {
return new String[] {"TM"};
}
@Override
public double getMemoryFootprintRatio() {
return 10.0;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float)params[1];
if (params.length > 2)
lambda = (float)params[2];
}
@Override
public double[] getDefaultParameters() {
return new double[] {10, 1, 0.1};
}
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax(), gamma, lambda};
+ return new double[] {iterMax, gamma, lambda};
}
@Override
public double getRegularizationFactor() {
return lambda;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittert.java b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittert.java
index 11c33fa..7dfccbc 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittert.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittert.java
@@ -1,145 +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 deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
public class VanCittert extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
- public VanCittert(int iter, double gamma) {
+ public VanCittert(int iterMax, double gamma) {
super();
- controller.setIterationMax(iter);
+ this.iterMax = iterMax;
this.gamma = gamma;
}
@Override
// VAnCitter algorithm
// X(n+1) = X(n) + g*(Y-H*X(n))
// => X(n+1) = X(n) - g*H*X(n) + g*Y
// => X(n+1) = X(n) * (I-g*H) + g*Y
// => pre-compute: A = (I-g*H) and G = g*Y
// => Iteration : X(n+1) = X(n) * A + G with F(0) = G
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal A = Operations.delta1(gamma, H);
SignalCollector.free(H);
ComplexSignal G = Operations.multiply(gamma, Y);
SignalCollector.free(Y);
ComplexSignal X = G.duplicate();
while(!controller.ends(X)) {
X.times(A);
X.plus(G);
}
SignalCollector.free(G);
SignalCollector.free(A);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
return x;
}
@Override
public int getComplexityNumberofFFT() {
- return 3 + (controller.needSpatialComputation() ? 2 * controller.getIterationMax() : 0);
+ return 3 + (controller.needSpatialComputation() ? 2 * iterMax : 0);
}
@Override
public String getName() {
return "Van Cittert";
}
@Override
public String[] getShortnames() {
return new String[] {"VC"};
}
@Override
public double getMemoryFootprintRatio() {
return 8.0;
}
@Override
public boolean isRegularized() {
return false;
}
@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]));
+ iterMax = (int) Math.round(params[0]);
if (params.length > 1)
gamma = (float)params[1];
}
@Override
public double[] getDefaultParameters() {
return new double[] {10, 1};
}
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax(), gamma};
+ return new double[] {iterMax, gamma};
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java
new file mode 100644
index 0000000..aab8f59
--- /dev/null
+++ b/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java
@@ -0,0 +1,117 @@
+/*
+ * 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.capsule;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import javax.swing.JFrame;
+import javax.swing.JSplitPane;
+
+import deconvolution.Deconvolution;
+import deconvolutionlab.Lab;
+import deconvolutionlab.monitor.Monitors;
+
+public abstract class AbstractCapsule {
+
+ protected Deconvolution deconvolution;
+ protected JSplitPane split;
+ private AsynchronousTimer signalTimer;
+ private Timer timer = new Timer();
+ private int count = 0;
+ private Monitors monitors;
+ private String message = "";
+
+ public AbstractCapsule(Deconvolution deconvolution) {
+ this.deconvolution = deconvolution;
+ this.monitors = deconvolution.getMonitors();
+ }
+
+ public JSplitPane getPane() {
+ return split;
+ }
+
+ public void show(String name) {
+ JFrame frame = new JFrame(name);
+ update();
+ frame.getContentPane().add(split);
+ frame.pack();
+ Lab.setVisible(frame);
+ }
+
+ public abstract void update();
+
+ public abstract String getName();
+
+ public void stopAsynchronousTimer() {
+ if (monitors != null)
+ monitors.progress(message, 100);
+ if (signalTimer != null) {
+ signalTimer.cancel();
+ signalTimer = null;
+ }
+ }
+
+ public void startAsynchronousTimer(String message, long refreshTime) {
+ if (signalTimer != null) {
+ signalTimer.cancel();
+ signalTimer = null;
+ }
+ this.message = message;
+ signalTimer = new AsynchronousTimer(message);
+ timer.schedule(signalTimer, 0, refreshTime);
+ }
+
+ public void signal(String message) {
+ if (monitors != null)
+ monitors.progress(message, count += 2);
+ }
+
+ private class AsynchronousTimer extends TimerTask {
+ private String message;
+
+ public AsynchronousTimer(String message) {
+ this.message = message;
+ }
+
+ @Override
+ public void run() {
+ signal(message);
+ }
+ }
+
+ @Override
+ public void finalize() {
+ stopAsynchronousTimer();
+ }
+
+}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java b/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
similarity index 67%
rename from DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
rename to DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
index 0415057..60af01a 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
@@ -1,153 +1,183 @@
-package deconvolution.modules;
+/*
+ * 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.capsule;
import javax.swing.JSplitPane;
import bilib.component.HTMLPane;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
-import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.SignalCollector;
-public class AlgorithmDModule extends AbstractDModule implements Runnable {
+/**
+ * This class is a information module for the algorithm.
+ *
+ * @author Daniel Sage
+ *
+ */
+public class AlgorithmCapsule extends AbstractCapsule implements Runnable {
private CustomizedTable table;
private HTMLPane doc;
- public AlgorithmDModule(Deconvolution deconvolution) {
+ public AlgorithmCapsule(Deconvolution deconvolution) {
super(deconvolution);
doc = new HTMLPane(100, 1000);
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), doc.getPane());
}
public void update() {
if (doc == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
split.setDividerLocation(300);
}
@Override
public String getName() {
return "Algorithm";
}
@Override
public void run() {
Features features = new Features();
- if (deconvolution.algo == null) {
+ if (deconvolution.getAlgorithm() == null) {
features.add("Algorithm", "No valid algorithm");
return;
}
- AbstractAlgorithm algo = deconvolution.algo;
+ AbstractAlgorithm algo = deconvolution.getAlgorithm();
doc.clear();
String name = algo.getShortnames()[0];
AbstractAlgorithmPanel algoPanel = Algorithm.getPanel(name);
if (algoPanel != null)
doc.append(algoPanel.getDocumentation());
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
- if (deconvolution.pad == null) {
+ if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
- if (deconvolution.apo == null) {
+ if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("Image", "No valid PSF");
return;
}
- Controller controller = deconvolution.algo.getController();
- if (controller == null) {
- features.add("Controller", "No valid controller");
- return;
- }
-
startAsynchronousTimer("Run FFT", 200);
- deconvolution.algo.setController(controller);
+
AbstractFFT f = FFT.getFastestFFT().getDefaultFFT();
double Q = Math.sqrt(2);
if (deconvolution.image != null) {
int mx = deconvolution.image.nx;
int my = deconvolution.image.ny;
int mz = deconvolution.image.nz;
while (mx * my * mz > Math.pow(2, 15)) {
mx = (int)(mx / Q);
my = (int)(my / Q);
mz = (int)(mz / Q);
}
double N = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
double M = mx * my * mz;
double ratio = 1;
if (M != 0)
ratio = (N * Math.log(N)) / (M * Math.log(M));
double chrono = System.nanoTime();
RealSignal x = new RealSignal("test", mx, my, mz);
ComplexSignal c = new ComplexSignal("test", mx, my, mz);
f.init(Monitors.createDefaultMonitor(), mx, my, mz);
f.transform(x, c);
SignalCollector.free(x);
SignalCollector.free(c);
chrono = (System.nanoTime() - chrono);
features.add("Tested on", mx + "x" + my + "x" + mz);
features.add("Estimated Time on small", NumFormat.time(chrono) );
chrono = chrono * ratio * algo.getComplexityNumberofFFT();
- int n = algo.isIterative() ? controller.getIterationMax() : 1;
+ int n = algo.isIterative() ? algo.getIterationsMax() : 1;
features.add("Estimated Time", NumFormat.time(chrono) );
features.add("Estimated Number of FFT / Transform", ""+algo.getComplexityNumberofFFT());
}
else
features.add("Estimated Time", "Error" );
double mem = (algo.getMemoryFootprintRatio() * deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz * 4);
features.add("Estimated Memory", NumFormat.bytes(mem));
- features.add("Iterative", algo.isIterative() ? "" + controller.getIterationMax() : "Direct");
+ features.add("Iterative", algo.isIterative() ? "" + algo.getIterationsMax() : "Direct");
table.removeRows();
for (String[] feature : features)
table.append(feature);
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java b/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
similarity index 51%
rename from DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
rename to DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
index a1832ee..6091f29 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
@@ -1,109 +1,151 @@
-package deconvolution.modules;
+/*
+ * 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.capsule;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import bilib.component.PanelImage;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import signal.RealSignal;
import signal.SignalCollector;
+import signal.apodization.Apodization;
+import signal.padding.Padding;
-public class ImageDModule extends AbstractDModule implements Runnable {
+/**
+ * This class is a information module for the image source.
+ *
+ * @author Daniel Sage
+ *
+ */
+public class ImageCapsule extends AbstractCapsule implements Runnable {
private PanelImage pnImage;
private CustomizedTable table;
- public ImageDModule(Deconvolution deconvolution) {
+ public ImageCapsule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] {"Image", "Waiting for loading ..."});
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public String getName() {
return "Image";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
- if (deconvolution.pad == null) {
+ if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
- if (deconvolution.apo == null) {
+ if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
startAsynchronousTimer("Preprocessing image", 200);
float stati[] = deconvolution.image.getStats();
int sizi = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal Image</b></html>", "");
features.add("Size", deconvolution.image.dimAsString() + " " + NumFormat.bytes(sizi*4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
- features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
- features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
+ features.add("Extrema (min, max)", NumFormat.nice(stati[1]) + ", " + NumFormat.nice(stati[2]));
+ features.add("Energy (integral)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
-
- RealSignal signal = deconvolution.pad.pad(deconvolution.monitors, deconvolution.image);
- deconvolution.apo.apodize(deconvolution.monitors, signal);
+ Padding pad = deconvolution.getController().getPadding();
+ Apodization apo = deconvolution.getController().getApodization();
+ RealSignal signal = pad.pad(deconvolution.getMonitors(), deconvolution.image);
+ apo.apodize(deconvolution.getMonitors(), signal);
float stats[] = signal.getStats();
int sizs = signal.nx * signal.ny * signal.nz;
float totals = stats[0] * sizs;
+ double incpad = (double)((sizs-sizi)/sizi*100.0);
features.add("<html><b>Working Image</b></html>", "");
features.add("Size", signal.dimAsString() + " " + NumFormat.bytes(sizs*4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
- features.add("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
- features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
+ features.add("Extrema (min, max)", NumFormat.nice(stats[1]) + ", " + NumFormat.nice(stats[2]));
+ features.add("Energy (integral)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
+
features.add("<html><b>Information</b></html>", "");
- features.add("Size Increase ", NumFormat.nice((double)(sizs-sizi)/sizi*100.0));
- features.add("Energy Lost", NumFormat.nice((stats[5]-stati[5])/stati[5]*100));
+ features.add("Size increase (pad.)", NumFormat.nice(incpad) + "%");
+ features.add("Energy lost (apo.)", NumFormat.nice((stats[5]-stati[5])/stati[5]*100));
SignalCollector.free(signal);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.image.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java b/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
similarity index 53%
rename from DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
rename to DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
index 1e3d408..0d38cb1 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
@@ -1,118 +1,157 @@
-package deconvolution.modules;
+/*
+ * 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.capsule;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import bilib.component.PanelImage;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import signal.RealSignal;
import signal.SignalCollector;
-public class PSFDModule extends AbstractDModule implements Runnable {
+/**
+ * This class is a information module for the PSF source.
+ *
+ * @author Daniel Sage
+ *
+ */
+public class PSFCapsule extends AbstractCapsule implements Runnable {
private PanelImage pnImage;
private CustomizedTable table;
- public PSFDModule(Deconvolution deconvolution) {
+ public PSFCapsule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public String getName() {
return "PSF";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
- if (deconvolution.image == null) {
- features.add("Image", "No valid input image");
- return;
- }
-
- if (deconvolution.pad == null) {
+ if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
- if (deconvolution.apo == null) {
+ if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("PSF", "No valid PSF");
return;
}
startAsynchronousTimer("Preprocessing PSF", 200);
float stati[] = deconvolution.psf.getStats();
int sizi = deconvolution.psf.nx * deconvolution.psf.ny * deconvolution.psf.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal PSF</b></html>", "");
features.add("Size", deconvolution.psf.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
- features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
- features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
+ features.add("Extrema (min, max)", NumFormat.nice(stati[1]) + ", " + NumFormat.nice(stati[2]));
+ features.add("Energy (integral)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
- RealSignal h = deconvolution.psf.changeSizeAs(deconvolution.image);
- h.normalize(deconvolution.norm);
+ RealSignal h;
+ if (deconvolution.image == null) {
+ features.add("Image", "No valid input image to resize");
+ h = deconvolution.psf.duplicate();
+ }
+ else
+ h = deconvolution.psf.changeSizeAs(deconvolution.image);
+ h.normalize(deconvolution.getController().getNormalizationPSF());
float stats[] = h.getStats();
int sizs = h.nx * h.ny * h.nz;
float totals = stats[0] * sizs;
+ double incpad = (double)((sizs-sizi)/sizi*100.0);
features.add("<html><b>Working PSF</b></html>", "");
features.add("Size", h.dimAsString() + " " + NumFormat.bytes(sizs * 4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
- features.add("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
- features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
+ features.add("Extrema (min, max)", NumFormat.nice(stats[1]) + ", " + NumFormat.nice(stats[2]));
+ features.add("Energy (integral)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
- features.add("Size Increase ", NumFormat.nice((double) (sizs - sizi) / sizi * 100.0));
- features.add("Energy Lost", NumFormat.nice((stats[5] - stati[5]) / stati[5] * 100));
+ features.add("Size increase (image)", NumFormat.nice(incpad) + "%");
+ features.add("Energy lost", NumFormat.nice((stats[5] - stati[5]) / stati[5] * 100));
SignalCollector.free(h);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.psf.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java b/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
similarity index 50%
rename from DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
rename to DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
index cb0f5c0..27e247f 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
@@ -1,74 +1,111 @@
-package deconvolution.modules;
+/*
+ * 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.capsule;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JSplitPane;
import javax.swing.text.BadLocationException;
import bilib.component.HTMLPane;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
-public class RecapDModule extends AbstractDModule implements KeyListener {
+/**
+ * This class is a information module for a recapitulation of the command line.
+ *
+ * @author Daniel Sage
+ *
+ */
+public class RecapCapsule extends AbstractCapsule implements KeyListener {
private HTMLPane pnCommand;
private CustomizedTable table;
- public RecapDModule(Deconvolution deconvolution) {
+ public RecapCapsule(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());
}
public void update() {
if (table == null)
return;
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
split.setDividerLocation(0.5);
split.repaint();
}
public String getCommand() {
return pnCommand.getText();
}
@Override
public String getName() {
return "Recap";
}
@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/signal/factory/Astigmatism.java b/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
similarity index 50%
copy from DeconvolutionLab2/src/signal/factory/Astigmatism.java
copy to DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
index 36017a6..7337fe3 100644
--- a/DeconvolutionLab2/src/signal/factory/Astigmatism.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
@@ -1,90 +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.factory;
+package deconvolution.capsule;
-import signal.RealSignal;
+import java.awt.Dimension;
-public class Astigmatism extends SignalFactory {
+import javax.swing.JSplitPane;
- private double fwhm = 3.0;
- private double factor = 0.20;
-
- public Astigmatism(double fwhm, double factor) {
- super(new double[] {fwhm, factor});
- }
-
- @Override
- public String getName() {
- return "Astigmatism";
- }
-
- @Override
- public String[] getParametersName() {
- return new String[] {"FWHM at focus plane", "Astigmatism factor"};
- }
+import bilib.component.PanelImage;
+import bilib.table.CustomizedTable;
+import deconvolution.Deconvolution;
+import signal.RealSignal;
- @Override
- public void setParameters(double[] parameters) {
- if (parameters.length >= 1)
- this.fwhm = parameters[0];
- if (parameters.length >= 2)
- this.fwhm = parameters[1];
- }
+/**
+ * This class is a information module for report the output.
+ *
+ * @author Daniel Sage
+ *
+ */
+public class ReportCapsule extends AbstractCapsule {
- @Override
- public double[] getParameters() {
- return new double[] {fwhm, factor};
+ private PanelImage pnImage;
+ private CustomizedTable table;
+
+ public ReportCapsule(Deconvolution deconvolution) {
+ super(deconvolution);
+ pnImage = new PanelImage();
+ table = new CustomizedTable(new String[] { "Output", "Values" }, false);
+ pnImage.setPreferredSize(new Dimension(300, 300));
+ split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
- @Override
- public void fill(RealSignal signal) {
- double A = (amplitude-background);
- double sigma = 0.8493218 * fwhm; // 1/sqrt(-2*log(0.5))
- for(int z=0; z<nz; z++) {
- double dx = (zc-z) * factor + 1;
- double dy = 1/dx;
- if (z-zc > 0) {
- dy = (z-zc) * factor + 1;
- dx = 1.0 / dy;
- }
- double kx = 1.0 / (dx * dx * sigma * sigma * 2.0);
- double ky = 1.0 / (dy * dy * sigma * sigma * 2.0);
- for(int x=0; x<nx; x++)
- for(int y=0; y<ny; y++) {
- double r2 = kx*(x-xc)*(x-xc) + ky*(y-yc)*(y-yc);
- signal.data[z][x+nx*y] = (float)(A * Math.exp(-r2) + background);
- }
+ public void update() {
+ split.setDividerLocation(300);
+ if (pnImage == null)
+ return;
+ if (table == null)
+ return;
+ table.removeRows();
+
+ for (String[] feature : deconvolution.getDeconvolutionReports())
+ table.append(feature);
+ RealSignal image = deconvolution.getOutput();
+ if (image == null) {
+ table.append(new String[] {"ERROR", "No open output"});
+ return;
}
+ pnImage.setImage(image.preview());
+ for (String[] feature : deconvolution.checkOutput())
+ table.append(feature);
+ split.setDividerLocation(300);
}
-
+ @Override
+ public String getName() {
+ return "Report";
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java b/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java
deleted file mode 100644
index 35eb768..0000000
--- a/DeconvolutionLab2/src/deconvolution/modules/AbstractDModule.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package deconvolution.modules;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.JFrame;
-import javax.swing.JSplitPane;
-
-import deconvolution.Deconvolution;
-import deconvolutionlab.Lab;
-import deconvolutionlab.monitor.Monitors;
-
-public abstract class AbstractDModule {
-
- protected Deconvolution deconvolution;
- protected JSplitPane split;
- private AsynchronousTimer signalTimer;
- private Timer timer = new Timer();
- private int count = 0;
-
- private Monitors monitors;
- private String message = "";
-
- public AbstractDModule(Deconvolution deconvolution) {
- this.deconvolution = deconvolution;
- this.monitors = deconvolution.monitors;
- }
-
- public JSplitPane getPane() {
- return split;
- }
-
- public void show(String name) {
- JFrame frame = new JFrame(name);
- update();
- frame.getContentPane().add(split);
- frame.pack();
- Lab.setVisible(frame);
- }
-
- public abstract void update();
- public abstract String getName();
-
- public void stopAsynchronousTimer() {
- if (monitors != null)
- monitors.progress(message, 100);
- if (signalTimer != null) {
- signalTimer.cancel();
- signalTimer = null;
- }
- }
-
- public void startAsynchronousTimer(String message, long refreshTime) {
- if (signalTimer != null) {
- signalTimer.cancel();
- signalTimer = null;
- }
- this.message = message;
- signalTimer = new AsynchronousTimer(message);
- timer.schedule(signalTimer, 0, refreshTime);
- }
-
- public void signal(String message) {
- if (monitors != null)
- monitors.progress(message, count+=2);
- }
-
- private class AsynchronousTimer extends TimerTask {
- private String message;
- public AsynchronousTimer(String message) {
- this.message = message;
- }
- @Override
- public void run() {
- signal(message);
- }
- }
-
- @Override
- public void finalize() {
- stopAsynchronousTimer();
- }
-
-}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
deleted file mode 100644
index 2a38463..0000000
--- a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package deconvolution.modules;
-
-import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-
-import javax.swing.JSplitPane;
-
-import bilib.component.PanelImage;
-import bilib.table.CustomizedTable;
-import deconvolution.Deconvolution;
-import signal.RealSignal;
-
-public class ReportDModule extends AbstractDModule {
-
- private PanelImage pnImage;
- private CustomizedTable table;
-
- public ReportDModule(Deconvolution deconvolution) {
- super(deconvolution);
- pnImage = new PanelImage();
- table = new CustomizedTable(new String[] { "Output", "Values" }, false);
- pnImage.setPreferredSize(new Dimension(300, 300));
- split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
- }
-
- public void update() {
- split.setDividerLocation(300);
- if (pnImage == null)
- return;
- if (table == null)
- return;
- table.removeRows();
-
- for (String[] feature : deconvolution.getDeconvolutionReports())
- table.append(feature);
- RealSignal image = deconvolution.getOutput();
- if (image == null) {
- table.append(new String[] {"ERROR", "No open output"});
- return;
- }
- pnImage.setImage(image.preview());
- for (String[] feature : deconvolution.checkOutput())
- table.append(feature);
- split.setDividerLocation(300);
- }
-
- @Override
- public String getName() {
- return "Report";
- }
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
index 3568db5..6e768b9 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
@@ -1,293 +1,297 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.PanelImage;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.dialog.BatchDialog;
-import deconvolutionlab.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.RunningModule;
+import deconvolutionlab.module.AboutModule;
+import deconvolutionlab.module.AbstractModule;
+import deconvolutionlab.module.AlgorithmModule;
+import deconvolutionlab.module.BatchModule;
+import deconvolutionlab.module.BorderModule;
+import deconvolutionlab.module.CommandModule;
+import deconvolutionlab.module.ComputationModule;
+import deconvolutionlab.module.ConfigModule;
+import deconvolutionlab.module.ControllerModule;
+import deconvolutionlab.module.DirectoryModule;
+import deconvolutionlab.module.GroupedModulePanel;
+import deconvolutionlab.module.ImageModule;
+import deconvolutionlab.module.LanguageModule;
+import deconvolutionlab.module.LicenceModule;
+import deconvolutionlab.module.OutputModule;
+import deconvolutionlab.module.PSFModule;
+import deconvolutionlab.module.RunningModule;
import deconvolutionlab.system.SystemInfo;
public class LabPanel extends JPanel implements ActionListener, ChangeListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnQuit = new JButton("Quit");
private JButton bnSystem = new JButton("System");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnClose;
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
- private FFTModule fourier;
+ private ComputationModule computation;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
private RunningModule running;
+ private DirectoryModule directory;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
public LabPanel(JButton bnClose) {
this.bnClose = bnClose;
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
- fourier = new FFTModule(false);
+ computation = new ComputationModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
running = new RunningModule(false);
- modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, batch, running };
+ directory = new DirectoryModule(false);
+
+ modules = new AbstractModule[] { image, psf, algo, output, controller, border, computation, batch, directory };
Command.active(modules, command);
Command.command();
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
PanelImage bottom = new PanelImage("celegans.jpg");
bottom.setBorder(border);
bottom.setLayout(new GridLayout(1, 6));
bottom.setBorder(border);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Scripting", panelScript);
tab.add("About", panelAbout);
tab.addChangeListener(this);
setLayout(new BorderLayout());
add(tab, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
bnSystem.addActionListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.load();
running.init();
//sizeModule();
Command.command();
running.update();
image.update();
psf.update();
output.update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnClose)
Config.store();
else if (e.getSource() == bnSystem)
SystemInfo.activate();
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
BatchDialog dlg = new BatchDialog(batch);
Lab.setVisible(dlg, true);
}
else if (e.getSource() == bnLaunch) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command(), Deconvolution.Finish.ALIVE);
d.launch();
}
else if (e.getSource() == bnRun) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command());
d.deconvolve();
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
- list.add(running);
+ list.add(directory);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
+ list.add(computation);
list.add(border);
- list.add(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;
}
public void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
Lab.close();
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0)
sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1)
sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2)
sizePanel(panelScript);
if (tab.getSelectedIndex() == 3)
sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 70;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
setMinimumSize(new Dimension(Constants.widthGUI, 4*hpc));
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/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index 05d9042..eb6a621 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,370 +1,368 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import bilib.tools.NumFormat;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import signal.Constraint;
import signal.RealSignal;
public class Output {
public enum View {
STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE
};
public enum Dynamic {
INTACT, RESCALED, NORMALIZED, CLIPPED
};
- private ContainerImage container = null;
- private int px = 0;
- private int py = 0;
- private int pz = 0;
- private boolean center = true;
+ private 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 String name = "";
+ private boolean save = true;
+ private boolean show = true;
- private View view = View.STACK;
- private Imager.Type type = Imager.Type.FLOAT;
- private Dynamic dynamic = Dynamic.INTACT;
+ private View view = View.STACK;
+ private Imager.Type type = Imager.Type.FLOAT;
+ private Dynamic dynamic = Dynamic.INTACT;
- private int frequency = 0;
- private String path = "";
+ private int frequency = 0;
public Output(View view, int frequency, String param) {
String[] tokens = param.trim().split(" ");
this.view = view;
this.frequency = frequency;
this.name = "";
this.center = true;
this.save = true;
this.show = true;
this.container = Lab.createContainer(Monitors.createDefaultMonitor(), "");
for (int i = 0; i < tokens.length; i++) {
boolean found = false;
String p = tokens[i].trim().toLowerCase();
if (p.startsWith("@")) {
found = true;
}
if (p.startsWith("noshow")) {
show = false;
found = true;
}
if (p.startsWith("nosave")) {
save = false;
found = true;
}
for (Dynamic d : Dynamic.values()) {
if (p.toLowerCase().equals(d.name().toLowerCase())) {
dynamic = d;
found = true;
}
}
for (View v : View.values()) {
if (p.toLowerCase().equals(v.name().toLowerCase())) {
view = v;
found = true;
}
}
for (Imager.Type t : Imager.Type.values()) {
if (p.toLowerCase().equals(t.name().toLowerCase())) {
type = t;
found = true;
}
}
if (p.startsWith("(") && p.endsWith(")")) {
double pos[] = NumFormat.parseNumbers(p);
if (pos.length > 0)
px = (int) Math.round(pos[0]);
if (pos.length > 1)
py = (int) Math.round(pos[1]);
if (pos.length > 2)
pz = (int) Math.round(pos[2]);
found = true;
center = false;
}
if (!found)
name += tokens[i] + " ";
name = name.trim();
}
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, boolean center) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = center;
this.frequency = frequency;
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, int px, int py, int pz) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = false;
this.px = px;
this.py = py;
this.pz = pz;
this.frequency = frequency;
}
public boolean is(int iterations) {
if (frequency == 0)
return false;
return iterations % frequency == 0;
}
public View getView() {
return view;
}
public String getName() {
return name;
}
- public 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 == Imager.Type.FLOAT ? "" : type.name().toLowerCase());
String d = (dynamic == Dynamic.INTACT ? "" : dynamic.name().toLowerCase());
String k = "";
if (!center)
k = " (" + px + "," + py + "," + pz + ")";
else
k = "";
String sa = save ? "\u2713" : "";
String sh = show ? "\u2713" : "";
String fr = frequency > 0 ? " @" + frequency : "";
return new String[] { view.name().toLowerCase() + fr, name, d, t, k, sh, sa, "\u232B" };
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
+ if (signal == null)
+ return;
execute(monitors, signal, controller, true, false, false, 0);
}
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
+ if (signal == null)
+ return;
execute(monitors, signal, controller, false, false, true, 0);
}
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
- 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;
+ execute(monitors, signal, controller, false, true, false, iter);
+ }
+ private void execute(Monitors monitors, RealSignal signal, Controller controller, boolean start, boolean live, boolean finish, int iter) {
String title = name;
if (live)
if (!is(iter))
return;
if (controller != null && live) {
if (controller.getIterations() > 0) {
title += "@" + controller.getIterations();
}
}
RealSignal x = null;
Constraint constraint = new Constraint(monitors);
switch (dynamic) {
case RESCALED:
x = signal.duplicate();
constraint.rescaled(x, 0, 255);
break;
case CLIPPED:
x = signal.duplicate();
- float[] stats = controller.getStatsInput();
+ float[] stats = controller.getStats().getStatsInput();
if (stats != null)
constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
- float[] stats1 = controller.getStatsInput();
+ float[] stats1 = controller.getStats().getStatsInput();
if (stats1 != null)
constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
- String filename = path + File.separator + title + ".tif";
+ String filename = controller.getPath() + File.separator + title + ".tif";
switch (view) {
case STACK:
if (show && !live)
Lab.show(monitors, x, title, type, (center ? x.nz / 2 : pz));
if (save && !live)
Lab.save(monitors, x, filename, type);
break;
case SERIES:
for (int k = 0; k < x.nz; k++) {
RealSignal slice = x.getSlice(k);
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
deleted file mode 100644
index db2b6d3..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
+++ /dev/null
@@ -1,83 +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 deconvolution.algorithm.Controller;
-import deconvolutionlab.monitor.Monitors;
-import signal.RealSignal;
-
-public class OutputCollection extends ArrayList<Output> {
-
- public void setPath(String path) {
- for (Output out : this)
- out.setPath(path);
- }
-
- public boolean hasShow(int iterations) {
- boolean flag = false;
- for (Output out : this)
- flag = flag | out.is(iterations);
- return flag;
- }
-
- public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
- for (Output out : this)
- if (out != null)
- out.executeStarting(monitors, signal, controller);
- }
-
- public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
- 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 : this)
- if (out != null)
- out.executeIterative(monitors, signal, controller, iter);
- }
-
- public ArrayList<String> getInformation() {
- ArrayList<String> lines = new ArrayList<String>();
- for (Output out : this) {
- if (out == null)
- lines.add("ERR>" + this.size());
- else
- lines.add("" + out.toString());
- }
- return lines;
- }
-
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
deleted file mode 100644
index 028285f..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
+++ /dev/null
@@ -1,88 +0,0 @@
-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.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.table.DefaultTableModel;
-
-import bilib.table.CustomizedColumn;
-import bilib.table.CustomizedTable;
-import deconvolutionlab.monitor.Monitors;
-
-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("Iterations", String.class, 100, false));
- columns.add(new CustomizedColumn("Mean", String.class, 100, false));
- columns.add(new CustomizedColumn("Minimum", String.class, 100, false));
- columns.add(new CustomizedColumn("Maximum", String.class, 100, false));
- columns.add(new CustomizedColumn("Stdev", String.class, 100, false));
- columns.add(new CustomizedColumn("Energy", String.class, 100, false));
- columns.add(new CustomizedColumn("Time", String.class, 100, false));
- columns.add(new CustomizedColumn("Memory", String.class, 100, false));
- columns.add(new CustomizedColumn("Signal", String.class, 100, false));
- columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
- columns.add(new CustomizedColumn("SNR", String.class, 100, false));
- columns.add(new CustomizedColumn("Residu", String.class, 100, false));
- table = new CustomizedTable(columns, true);
-
- 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 clear() {
- DefaultTableModel model = (DefaultTableModel) table.getModel();
- model.setRowCount(0);
- }
-
- 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;
- }
-
-}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
index f6ffa22..3104f9a 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
@@ -1,152 +1,152 @@
/*
* 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 bilib.component.GridPanel;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
-import deconvolutionlab.modules.BatchModule;
+import deconvolutionlab.module.BatchModule;
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(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);
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/SyntheticDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
index 78011ef..6a95ed2 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
@@ -1,311 +1,336 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeDouble;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.gui.GUI;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class SyntheticDialog extends JDialog implements ActionListener, WindowListener {
- private SpinnerRangeDouble spnSignal = new SpinnerRangeDouble(100, -999999, 999999, 1);
- private SpinnerRangeDouble spnBackground = new SpinnerRangeDouble(0, -999999, 999999, 1);
+ private SpinnerRangeDouble spnIntensity = new SpinnerRangeDouble(255, -999999, 999999, 1);
private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(32, 1, 9999, 1);
private SpinnerRangeDouble spnCenterX = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterY = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterZ = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnParameter1 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter2 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter3 = new SpinnerRangeDouble(10, -9999, 9999, 1);
+ private SpinnerRangeDouble spnParameter4 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private JLabel lbl1 = new JLabel("Parameters 1 of the shape");
private JLabel lbl2 = new JLabel("Parameters 2 of the shape");
private JLabel lbl3 = new JLabel("Parameters 3 of the shape");
+ private JLabel lbl4 = new JLabel("Parameters 4 of the shape");
private JComboBox<String> cmbShapes;
private JButton bnShow = new JButton("Show");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String shape;
private String command;
public SyntheticDialog(ArrayList<SignalFactory> list) {
super(new JFrame(), "Synthetic");
String[] cmb = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
cmb[i] = list.get(i).getName();
}
cmbShapes = new JComboBox<String>(cmb);
- GridPanel 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 pnParams = new GridPanel("parameters", 3);
+ pnParams.place(8, 0, lbl1);
+ pnParams.place(8, 1, spnParameter1);
+ pnParams.place(9, 0, lbl2);
+ pnParams.place(9, 1, spnParameter2);
+ pnParams.place(10, 0, lbl3);
+ pnParams.place(10, 1, spnParameter3);
+ pnParams.place(11, 0, lbl4);
+ pnParams.place(11, 1, spnParameter4);
- GridPanel pnSize = new GridPanel("Dimension", 3);
+ GridPanel pnSize = new GridPanel("size", 3);
pnSize.place(1, 0, "Width [pixels] (nx)");
pnSize.place(1, 1, spnWidth);
pnSize.place(2, 0, "Height [pixels] (ny)");
pnSize.place(2, 1, spnHeight);
pnSize.place(3, 0, "Number of Slices (nz)");
pnSize.place(3, 1, spnSlices);
- GridPanel pnCenter = new GridPanel("Center", 3);
+ GridPanel pnIntensity = new GridPanel("intensity", 3);
+ pnIntensity.place(1, 0, "Signal Intensity");
+ pnIntensity.place(1, 1, spnIntensity);
+
+ GridPanel pnCenter = new GridPanel("center", 3);
pnCenter.place(4, 0, "Center [% of nx] (cx)");
pnCenter.place(4, 1, spnCenterX);
pnCenter.place(5, 0, "Center [% of ny] (cy)");
pnCenter.place(5, 1, spnCenterY);
pnCenter.place(7, 0, "Center [% of nz] (cz)");
pnCenter.place(7, 1, spnCenterZ);
- GridPanel 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(1, 0, 3, 1, pnParams);
+ pn.place(2, 0, 3, 1, pnSize);
+ pn.place(3, 0, 3, 1, pnIntensity);
pn.place(4, 0, 3, 1, pnCenter);
pn.place(11, 0, bnCancel);
pn.place(11, 1, bnShow);
pn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnShow.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
cmbShapes.addActionListener(this);
add(pn);
pack();
updateInterface();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void updateInterface() {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
String labels[] = factory.getParametersName();
lbl1.setVisible(false);
lbl2.setVisible(false);
lbl3.setVisible(false);
if (labels.length >= 1) {
lbl1.setVisible(true);
lbl1.setText(labels[0]);
}
if (labels.length >= 2) {
lbl2.setVisible(true);
lbl2.setText(labels[1]);
}
if (labels.length >= 3) {
lbl3.setVisible(true);
lbl3.setText(labels[2]);
}
+ if (labels.length >= 4) {
+ lbl4.setVisible(true);
+ lbl4.setText(labels[3]);
+ }
+
double params[] = factory.getParameters();
spnParameter1.setVisible(false);
spnParameter2.setVisible(false);
spnParameter3.setVisible(false);
+ spnParameter4.setVisible(false);
if (params.length >= 1) {
spnParameter1.setVisible(true);
spnParameter1.set(params[0]);
}
if (params.length >= 2) {
spnParameter2.setVisible(true);
spnParameter2.set(params[1]);
}
if (params.length >= 3) {
spnParameter3.setVisible(true);
spnParameter3.set(params[2]);
}
+ if (params.length >= 4) {
+ spnParameter4.setVisible(true);
+ spnParameter4.set(params[3]);
+ }
pack();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnShow) {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
double params[] = factory.getParameters();
factory.setParameters(params);
- factory.center(spnCenterX.get(), spnCenterX.get(), spnCenterX.get());
- RealSignal signal = factory.generate(spnWidth.get(), spnWidth.get(), spnWidth.get());
+ factory.intensity(spnIntensity.get());
+ factory.center(spnCenterX.get(), spnCenterY.get(), spnCenterZ.get());
+ RealSignal signal = factory.generate(spnWidth.get(), spnHeight.get(), spnSlices.get());
Lab.show(Monitors.createDefaultMonitor(), signal, factory.getName());
}
if (e.getSource() == cmbShapes) {
updateInterface();
}
if (e.getSource() == bnCancel) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
if (e.getSource() == bnOK) {
int nx = spnWidth.get();
int ny = spnHeight.get();
int nz = spnSlices.get();
shape = (String) cmbShapes.getSelectedItem();
- command = shape + " " + spnSignal.get() + " " + spnBackground.get() + " ";
+ command = shape + " ";
SignalFactory factory = SignalFactory.get(shape);
int n = factory.getParameters().length;
if (n >= 1) {
command += "" + spnParameter1.get();
if (n >= 2)
command += " " + spnParameter2.get();
if (n >= 3)
command += " " + spnParameter3.get();
+ if (n >= 4)
+ command += " " + spnParameter4.get();
command += " ";
}
- command += " size " + nx + " " + ny + " " + nz + " ";
+ command += " size " + nx + " " + ny + " " + nz + " intensity " + + spnIntensity.get() + " ";
if (spnCenterX.get() != 0.5 || spnCenterY.get() != 0.5 || spnCenterZ.get() != 0.5) {
double cx = Math.round(spnCenterX.get() * 1000000) / 1000000.0;
double cy = Math.round(spnCenterY.get() * 1000000) / 1000000.0;
double cz = Math.round(spnCenterZ.get() * 1000000) / 1000000.0;
command += " center " + cx + " " + cy + " " + cz + " ";
}
dispose();
cancel = false;
}
}
+ /**
+ * Set the command line parameters to the components of the user interface
+ *
+ * @param name String containing the name of shape
+ * @param parameters String containing all the parameters plus the optional keywords: size, intensity, center
+ */
public void setParameters(String name, String parameters) {
- 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]);
-
+ double params[] = NumFormat.parseNumbers(parameters);
+ if (np >= 1 && params.length >= 1)
+ spnParameter1.set(params[0]);
+ if (np >= 2 && params.length >= 2)
+ spnParameter2.set(params[1]);
+ if (np >= 3 && params.length >= 3)
+ spnParameter3.set(params[2]);
+ if (np >= 4 && params.length >= 4)
+ spnParameter4.set(params[3]);
+
+ double size[] = NumFormat.parseNumbersAfter("size", parameters);
+ if (size.length > 0)
+ spnWidth.set((int) size[0]);
+ if (size.length > 1)
+ spnHeight.set((int) size[1]);
+ if (size.length > 2)
+ spnSlices.set((int) size[2]);
+
+ double intensity[] = NumFormat.parseNumbersAfter("intensity", parameters);
+ if (intensity.length > 0)
+ spnIntensity.set(intensity[0]);
+
+ double center[] = NumFormat.parseNumbersAfter("center", parameters);
+ if (center.length > 0)
+ spnCenterX.set(center[0]);
+ if (center.length > 1)
+ spnCenterY.set(center[1]);
+ if (center.length > 2)
+ spnCenterZ.set(center[2]);
}
public String getShapeName() {
return shape;
}
public String getCommand() {
return command;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
similarity index 88%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
index 8ce410b..ad2c0f1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AboutModule.java
@@ -1,78 +1,72 @@
/*
* 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;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
public class AboutModule extends AbstractModule {
public AboutModule(boolean expanded) {
- super("About", "", "Help", "", expanded);
+ super("About", "", "", "", expanded);
}
@Override
public String getCommand() {
+ setSynopsis("DeconvolutionLab2 " + Constants.version);
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p", Constants.copyright);
html.append("p", "<b>Reference:</b> " + Constants.reference);
html.append("h3", "<b>Authors:</b> " + Constants.authors);
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
+ setSynopsis("DeconvolutionLab2 " + Constants.version);
return panel;
}
- @Override
- public void 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/AbstractModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
similarity index 92%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
index baf3073..a75fa58 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AbstractModule.java
@@ -1,233 +1,231 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public abstract class AbstractModule extends JPanel implements ActionListener {
- private JButton bnTitle;
- private JButton bnSynopsis;
- private JButton bnAction1 = new JButton();
- private JButton bnAction2 = new JButton();
+ protected JButton bnTitle = new JButton("");
+ protected JButton bnSynopsis = new JButton("");
+ protected JButton bnAction1 = new JButton();
+ protected JButton bnAction2 = new JButton();
+ protected JButton bnExpand = new JButton("\u25BA");
private JLabel lblCommand;
-
- private JButton bnExpand;
- private CardLayout card = new CardLayout();
- private JPanel space = new JPanel(card);
- private boolean expanded = false;
+ protected CardLayout card = new CardLayout();
+ private JPanel space = new JPanel(card);
+ private boolean expanded = false;
private GroupedModulePanel mpns;
private JPanel pnExpanded;
private JPanel pnCollapsed;
private String name;
private String key;
- private int heightButton = 22;
-
+ private int heightButton = 22;
+
public AbstractModule(String name, String key, String action1, String action2, boolean expanded) {
this.name = name;
this.key = key;
pnCollapsed = buildCollapsedPanel();
pnExpanded = buildExpandedPanel();
setLayout(new BorderLayout());
this.expanded = expanded;
- bnTitle = new JButton("<html><b>" + name + "</b></html>");
+
+ bnTitle.setText("<html><b>" + name + "</b></html>");
bnTitle.setHorizontalAlignment(SwingConstants.LEFT);
bnTitle.setPreferredSize(new Dimension(150, heightButton));
bnTitle.setMaximumSize(new Dimension(250, heightButton));
bnTitle.setMinimumSize(new Dimension(120, heightButton));
bnTitle.setMargin(new Insets(1, 1, 1, 1));
bnTitle.addActionListener(this);
- bnSynopsis = new JButton("");
bnSynopsis.setHorizontalAlignment(SwingConstants.LEFT);
bnSynopsis.setPreferredSize(new Dimension(200, heightButton));
bnSynopsis.setMargin(new Insets(1, 1, 1, 1));
bnSynopsis.addActionListener(this);
- bnExpand = new JButton("\u25BA");
Font font = bnExpand.getFont();
bnExpand.setFont(new Font(font.getFamily(), font.getStyle(), font.getSize()-3));
bnExpand.setPreferredSize(new Dimension(40, heightButton));
bnExpand.setMaximumSize(new Dimension(40, heightButton));
bnExpand.setMinimumSize(new Dimension(40, heightButton));
bnExpand.setMargin(new Insets(1, 1, 1, 1));
bnExpand.addActionListener(this);
JPanel tool0 = new JPanel(new BorderLayout());
JPanel tool1 = new JPanel(new BorderLayout());
tool1.add(bnExpand, BorderLayout.WEST);
tool1.add(bnTitle, BorderLayout.EAST);
tool0.add(tool1, BorderLayout.WEST);
tool0.add(bnSynopsis, BorderLayout.CENTER);
JPanel toola = null;
if (!action1.equals("")) {
bnAction1.setText(action1);
bnAction1.setPreferredSize(new Dimension(70, heightButton));
bnAction1.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction1, BorderLayout.WEST);
}
if (!action2.equals("")) {
bnAction2.setText(action2);
bnAction2.setPreferredSize(new Dimension(70, heightButton));
bnAction2.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction2, BorderLayout.EAST);
}
if (toola != null)
tool0.add(toola, BorderLayout.EAST);
space.add(pnExpanded, "expand");
space.add(pnCollapsed, "collapse");
add(tool0, BorderLayout.NORTH);
add(space, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (expanded)
expand();
else
collapse();
setPreferredSize(pnCollapsed.getPreferredSize());
}
public JPanel buildCollapsedPanel() {
JPanel panel = new JPanel(new BorderLayout());
lblCommand = new JLabel("");
lblCommand.setBorder(BorderFactory.createEtchedBorder());
lblCommand.setHorizontalAlignment(SwingConstants.LEFT);
lblCommand.setPreferredSize(new Dimension(500, 32));
panel.add(lblCommand, BorderLayout.NORTH);
lblCommand.setMinimumSize(new Dimension(500, 36));
return panel;
}
public abstract JPanel buildExpandedPanel();
public abstract String getCommand();
public abstract void close();
public JButton getAction1Button() {
return bnAction1;
}
public JButton getAction2Button() {
return bnAction2;
}
@Override
public String getName() {
return name;
}
public String getKey() {
return key;
}
public String getTitle() {
return bnTitle.getText();
}
public void setCommand(String command) {
lblCommand.setText("<html><p style=\"font-family: monospace\"><small>" + command + "</small></p></html>");
}
public void setSynopsis(String synopsis) {
bnSynopsis.setText(synopsis);
}
public JPanel getCollapsedPanel() {
return pnCollapsed;
}
public JPanel getExpandedPanel() {
return pnExpanded;
}
public void setMultipleModulePanel(GroupedModulePanel mpns) {
this.mpns = mpns;
}
@Override
public Dimension getPreferredSize() {
if (expanded)
return pnExpanded.getPreferredSize();
else
return pnCollapsed.getPreferredSize();
}
public boolean isExpanded() {
return expanded;
}
public void collapse() {
expanded = false;
card.show(space, "collapse");
bnExpand.setText("\u25BA");
}
public void expand() {
expanded = true;
card.show(space, "expand");
bnExpand.setText("\u25BC");
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnTitle || e.getSource() == bnExpand || e.getSource() == bnSynopsis) {
if (expanded) {
collapse();
}
else {
for (AbstractModule module : mpns.getModules())
module.collapse();
expand();
}
mpns.organize();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
similarity index 88%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
index 62230dc..70a6d4e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/AlgorithmModule.java
@@ -1,155 +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 deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
+import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
-
+ private JLabel shortname;
+
public AlgorithmModule(boolean expanded) {
super("Algorithm", "-algorithm", "", "Check", expanded);
ArrayList<AbstractAlgorithmPanel> deconv = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : deconv)
cmb.addItem(panel.getName());
cmb.addActionListener(this);
}
@Override
public String getCommand() {
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
String cmd = "-algorithm " + algo.getShortnames()[0] + " " + algo.getCommand();
String synopsis = algo.getShortnames()[0] + " " + algo.getCommand();
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
+ shortname = new JLabel("-------");
+ Border bl1 = BorderFactory.createEtchedBorder();
+ Border bl2 = BorderFactory.createEmptyBorder(0, 10, 0, 10);
+ shortname.setBorder(BorderFactory.createCompoundBorder(bl1, bl2));
cmb = new JComboBox<String>();
JPanel pnc = new JPanel();
pnc.add(cmb);
doc = new HTMLPane(100, 1000);
cards = new JPanel(new CardLayout());
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : panels) {
JScrollPane scroll = new JScrollPane(panel.getPanelParameters());
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cards.add(panel.getName(), scroll);
}
cmb.setMaximumRowCount(panels.size());
+ JPanel top = new JPanel(new BorderLayout());
+ top.add(cmb, BorderLayout.CENTER);
+ top.add(shortname, BorderLayout.EAST);
+
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
cards.setBorder(BorderFactory.createEtchedBorder());
- control.add(cmb);
+ control.add(top);
control.add(cards);
doc.append("h1", "Documentation");
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.NORTH);
panel.add(doc.getPane(), BorderLayout.CENTER);
// cmb.addActionListener(this);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
Config.register(getName(), "algorithm", cmb, Algorithm.getDefaultAlgorithm());
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb) {
doc.clear();
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
doc.append(algo.getDocumentation());
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, name);
+ String s = "<html><b><p style =\"font-family:georgia\">";
+ for(int i=0; i<algo.getShortnames().length; i++)
+ s += (i==0 ? "" : " | ") + algo.getShortnames()[i] ;
+ shortname.setText(s + "</b></html>");
}
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Algorithm", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.ALGO, deconvolution, null, null);
Lab.setVisible(d, false);
}
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
similarity index 99%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.java
index db5dbd8..47cfaab 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/BatchModule.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 deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnRun;
private JButton bnLaunch;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnRun = new JButton("Run Jobs");
bnLaunch = new JButton("Launch Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 2));
pn.setFloatable(false);
pn.add(bnRun);
pn.add(bnLaunch);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRun) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
else if (e.getSource() == bnLaunch) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
}
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/module/BorderModule.java
similarity index 97%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/BorderModule.java
index eb49308..6d97e0a 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/BorderModule.java
@@ -1,243 +1,243 @@
/*
* 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;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeInteger;
import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
private JLabel lblPad;
private JLabel lblApo;
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() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
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);
- GridPanel pnBorder = new GridPanel(false, 3);
+ GridPanel pnBorder = new GridPanel(false, 2);
pnBorder.place(0, 1, "Lateral (XY)");
pnBorder.place(0, 2, "Axial (Z)");
pnBorder.place(2, 0, "Apodization");
pnBorder.place(2, 1, cmbApoXY);
pnBorder.place(2, 2, cmbApoZ);
pnBorder.place(3, 0, "Padding Extension");
pnBorder.place(3, 1, spnExtensionXY);
pnBorder.place(3, 2, spnExtensionZ);
pnBorder.place(4, 0, "Padding Constraint");
pnBorder.place(4, 1, cmbPadXY);
pnBorder.place(4, 2, cmbPadZ);
pnBorder.place(5, 0, 3, 1, lblPad);
pnBorder.place(6, 0, 3, 1, lblApo);
JScrollPane scroll = new JScrollPane(pnBorder);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
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);
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);
Deconvolution d = new Deconvolution("CheckImage", Command.command());
- Apodization apo = d.getApodization();
+ Apodization apo = d.getController().getApodization();
if (apo == null) {
lblApo.setText("Error in Apodization");
return;
}
- Padding pad = d.getPadding();
+ Padding pad = d.getController().getPadding();
if (pad == null) {
lblPad.setText("Error in Padding");
return;
}
RealSignal x = d.openImage();
if (x == null) {
lblPad.setText("Error in input image");
lblApo.setText("Error in input image");
return;
}
Monitors m = Monitors.createDefaultMonitor();
RealSignal y = pad.pad(m, x);
apo.apodize(m, y);
lblPad.setText(x.dimAsString() + " > " + y.dimAsString());
lblApo.setText(NumFormat.nice(x.getStats()[5]) + " > " + NumFormat.nice(y.getStats()[5]));
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
update();
}
@Override
public void close() {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
similarity index 97%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
index 3eb9faf..abc1941 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/CommandModule.java
@@ -1,92 +1,92 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Lab;
public class CommandModule extends AbstractModule {
private HTMLPane window;
public CommandModule() {
super("Command", "", "", "Check", true);
}
public HTMLPane getPane() {
return window;
}
@Override
public JPanel buildExpandedPanel() {
window = new HTMLPane("Monaco", 100, 100);
JPanel panel = new JPanel(new BorderLayout());
panel.add(window.getPane(), BorderLayout.CENTER);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Command", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
window.clear();
window.append("p", command);
}
@Override
public String getCommand() {
- return "";
+ return window.getText();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
similarity index 66%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
index fb27b6b..0e6ff1b 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ComputationModule.java
@@ -1,170 +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;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import fft.FFT;
-public class FFTModule extends AbstractModule implements ActionListener, ChangeListener {
+public class ComputationModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbFFT;
- private JComboBox<String> cmbType;
- private JComboBox<String> cmbSep;
+ private JComboBox<String> cmbMultithreading;
+ private JComboBox<String> cmbSystem;
+ private JComboBox<String> cmbDisplayFinal;
private JComboBox<String> cmbEpsilon;
private JComboBox<String> cmbNormalization;
boolean init = false;
- public FFTModule(boolean expanded) {
- super("Computation", "", "", "Default", expanded);
+ public ComputationModule(boolean expanded) {
+ super("Computation", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbNormalization.getSelectedIndex() != 0)
cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
- if (cmbFFT.getSelectedIndex() != 0) {
+ if (cmbSystem.getSelectedIndex() != 0)
+ cmd += " -system no";
+ if (cmbMultithreading.getSelectedIndex() != 0)
+ cmd += " -multithreading no";
+ if (cmbDisplayFinal.getSelectedIndex() != 0)
+ cmd += " -display no";
+ if (cmbFFT.getSelectedIndex() != 0)
cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
- }
if (cmbEpsilon.getSelectedIndex() != 6)
cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
- cmbType = new JComboBox<String>(new String[] { "float" });
- cmbSep = new JComboBox<String>(new String[] { "XYZ" });
+ cmbSystem = new JComboBox<String>(new String[] { "yes", "no" });
+ cmbMultithreading = new JComboBox<String>(new String[] { "yes", "no" });
+ cmbDisplayFinal = new JComboBox<String>(new String[] { "yes", "no" });
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(1, 0, "PSF Normalization");
+ GridPanel pnNumeric = new GridPanel(false, 2);
+ pnNumeric.place(1, 0, "norm");
pnNumeric.place(1, 1, cmbNormalization);
- pnNumeric.place(1, 2, "1, recommended");
- pnNumeric.place(3, 0, new JLabel("FFT Library"));
+ pnNumeric.place(1, 2, "PSF normalization (def:1)");
+ pnNumeric.place(3, 0, new JLabel("fft"));
pnNumeric.place(3, 1, cmbFFT);
- pnNumeric.place(3, 2, new JLabel("Fourier"));
- pnNumeric.place(6, 0, new JLabel("FFT Processing"));
- pnNumeric.place(6, 1, cmbSep);
- pnNumeric.place(6, 2, new JLabel("Dimension Ordering"));
+ pnNumeric.place(3, 2, new JLabel("FFT library (Fourier)"));
+ pnNumeric.place(6, 0, new JLabel("system"));
+ pnNumeric.place(6, 1, cmbSystem);
+ pnNumeric.place(6, 2, new JLabel("Show the system panel"));
- pnNumeric.place(7, 0, new JLabel("Machine Epsilon"));
- pnNumeric.place(7, 1, cmbEpsilon);
- 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)"));
+ pnNumeric.place(7, 0, new JLabel("display"));
+ pnNumeric.place(7, 1, cmbDisplayFinal);
+ pnNumeric.place(7, 2, new JLabel("Display the final output"));
+
+ pnNumeric.place(8, 0, new JLabel("multithreading"));
+ pnNumeric.place(8, 1, cmbMultithreading);
+ pnNumeric.place(8, 2, new JLabel("Activate multithreading"));
+
+ pnNumeric.place(9, 0, new JLabel("epsilon"));
+ pnNumeric.place(9, 1, cmbEpsilon);
+ pnNumeric.place(9, 2, new JLabel("<html>Machine Epsilon &epsilon;</html>"));
JScrollPane scroll = new JScrollPane(pnNumeric);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
- Config.register(getName(), "dim", cmbSep, "XYZ");
+ Config.register(getName(), "system", cmbSystem, cmbSystem.getItemAt(0));
+ Config.register(getName(), "display", cmbDisplayFinal, cmbDisplayFinal.getItemAt(0));
+ Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
cmbFFT.addActionListener(this);
- cmbType.addActionListener(this);
- cmbSep.addActionListener(this);
+ cmbSystem.addActionListener(this);
+ cmbDisplayFinal.addActionListener(this);
+ cmbMultithreading.addActionListener(this);
cmbEpsilon.addActionListener(this);
cmbNormalization.addActionListener(this);
getAction1Button().addActionListener(this);
init = true;
return panel;
}
private void update() {
setCommand(getCommand());
if (init)
setSynopsis("Norm " + cmbNormalization.getSelectedItem() + " " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
-System.out.println("" + e);
super.actionPerformed(e);
+System.out.println("" + e);
if (e.getSource() == getAction1Button()) {
cmbFFT.setSelectedIndex(0);
- cmbSep.setSelectedIndex(0);
- cmbType.setSelectedIndex(0);
+ cmbMultithreading.setSelectedIndex(0);
+ cmbDisplayFinal.setSelectedIndex(0);
+ cmbSystem.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
cmbNormalization.setSelectedIndex(0);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
- cmbSep.removeActionListener(this);
- cmbType.removeActionListener(this);
+ cmbMultithreading.removeActionListener(this);
+ cmbDisplayFinal.removeActionListener(this);
+ cmbSystem.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
cmbNormalization.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
similarity index 96%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
index 483370d..64a71fe 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ConfigModule.java
@@ -1,124 +1,126 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class ConfigModule extends AbstractModule implements ActionListener {
private JButton bnLoad;
private JButton bnSave;
private CustomizedTable table;
private JLabel lblDefault;
public ConfigModule(boolean expanded) {
super("Config", "", "", "", expanded);
}
@Override
public String getCommand() {
+ setSynopsis(new File(Config.getFilename()).getName());
return "";
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Key", String.class, 180, false));
columns.add(new CustomizedColumn("Value", String.class, Constants.widthGUI - 80, true));
table = new CustomizedTable(columns, true);
read();
lblDefault = new JLabel(Config.getFilename());
bnLoad = new JButton("Load");
bnSave = new JButton("Save");
lblDefault.setBorder(BorderFactory.createEtchedBorder());
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
button.add(bnLoad);
button.add(bnSave);
JPanel panel = new JPanel(new BorderLayout());
panel.add(lblDefault, BorderLayout.NORTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnLoad.addActionListener(this);
bnSave.addActionListener(this);
+ setSynopsis(new File(Config.getFilename()).getName());
return panel;
}
private void read() {
String filename = Config.getFilename();
File file = new File(filename);
if (file.exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String entry = line.trim();
if (!entry.startsWith("#")) {
String[] parts = entry.split("=");
if (parts.length == 2)
table.append(parts);
}
}
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void close() {
bnLoad.removeActionListener(this);
bnSave.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
similarity index 70%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
index 74716db..e66b396 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ControllerModule.java
@@ -1,244 +1,266 @@
/*
* 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;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import signal.Constraint;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtTime;
private JTextField txtIterations;
private JComboBox<String> cmbConstraint;
+ private JComboBox<String> cmbStats;
+ private JComboBox<String> cmbMonitor;
+ private JComboBox<String> cmbVerbose;
private JCheckBox chkResidu;
private JCheckBox chkReference;
- private JCheckBox chkConstraint;
private JCheckBox chkTime;
- private JCheckBox chkItermax;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
- if (chkConstraint.isSelected())
+ if (cmbMonitor.getSelectedIndex() != 0)
+ cmd += "-monitor " + cmbMonitor.getSelectedItem() + " ";
+ if (cmbVerbose.getSelectedIndex() != 0)
+ cmd += "-verbose " + cmbVerbose.getSelectedItem() + " ";
+ if (cmbStats.getSelectedIndex() != 0)
+ cmd += "-stats " + cmbStats.getSelectedItem() + " ";
+ if (cmbConstraint.getSelectedIndex() != 0)
cmd += "-constraint " + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + txtResidu.getText() + " ";
if (chkTime.isSelected())
cmd += "-time " + txtTime.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
- chkTime = new JCheckBox("Time Limitation (s)");
- chkItermax = new JCheckBox("Early Stopping");
- chkConstraint = new JCheckBox("Constraint");
- chkResidu = new JCheckBox("Residu Minimun");
- chkReference = new JCheckBox("Reference");
+ chkTime = new JCheckBox("");
+ chkResidu = new JCheckBox("");
+ chkReference = new JCheckBox("");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtTime = new JTextField("3600");
txtIterations = new JTextField("Iteration max (mandatory)");
txtIterations.setEditable(false);
+ cmbMonitor = new JComboBox<String>(new String[] {"console table", "console", "table", "no" });
+ cmbVerbose = new JComboBox<String>(new String[] {"log", "quiet", "mute", "prolix" });
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
+ cmbStats = new JComboBox<String>(new String[] {"no", "show", "show + save", "save"});
txtReference.setPreferredSize(new Dimension(200, 20));
- GridPanel pn = new GridPanel(true);
-
- 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);
+ GridPanel pn = new GridPanel(true, 2);
+
+ pn.place(0, 0, "monitor");
+ pn.place(0, 2, cmbMonitor);
+ pn.place(0, 3, "Monitoring message");
+
+ pn.place(1, 0, "verbose");
+ pn.place(1, 2, cmbVerbose);
+ pn.place(1, 3, "");
+
+ pn.place(3, 0, "stats");
+ pn.place(3, 2, cmbStats);
+ pn.place(3, 3, "Signal's statistics");
+
+ pn.place(4, 0, "constraint");
+ pn.place(4, 2, cmbConstraint);
+ pn.place(4, 3, "Additional constraint");
+
+ pn.place(5, 0, "residu");
+ pn.place(5, 1, chkResidu);
+ pn.place(5, 2, txtResidu);
+ pn.place(5, 3, "Additional stopping criteria");
+
+ pn.place(6, 0, "time");
+ pn.place(6, 1, chkTime);
+ pn.place(6, 2, txtTime);
+ pn.place(6, 3, "Additional stopping criteria");
+
+ pn.place(7, 0, "reference");
+ pn.place(7, 1, chkReference);
+ pn.place(7, 2, 2, 1, txtReference);
+ pn.place(8, 2, bnBrowse);
+ pn.place(8, 3, 1, 1, "Ground-truth file");
JScrollPane scroll = new JScrollPane(pn);
- scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "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");
+ Config.register(getName(), "constraint", cmbConstraint, cmbConstraint.getItemAt(0));
+ Config.register(getName(), "stats", cmbStats, cmbStats.getItemAt(0));
+ Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
+ Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
- 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);
+ cmbMonitor.addActionListener(this);
+ cmbVerbose.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");
+ count += (chkReference.isSelected() ? 1 : 0);
+ setSynopsis("" + count + " controls");
+
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
- 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);
-
+ cmbStats.setSelectedIndex(0);
+ cmbMonitor.setSelectedIndex(0);
+ cmbVerbose.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);
+ cmbVerbose.removeActionListener(this);
+ cmbMonitor.removeActionListener(this);
+ cmbConstraint.removeActionListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
similarity index 61%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
index 0f5168e..3ab5d1a 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/DirectoryModule.java
@@ -1,186 +1,207 @@
/*
* 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;
-
+package deconvolutionlab.module;
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
+import java.io.IOException;
+import java.util.List;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.component.GridPanel;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
+import deconvolutionlab.module.ImageModule.LocalDropTarget;
-public class WatcherModule extends AbstractModule implements ActionListener, KeyListener {
+public class DirectoryModule 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;
- public WatcherModule(boolean expanded) {
- super("Path & Watcher", "", "Default", "", expanded);
+ public DirectoryModule(boolean expanded) {
+ super("Path", "", "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);
+ txtPath = new JTextField("", 35);
bnBrowse = new JButton("Browse");
GridPanel pn1 = new GridPanel(true, 3);
- pn1.place(0, 0, 2, 1, "Working directory");
+ pn1.place(0, 0, 3, 1, "Working directory");
pn1.place(1, 0, cmbPath);
pn1.place(1, 1, bnBrowse);
- pn1.place(2, 0, 2, 1, txtPath);
+ pn1.place(2, 0, 3, 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);
-
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);
-
+
+ // Add drop area
+ pn1.setDropTarget(new LocalDropTarget());
+ txtPath.setDropTarget(new LocalDropTarget());
+ getCollapsedPanel().setDropTarget(new LocalDropTarget());
+ bnTitle.setDropTarget(new LocalDropTarget());
+ bnSynopsis.setDropTarget(new LocalDropTarget());
+ bnExpand.setDropTarget(new LocalDropTarget());
+
cmbPath.addActionListener(this);
txtPath.addKeyListener(this);
- cmbVerbose.addActionListener(this);
- cmbDisplay.addActionListener(this);
- cmbMultithreading.addActionListener(this);
- cmbMonitor.addActionListener(this);
bnBrowse.addActionListener(this);
+ getAction1Button().addActionListener(this);
return panel;
}
private void update() {
-
setCommand(getCommand());
if (cmbPath.getSelectedIndex() == 0) {
txtPath.setText(System.getProperty("user.dir"));
txtPath.setEnabled(false);
bnBrowse.setEnabled(false);
}
else {
txtPath.setEnabled(true);
bnBrowse.setEnabled(true);
}
- setSynopsis(txtPath.getText());
+ setSynopsis(new File(txtPath.getText()).getName());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtPath.setText(f.getAbsolutePath());
}
}
else if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
}
+ else if (e.getSource() == getAction1Button()) {
+ txtPath.setText(System.getProperty("user.dir"));
+ txtPath.setEnabled(false);
+ bnBrowse.setEnabled(false);
+ }
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();
}
+ public class LocalDropTarget extends DropTarget {
+
+ @Override
+ public void drop(DropTargetDropEvent e) {
+ e.acceptDrop(DnDConstants.ACTION_COPY);
+ e.getTransferable().getTransferDataFlavors();
+ Transferable transferable = e.getTransferable();
+ DataFlavor[] flavors = transferable.getTransferDataFlavors();
+ for (DataFlavor flavor : flavors) {
+ if (flavor.isFlavorJavaFileListType()) {
+ try {
+ List<File> files = (List<File>) transferable.getTransferData(flavor);
+ for (File file : files) {
+ cmbPath.setSelectedIndex(1);
+ bnBrowse.setEnabled(true);
+ txtPath.setEnabled(true);
+ if (file.isDirectory())
+ txtPath.setText(file.getAbsolutePath());
+ else
+ txtPath.setText(file.getParent());
+ update();
+ }
+ }
+ catch (UnsupportedFlavorException ex) {
+ ex.printStackTrace();
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ e.dropComplete(true);
+ super.drop(e);
+ }
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java b/DeconvolutionLab2/src/deconvolutionlab/module/GroupedModulePanel.java
similarity index 98%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/GroupedModulePanel.java
index 8fec2b5..c483500 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/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;
+package deconvolutionlab.module;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import deconvolutionlab.LabPanel;
public class GroupedModulePanel extends JPanel {
private ArrayList<AbstractModule> modules;
private LabPanel parent;
private Dimension min;
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/module/ImageModule.java
similarity index 92%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
index 1e9e5b0..0e11e00 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ImageModule.java
@@ -1,353 +1,362 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
super("Image", "-image", (Lab.getPlatform() == Imager.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
+ // Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
-
+ bnTitle.setDropTarget(new LocalDropTarget());
+ bnSynopsis.setDropTarget(new LocalDropTarget());
+ bnExpand.setDropTarget(new LocalDropTarget());
+
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
+ bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
+ bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
+ bnSynthetic.setToolTipText("Add a new source artificially created");
+ bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
- getAction1Button().setToolTipText("Select the active window");
+ getAction1Button().setToolTipText("Select the active window from the running platform");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
-
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
- dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
+ dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
-
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
- if (name.equals(factory.getName().trim()))
+ System.out.println(">>edit>> " + name + " == " + factory.getName().trim());
+
+ if (name.equals(factory.getName().trim())) {
synthetic(true);
- return;
+ return;
+ }
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
deconvolution.openImage();
if (stack) {
RealSignal x = deconvolution.getImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
-
+
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
-
+
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
- table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
+ table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
- table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
+ table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
similarity index 99%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
index b6eca9e..5227327 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/LanguageModule.java
@@ -1,251 +1,251 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.Token;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolutionlab.Config;
public class LanguageModule extends AbstractModule implements ActionListener {
private HTMLPane language;
private JComboBox<String> cmb;
private JComboBox<String> gui;
private JTextField txt;
public LanguageModule(boolean expanded) {
super("Language", "", "", "", expanded);
}
public String getJobName() {
if (txt != null)
return txt.getText();
return "";
}
@Override
public JPanel buildExpandedPanel() {
language = new HTMLPane("Monaco", 100, 100);
cmb = new JComboBox<String>(new String[] { "Command line", "ImageJ Macro", "Java", "Matlab" });
gui = new JComboBox<String>(new String[] { "Run (Headless)", "Launch (with control panel)" });
txt = new JTextField("Job", 8);
JPanel pn = new JPanel(new BorderLayout());
pn.add(cmb, BorderLayout.WEST);
pn.add(txt, BorderLayout.CENTER);
pn.add(gui, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(language.getPane(), BorderLayout.CENTER);
cmb.addActionListener(this);
gui.addActionListener(this);
Config.register(getName(), "language", cmb, cmb.getItemAt(0));
Config.register(getName(), "headless", gui, gui.getItemAt(0));
Config.register(getName(), "job", txt, "Job");
language.clear();
return panel;
}
@Override
public void expand() {
super.expand();
update();
}
public void update() {
if (cmb.getSelectedIndex() == 0) {
language.clear();
String run = gui.getSelectedIndex() == 0 ? " Run " : " Launch ";
language.append("p", "java -jar DeconvolutionLab_2.jar " + run + Command.command());
language.append("p", "");
language.append("p", "java -cp JTransforms.jar:DeconvolutionLab_2.jar DeconvolutionLab2 "+ run + Command.command());
}
else if (cmb.getSelectedIndex() == 1) {
language.clear();
language.append("p", imagej(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 2) {
language.clear();
language.append("p", java(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 3) {
language.clear();
language.append("p", matlab());
}
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb)
update();
if (e.getSource() == gui)
update();
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
update();
}
@Override
public String getCommand() {
return "";
}
private String matlab() {
String job = txt.getText();
String script = "";
String cmd = Command.command();
Deconvolution d = new Deconvolution("Matlab", cmd);
String options = Command.extractOptions(cmd);
- AbstractAlgorithm algo = d.getAlgo();
+ AbstractAlgorithm algo = d.getAlgorithm();
if (algo == null)
return "ERROR";
String s = algo.getShortnames()[0];
String param = algo.getParametersAsString();
script += p("% this function returns the deconvolved image as an 3D matrix");
script += p("% image is a 3D matrix containing the image");
script += p("% psf is a 3D matrix containing the PSF");
script += p("function result = " + job + "(image, psf)");
script += p1("% Install first DeconvolutionLab_2.jar into the java directory of Matlab");
script += p1("javaaddpath([matlabroot filesep 'java' filesep 'DeconvolutionLab_2.jar'])");
script += p1("% Run the deconvolution\n");
script += p1("result = DL2." + s + "(image, psf, " + param +" , '" + options +"');");
script += p("end");
return script;
}
private String imagej(boolean headless) {
String job = txt.getText();
String macro = p("// Job: " + job + " ");
macro += p("// Macro generated by DeconvolutionLab2 ");
macro += p("// " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()) + " ");
String param = p("parameters = \"\" ");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = "image = \" NOT DEFINED \" ";
String psf = "psf = \" NOT DEFINED \" ";
String algo = "algo = \" NOT DEFINED \" ";
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p("image = \" -image " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-psf"))
psf = p("psf = \" -psf " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-algorithm"))
algo = p("algorithm = \" -algorithm " + token.parameters.trim() + "\" ");
else
param += p("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\"");
}
String option = macro + image + psf + algo + param;
String cmd = "";
if (headless)
cmd = p("run(\"DeconvolutionLab2 Run\", image + psf + algorithm + parameters)");
else
cmd = p("run(\"DeconvolutionLab2 Launch\", image + psf + algorithm + parameters)");
return option + cmd;
}
private String java(boolean headless) {
String job = txt.getText();
String code = "";
code += p("import deconvolution.Deconvolution;");
code += p("import ij.plugin.PlugIn;");
code += p("");
code += p("public class DeconvolutionLab2_" + job + " implements PlugIn {");
code += p1("public DeconvolutionLab2_" + job + "() {");
String param = p2("String parameters = \"\";");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = p2("String image = \" NOT DEFINED \";");
String psf = p2("String psf = \" NOT DEFINED \";");
String algo = p2("String algo = \" NOT DEFINED \";");
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p2("String image = \" -image " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-psf"))
psf = p2("String psf = \" -psf " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-algorithm"))
algo = p2("String algorithm = \" -algorithm " + token.parameters.trim() + "\";");
else
param += p2("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\";");
}
code += image + psf + algo + param;
code += p2("new Deconvolution(image + psf + algorithm + parameters)");
code += p1("}");
code += p1("");
code += p1("@Override");
code += p1("public void run(String arg0) {");
code += p2(" new DeconvolutionLab2_" + job + "();");
code += p1("}");
code += p("}");
return code;
}
private String p(String content) {
return "<p>" + content + "</p>";
}
private String p1(String content) {
return "<p style=\"padding-left:10px\">" + content + "</p>";
}
private String p2(String content) {
return "<p style=\"padding-left:20px\">" + content + "</p>";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
similarity index 90%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
index 1052d7f..122e3c7 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/LicenceModule.java
@@ -1,88 +1,81 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
public class LicenceModule extends AbstractModule {
public LicenceModule(boolean expanded) {
super("Licence", "", "", "", expanded);
}
@Override
public String getCommand() {
+ setSynopsis("GNU General Public License");
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p",
"DeconvolutionLab2 is free software: you can redistribute it "+
"and/or modify it under the terms of the GNU General " +
"Public License as published by the Free Software Foundation, " +
"either version 3 of the License, or (at your option) any later version.");
html.append("p",
"DeconvolutionLab2 is distributed in the hope that it will be useful, " +
"but WITHOUT ANY WARRANTY; without even the implied warranty " +
"of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " +
"See the GNU General Public License for more details.");
html.append("p",
"You should have received a copy of the GNU General Public License along with " +
"DeconvolutionLab2. If not, see http://www.gnu.org/licenses/.");
panel.add(html.getPane(), BorderLayout.CENTER);
- getAction1Button().addActionListener(this);
+ setSynopsis("GNU General Public License");
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/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
similarity index 99%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
index 105dd9c..01bf3fe 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/OutputModule.java
@@ -1,236 +1,236 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
public class OutputModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnStack;
private JButton bnSeries;
private JButton bnMIP;
private JButton bnOrtho;
private JButton bnPlanar;
private JButton bnFigure;
public OutputModule(boolean expanded) {
super("Output", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = " ";
if (table == null)
return cmd;
for (int i = 0; i < table.getRowCount(); i++) {
String[] values = new String[table.getColumnCount()];
for(int c=0; c<table.getColumnCount(); c++)
values[c] = table.getCell(i, c) == null ? "" : table.getCell(i, c).trim();
cmd += " -out " + values[0] + " " + values[1] + " " + values[2] + " " + values[3] + " " + values[4];
if (values[5].equals(""))
cmd += " noshow";
if (values[6].equals(""))
cmd += " nosave";
}
return cmd;
}
public void update() {
setCommand(getCommand());
setSynopsis(table.getRowCount() + " output" + (table.getRowCount() > 1 ? "s" : ""));
Command.command();
getAction1Button().setEnabled(table.getRowCount() > 0);
}
@Override
public JPanel buildExpandedPanel() {
String[] dynamics = { "intact", "rescaled", "normalized", "clipped" };
String[] types = { "float", "short", "byte" };
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Mode", String.class, 80, false));
columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
columns.add(new CustomizedColumn("Keypoint", String.class, 120, false));
columns.add(new CustomizedColumn("Show", String.class, 50, false));
columns.add(new CustomizedColumn("Save", String.class, 50, false));
columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(5).setMaxWidth(50);
table.getColumnModel().getColumn(6).setMaxWidth(50);
table.getColumnModel().getColumn(7).setMaxWidth(30);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(3).setMaxWidth(100);
table.addMouseListener(this);
bnStack = new JButton("\u2295 stack");
bnSeries = new JButton("\u2295 series");
bnMIP = new JButton("\u2295 mip");
bnOrtho = new JButton("\u2295 ortho");
bnPlanar = new JButton("\u2295 planar");
bnFigure = new JButton("\u2295 figure");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 6));
pn.setFloatable(false);
pn.add(bnStack);
pn.add(bnSeries);
pn.add(bnMIP);
pn.add(bnOrtho);
pn.add(bnPlanar);
pn.add(bnFigure);
JToolBar tool = new JToolBar("Path");
tool.setBorder(BorderFactory.createEmptyBorder());
tool.setLayout(new BorderLayout());
tool.setFloatable(false);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(tool, BorderLayout.NORTH);
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnStack.addActionListener(this);
bnSeries.addActionListener(this);
bnMIP.addActionListener(this);
bnOrtho.addActionListener(this);
bnPlanar.addActionListener(this);
bnFigure.addActionListener(this);
getAction1Button().addActionListener(this);
Config.registerTable(getName(), "output", table);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
View view = null;
if (e.getSource() == bnStack)
view = View.STACK;
else if (e.getSource() == bnSeries)
view = View.SERIES;
else if (e.getSource() == bnMIP)
view = View.MIP;
else if (e.getSource() == bnOrtho)
view = View.ORTHO;
else if (e.getSource() == bnPlanar)
view = View.PLANAR;
else if (e.getSource() == bnFigure)
view = View.FIGURE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out != null)
table.insert(out.getAsString());
//Lab.setVisible(new OutputPanel(view), "panel", 30, 30);
update();
}
if (e.getSource() == getAction1Button()) {
table.removeRows();
}
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 7) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnStack.removeActionListener(this);
bnSeries.removeActionListener(this);
bnMIP.removeActionListener(this);
bnOrtho.removeActionListener(this);
bnPlanar.removeActionListener(this);
bnFigure.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
similarity index 92%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
index 43d9f18..3019f59 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PSFModule.java
@@ -1,341 +1,350 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
super("PSF", "-psf", "", "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
+ // Add drop area
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
+ bnTitle.setDropTarget(new LocalDropTarget());
+ bnSynopsis.setDropTarget(new LocalDropTarget());
+ bnExpand.setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
- if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
- bnPlatform.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");
+
+ bnFile.setToolTipText("Add a new source read from a single file (3D z-stack)");
+ bnDirectory.setToolTipText("Add a new source read from the 2D images from a directory");
+ bnSynthetic.setToolTipText("Add a new source artificially created");
+ bnPlatform.setToolTipText("Add a new source from a list of images of the platform");
+getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
- dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
+ dlg.setParameters(table.getCell(row, 0), table.getCell(row, 2));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
- if (name.equals(factory.getName().trim()))
+ if (name.equals(factory.getName().trim())) {
synthetic(true);
return;
+ }
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
- table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
+ table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "\u232B" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
- table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
+ table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
similarity index 98%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
index 7537dd6..56419f5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/PreferencesModule.java
@@ -1,73 +1,73 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import bilib.component.GridPanel;
import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Config;
public class PreferencesModule extends AbstractModule {
private SpinnerRangeInteger spnMaxItems;
public PreferencesModule(boolean expanded) {
super("Preferences", "", "", "", expanded);
}
@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/module/RunningModule.java
similarity index 70%
rename from DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
rename to DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java
index 89baf47..4ce133a 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/RunningModule.java
@@ -1,264 +1,216 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package deconvolutionlab.modules;
+package deconvolutionlab.module;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JTextField;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
public class RunningModule extends AbstractModule implements MouseListener {
private CustomizedTable table;
private String[] valuesMonitor;
private String[] valuesVerbose;
- private String[] 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", "mute", "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/fft/AbstractFFT.java b/DeconvolutionLab2/src/fft/AbstractFFT.java
index 271bdb7..90d3819 100644
--- a/DeconvolutionLab2/src/fft/AbstractFFT.java
+++ b/DeconvolutionLab2/src/fft/AbstractFFT.java
@@ -1,101 +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 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("fft(" + x.name + ")", nx, ny, nz);
transformInternal(x, XAllocated);
return XAllocated;
}
public ComplexSignal transform(RealSignal x) {
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("ifft(" + X.name + ")", nx, ny, nz);
inverseInternal(X, xAllocated);
return xAllocated;
}
public RealSignal inverse(ComplexSignal X) {
RealSignal x = new RealSignal("ifft(" + X.name + ")", nx, ny, nz);
inverseInternal(X, x);
return x;
}
public abstract String getName();
+ public abstract boolean isMultithreadable();
public int getSizeX() {
return nx;
}
public int getSizeY() {
return ny;
}
public int getSizeZ() {
return nz;
}
}
diff --git a/DeconvolutionLab2/src/fft/AbstractFFTLibrary.java b/DeconvolutionLab2/src/fft/AbstractFFTLibrary.java
index 60355ba..f1673ca 100644
--- a/DeconvolutionLab2/src/fft/AbstractFFTLibrary.java
+++ b/DeconvolutionLab2/src/fft/AbstractFFTLibrary.java
@@ -1,57 +1,56 @@
/*
* 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;
public abstract class AbstractFFTLibrary {
protected boolean installed = false;
protected ArrayList<AbstractFFT> ffts = new ArrayList<AbstractFFT>();
public abstract AbstractFFT getDefaultFFT();
public abstract String getLibraryName();
public abstract String getCredit();
public abstract String getLicence();
- public abstract boolean isMultithreadable();
public abstract String getLocation();
public boolean isInstalled() {
return installed;
}
public ArrayList<AbstractFFT> getFFTs() {
return ffts;
}
}
diff --git a/DeconvolutionLab2/src/fft/FFTPanel.java b/DeconvolutionLab2/src/fft/FFTPanel.java
index 377962d..7fdeb14 100644
--- a/DeconvolutionLab2/src/fft/FFTPanel.java
+++ b/DeconvolutionLab2/src/fft/FFTPanel.java
@@ -1,86 +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 bilib.component.HTMLPane;
import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
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 multit = lib.getDefaultFFT().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/fft/academic/Academic.java b/DeconvolutionLab2/src/fft/academic/Academic.java
index 66a090c..1f50501 100644
--- a/DeconvolutionLab2/src/fft/academic/Academic.java
+++ b/DeconvolutionLab2/src/fft/academic/Academic.java
@@ -1,74 +1,80 @@
/*
* 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.academic;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.Separability;
import signal.ComplexSignal;
import signal.RealSignal;
public class Academic extends AbstractFFT {
private AcademicFFT fftXYZ;
public Academic() {
super(Separability.XYZ);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
fftXYZ = new AcademicFFT(nx, ny, nz, 0, 0, 0);
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
float imag[] = new float[nx * ny * nz];
float real[] = x.getXYZ();
fftXYZ.directTransform(real, imag, null, null, AcademicFFT.InputDataType.REALINPUT);
X.setXYZ(real, imag);
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
float real[] = X.getRealXYZ();
float imag[] = X.getImagXYZ();
fftXYZ.inverseTransform(real, imag, null, null);
x.setXYZ(real);
}
@Override
public String getName() {
return "AcademicFFT";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return false;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/academic/AcademicFFT_XYZ.java b/DeconvolutionLab2/src/fft/academic/AcademicFFT_XYZ.java
index 950a230..8ca6d97 100644
--- a/DeconvolutionLab2/src/fft/academic/AcademicFFT_XYZ.java
+++ b/DeconvolutionLab2/src/fft/academic/AcademicFFT_XYZ.java
@@ -1,105 +1,112 @@
/*
* 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.academic;
/*
* 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.monitor.Monitors;
import fft.AbstractFFT;
import fft.Separability;
import signal.ComplexSignal;
import signal.RealSignal;
public class AcademicFFT_XYZ extends AbstractFFT {
private AcademicFFT fftXYZ;
public AcademicFFT_XYZ() {
super(Separability.XYZ);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
fftXYZ = new AcademicFFT(nx, ny, nz, 0, 0, 0);
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
float imag[] = new float[nx * ny * nz];
float real[] = x.getXYZ();
fftXYZ.directTransform(real, imag, null, null, AcademicFFT.InputDataType.REALINPUT);
X.setXYZ(real, imag);
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
float real[] = X.getRealXYZ();
float imag[] = X.getImagXYZ();
fftXYZ.inverseTransform(real, imag, null, null);
x.setXYZ(real);
}
@Override
public String getName() {
return "AcademicFFT XYZ";
}
+
+
+ @Override
+ public boolean isMultithreadable() {
+ return false;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/academic/AcademicFFT_XY_Z.java b/DeconvolutionLab2/src/fft/academic/AcademicFFT_XY_Z.java
index 1435d3d..301ca63 100644
--- a/DeconvolutionLab2/src/fft/academic/AcademicFFT_XY_Z.java
+++ b/DeconvolutionLab2/src/fft/academic/AcademicFFT_XY_Z.java
@@ -1,99 +1,105 @@
/*
* 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.academic;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.Separability;
import signal.ComplexSignal;
import signal.RealSignal;
public class AcademicFFT_XY_Z extends AbstractFFT {
private AcademicFFT fftXY;
private AcademicFFT fftZ;
public AcademicFFT_XY_Z() {
super(Separability.XY_Z);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
fftXY = new AcademicFFT(nx, ny, 0, 0);
fftZ = new AcademicFFT(nz, 0);
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
for (int k = 0; k < nz; k++) {
float real[] = new float[nx * ny];
float imag[] = new float[nx * ny];
System.arraycopy(x.data[k], 0, real, 0, nx * ny);
fftXY.directTransform(real, imag, null, null, AcademicFFT.InputDataType.REALINPUT);
X.setRealXY(k, real);
X.setImagXY(k, imag);
}
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
float real[] = X.getRealZ(i, j);
float imag[] = X.getImagZ(i, j);
fftZ.directTransform(real, imag, null, null, AcademicFFT.InputDataType.COMPLEXINPUT);
X.setRealZ(i, j, real);
X.setImagZ(i, j, imag);
}
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
for (int k = 0; k < nz; k++) {
float real[] = X.getRealXY(k);
float imag[] = X.getImagXY(k);
fftXY.inverseTransform(real, imag, null, null);
X.setRealXY(k, real);
X.setImagXY(k, imag);
}
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
float real[] = X.getRealZ(i, j);
float imag[] = X.getImagZ(i, j);
fftZ.inverseTransform(real, imag, null, null);
x.setZ(i, j, real);
}
}
@Override
public String getName() {
return "AcademicFFT XY and Z";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return false;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/academic/AcademicLibrary.java b/DeconvolutionLab2/src/fft/academic/AcademicLibrary.java
index 7134c58..861a5e0 100644
--- a/DeconvolutionLab2/src/fft/academic/AcademicLibrary.java
+++ b/DeconvolutionLab2/src/fft/academic/AcademicLibrary.java
@@ -1,82 +1,77 @@
/*
* 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.academic;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
public class AcademicLibrary extends AbstractFFTLibrary {
public AcademicLibrary() {
installed = true;
if (installed) {
ffts.add(new Academic());
ffts.add(new AcademicFFT_XYZ());
ffts.add(new AcademicFFT_XY_Z());
}
}
@Override
public String getLocation() {
return AcademicLibrary.class.getCanonicalName();
}
-
- @Override
- public boolean isMultithreadable() {
- return false;
- }
@Override
public String getCredit() {
return "http://bigwww.epfl.ch/thevenaz/academicFFT/ (P. Thévenaz)";
}
@Override
public String getLicence() {
String licence = "<h1>AcademicFFT of Philippe Thévenaz, EPFL.</h1>";
licence += "<p>EPFL makes no warranties of any kind on this software and ";
licence += "shall in no event be liable for damages of any kind in ";
licence += "connection with the use and exploitation of this technology.</p>";
return licence;
}
@Override
public String getLibraryName() {
return "Academic";
}
@Override
public AbstractFFT getDefaultFFT() {
return new Academic();
}
}
diff --git a/DeconvolutionLab2/src/fft/fftw/FFTW3D.java b/DeconvolutionLab2/src/fft/fftw/FFTW3D.java
index 4950293..afb2c8d 100644
--- a/DeconvolutionLab2/src/fft/fftw/FFTW3D.java
+++ b/DeconvolutionLab2/src/fft/fftw/FFTW3D.java
@@ -1,77 +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 fft.fftw;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.Separability;
import jfftw.complex.nd.Plan;
import signal.ComplexSignal;
import signal.RealSignal;
public class FFTW3D extends AbstractFFT {
private Plan planForwardFFTW = null;
private Plan planBackwardFFTW = null;
public FFTW3D() {
super(Separability.XYZ);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
int dim[] = new int[] {nz, ny, nx};
planForwardFFTW = new Plan(dim, Plan.FORWARD, Plan.ESTIMATE | Plan.IN_PLACE | Plan.USE_WISDOM);
planBackwardFFTW = new Plan(dim, Plan.BACKWARD, Plan.ESTIMATE | Plan.IN_PLACE | Plan.USE_WISDOM);
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
float interleave[] = x.getInterleaveXYZAtReal();
planForwardFFTW.transform(interleave);
X.setInterleaveXYZ(interleave);
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
float[] interleave = X.getInterleaveXYZ();
planBackwardFFTW.transform(interleave);
x.setInterleaveXYZAtReal(interleave);
x.multiply(1.0/(nx*ny*nz));
}
@Override
public String getName() {
return "FFTW2";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return true;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java b/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
index a8e2eb8..b0ceaa2 100644
--- a/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
+++ b/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
@@ -1,206 +1,200 @@
/*
* 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.fftw;
import java.io.File;
import java.security.CodeSource;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import jfftw.complex.nd.Plan;
public class FFTWLibrary extends AbstractFFTLibrary {
private String location;
public FFTWLibrary(Monitors monitors) {
String path = "";
boolean found = false;
if (!found) {
try {
CodeSource code = FFTWLibrary.class.getProtectionDomain().getCodeSource();
File file = new File(code.getLocation().toURI().getPath());
path = file.getParentFile().getPath() + File.separator + "FFTW" + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
CodeSource code = FFTWLibrary.class.getProtectionDomain().getCodeSource();
File file = new File(code.getLocation().toURI().getPath());
path = file.getParentFile().getPath() + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
path = System.getProperty("user.home") + File.separator + "FFTW" + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
path = System.getProperty("user.home") + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found)
return;
loadLibraries(monitors, path);
try {
new Plan(new int[] { 20, 20, 20 }, Plan.FORWARD, Plan.ESTIMATE | Plan.IN_PLACE | Plan.USE_WISDOM);
ffts.add(new FFTW3D());
installed = true;
}
catch (UnsatisfiedLinkError ex) {
ex.printStackTrace();
installed = false;
}
}
@Override
public String getLocation() {
return location;
}
- @Override
- public boolean isMultithreadable() {
- return true;
- }
-
@Override
public String getCredit() {
return "http://www.fftw.org (FFTW Version 2)";
}
@Override
public String getLibraryName() {
return "FFTW2";
}
@Override
public String getLicence() {
return "<h1>FFTW Version 2, " + "<p>http://www.fftw.org" + "<p>FFTW 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 2 of the License, or " + "(at your option) any later version.";
}
private static void loadLibraries(Monitors monitors, String path) {
try {
String osname = System.getProperty("os.name");
if (osname.startsWith("Linux")) {
String osarch = System.getProperty("os.arch");
if (osarch.contains("64")) {
System.load(path + "libFFTWJNI64.so");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "libFFTWJNI64.so");
}
else {
System.load(path + "libFFTWJNI32.so");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "libFFTWJNI32.so");
}
}
else if (osname.startsWith("Windows")) {
String osarch = System.getProperty("os.arch");
if (osarch.contains("64")) {
System.load(path + "FFTWJNIWin64.dll");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "FFTWJNIWin64.dll");
}
else {
System.load(path + "FFTWJNIWin32.dll");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "FFTWJNIWin32.dll");
}
}
else if (osname.startsWith("Mac")) {
System.load(path + "libFFTWJNIMac.jnilib");
monitors.log("Loading library FFTW for " + osname + " " + path + "libFFTWJNIMac.jnilib");
}
else {
monitors.log("FFTW is not provided for the architecture : " + osname);
}
}
catch (Exception ex) {
monitors.log("FFTW not found in : " + path);
}
}
private static boolean existsWidsom(Monitors monitors, String path) {
boolean found = false;
if (new File(path + "Wisdom").exists()) {
monitors.log("FFTW found in : " + path);
found = true;
}
else {
monitors.log("FFTW Widsom not found in : " + path);
found = false;
}
return found;
}
@Override
public AbstractFFT getDefaultFFT() {
return new FFTW3D();
}
-
}
diff --git a/DeconvolutionLab2/src/fft/jtransforms/JTransforms.java b/DeconvolutionLab2/src/fft/jtransforms/JTransforms.java
index ff5719b..039d8d6 100644
--- a/DeconvolutionLab2/src/fft/jtransforms/JTransforms.java
+++ b/DeconvolutionLab2/src/fft/jtransforms/JTransforms.java
@@ -1,89 +1,95 @@
/*
* 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.jtransforms;
import signal.ComplexSignal;
import signal.RealSignal;
import deconvolutionlab.monitor.Monitors;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_2D;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_3D;
import fft.AbstractFFT;
import fft.Separability;
public class JTransforms extends AbstractFFT {
private FloatFFT_3D fftXYZ = null;
private FloatFFT_2D fftXY = null;
public JTransforms() {
super(Separability.XYZ);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
try {
if (nz > 1)
fftXYZ = new FloatFFT_3D(nz, ny, nx);
else
fftXY = new FloatFFT_2D(ny, nx);
}
catch (Exception ex) {
System.out.println("check " + ex + ". " + nx + " " + ny + " " + nz);
}
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
float[] interleave = x.getInterleaveXYZAtReal();
if (fftXYZ != null)
fftXYZ.complexForward(interleave);
if (fftXY != null)
fftXY.complexForward(interleave);
X.setInterleaveXYZ(interleave);
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
float[] interleave = X.getInterleaveXYZ();
if (fftXYZ != null)
fftXYZ.complexInverse(interleave, true);
if (fftXY != null)
fftXY.complexInverse(interleave, true);
x.setInterleaveXYZAtReal(interleave);
}
@Override
public String getName() {
return "JTransforms";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return true;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XYZ.java b/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XYZ.java
index da8d8c6..2358533 100644
--- a/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XYZ.java
+++ b/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XYZ.java
@@ -1,89 +1,95 @@
/*
* 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.jtransforms;
import signal.ComplexSignal;
import signal.RealSignal;
import deconvolutionlab.monitor.Monitors;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_2D;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_3D;
import fft.AbstractFFT;
import fft.Separability;
public class JTransformsFFT_XYZ extends AbstractFFT {
private FloatFFT_3D fftXYZ = null;
private FloatFFT_2D fftXY = null;
public JTransformsFFT_XYZ() {
super(Separability.XYZ);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
try {
if (nz > 1)
fftXYZ = new FloatFFT_3D(nz, ny, nx);
else
fftXY = new FloatFFT_2D(ny, nx);
}
catch (Exception ex) {
System.out.println("check " + ex + ". " + nx + " " + ny + " " + nz);
}
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
float[] interleave = x.getInterleaveXYZAtReal();
if (fftXYZ != null)
fftXYZ.complexForward(interleave);
if (fftXY != null)
fftXY.complexForward(interleave);
X.setInterleaveXYZ(interleave);
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
float[] interleave = X.getInterleaveXYZ();
if (fftXYZ != null)
fftXYZ.complexInverse(interleave, true);
if (fftXY != null)
fftXY.complexInverse(interleave, true);
x.setInterleaveXYZAtReal(interleave);
}
@Override
public String getName() {
return "JTransforms XYZ";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return true;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XY_Z.java b/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XY_Z.java
index 5f02651..b6c6f09 100644
--- a/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XY_Z.java
+++ b/DeconvolutionLab2/src/fft/jtransforms/JTransformsFFT_XY_Z.java
@@ -1,102 +1,108 @@
/*
* 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.jtransforms;
import signal.ComplexSignal;
import signal.RealSignal;
import deconvolutionlab.monitor.Monitors;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_1D;
import edu.emory.mathcs.jtransforms.fft.FloatFFT_2D;
import fft.AbstractFFT;
import fft.Separability;
public class JTransformsFFT_XY_Z extends AbstractFFT {
private FloatFFT_2D fftXY = null;
private FloatFFT_1D fftZ = null;
public JTransformsFFT_XY_Z() {
super(Separability.XY_Z);
}
@Override
public void init(Monitors monitors, int nx, int ny, int nz) {
super.init(monitors, nx, ny, nz);
try {
fftXY = new FloatFFT_2D(ny, nx);
if (nz > 1)
fftZ = new FloatFFT_1D(nz);
}
catch (Exception ex) {
}
}
@Override
public void transformInternal(RealSignal x, ComplexSignal X) {
for (int k = 0; k < nz; k++) {
float interleave[] = x.getInterleaveXYAtReal(k);
fftXY.complexForward(interleave);
X.setInterleaveXY(k, interleave);
}
if (fftZ == null)
return;
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
float interleave[] = X.getInterleaveZ(i, j);
fftZ.complexForward(interleave);
X.setInterleaveZ(i, j, interleave);
}
}
@Override
public void inverseInternal(ComplexSignal X, RealSignal x) {
for (int k = 0; k < nz; k++) {
float interleave[] = X.getInterleaveXY(k);
fftXY.complexInverse(interleave, true);
X.setInterleaveXY(k, interleave);
}
if (fftZ != null) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
float interleave[] = X.getInterleaveZ(i, j);
fftZ.complexInverse(interleave, true);
X.setInterleaveZ(i, j, interleave);
}
}
x = X.getRealSignal();
}
@Override
public String getName() {
return "JTransforms XY_Z";
}
+
+ @Override
+ public boolean isMultithreadable() {
+ return true;
+ }
+
}
diff --git a/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java b/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
index 33ec577..50ca6b3 100644
--- a/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
+++ b/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
@@ -1,87 +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 fft.jtransforms;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
public class JTransformsLibrary extends AbstractFFTLibrary {
public JTransformsLibrary() {
System.out.println("JTransformsLibrary");
try {
Class.forName("org.jtransforms.fft.FloatFFT_3D");
Class.forName("org.jtransforms.fft.FloatFFT_1D");
Class.forName("org.jtransforms.fft.FloatFFT_2D");
installed = true;
}
catch (ClassNotFoundException ex) {
System.out.println("" + ex);
installed = false;
}
if (installed) {
ffts.add(new JTransforms());
ffts.add(new JTransformsFFT_XYZ());
ffts.add(new JTransformsFFT_XY_Z());
}
}
@Override
public String getLocation() {
return JTransformsLibrary.class.getCanonicalName();
}
- @Override
- public boolean isMultithreadable() {
- return true;
- }
-
@Override
public String getCredit() {
return "JTransforms of Piotr Wendykier";
}
@Override
public String getLibraryName() {
return "JTransforms";
}
@Override
public String getLicence() {
return "<h1>JTransforms of Piotr Wendykier</h1>" + "<p>https://sites.google.com/site/piotrwendykier/software/jtransforms" + "<p>JTransforms is distributed under the terms of the BSD-2-Clause license." + "<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " + "AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT " + "LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS" + "FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT " + "HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, " + "SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED " + "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; " + "OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, " + "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR " + "OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED " + "OF THE POSSIBILITY OF SUCH DAMAGE.";
}
@Override
public AbstractFFT getDefaultFFT() {
return new JTransforms();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java b/DeconvolutionLab2/src/resources/ImageLoader.java
similarity index 82%
rename from DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java
rename to DeconvolutionLab2/src/resources/ImageLoader.java
index 53f3827..b104ecc 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/splash/ImageLoader.java
+++ b/DeconvolutionLab2/src/resources/ImageLoader.java
@@ -1,50 +1,48 @@
/*
- * DeconvolutionLab2
+ * bilib --- Java Bioimaging Library ---
+ *
+ * Author: Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland
*
* 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.splash;
+package resources;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
public class ImageLoader {
public static Image get(String filename) {
URL url = ImageLoader.class.getResource(filename);
if (url != null) {
ImageIcon img = new ImageIcon(url, "") ;
return img.getImage();
}
return null;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/splash/celegans.jpg b/DeconvolutionLab2/src/resources/celegans.jpg
similarity index 100%
rename from DeconvolutionLab2/src/deconvolutionlab/splash/celegans.jpg
rename to DeconvolutionLab2/src/resources/celegans.jpg
diff --git a/DeconvolutionLab2/src/signal/RealSignal.java b/DeconvolutionLab2/src/signal/RealSignal.java
index 44351d4..1af1ba2 100644
--- a/DeconvolutionLab2/src/signal/RealSignal.java
+++ b/DeconvolutionLab2/src/signal/RealSignal.java
@@ -1,706 +1,732 @@
/*
* 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.awt.image.BufferedImage;
import deconvolutionlab.monitor.Monitors;
public class RealSignal extends Signal implements SignalListener {
private BufferedImage preview;
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(this);//name, nx, ny, ny, false);
}
@Override
public void notify(String name, double progress) {
SignalCollector.setProgress(progress);
}
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];
}
}
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];
}
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];
}
/**
* 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;
}
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];
}
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;
}
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];
}
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];
}
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;
}
return this;
}
+ /**
+ * Subtracts a scalar term (in-place processing)
+ *
+ * @param term
+ * @return the instance of the calling object
+ */
+ public RealSignal minus(float term) {
+ int nxy = nx * ny;
+ 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)
*
* @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]);
}
return this;
}
/**
* 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]);
}
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("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));
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 };
}
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 };
}
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];
}
public RealSignal getSlice(int z) {
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];
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];
}
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];
}
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];
}
}
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)
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];
}
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;
}
public RealSignal changeSizeAs(RealSignal model) {
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(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 RealSignal createOrthoview() {
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(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(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));
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];
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];
return view;
}
public RealSignal createMIP() {
String n = "mip(" + name + ")";
- int vx = nx + nz + 1;
- int vy = ny + nz + 1;
+ int vx = nx + nz;
+ int vy = ny + nz;
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 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;
+ int index = nx + 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);
+ int index = x + vx * (ny + z);
view.data[0][index] = Math.max(view.data[0][index], data[z][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(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;
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];
}
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) {
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 + "]";
}
public BufferedImage preview() {
if (preview != null)
return preview;
int nxy = nx*ny;
float[] pixels = new float[nx*ny];
for (int i = 0; i < nxy; i++)
for (int k = 0; k < nz; k++) {
pixels[i] = Math.max(pixels[i], data[k][i]);
}
float max = -Float.MAX_VALUE;
float min = Float.MAX_VALUE;
for (int i = 0; i < nxy; i++) {
if (pixels[i] > max)
max = pixels[i];
if (pixels[i] < min)
min = pixels[i];
}
float a = 255f / Math.max(max-min, (float)Operations.epsilon);
preview = 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)(a*(pixels[i+j*nx] - min));
preview.setRGB(i, j, alpha | (v << 16) | (v << 8) | v);
}
return preview;
}
public RealSignal log10() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)Math.log10(data[k][i]);
}
return this;
}
public RealSignal log() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)Math.log(data[k][i]);
}
return this;
}
public RealSignal exp() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)Math.exp(data[k][i]);
}
return this;
}
public RealSignal abs() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)Math.abs(data[k][i]);
}
return this;
}
public RealSignal sqrt() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)Math.sqrt(data[k][i]);
}
return this;
}
public RealSignal sqr() {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = (float)(data[k][i]*data[k][i]);
}
return this;
}
+ public RealSignal rescale(double min, double max) {
+ int nxy = nx * ny;
+ float minf = (float)min;
+ float stats[] = getStats();
+ float a = ((float)max-minf) / (stats[2] - stats[1]);
+ for(int k=0; k<nz; k++)
+ for(int i=0; i<nxy; i++) {
+ data[k][i] = a*(data[k][i] - stats[1]) + minf;
+ }
+ return this;
+ }
}
diff --git a/DeconvolutionLab2/src/signal/apodization/Apodization.java b/DeconvolutionLab2/src/signal/apodization/Apodization.java
index 1378a5e..20c0cd9 100644
--- a/DeconvolutionLab2/src/signal/apodization/Apodization.java
+++ b/DeconvolutionLab2/src/signal/apodization/Apodization.java
@@ -1,160 +1,161 @@
/*
* 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.Lab;
import deconvolutionlab.monitor.Monitors;
+import signal.Operations;
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 void apodize(Monitors monitors, RealSignal signal) {
if (apoX instanceof UniformApodization &&
apoY instanceof UniformApodization &&
apoZ instanceof UniformApodization) {
return;
}
if (monitors != null)
monitors.log("Apodization (" + apoX.getName() + ", " + apoY.getName() + ", " + apoZ.getName() + ")");
signal.setName("apo(" + signal.name + ")");
for(int i=0; i<signal.nx; i++) {
double cx = apoX.apodize(i, signal.nx);
for(int j=0; j<signal.ny; j++) {
double cy = apoY.apodize(j, signal.ny);
int index = i + signal.nx*j;
for(int k=0; k<signal.nz; k++) {
double cz = apoZ.apodize(k, signal.nz);
signal.data[k][index] = (float)(cx * cy * cz * signal.data[k][index]);
}
}
}
}
@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/Defocus.java b/DeconvolutionLab2/src/signal/factory/Airy.java
similarity index 53%
copy from DeconvolutionLab2/src/signal/factory/Defocus.java
copy to DeconvolutionLab2/src/signal/factory/Airy.java
index 14fc015..4eef21a 100644
--- a/DeconvolutionLab2/src/signal/factory/Defocus.java
+++ b/DeconvolutionLab2/src/signal/factory/Airy.java
@@ -1,99 +1,96 @@
/*
* 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 bilib.tools.Bessel;
import signal.RealSignal;
-public class Defocus extends SignalFactory {
+public class Airy extends SignalFactory {
- private double fwhm = 3.0;
- private double low2fwhm = 10;
- private double up2fwhm = 10;
+ private double pupil = 5;
+ private double lambda = 1;
+ private double distanceAxial = 0.5;
+ private double attenuationFactor = 3;
- public Defocus(double fwhm, double low2fwhm, double up2fwhm) {
- super(new double[] {fwhm, low2fwhm, up2fwhm});
+ public Airy(double pupil, double lambda, double distanceAxial, double attenuationFactor) {
+ super(new double[] {pupil, lambda, distanceAxial, attenuationFactor});
+ setParameters(new double[] {pupil, lambda, distanceAxial, attenuationFactor});
}
@Override
public String getName() {
- return "Defocus";
+ return "Airy";
}
-
+
@Override
public String[] getParametersName() {
- return new String[] {"FWHM at focus plane", "-Delta Z (2xFWHM)", "+Delta Z (2xFWHM)"};
- }
+ return new String[] { "Pupil (normalized unit)", "Wavelength (normalized unit)", "Axial distance (normalized unit)", "Attenuation Factor" };
+ }
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
- this.fwhm = parameters[0];
+ this.pupil = parameters[0];
if (parameters.length >= 2)
- this.low2fwhm = parameters[1];
+ this.lambda = parameters[1];
if (parameters.length >= 3)
- this.up2fwhm = parameters[2];
+ this.distanceAxial = parameters[2];
+ if (parameters.length >= 4)
+ this.attenuationFactor = parameters[3];
+
}
@Override
public double[] getParameters() {
- return new double[] {fwhm, low2fwhm, up2fwhm};
+ return new double[] {pupil, lambda, distanceAxial, attenuationFactor};
}
-
+
@Override
public void fill(RealSignal signal) {
- double sigma = 2.0 * Math.sqrt(2.0 * Math.log(2.0));
- double zup = zc - low2fwhm;
- double zlw = zc + up2fwhm;
- double Q = 2.0*Math.PI;
-
- double A0 = (amplitude-background) * (sigma * sigma * Q);
- double aup = 2.0 / ((zup-zc)*(zup-zc));
- double alw = 2.0 / ((zlw-zc)*(zlw-zc));
- for(int z=0; z<nz; z++) {
- double sigmaZ = sigma;
- if (z > zc)
- sigmaZ += sigma * aup * (z-zc)*(z-zc);
- else
- sigmaZ += sigma * alw * (z-zc)*(z-zc);
-
- double K = 1.0 / (2.0*sigmaZ*sigmaZ);
- double A = A0 / (sigmaZ * sigmaZ * 2);
- for(int x=0; x<nx; x++)
- for(int y=0; y<ny; y++) {
- double r2 = (x-xc)*(x-xc) + (y-yc)*(y-yc);
- signal.data[z][x+nx*y] = (float)(A * Math.exp(-K*r2) + background);
+ int xsize = nx / 2;
+ int ysize = ny / 2;
+ double d = Math.max(0.01, distanceAxial);
+ double diag = Math.sqrt(xsize*xsize + ysize*ysize);
+ double b = 2.0 * Math.PI * pupil / lambda;
+ double epsilon = 0.01 / diag;
+ for(int i=0; i<nx; i++)
+ for(int j=0; j<ny; j++) {
+ double r = Math.max(epsilon, Math.sqrt((i-xc)*(i-xc)+(j-yc)*(j-yc)) / diag);
+ for(int k=0; k<nz; k++) {
+ double dz = Math.abs(k-zc)/nz;
+ double z1 = d + dz;
+ double jc = Bessel.J1(r * b / z1) / r;
+ signal.data[k][i+j*nx] = (float)(jc*jc* Math.exp(-dz*attenuationFactor));
}
}
}
-
-
}
diff --git a/DeconvolutionLab2/src/signal/factory/Astigmatism.java b/DeconvolutionLab2/src/signal/factory/Astigmatism.java
index 36017a6..674eb7f 100644
--- a/DeconvolutionLab2/src/signal/factory/Astigmatism.java
+++ b/DeconvolutionLab2/src/signal/factory/Astigmatism.java
@@ -1,90 +1,95 @@
/*
* 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.RealSignal;
public class Astigmatism extends SignalFactory {
- private double fwhm = 3.0;
- private double factor = 0.20;
+ private double fwhm = 5.0;
+ private double factor = 1;
public Astigmatism(double fwhm, double factor) {
super(new double[] {fwhm, factor});
+ setParameters(new double[] {fwhm, factor});
}
@Override
public String getName() {
return "Astigmatism";
}
@Override
public String[] getParametersName() {
return new String[] {"FWHM at focus plane", "Astigmatism factor"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.fwhm = parameters[0];
if (parameters.length >= 2)
- this.fwhm = parameters[1];
+ this.factor = parameters[1];
}
@Override
public double[] getParameters() {
return new double[] {fwhm, factor};
}
@Override
public void fill(RealSignal signal) {
- double A = (amplitude-background);
double sigma = 0.8493218 * fwhm; // 1/sqrt(-2*log(0.5))
+ factor = 1;
for(int z=0; z<nz; z++) {
- double dx = (zc-z) * factor + 1;
- double dy = 1/dx;
- if (z-zc > 0) {
- dy = (z-zc) * factor + 1;
+ double dx = 1.0;
+ double dy = 1.0;
+ if (z>zc) {
+ dy = (1.0-factor*(z-zc)/(double)nz);
dx = 1.0 / dy;
}
+ if (z<zc) {
+ dx = (1.0-factor*(zc-z)/(double)nz);
+ dy = 1.0 / dx;
+ }
double kx = 1.0 / (dx * dx * sigma * sigma * 2.0);
double ky = 1.0 / (dy * dy * sigma * sigma * 2.0);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++) {
double r2 = kx*(x-xc)*(x-xc) + ky*(y-yc)*(y-yc);
- signal.data[z][x+nx*y] = (float)(A * Math.exp(-r2) + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * Math.exp(-r2));
}
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java b/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java
new file mode 100644
index 0000000..db3459f
--- /dev/null
+++ b/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java
@@ -0,0 +1,116 @@
+/*
+ * 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.monitor.Monitors;
+import fft.AbstractFFT;
+import fft.FFT;
+import signal.ComplexSignal;
+import signal.RealSignal;
+import signal.factory.complex.ComplexSignalFactory;
+
+public class AxialDiffractionSimulation extends SignalFactory {
+
+ private double pupil = 10;
+ private double defocusFactor = 10;
+ private double waveNumberAxial = 2;
+
+ public AxialDiffractionSimulation(double pupil, double defocusFactor, double waveNumberAxial) {
+ super(new double[] {pupil, defocusFactor, waveNumberAxial});
+ setParameters(new double[] {pupil, defocusFactor, waveNumberAxial});
+ }
+
+ @Override
+ public String getName() {
+ return "Axial Diffraction Simulation";
+ }
+
+ @Override
+ public String[] getParametersName() {
+ return new String[] { "Pupil Size", "Defocus Factor", "Wave Number (Axial)" };
+ }
+
+ @Override
+ public void setParameters(double[] parameters) {
+ if (parameters.length >= 1)
+ this.pupil = parameters[0];
+ if (parameters.length >= 2)
+ this.defocusFactor = parameters[1];
+ if (parameters.length >= 3)
+ this.waveNumberAxial = parameters[2];
+
+ }
+
+ @Override
+ public double[] getParameters() {
+ return new double[] {pupil, defocusFactor, waveNumberAxial};
+ }
+
+ @Override
+ public void fill(RealSignal signal) {
+ AbstractFFT fft = FFT.getFastestFFT().getDefaultFFT();
+ fft.init(Monitors.createDefaultMonitor(), nx, ny, 1);
+
+ double defocusTop = 2.0*Math.PI / (defocusFactor*pupil);
+ double defocusCen = 2.0*Math.PI / pupil;
+ int xsize = nx / 2;
+ int ysize = ny / 2;
+ int zsize = nz / 2;
+
+ double diag = Math.sqrt(xsize*xsize + ysize*ysize);
+ double wx, wy, wz;
+ for (int z = 0; z <= zsize; z++) {
+ float[][][] real = new float[xsize + 1][ysize + 1][1];
+ float[][][] imag = new float[xsize + 1][ysize + 1][1];
+ wz = waveNumberAxial*(zsize-z)*2.0*Math.PI / zsize;
+ double cosz = Math.cos(wz);
+ double sinz = Math.sin(wz);
+ double fcz = z * Math.abs(defocusTop-defocusCen) / zsize + defocusCen;
+ double fcz2 = fcz*fcz;
+ for (int y = 0; y <= ysize; y++)
+ for (int x = 0; x <= xsize; x++) {
+ wx = x * x;
+ wy = y * y;
+ double g = (wy + wx) / diag;
+ if (g < fcz2) {
+ real[x][y][0] = (float) (g * cosz);
+ imag[x][y][0] = (float) (g * sinz);
+ }
+ }
+ ComplexSignal c = ComplexSignalFactory.createHermitian(""+z, nx, ny, 1, real, imag);
+ RealSignal pz = fft.inverse(c).circular();
+ signal.setXY(z, pz.getXY(0));
+ signal.setXY(nz-1-z, pz.duplicate().getXY(0));
+ }
+ signal.rescale(0, amplitude);
+ }
+}
diff --git a/DeconvolutionLab2/src/signal/factory/Constant.java b/DeconvolutionLab2/src/signal/factory/Constant.java
index de0367f..30d09fe 100644
--- a/DeconvolutionLab2/src/signal/factory/Constant.java
+++ b/DeconvolutionLab2/src/signal/factory/Constant.java
@@ -1,70 +1,70 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal.factory;
import signal.RealSignal;
public class Constant extends SignalFactory {
public Constant() {
super(new double[] {});
}
@Override
public String getName() {
return "Constant";
}
@Override
public String[] getParametersName() {
return new String[] {};
}
@Override
public void setParameters(double[] parameters) {
}
@Override
public double[] getParameters() {
return new double[] {};
}
@Override
public void fill(RealSignal signal) {
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
- signal.data[z][x+nx*y] = (float)(amplitude + background);
+ signal.data[z][x+nx*y] = (float)(amplitude);
}
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/signal/factory/Cross.java b/DeconvolutionLab2/src/signal/factory/Cross.java
index d8d5d92..1a7b8fc 100644
--- a/DeconvolutionLab2/src/signal/factory/Cross.java
+++ b/DeconvolutionLab2/src/signal/factory/Cross.java
@@ -1,111 +1,112 @@
/*
* 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.RealSignal;
public class Cross extends SignalFactory {
private double thickness = 1.0;
private double slope = 1.0;
private double lengthPercentage = 30.0;
public Cross(double thickness, double slope, double lengthPercentage) {
super(new double[] {thickness, slope, lengthPercentage});
+ setParameters(new double[] {thickness, slope, lengthPercentage});
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.thickness = parameters[0];
if (parameters.length >= 2)
this.slope = parameters[1];
if (parameters.length >= 3)
this.lengthPercentage = parameters[2];
}
@Override
public String getName() {
return "Cross";
}
@Override
public double[] getParameters() {
return new double[] { thickness, slope, lengthPercentage };
}
@Override
public String[] getParametersName() {
return new String[] { "Thickness", "Sigmoid Curve Slope", "Length (percentage)" };
}
@Override
public void fill(RealSignal signal) {
double length = lengthPercentage * 0.01 * 0.5;
- double A = (amplitude - background);
int x1 = (int) Math.round(xc - nx * length);
int x2 = (int) Math.round(xc + nx * length);
int y1 = (int) Math.round(yc - ny * length);
int y2 = (int) Math.round(yc + ny * length);
int z1 = (int) Math.round(zc - nz * length);
int z2 = (int) Math.round(zc + nz * length);
for (int z = 0; z < nz; z++) {
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
double px = (x - xc) * (x - xc);
double py = (y - yc) * (y - yc);
double pz = (z - zc) * (z - zc);
double dx = Double.MAX_VALUE;
for (int i = x1; i < x2; i++)
dx = Math.min(dx, (i - x) * (i - x) + py + pz);
dx = Math.sqrt(dx) - thickness;
double ax = (1.0 - 1.0 / (1.0 + Math.exp(-dx / slope)));
double dy = Double.MAX_VALUE;
for (int j = y1; j < y2; j++)
dy = Math.min(dy, px + (j - y) * (j - y) + pz);
dy = Math.sqrt(dy) - thickness;
double ay = (1.0 - 1.0 / (1.0 + Math.exp(-dy / slope)));
double dz = Double.MAX_VALUE;
for (int k = z1; k < z2; k++)
dz = Math.min(dz, px + py + (k - z) * (k - z));
dz = Math.sqrt(dz) - thickness;
double az = (1.0 - 1.0 / (1.0 + Math.exp(-dz / slope)));
- signal.data[z][x + nx * y] = (float) (A * Math.max(Math.max(ax, ay), az) + background);
+ signal.data[z][x + nx * y] = (float) (Math.max(Math.max(ax, ay), az));
}
}
+ signal.rescale(0, amplitude);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Cube.java b/DeconvolutionLab2/src/signal/factory/Cube.java
index 1af4c5a..95c6712 100644
--- a/DeconvolutionLab2/src/signal/factory/Cube.java
+++ b/DeconvolutionLab2/src/signal/factory/Cube.java
@@ -1,85 +1,84 @@
/*
* 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.RealSignal;
public class Cube extends SignalFactory {
private double side = 10;
private double slope = 1;
public Cube(double side, double slope) {
super(new double[] {side, slope});
setParameters(new double[] {side, slope});
}
@Override
public String getName() {
return "Cube";
}
@Override
public String[] getParametersName() {
return new String[] {"Side", "Sigmoid Curve Slope"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.side = parameters[0];
if (parameters.length >= 2)
this.slope = parameters[1];
}
@Override
public double[] getParameters() {
return new double[] {side, slope};
}
@Override
public void fill(RealSignal signal) {
- double A = (amplitude-background);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
double dx = Math.sqrt((x-xc)*(x-xc)) - side;
double dy = Math.sqrt((y-yc)*(y-yc)) - side;
double dz = Math.sqrt((z-zc)*(z-zc)) - side;
double rx = 1.0- 1.0 / (1.0 + Math.exp(-dx/slope));
double ry = 1.0- 1.0 / (1.0 + Math.exp(-dy/slope));
double rz = 1.0- 1.0 / (1.0 + Math.exp(-dz/slope));
- signal.data[z][x+nx*y] = (float)(A * (rx *ry * rz) + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * (rx *ry * rz));
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/GridSpots.java b/DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
similarity index 68%
rename from DeconvolutionLab2/src/signal/factory/GridSpots.java
rename to DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
index c8ab88c..4214275 100644
--- a/DeconvolutionLab2/src/signal/factory/GridSpots.java
+++ b/DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
@@ -1,116 +1,113 @@
/*
* 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.RealSignal;
-public class GridSpots extends SignalFactory {
+public class CubeSphericalBeads extends SignalFactory {
private double radius = 3.0;
- private double slope = 1;
- private double spacing = 10.0;
+ private double slope = 0.5;
+ private double spacing = 8.0;
+ private double border = 8.0;
- public GridSpots(double radius, double slope, double spacing) {
- super(new double[] {radius, spacing});
+ public CubeSphericalBeads(double side, double slope, double spacing, double border) {
+ super(new double[] { side, slope, spacing, border });
+ setParameters(new double[] { side, slope, spacing, border });
}
@Override
public String getName() {
- return "GridSpots";
+ return "Cube of Spherical Beads";
}
@Override
public String[] getParametersName() {
- return new String[] { "Radius", "Sigmoid Curve Slope", "Spacing" };
+ return new String[] { "Radius", "Sigmoid Curve Slope", "Spacing", "Border" };
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.radius = parameters[0];
if (parameters.length >= 2)
this.slope = parameters[1];
if (parameters.length >= 3)
this.spacing = parameters[2];
+ if (parameters.length >= 4)
+ this.border = parameters[3];
}
@Override
public double[] getParameters() {
- return new double[] { radius, slope, spacing };
+ return new double[] { radius, slope, spacing, border };
}
@Override
- public void fill(RealSignal signal) {
- float b = (float) background;
- for (int x = 0; x < nx; x++)
- for (int y = 0; y < ny; y++)
- for (int z = 0; z < nz; z++)
- signal.data[z][x + nx * y] = b;
-
- int nc = (int) ((nx - spacing) / spacing);
-
- int nr = (int) ((2 * (ny - spacing)) / spacing);
- double deltaY = spacing / nr;
- int np = (int) ((2 * (nz - spacing)) / spacing);
- double deltaZ = spacing / np;
- double y = 0;
- double z = 0;
- for (int j = 0; j < nr; j++) {
- y += (spacing - j * deltaY);
- z = 0;
- for (int k = 0; k < np; k++) {
- z += (spacing - k * deltaZ);
- for (int i = 0; i < nc; i++) {
- double x = spacing + i * spacing;
- double A = amplitude- background; //i*(amplitude-background) / (nc+1);
- spot(signal, x, y, z, A);
+ public void fill(RealSignal signal) {
+ double dimx = (nx - 2.0 * border);
+ double dimy = (ny - 2.0 * border);
+ double dimz = (nz - 2.0 * border);
+ int mx = (int) (dimx / spacing) - 1;
+ int my = (int) (dimy / spacing) - 1;
+ int mz = (int) (dimz / spacing) - 1;
+ double stepx = dimx / mx;
+ float stepa = (float) (0.5 * amplitude / mx);
+ double x = border;
+ for (int i = 0; i < mx; i++) {
+ for (int j = 0; j < my; j++) {
+ double y = border + (dimy) * Math.sin(j * 0.5 * Math.PI / my);
+ for (int k = 0; k < mz; k++) {
+ double z = border + (dimz) * Math.sin(k * 0.5 * Math.PI / mz);
+ spot(signal, x, y, z, amplitude - i * stepa);
}
}
+ x += stepx;
}
}
private void spot(RealSignal signal, double xc, double yc, double zc, double A) {
int x1 = (int) Math.max(0, Math.round(xc - radius - 3 * slope));
int x2 = (int) Math.min(nx - 1, Math.round(xc + radius + 3 * slope));
int y1 = (int) Math.max(0, Math.round(yc - radius - 3 * slope));
int y2 = (int) Math.min(ny - 1, Math.round(yc + radius + 3 * slope));
int z1 = (int) Math.max(0, Math.round(zc - radius - 3 * slope));
int z2 = (int) Math.min(nz - 1, Math.round(zc + radius + 3 * slope));
for (int x = x1; x <= x2; x++)
for (int y = y1; y <= y2; y++)
for (int z = z1; z <= z2; z++) {
double dr = Math.sqrt((x - xc) * (x - xc) + (y - yc) * (y - yc) + (z - zc) * (z - zc)) - radius;
signal.data[z][x + nx * y] = Math.max(signal.data[z][x + nx * y], (float) (A - A / (1.0 + Math.exp(-dr / slope))));
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Defocus.java b/DeconvolutionLab2/src/signal/factory/Defocus.java
index 14fc015..c3ba9d8 100644
--- a/DeconvolutionLab2/src/signal/factory/Defocus.java
+++ b/DeconvolutionLab2/src/signal/factory/Defocus.java
@@ -1,99 +1,98 @@
/*
* 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.RealSignal;
public class Defocus extends SignalFactory {
private double fwhm = 3.0;
private double low2fwhm = 10;
private double up2fwhm = 10;
public Defocus(double fwhm, double low2fwhm, double up2fwhm) {
super(new double[] {fwhm, low2fwhm, up2fwhm});
+ setParameters(new double[] { fwhm, low2fwhm, up2fwhm });
}
@Override
public String getName() {
return "Defocus";
}
@Override
public String[] getParametersName() {
return new String[] {"FWHM at focus plane", "-Delta Z (2xFWHM)", "+Delta Z (2xFWHM)"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.fwhm = parameters[0];
if (parameters.length >= 2)
this.low2fwhm = parameters[1];
if (parameters.length >= 3)
this.up2fwhm = parameters[2];
}
@Override
public double[] getParameters() {
return new double[] {fwhm, low2fwhm, up2fwhm};
}
@Override
public void fill(RealSignal signal) {
- double sigma = 2.0 * Math.sqrt(2.0 * Math.log(2.0));
+ double sigma = fwhm;
double zup = zc - low2fwhm;
double zlw = zc + up2fwhm;
double Q = 2.0*Math.PI;
- double A0 = (amplitude-background) * (sigma * sigma * Q);
+ double A0 = (sigma * sigma * Q);
double aup = 2.0 / ((zup-zc)*(zup-zc));
double alw = 2.0 / ((zlw-zc)*(zlw-zc));
for(int z=0; z<nz; z++) {
double sigmaZ = sigma;
if (z > zc)
sigmaZ += sigma * aup * (z-zc)*(z-zc);
else
sigmaZ += sigma * alw * (z-zc)*(z-zc);
double K = 1.0 / (2.0*sigmaZ*sigmaZ);
double A = A0 / (sigmaZ * sigmaZ * 2);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++) {
double r2 = (x-xc)*(x-xc) + (y-yc)*(y-yc);
- signal.data[z][x+nx*y] = (float)(A * Math.exp(-K*r2) + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * Math.exp(-K*r2));
}
}
}
-
-
}
diff --git a/DeconvolutionLab2/src/signal/factory/AirySimulated.java b/DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
similarity index 74%
copy from DeconvolutionLab2/src/signal/factory/AirySimulated.java
copy to DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
index 644d04a..ef6e451 100644
--- a/DeconvolutionLab2/src/signal/factory/AirySimulated.java
+++ b/DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
@@ -1,80 +1,86 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal.factory;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.complex.ComplexSignalFactory;
-public class AirySimulated extends SignalFactory {
+public class DirectionalDerivative extends SignalFactory {
- private double mu = 1.0;
+ private double vx = 1.0;
+ private double vy = 1.0;
+ private double vz = 0.0;
- public AirySimulated(double mu) {
- super(new double[] {mu});
+ public DirectionalDerivative(double vx, double vy, double vz) {
+ super(new double[] {vx, vy, vz});
+ setParameters(new double[] {vx, vy, vz});
}
@Override
public String getName() {
- return "AirySimulated";
+ return "Directional Derivative";
}
@Override
public String[] getParametersName() {
- return new String[] {"Parameter (mu)"};
+ return new String[] {"Direction in X", "Direction in Y", "Direction in Z"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
- this.mu = parameters[0];
+ this.vx = parameters[0];
+ if (parameters.length >= 2)
+ this.vy = parameters[1];
+ if (parameters.length >= 3)
+ this.vz = parameters[2];
}
@Override
public double[] getParameters() {
- return new double[] {mu};
+ return new double[] {vx, vy, vz};
}
@Override
public void fill(RealSignal signal) {
AbstractFFT fft = FFT.createDefaultFFT(Monitors.createDefaultMonitor(), nx, ny, nz);
- ComplexSignal C = ComplexSignalFactory.airySimulated(nx, ny, nz, mu);
+ ComplexSignal C = ComplexSignalFactory.directionalDerivative(nx, ny, nz, vx, vy, vz);
RealSignal s = fft.inverse(C).circular().times((float)amplitude);
- s.times(s);
signal.copy(s);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/MotionBlur.java b/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
similarity index 58%
rename from DeconvolutionLab2/src/signal/factory/MotionBlur.java
rename to DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
index 61042fa..1d64521 100644
--- a/DeconvolutionLab2/src/signal/factory/MotionBlur.java
+++ b/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
@@ -1,93 +1,106 @@
/*
* 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 {
+public class DirectionalMotionBlur extends SignalFactory {
private double sigma = 3.0;
private double direction = 30.0;
- private double elongation = 3.0;
+ private double elongation = 30.0;
- public MotionBlur(double sigma, double direction, double elongation) {
+ public DirectionalMotionBlur(double sigma, double direction, double elongation) {
super(new double[] { sigma, direction, elongation });
+ setParameters(new double[] { sigma, direction, elongation });
}
@Override
public String getName() {
- return "MotionBlur";
+ return "Direction Motion Blur";
}
@Override
public String[] getParametersName() {
- return new String[] { "Sigma", "Direction", "Elongation" };
+ return new String[] { "Sigma", "Lateral Direction (Degree)", "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, 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);
+ double xe = elongation * cosa + xc;
+ double ye = elongation * sina + yc;
+ double dx = (xe - xc) / elongation;
+ double dy = (ye - yc) / elongation;
+ for(int k=0; k<elongation; k++) {
+ double x = xc + k*dx;
+ double y = yc + k*dy;
+ spot(signal, x, y, amplitude);
+ }
+ }
+
+ private void spot(RealSignal signal, double xc, double yc, double A) {
+ double slope = 1;
+ int x1 = (int) Math.max(0, Math.round(xc - sigma - 3 * slope));
+ int x2 = (int) Math.min(nx - 1, Math.round(xc + sigma + 3 * slope));
+ int y1 = (int) Math.max(0, Math.round(yc - sigma - 3 * slope));
+ int y2 = (int) Math.min(ny - 1, Math.round(yc + sigma + 3 * slope));
+ int z1 = (int) Math.max(0, Math.round(zc - sigma - 3 * slope));
+ int z2 = (int) Math.min(nz - 1, Math.round(zc + sigma + 3 * slope));
+ for (int x = x1; x <= x2; x++)
+ for (int y = y1; y <= y2; y++) {
+ double dr = Math.sqrt((x - xc) * (x - xc) + (y - yc) * (y - yc)) - sigma;
+ float v = (float) (A - A / (1.0 + Math.exp(-dr / slope)));
+ for (int z = z1; z <= z2; z++) {
+ signal.data[z][x + nx * y] = Math.max(signal.data[z][x + nx * y], v);
}
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/DoG.java b/DeconvolutionLab2/src/signal/factory/DoG.java
index 74dc3ce..dee4526 100644
--- a/DeconvolutionLab2/src/signal/factory/DoG.java
+++ b/DeconvolutionLab2/src/signal/factory/DoG.java
@@ -1,80 +1,81 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal.factory;
import signal.RealSignal;
public class DoG extends SignalFactory {
private double sigma1 = 3.0;
private double sigma2 = 4.0;
public DoG(double sigma1, double sigma2) {
super(new double[] {sigma1, sigma2});
+ setParameters(new double[] {sigma1, sigma2});
}
@Override
public String getName() {
return "DoG";
}
@Override
public String[] getParametersName() {
return new String[] {"Sigma 1", "Sigma 2"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.sigma1 = parameters[0];
if (parameters.length >= 2)
this.sigma2 = parameters[1];
}
@Override
public double[] getParameters() {
return new double[] {sigma1, sigma2};
}
@Override
public void fill(RealSignal signal) {
double K1 = 0.5 / (sigma1*sigma1);
double K2 = 0.5 / (sigma2*sigma2);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
double r2 = (x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc);
double v = Math.exp(-K2*r2) - Math.exp(-K1*r2);
- signal.data[z][x+nx*y] = (float)((amplitude-background) * v + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * v);
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/DoubleHelix.java b/DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
similarity index 52%
copy from DeconvolutionLab2/src/signal/factory/DoubleHelix.java
copy to DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
index b40c050..0f5ad20 100644
--- a/DeconvolutionLab2/src/signal/factory/DoubleHelix.java
+++ b/DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
@@ -1,92 +1,95 @@
-package signal.factory;
-
/*
* 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.RealSignal;
-public class DoubleHelix extends SignalFactory {
+public class DoubleConeWave extends SignalFactory {
- private double fwhm = 3.0;
- private double dist = 10;
- private double delta = 10;
+ private double aperture = 60;
+ private double periodTopZ = 5;
+ private double periodCenterZ = 15;
+ private double attenuation = 10;
- public DoubleHelix(double fwhm, double dist, double delta) {
- super(new double[] {fwhm, dist, delta});
+ public DoubleConeWave(double aperture, double periodTopZ, double periodCenterZ, double attenuation) {
+ super(new double[] {aperture, periodTopZ, periodCenterZ, attenuation});
+ setParameters(new double[] {aperture, periodTopZ, periodCenterZ, attenuation});
}
@Override
public String getName() {
- return "Double-Helix";
+ return "Double Cone Wave";
}
-
+
@Override
public String[] getParametersName() {
- return new String[] {"FWHM at focus plane", "Distance", "Delta Z (rotation PI)"};
- }
+ return new String[] { "Aperture", "Period TopZ", "Period CenterZ", "Attenuation" };
+ }
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
- this.fwhm = parameters[0];
+ this.aperture = parameters[0];
if (parameters.length >= 2)
- this.dist = parameters[1];
+ this.periodTopZ = parameters[1];
if (parameters.length >= 3)
- this.delta = parameters[2];
+ this.periodCenterZ = parameters[2];
+ if (parameters.length >= 4)
+ this.attenuation = parameters[3];
}
@Override
public double[] getParameters() {
- return new double[] {fwhm, dist, delta};
+ return new double[] {aperture, periodTopZ, periodCenterZ, attenuation};
}
-
+
@Override
public void fill(RealSignal signal) {
- double K = 0.5 / (fwhm*fwhm);
- double A = (amplitude-background);
- double T = Math.PI/(delta*2.0);
- for(int z=0; z<nz; z++) {
- double cosa = Math.cos((z-zc)*T);
- double sina = Math.sin((z-zc)*T);
- for(int x=0; x<nx; x++)
- for(int y=0; y<ny; y++) {
- double u = (x-xc) * cosa + (y-yc) * sina;
- double v = -(x-xc) * sina + (y-yc) * cosa;
- double u1 = (u - dist * 0.5);
- double u2 = (u + dist * 0.5);
- double p = Math.exp(-((u1 * u1 + v * v) * K)) + Math.exp(-((u2 * u2 + v * v) * K));
- signal.data[z][x+nx*y] = (float)(A * p + background);
+ double apernorm = (2.0*aperture)/(nx+ny);
+ double diag = Math.sqrt(nx*nx+ny*ny+nz*nz);
+ double step = (periodCenterZ-periodTopZ)/nz;
+ for(int i=0; i<nx; i++)
+ for(int j=0; j<ny; j++) {
+ double r = Math.sqrt((i-xc)*(i-xc)+(j-yc)*(j-yc));
+ for(int k=0; k<nz; k++) {
+ double z = Math.abs(k-zc);
+ double p = Math.sqrt(r*r + z*z)/diag;
+ double period = Math.max(1, periodCenterZ-step*z);
+ double sz = apernorm*z + period*0.25;
+ double s = 1.0 / (1.0+Math.exp(-(r+sz))) - 1.0 / (1.0+Math.exp(-(r-sz)));
+ double q = Math.cos(2.0*Math.PI*(r-apernorm*z)/period);
+ double g = (attenuation*p+1);
+ signal.data[k][i+j*nx] = (float)(amplitude * s * q * q / g);
}
}
}
-
-
}
diff --git a/DeconvolutionLab2/src/signal/factory/DoubleHelix.java b/DeconvolutionLab2/src/signal/factory/DoubleHelix.java
index b40c050..8720576 100644
--- a/DeconvolutionLab2/src/signal/factory/DoubleHelix.java
+++ b/DeconvolutionLab2/src/signal/factory/DoubleHelix.java
@@ -1,92 +1,92 @@
package signal.factory;
/*
* 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 signal.RealSignal;
public class DoubleHelix extends SignalFactory {
private double fwhm = 3.0;
- private double dist = 10;
+ private double dist = 30;
private double delta = 10;
public DoubleHelix(double fwhm, double dist, double delta) {
super(new double[] {fwhm, dist, delta});
+ setParameters(new double[] {fwhm, dist, delta});
}
@Override
public String getName() {
return "Double-Helix";
}
@Override
public String[] getParametersName() {
return new String[] {"FWHM at focus plane", "Distance", "Delta Z (rotation PI)"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.fwhm = parameters[0];
if (parameters.length >= 2)
this.dist = parameters[1];
if (parameters.length >= 3)
this.delta = parameters[2];
}
@Override
public double[] getParameters() {
return new double[] {fwhm, dist, delta};
}
@Override
public void fill(RealSignal signal) {
double K = 0.5 / (fwhm*fwhm);
- double A = (amplitude-background);
double T = Math.PI/(delta*2.0);
for(int z=0; z<nz; z++) {
double cosa = Math.cos((z-zc)*T);
double sina = Math.sin((z-zc)*T);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++) {
double u = (x-xc) * cosa + (y-yc) * sina;
double v = -(x-xc) * sina + (y-yc) * cosa;
double u1 = (u - dist * 0.5);
double u2 = (u + dist * 0.5);
double p = Math.exp(-((u1 * u1 + v * v) * K)) + Math.exp(-((u2 * u2 + v * v) * K));
- signal.data[z][x+nx*y] = (float)(A * p + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * p);
}
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Gaussian.java b/DeconvolutionLab2/src/signal/factory/Gaussian.java
index f4bfc01..95496f6 100644
--- a/DeconvolutionLab2/src/signal/factory/Gaussian.java
+++ b/DeconvolutionLab2/src/signal/factory/Gaussian.java
@@ -1,85 +1,86 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal.factory;
import signal.RealSignal;
public class Gaussian extends SignalFactory {
private double sigmaX = 3.0;
private double sigmaY = 3.0;
private double sigmaZ = 3.0;
public Gaussian(double sigmaX, double sigmaY, double sigmaZ) {
super(new double[] {sigmaX, sigmaY, sigmaZ});
+ setParameters(new double[] {sigmaX, sigmaY, sigmaZ});
}
@Override
public String getName() {
return "Gaussian";
}
@Override
public String[] getParametersName() {
return new String[] {"Sigma X", "Sigma Y", "Sigma Z"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.sigmaX = parameters[0];
if (parameters.length >= 2)
this.sigmaY = parameters[1];
if (parameters.length >= 3)
this.sigmaZ = parameters[2];
}
@Override
public double[] getParameters() {
return new double[] {sigmaX, sigmaY, sigmaZ};
}
@Override
public void fill(RealSignal signal) {
double KX = 0.5 / (sigmaX*sigmaX);
double KY = 0.5 / (sigmaY*sigmaY);
double KZ = 0.5 / (sigmaZ*sigmaZ);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
double r2 = KX*(x-xc)*(x-xc) + KY*(y-yc)*(y-yc) + KZ*(z-zc)*(z-zc);
- signal.data[z][x+nx*y] = (float)((amplitude-background) * Math.exp(-r2) + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * Math.exp(-r2));
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/GridGroupedSpots.java b/DeconvolutionLab2/src/signal/factory/GridGroupedSpots.java
deleted file mode 100644
index 4038774..0000000
--- a/DeconvolutionLab2/src/signal/factory/GridGroupedSpots.java
+++ /dev/null
@@ -1,123 +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 signal.factory;
-
-import signal.RealSignal;
-
-public class GridGroupedSpots extends SignalFactory {
-
- private double radius = 3.0;
- private double slope = 1;
- private double largest = 10;
- private double spacing = 10.0;
-
- public GridGroupedSpots(double side, double slope, double largest, double spacing) {
- super(new double[] {side, slope, largest, spacing});
- }
-
- @Override
- public String getName() {
- return "GridGroupedSpots";
- }
-
- @Override
- public String[] getParametersName() {
- return new String[] {"Radius", "Sigmoid Curve Slope", "LargestDistance", "Spacing"};
- }
-
- @Override
- public void setParameters(double[] parameters) {
- if (parameters.length >= 1)
- this.radius = parameters[0];
- if (parameters.length >= 2)
- this.slope = parameters[1];
- if (parameters.length >= 3)
- this.largest = parameters[2];
- if (parameters.length >= 4)
- this.spacing = parameters[3];
- }
-
- @Override
- public double[] getParameters() {
- return new double[] {radius, slope, largest, spacing};
- }
-
- @Override
- public void fill(RealSignal signal) {
- float b = (float)background;
- for(int x=0; x<nx; x++)
- for(int y=0; y<ny; y++)
- for(int z=0; z<nz; z++)
- signal.data[z][x+nx*y] = b;
-
- int nc = (int)( (nx-spacing) / spacing);
- int nr = (int)( (ny-spacing) / spacing);
- int np = (int)( (nz-spacing) / spacing);
-
- for(int i=0; i<nc; i++)
- for(int j=0; j<nr; j++)
- for(int k=0; k<np; k++) {
- double x = spacing + i*spacing;
- double y = spacing + j*spacing;
- double z = spacing + k*spacing;
- double dist = largest - j*largest / (nr-1);
- double distk = largest - k*largest / (np-1);
- double A = amplitude - i*(amplitude-background) / (nc+1);
- spot(signal, x, y, z, A);
- spot(signal, x+dist, y, z, A);
- spot(signal, x, y+dist, z, A);
- spot(signal, x+dist, y+dist, z, A);
-
- spot(signal, x, y, z+distk, A);
- spot(signal, x+dist, y, z+distk, A);
- spot(signal, x, y+dist, z+distk, A);
- spot(signal, x+dist, y+dist, z+distk, A);
- }
- }
-
- private void spot(RealSignal signal, double xc, double yc, double zc, double A) {
- int x1 = (int)Math.max(0, Math.round(xc-radius-3*slope));
- int x2 = (int)Math.min(nx-1, Math.round(xc+radius+3*slope));
- int y1 = (int)Math.max(0, Math.round(yc-radius-3*slope));
- int y2 = (int)Math.min(ny-1, Math.round(yc+radius+3*slope));
- int z1 = (int)Math.max(0, Math.round(zc-radius-3*slope));
- int z2 = (int)Math.min(nz-1, Math.round(zc+radius+3*slope));
- for(int x=x1; x<=x2; x++)
- for(int y=y1; y<=y2; y++)
- for(int z=z1; z<=z2; z++) {
- double dr = Math.sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc)) - radius;
- signal.data[z][x+nx*y] = Math.max(signal.data[z][x+nx*y], (float)(A - A / (1.0 + Math.exp(-dr/slope))));
- }
- }
-
-
-}
diff --git a/DeconvolutionLab2/src/signal/factory/Impulse.java b/DeconvolutionLab2/src/signal/factory/Impulse.java
index ec60144..2356025 100644
--- a/DeconvolutionLab2/src/signal/factory/Impulse.java
+++ b/DeconvolutionLab2/src/signal/factory/Impulse.java
@@ -1,70 +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 signal.factory;
import signal.RealSignal;
public class Impulse extends SignalFactory {
@Override
public String getName() {
return "Impulse";
}
@Override
public String[] getParametersName() {
return new String[] {};
}
@Override
public void setParameters(double[] parameters) {
}
@Override
public double[] getParameters() {
return new double[] {};
}
@Override
public void fill(RealSignal signal) {
- for(int x=0; x<nx; x++)
- for(int y=0; y<ny; y++)
- for(int z=0; z<nz; z++) {
- signal.data[z][x+nx*y] = (float)(background);
- }
int i = (int)(xc);
int j = (int)(yc);
int k = (int)(zc);
-
signal.data[k][i+nx*j] += (float)(amplitude);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/AirySimulated.java b/DeconvolutionLab2/src/signal/factory/Laplacian.java
similarity index 83%
rename from DeconvolutionLab2/src/signal/factory/AirySimulated.java
rename to DeconvolutionLab2/src/signal/factory/Laplacian.java
index 644d04a..1b326e3 100644
--- a/DeconvolutionLab2/src/signal/factory/AirySimulated.java
+++ b/DeconvolutionLab2/src/signal/factory/Laplacian.java
@@ -1,80 +1,74 @@
/*
* 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 deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.complex.ComplexSignalFactory;
-public class AirySimulated extends SignalFactory {
+public class Laplacian extends SignalFactory {
- private double mu = 1.0;
-
- public AirySimulated(double mu) {
- super(new double[] {mu});
+ public Laplacian() {
+ super(new double[] {});
}
@Override
public String getName() {
- return "AirySimulated";
+ return "Laplacian";
}
@Override
public String[] getParametersName() {
- return new String[] {"Parameter (mu)"};
+ return new String[] {};
}
@Override
public void setParameters(double[] parameters) {
- if (parameters.length >= 1)
- this.mu = parameters[0];
}
@Override
public double[] getParameters() {
- return new double[] {mu};
+ return new double[] {};
}
@Override
public void fill(RealSignal signal) {
AbstractFFT fft = FFT.createDefaultFFT(Monitors.createDefaultMonitor(), nx, ny, nz);
- ComplexSignal C = ComplexSignalFactory.airySimulated(nx, ny, nz, mu);
+ ComplexSignal C = ComplexSignalFactory.laplacian(nx, ny, nz);
RealSignal s = fft.inverse(C).circular().times((float)amplitude);
- s.times(s);
signal.copy(s);
}
-
-
}
diff --git a/DeconvolutionLab2/src/signal/factory/Ramp.java b/DeconvolutionLab2/src/signal/factory/Ramp.java
index 0607dd4..0298091 100644
--- a/DeconvolutionLab2/src/signal/factory/Ramp.java
+++ b/DeconvolutionLab2/src/signal/factory/Ramp.java
@@ -1,89 +1,90 @@
/*
* 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.RealSignal;
public class Ramp extends SignalFactory {
private double orientationX = 1;
- private double orientationY = 0;
- private double orientationZ = 0;
+ private double orientationY = 1;
+ private double orientationZ = 1;
public Ramp(double orientationX, double orientationY, double orientationZ) {
super(new double[] {orientationX, orientationY, orientationZ});
+ setParameters(new double[] {orientationX, orientationY, orientationZ});
}
@Override
public String getName() {
return "Ramp";
}
@Override
public String[] getParametersName() {
return new String[] {"Orientation X", "Orientation Y", "Orientation Z"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.orientationX = parameters[0];
if (parameters.length >= 2)
this.orientationY = parameters[1];
if (parameters.length >= 3)
this.orientationZ = parameters[1];
}
@Override
public double[] getParameters() {
return new double[] {orientationX, orientationY, orientationZ};
}
@Override
public void fill(RealSignal signal) {
- double A = (amplitude-background);
double ox = orientationX;
double oy = orientationY;
double oz = orientationZ;
- double diag = Math.sqrt(nx*nx + ny*ny + nz*nz);
- double len = Math.sqrt(ox*ox + oy*oy + oz*oz);
+ double mx = 1 / (3.0*nx);
+ double my = 1 / (3.0*ny);
+ double mz = 1 / (3.0*nz);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
- double dx = (xc-x);
- double dy = (yc-y);
- double dz = (zc-z);
- double r = (dx*ox + dy*oy + dz*oz) / (diag * len);
- signal.data[z][x+nx*y] = (float)(A * r + background);
+ double dx = (xc-x) * mx;
+ double dy = (yc-y) * my;
+ double dz = (zc-z) * mz;
+ signal.data[z][x+nx*y] = (float)(dx*ox + dy*oy + dz*oz);
}
+ signal.rescale(0, amplitude);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/RandomLines.java b/DeconvolutionLab2/src/signal/factory/RandomLines.java
index 36385b6..05b03ec 100644
--- a/DeconvolutionLab2/src/signal/factory/RandomLines.java
+++ b/DeconvolutionLab2/src/signal/factory/RandomLines.java
@@ -1,108 +1,107 @@
package signal.factory;
import java.util.Random;
/*
* 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 signal.RealSignal;
public class RandomLines extends SignalFactory {
- private double number = 3.0;
+ private double number = 100.0;
public RandomLines(double number) {
super(new double[] {number});
+ setParameters(new double[] {number});
}
@Override
public String getName() {
return "RandomLines";
}
@Override
public String[] getParametersName() {
return new String[] { "Number of lines" };
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1) this.number = parameters[0];
}
@Override
public double[] getParameters() {
return new double[] { number };
}
@Override
public void fill(RealSignal signal) {
Random rand = new Random(12345);
- float A = (float)(amplitude - background);
- signal.fill((float) (background));
double Q = Math.sqrt(3)*1.5;
for (int index = 0; index < number; index++) {
double x1 = -rand.nextDouble() * nx;
double x2 = nx + rand.nextDouble() * nx;
double y1 = (-0.1 + rand.nextDouble() * 1.2) * ny;
double y2 = (-0.1 + rand.nextDouble() * 1.2) * ny;
double z1 = (-0.1 + rand.nextDouble() * 1.2) * nz;
double z2 = (-0.1 + rand.nextDouble() * 1.2) * nz;
double d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
d = Math.sqrt(d);
int n = (int) (d / 0.3);
double dx = (x2 - x1) / d;
double dy = (y2 - y1) / d;
double dz = (z2 - z1) / d;
for (int s = 0; s < n; s++) {
double x = x1 + s * dx;
int i = (int) Math.round(x);
if (i >= 1 && i < nx-1) {
double y = y1 + s * dy;
int j = (int) Math.round(y);
if (j >= 1 && j < ny-1) {
double z = z1 + s * dz;
int k = (int) Math.round(z);
if (k >= 1 && k < nz-1) {
- //for(int ii=i-1; ii<=i+1; ii++)
- //for(int jj=j-1; jj<=j+1; jj++)
- //for(int kk=k-1; kk<=k+1; kk++) {
- double p = Q - Math.sqrt((x - i) * (x - i) + (y - j) * (y - j) + (z - k) * (z - k));
- signal.data[k][i + nx * j] = Math.max(signal.data[k][i + nx * j], (float)(p*A));
- //}
+ for(int ii=i-1; ii<=i+1; ii++)
+ for(int jj=j-1; jj<=j+1; jj++)
+ for(int kk=k-1; kk<=k+1; kk++) {
+ double p = 1.0 - Math.sqrt((x - i) * (x - i) + (y - j) * (y - j) + (z - k) * (z - k))/Q;
+ signal.data[k][i + nx * j] = Math.max(signal.data[k][i + nx * j], (float)(p*amplitude));
+ }
}
}
}
}
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/SignalFactory.java b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
index ee1f9d3..cb5d407 100644
--- a/DeconvolutionLab2/src/signal/factory/SignalFactory.java
+++ b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
@@ -1,244 +1,274 @@
/*
* 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 bilib.tools.NumFormat;
import deconvolution.Command;
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 RealSignal createFromCommand(String cmd) {
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;
+ double parameters[] = new double[np];
+ if (np >= 1 && params.length >= 1)
+ parameters[0] = params[0];
+ if (np >= 2 && params.length >= 2)
+ parameters[1] = params[1];
+ if (np >= 3 && params.length >= 3)
+ parameters[2] = params[2];
+ if (np >= 4 && params.length >= 4)
+ parameters[3] = params[3];
+
+ double size[] = NumFormat.parseNumbersAfter("size", cmd);
+ int nx = 128;
+ int ny = 128;
+ int nz = 32;
+ if (size.length > 0)
+ nx = (int) size[0];
+ if (size.length > 1)
+ ny = (int) size[1];
+ if (size.length > 2)
+ nz = (int) size[2];
+
+ double intensity[] = NumFormat.parseNumbersAfter("intensity", cmd);
+ double amplitude = 255;
+ if (intensity.length > 0)
+ amplitude = intensity[0];
+
+ double center[] = NumFormat.parseNumbersAfter("center", cmd);
+ double cx = 0.5;
+ double cy = 0.5;
+ double cz = 0.5;
+ if (center.length > 0)
+ cx = center[0];
+ if (center.length > 1)
+ cy = center[1];
+ if (center.length > 2)
+ cz = center[2];
+
+ factory.intensity(amplitude);
+ factory.setParameters(parameters);
factory = factory.center(cx, cy, cz);
return factory.generate(nx, ny, nz);
}
}
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 Airy(5, 1, 0.5, 3));
+ list.add(new Astigmatism(5, 1));
+ list.add(new AxialDiffractionSimulation(10, 10, 2));
list.add(new Constant());
list.add(new Cross(1, 1, 30));
list.add(new Cube(10 ,1));
+ list.add(new CubeSphericalBeads(3, 0.5, 8, 16));
list.add(new Defocus(3, 10, 10));
+ list.add(new DirectionalDerivative(1, 1, 0));
+ list.add(new DirectionalMotionBlur(3, 30, 3));
list.add(new DoG(3, 4));
- list.add(new DoubleHelix(3, 10, 10));
+ list.add(new DoubleConeWave(60, 5, 15, 10));
+ list.add(new DoubleHelix(3, 30, 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 Laplacian());
+ list.add(new Ramp(1, 1, 1));
+ list.add(new RandomLines(100));
list.add(new Sinc(3, 3, 3));
list.add(new Sphere(10, 1));
- list.add(new Torus(10));
+ list.add(new Torus(30));
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 Airy(5, 1, 0.5, 3));
+ list.add(new Astigmatism(5, 1));
+ list.add(new AxialDiffractionSimulation(10, 10, 2));
+ list.add(new Cross(1, 1, 30));
+ list.add(new CubeSphericalBeads(3, 0.5, 8, 16));
list.add(new Defocus(3, 10, 10));
+ list.add(new DirectionalDerivative(1, 1, 0));
+ list.add(new DirectionalMotionBlur(3, 30, 3));
list.add(new DoG(3, 4));
- list.add(new DoubleHelix(3, 10, 10));
+ list.add(new DoubleConeWave(60, 5, 15, 10));
+ list.add(new DoubleHelix(3, 30, 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 Laplacian());
+ 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;
+ public SignalFactory intensity(double amplitude) {
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(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 7adf5f8..e60ea6c 100644
--- a/DeconvolutionLab2/src/signal/factory/Sinc.java
+++ b/DeconvolutionLab2/src/signal/factory/Sinc.java
@@ -1,91 +1,92 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package 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});
+ setParameters(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 > Operations.epsilon)
v = Math.sin(r) / r;
- signal.data[z][x+nx*y] = (float)((amplitude-background) * v + background);
+ signal.data[z][x+nx*y] = (float)(v);
}
+ signal.rescale(0, amplitude);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Sphere.java b/DeconvolutionLab2/src/signal/factory/Sphere.java
index d1f4c8e..720f974 100644
--- a/DeconvolutionLab2/src/signal/factory/Sphere.java
+++ b/DeconvolutionLab2/src/signal/factory/Sphere.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 signal.factory;
import signal.RealSignal;
public class Sphere extends SignalFactory {
private double radius = 10;
private double slope = 1;
public Sphere(double radius, double slope) {
super(new double[] {radius, slope});
+ setParameters(new double[] {radius, slope});
}
@Override
public String getName() {
return "Sphere";
}
@Override
public String[] getParametersName() {
return new String[] {"Radius", "Sigmoid Curve Slope"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.radius = parameters[0];
if (parameters.length >= 2)
this.slope = parameters[1];
}
@Override
public double[] getParameters() {
return new double[] {radius, slope};
}
@Override
public void fill(RealSignal signal) {
- double A = (amplitude-background);
for(int x=0; x<nx; x++)
for(int y=0; y<ny; y++)
for(int z=0; z<nz; z++) {
double dr = Math.sqrt((x-xc)*(x-xc) + (y-yc)*(y-yc) + (z-zc)*(z-zc)) - radius;
- signal.data[z][x+nx*y] = (float)(A * (1.0- 1.0 / (1.0 + Math.exp(-dr/slope))) + background);
+ signal.data[z][x+nx*y] = (float)(amplitude * (1.0- 1.0 / (1.0 + Math.exp(-dr/slope))));
}
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/Torus.java b/DeconvolutionLab2/src/signal/factory/Torus.java
index 13e2a83..4ee7371 100644
--- a/DeconvolutionLab2/src/signal/factory/Torus.java
+++ b/DeconvolutionLab2/src/signal/factory/Torus.java
@@ -1,92 +1,86 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal.factory;
import signal.RealSignal;
public class Torus extends SignalFactory {
private double radius = 10.0;
public Torus(double radius) {
super(new double[] {radius});
+ setParameters(new double[] {radius});
}
@Override
public String getName() {
return "Torus";
}
@Override
public String[] getParametersName() {
return new String[] {"Radius"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.radius = parameters[0];
}
@Override
public double[] getParameters() {
return new double[] {radius};
}
@Override
public void fill(RealSignal signal) {
- float A = (float)(amplitude-background);
- float B = (float)(background);
double thick = radius * 0.2;
double thick2 = thick * thick;
- double hx = nx * 0.5;
- double hy = ny * 0.5;
- double hz = nz * 0.5;
- for(int i=0; i<nx; i++)
+ for(int i=0; i<nx; i++)
for(int j=0; j<ny; j++) {
- double dxy = Math.abs(radius - dist(i, j, hx, hy));
+ double dxy = Math.abs(radius - dist(i, j, xc, yc));
if (dxy < thick) {
for(int k=0; k<nz; k++) {
- double dz = k - hz;
+ double dz = k - zc;
if (dxy*dxy + dz*dz < thick2)
- signal.data[k][i+j*nx] = A;
- else
- signal.data[k][i+j*nx] = B;
+ signal.data[k][i+j*nx] = (float)(amplitude * (1.0-(dxy*dxy + dz*dz)/thick2));
}
}
}
}
private static double dist(double x1, double y1, double x2, double y2) {
return Math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java b/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
index 00ef89e..a17d6c1 100644
--- a/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
+++ b/DeconvolutionLab2/src/signal/factory/complex/ComplexSignalFactory.java
@@ -1,151 +1,222 @@
/*
* 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("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("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;
+ wz = Math.PI * z / zsize;
function[x][y][z] = (float) ((wx * wx + wy * wy + wz * wz));
}
return createHermitian("Laplacian", nx, ny, nz, function);
}
+
+ public static ComplexSignal directionalDerivative(int nx, int ny, int nz, double vx, double vy, double vz) {
+ 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 / zsize;
+ function[x][y][z] = (float) ((wx * vx + vy * wy + vz * wz));
+ }
+ return createHermitian("Directional Derivative", nx, ny, nz, function);
+ }
- public static ComplexSignal airySimulated(int nx, int ny, int nz, double mu) {
+ public static ComplexSignal rings(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("Airy", nx, ny, nz, function);
}
+ public static ComplexSignal createHermitian(String name, int nx, int ny, int nz, float[][][] firstQuadrantReal, float[][][] firstQuadrantImag) {
+ ComplexSignal signal = new ComplexSignal(name, nx, ny, nz);
+ int xsize = firstQuadrantReal.length - 1;
+ int ysize = firstQuadrantReal[0].length - 1;
+ int zsize = firstQuadrantReal[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)] = firstQuadrantReal[x][y][z];
+ signal.data[z][2 * (x + nx * y)+1] = firstQuadrantImag[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)] = firstQuadrantReal[x + 1][y][z];
+ signal.data[z][2 * (a + b)] = firstQuadrantReal[x + 1][y + 1][z];
+ signal.data[z][2 * (x + b)] = firstQuadrantReal[x][y + 1][z];
+ signal.data[z][1 + 2 * (a + nx * y)] = firstQuadrantImag[x + 1][y][z];
+ signal.data[z][1 + 2 * (a + b)] = firstQuadrantImag[x + 1][y + 1][z];
+ signal.data[z][1 + 2 * (x + b)] = firstQuadrantImag[x][y + 1][z];
+ int c = nz - 1 - z;
+ signal.data[c][2 * (x + nx * y)] = firstQuadrantReal[x][y][z + 1];
+ signal.data[c][2 * (a + nx * y)] = firstQuadrantReal[x + 1][y][z + 1];
+ signal.data[c][2 * (a + b)] = firstQuadrantReal[x + 1][y + 1][z + 1];
+ signal.data[c][2 * (x + b)] = firstQuadrantReal[x][y + 1][z + 1];
+ signal.data[c][1 + 2 * (x + nx * y)] = firstQuadrantImag[x][y][z + 1];
+ signal.data[c][1 + 2 * (a + nx * y)] = firstQuadrantImag[x + 1][y][z + 1];
+ signal.data[c][1 + 2 * (a + b)] = firstQuadrantImag[x + 1][y + 1][z + 1];
+ signal.data[c][1 + 2 * (x + b)] = firstQuadrantImag[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)] = firstQuadrantReal[x][y][0];
+ signal.data[0][1 + 2 * (x + nx * y)] = firstQuadrantImag[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)] = firstQuadrantReal[x + 1][y][0];
+ signal.data[0][2 * (a + b)] = firstQuadrantReal[x + 1][y + 1][0];
+ signal.data[0][2 * (x + b)] = firstQuadrantReal[x][y + 1][0];
+ signal.data[0][1 + 2 * (a + nx * y)] = firstQuadrantImag[x + 1][y][0];
+ signal.data[0][1 + 2 * (a + b)] = firstQuadrantImag[x + 1][y + 1][0];
+ signal.data[0][1 + 2 * (x + b)] = firstQuadrantImag[x][y + 1][0];
+ }
+ }
+ return signal;
+ }
+
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 57f2102..32ad103 100644
--- a/DeconvolutionLab2/src/signal/padding/Padding.java
+++ b/DeconvolutionLab2/src/signal/padding/Padding.java
@@ -1,253 +1,252 @@
/*
* 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;
-import signal.SignalCollector;
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;
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.duplicate();
}
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;
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;
}
}

Event Timeline