Page MenuHomec4science

No OneTemporary

File Metadata

Created
Fri, Nov 22, 13:26
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 192c0b8..457d615 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,89 +1,93 @@
-#DeconvolutionLab2 [Beta 2]
-#DeconvolutionLab2 [Beta 2]
-#Thu Apr 20 22:35:15 CEST 2017
+#DeconvolutionLab2
+#DeconvolutionLab2
+#Fri Apr 21 11:36:46 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.reg=0.4642
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=1.000E-18
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
-Algorithm.algorithm=Richardson-Lucy
-Border.apoxy=Hamming
+Algorithm.algorithm=Richardson-Lucy Total Variation
+Border.apoxy=Uniform
Border.apoz=Uniform
-Border.extxy=6
+Border.extxy=0
Border.extz=0
Border.padxy=None
Border.padz=None
Computation.display=yes
Computation.epsilon=1E-6
Computation.fft=Fastest
Computation.multithreading=yes
Computation.normalization=1
Computation.system=no
Controller.constraint=no
Controller.monitor=console
-Controller.reference.enable=false
-Controller.reference.value=
-Controller.residu.enable=false
+Controller.reference.enable=true
+Controller.reference.value=/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png
+Controller.residu.enable=true
Controller.residu.value=0.01
-Controller.stats=show
+Controller.stats=show + save
Controller.time.enable=false
Controller.time.value=1
Controller.verbose=log
-DeconvolutionLab.MainDialog.location.h=626
+DeconvolutionLab.MainDialog.location.h=596
DeconvolutionLab.MainDialog.location.w=500
-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
+DeconvolutionLab.MainDialog.location.x=851
+DeconvolutionLab.MainDialog.location.y=84
+Image.image.row0=workspace;directory;/Users/dsage/Desktop/workspace;\u232B
+Image.image.row10=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row11=RandomLines;synthetic;RandomLines 100.0 size 128 128 32 intensity 255.0 ;\u232B
+Image.image.row12=active;platform;active;\u232B
+Image.image.row13=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.row14=Applications;directory;/users/dsage/Applications;\u232B
+Image.image.row15=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
+Image.image.row16=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
+Image.image.row1=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 10.0 5.0 size 128 128 128 intensity 255.0 ;\u232B
+Image.image.row2=CubeSphericalBeads;synthetic;CubeSphericalBeads 3.0 0.5 8.0 16.0 size 128 128 32 intensity 255.0 ;\u232B
+Image.image.row3=Cube of Spherical Beads;synthetic;Cube of Spherical Beads 3.0 0.5 8.0 8.0 size 128 128 128 intensity 255.0 ;\u232B
+Image.image.row4=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row5=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
Image.image.row6=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
-Image.image.row7=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
+Image.image.row7=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.row8=20170302_AIDE-MEMOIRE.pdf;file;/Users/dsage/Desktop/20170302_AIDE-MEMOIRE.pdf;null
+Image.image.row9=Screen Shot 2017-04-12 at 22.56.07.png;file;/Users/dsage/Desktop/Screen Shot 2017-04-12 at 22.56.07.png;null
+Image.image.selected=workspace;directory;/Users/dsage/Desktop/workspace;\u232B
Language.headless=Run (Headless)
Language.job=Job
Language.language=Java
Output.output.row0=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
Output.output.selected=mip;MI1;rescaled;;;\u2713;\u2713;\u232B
PSF.psf.row0=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
PSF.psf.row1=Sinc;synthetic;Sinc 3.0 3.0 3.0 size 100 128 200 intensity 255.0 ;null
PSF.psf.selected=Double-Helix;synthetic;Double-Helix 3.0 30.0 10.0 size 128 128 32 intensity 255.0 ;null
Path.current=Current
Path.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
Running.Directory=/Users/dsage/git/deconvolution/DeconvolutionLab2
Running.Monitor=table
Running.Path=specify
Running.Verbose=quiet
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
index 0bbc747..fc67f0e 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
@@ -1,123 +1,121 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package 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 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_Resolution.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
index 72a1933..de4efb0 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
@@ -1,154 +1,157 @@
/*
* 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.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 = 120;
int nz = 122;
int spacing = 12;
int border = 6;
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 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);
Convolution convo = new Convolution();
- convo.setController(controller);
+ convo.setSystem(true);
+ convo.setReference(res + "ref.tif");
+
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 TRIF 10e-5 -pad NO NO 100 100 -out mip TRIFoapo ";
new Deconvolution("TRIF apo", conv + psf + algo + param).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+ 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/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index 8dc0a8e..969f1fc 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,425 +1,424 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import 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.Output.View;
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.FFT;
import signal.Constraint;
import signal.Operations;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
import wavelets.Wavelets;
public class Command {
public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-system", "-stats", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft", "-epsilon" };
private static AbstractModule modules[];
private static CommandModule command;
public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
return cmd;
}
public static Controller decodeController(String command) {
Controller controller = new Controller();
ArrayList<Token> tokens = parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
controller.setPath(token.parameters);
if (token.keyword.equalsIgnoreCase("-monitor"))
controller.setMonitors(decodeMonitors(token.parameters));
if (token.keyword.equalsIgnoreCase("-verbose"))
controller.setVerbose(Verbose.getByName(token.parameters));
if (token.keyword.equalsIgnoreCase("-system"))
controller.setSystem(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-multithreading"))
controller.setMultithreading(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-display"))
controller.setDisplayFinal(decodeBoolean(token.parameters));
if (token.keyword.equalsIgnoreCase("-stats"))
controller.setStats(decodeStats(token));
if (token.keyword.equalsIgnoreCase("-constraint"))
controller.setConstraint(decodeConstraint(token));
if (token.keyword.equalsIgnoreCase("-time"))
controller.setTimeLimit(decodeTimeLimit(token));
if (token.keyword.equalsIgnoreCase("-residu"))
controller.setResiduMin(decodeResidu(token));
if (token.keyword.equalsIgnoreCase("-reference"))
controller.setReference(token.parameters);
if (token.keyword.equalsIgnoreCase("-pad"))
controller.setPadding(decodePadding(token));
if (token.keyword.equalsIgnoreCase("-apo"))
controller.setApodization(decodeApodization(token));
if (token.keyword.equalsIgnoreCase("-norm"))
controller.setNormalizationPSF(decodeNormalization(token));
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equalsIgnoreCase("-fft"))
controller.setFFT(FFT.getLibraryByName(token.parameters).getDefaultFFT());
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equals("-out")) {
Output out = decodeOut(token);
if (out != null)
controller.addOutput(out);
}
}
return controller;
}
public static AbstractAlgorithm decodeAlgorithm(String command) {
AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
ArrayList<Token> tokens = parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-algorithm"))
algo = Command.decodeAlgorithm(token);
}
return algo;
}
/**
* This methods first segments the command line, then create all the tokens
* of the command line
*
* @param command
* Command line
* @return the list of tokens extracted from the command line
*/
public static ArrayList<Token> parse(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
ArrayList<Token> tokens = new ArrayList<Token>();
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
Token token = new Token(keyword, command, begin, end);
tokens.add(token);
}
return tokens;
}
public static Token extract(String command, String keyword) {
ArrayList<Token> tokens = parse(command);
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase(keyword))
return token;
return (Token) null;
}
public static double[] parseNumeric(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static ArrayList<CommandSegment> findSegment(String command, String keyword) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
String regex = "(?<!\\w)" + keyword + "(?!\\w)";
if (command == null)
return segments;
Matcher matcher = Pattern.compile(regex).matcher(command);
while (matcher.find()) {
segments.add(new CommandSegment(keyword, matcher.start()));
}
return segments;
}
public static String extractOptions(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
String options = "";
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
if (keyword != "-image" && keyword != "-psf" && keyword != "-algorithm")
options += keyword + " " + command.substring(begin, end);
}
return options;
}
public static AbstractAlgorithm decodeAlgorithm(Token token) {
String option = token.option;
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
double params[] = parseNumeric(token.parameters);
if (params != null) {
algo.setParameters(params);
}
if (algo.isWaveletsBased()) {
for (String wavelet : Wavelets.getWaveletsAsArray()) {
int pos = token.parameters.toLowerCase().indexOf(wavelet.toLowerCase());
if (pos >= 0)
algo.setWavelets(wavelet);
}
}
return algo;
}
public static Output decodeOut(Token token) {
int freq = 0;
String line = token.parameters;
String parts[] = token.parameters.split(" ");
for (int i = 0; i < Math.min(2, parts.length); i++) {
if (parts[i].startsWith("@"))
freq = (int) NumFormat.parseNumber(parts[i], 0);
}
String p = token.parameters.toLowerCase();
Output out = null;
if (p.startsWith("stack"))
out = new Output(View.STACK, freq, line.substring("stack".length(), line.length()));
if (p.startsWith("series"))
out = new Output(View.SERIES, freq, line.substring("series".length(), line.length()));
if (p.startsWith("mip"))
out = new Output(View.MIP, freq, line.substring("mip".length(), line.length()));
if (p.startsWith("ortho"))
out = new Output(View.ORTHO, freq, line.substring("ortho".length(), line.length()));
if (p.startsWith("figure"))
out = new Output(View.FIGURE, freq, line.substring("figure".length(), line.length()));
if (p.startsWith("planar"))
out = new Output(View.PLANAR, freq, line.substring("planar".length(), line.length()));
return out;
}
public static double decodeNormalization(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return 0;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static Stats decodeStats(Token token) {
String parts[] = token.parameters.toLowerCase().split(" ");
int m = 0;
for (String p : parts) {
if (p.startsWith("no") || p.equals("false") || p.equals("0"))
return new Stats(Stats.Mode.NO);
if (p.equals("1"))
return new Stats(Stats.Mode.SHOW);
if (p.equals("2"))
return new Stats(Stats.Mode.SAVE);
if (p.equals("3"))
return new Stats(Stats.Mode.SHOWSAVE);
if (p.equals("show"))
m += 1;
if (p.equals("save"))
m += 2;
}
if (m==1)
return new Stats(Stats.Mode.SHOW);
if (m==2)
return new Stats(Stats.Mode.SAVE);
if (m==3)
return new Stats(Stats.Mode.SHOWSAVE);
return new Stats(Stats.Mode.NO);
}
public static Constraint.Mode decodeConstraint(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("non"))
return Constraint.Mode.NONNEGATIVE;
if (p.startsWith("no"))
return Constraint.Mode.NO;
if (p.startsWith("clip"))
return Constraint.Mode.CLIPPED;
if (p.equals("0"))
return Constraint.Mode.NO;
return Constraint.Mode.NO;
}
public static double decodeResidu(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return -1;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static double decodeTimeLimit(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return -1;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
String param = token.parameters.trim();
String[] parts = param.split(" ");
if (parts.length > 0)
padXY = Padding.getByShortname(parts[0].trim());
if (parts.length > 1)
padZ = Padding.getByShortname(parts[1].trim());
double[] ext = NumFormat.parseNumbers(param);
int extXY = 0;
if (ext.length > 0)
extXY = (int) Math.round(ext[0]);
int extZ = 0;
if (ext.length > 1)
extZ = (int) Math.round(ext[1]);
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
public static Apodization decodeApodization(Token token) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
String[] parts = token.parameters.trim().split(" ");
if (parts.length >= 1)
apoXY = Apodization.getByShortname(parts[0].trim());
if (parts.length >= 2)
apoZ = Apodization.getByShortname(parts[1].trim());
return new Apodization(apoXY, apoXY, apoZ);
}
public static String getPath() {
command();
ArrayList<Token> tokens = parse(command.getCommand());
String path = System.getProperty("user.dir");
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
path = token.parameters;
return path;
}
public static Monitors decodeMonitors(String cmd) {
String parts[] = cmd.toLowerCase().split(" ");
Monitors monitors = new Monitors();
for (String p : parts) {
if (p.equals("0") || p.startsWith("no"))
monitors.clear();
if (p.equals("1") || p.startsWith("console"))
monitors.add(new ConsoleMonitor());
if (p.equals("2"))
monitors.add(new TableMonitor("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/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index d6076c5..d80e9e4 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,393 +1,387 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.io.File;
import bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
-import deconvolutionlab.system.SystemInfo;
import signal.RealSignal;
import signal.SignalCollector;
/**
* This class is the main class to run deconvolution with or without user interface.
*
* All the parameters are given in the command line (String variable command).
*
* @author Daniel Sage
*
*/
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
private AbstractAlgorithm algo = null;
private Controller controller = new Controller();
private String command = "";
private Features report = new Features();
private String name = "";
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
public Deconvolution(String name, String command) {
this.name = name;
this.finish = Finish.DIE;
setCommand(command);
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
}
public void setCommand(String command) {
this.command = command;
controller = Command.decodeController(command);
algo = Command.decodeAlgorithm(command);
algo.setController(controller);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortnames()[0];
}
public RealSignal deconvolve() {
return deconvolve(image, psf);
}
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
Lab.setVisible(((TableMonitor)monitor).getPanel(), "Monitor of " + name, 10, 10);
if (controller.getFFT() == null) {
run();
return deconvolvedImage;
}
if (!controller.getFFT().isMultithreadable()) {
run();
return deconvolvedImage;
}
if (controller.isMultithreading()) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
return deconvolvedImage;
}
/**
* This method runs the deconvolution with a graphical user interface.
*/
public void launch() {
TableMonitor tableMonitor = null;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
tableMonitor = (TableMonitor)monitor;
dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this, tableMonitor, controller.getStats());
controller.getMonitors().add(new StatusMonitor(dialog.getProgressBar()));
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
Monitors monitors = controller.getMonitors();
- if (controller.isSystem())
- SystemInfo.activate();
-
report.add("Path", controller.toStringPath());
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
report.add("FFT", controller.getFFT().getName());
report.add("Algorithm", algo.getName());
algo.setController(controller);
deconvolvedImage = algo.run(image, psf, controller.getStats());
report.add("End", NumFormat.time(System.nanoTime() - chrono));
- 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;
System.gc();
}
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
Token image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
double norm = controller.getNormalizationPSF();
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReference());
features.add("Constraint", controller.getConstraintAsString());
features.add("Padding", controller.getPadding().toString());
features.add("Apodization", controller.getApodization().toString());
features.add("FFT", controller.getFFT() == null ? "null" : controller.getFFT().getName());
}
features.add("Path", controller.getPath());
features.add("Monitor", controller.toStringMonitor());
if (controller.getStats() != null)
features.add("Stats", controller.getStats().toStringStats());
features.add("Running", controller.toStringRunning());
for (Output out : controller.getOuts())
features.add("Output " + out.getName(), out.toString());
return features;
}
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
public void abort() {
algo.getController().abort();
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
image = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return image;
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
psf = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
return psf;
}
private static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
if (arg.equalsIgnoreCase("synthetic")) {
signal = Lab.createSynthetic(monitors, cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = Lab.getImage(monitors, cmd);
}
if (arg.equalsIgnoreCase("file")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.openFile(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.openFile(monitors, cmd);
}
}
}
if (arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
}
return signal;
}
public void setAlgorithm(AbstractAlgorithm algo) {
this.algo = algo;
}
public AbstractAlgorithm getAlgorithm() {
return algo;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public RealSignal getOutput() {
return deconvolvedImage;
}
public RealSignal getImage() {
return image;
}
public RealSignal getPSF() {
return psf;
}
public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public String getCommand() {
return command;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index b24857d..5a8026b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,398 +1,408 @@
/*
* 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.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.Verbose;
+import deconvolutionlab.system.SystemInfo;
import fft.AbstractFFT;
import fft.FFT;
import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h;
protected boolean threaded;
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint;
protected int iterMax = 0;
protected AbstractFFT fft;
protected Controller controller;
public AbstractAlgorithm() {
setController(new Controller());
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public AbstractAlgorithm(Controller controller) {
this.controller = controller;
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract String[] getShortnames();
public abstract double getMemoryFootprintRatio();
public abstract int getComplexityNumberofFFT();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract void setParameters(double[] params);
public abstract double getRegularizationFactor();
public abstract double getStepFactor();
public abstract double[] getParameters();
public abstract double[] getDefaultParameters();
public RealSignal run(RealSignal image, RealSignal psf) {
return run(image, psf, new Stats(Stats.Mode.NO));
}
public RealSignal run(RealSignal image, RealSignal psf, Stats stats) {
+
+ if (controller.isSystem())
+ SystemInfo.activate();
+
Padding pad = controller.getPadding();
Apodization apo = controller.getApodization();
double norm = controller.getNormalizationPSF();
fft = controller.getFFT();
controller.setIterationsMax(iterMax);
if (image == null)
return null;
if (psf == null)
return null;
// Prepare the controller and the outputs
Monitors monitors = controller.getMonitors();
monitors.setVerbose(controller.getVerbose());
monitors.log("Path: " + controller.toStringPath());
monitors.log("Algorithm: " + getName());
// Prepare the signal and the PSF
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? iterMax + " iterations" : "direct");
controller.setIterationsMax(iterMax);
monitors.log(getShortnames()[0] + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
controller.start(y, stats);
h.circular();
// FFT
fft.init(monitors, y.nx, y.ny, y.nz);
controller.setFFT(fft);
monitors.log(getShortnames()[0] + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortnames()[0] + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
SignalCollector.free(y);
SignalCollector.free(h);
x.setName("x");
RealSignal result = pad.crop(monitors, x);
controller.finish(result);
monitors.log(getName() + " is finished");
SignalCollector.free(x);
+
+ if (controller.isDisplayFinal())
+ Lab.show(monitors, result, "Final Display of " + getShortnames()[0]);
+
result.setName("Output of " + this.getShortnames()[0]);
return result;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public int getIterationsMax() {
return iterMax;
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + iterMax + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for (int i = 0; i < p.length; i++)
if (i == p.length - 1)
param += p[i];
else
param += p[i] + ", ";
return param;
}
public AbstractFFT getFFT() {
return controller.getFFT();
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
controller.setFFT(fft);
}
public String getPath() {
return controller.getPath();
}
public void setPath(String path) {
controller.setPath(path);
}
public boolean isSystem() {
return controller.isSystem();
}
public void setSystem(boolean system) {
controller.setSystem(system);
}
public boolean isMultithreading() {
return controller.isMultithreading();
}
public void setMultithreading(boolean multithreading) {
controller.setMultithreading(multithreading);
}
public boolean isDisplayFinal() {
return controller.isDisplayFinal();
}
public void setDisplayFinal(boolean displayFinal) {
controller.setDisplayFinal(displayFinal);
}
public double getNormalizationPSF() {
return controller.getNormalizationPSF();
}
public void setNormalizationPSF(double normalizationPSF) {
controller.setNormalizationPSF(normalizationPSF);
}
public double getEpsilon() {
return controller.getEpsilon();
}
public void setEpsilon(double epsilon) {
controller.setEpsilon(epsilon);
}
public Padding getPadding() {
return controller.getPadding();
}
public void setPadding(Padding padding) {
controller.setPadding(padding);
}
public Apodization getApodization() {
return controller.getApodization();
}
public void setApodization(Apodization apodization) {
controller.setApodization(apodization);
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public void setMonitors(Monitors monitors) {
controller.setMonitors(monitors);
}
public Verbose getVerbose() {
return controller.getVerbose();
}
public void setVerbose(Verbose verbose) {
controller.setVerbose(verbose);
}
public Constraint.Mode getConstraint() {
return controller.getConstraint();
}
public void setConstraint(Constraint.Mode constraint) {
controller.setConstraint(constraint);
}
public Stats getStats() {
return controller.getStats();
}
public void setStats(Stats stats) {
controller.setStats(stats);
}
public double getResiduMin() {
return controller.getResiduMin();
}
public void setResiduMin(double residuMin) {
controller.setResiduMin(residuMin);
}
public double getTimeLimit() {
return controller.getTimeLimit();
}
public void setTimeLimit(double timeLimit) {
controller.setTimeLimit(timeLimit);
}
public String getReference() {
return controller.getReference();
}
public void setReference(String reference) {
controller.setReference(reference);
}
public ArrayList<Output> getOuts() {
return controller.getOuts();
}
public void setOuts(ArrayList<Output> outs) {
controller.setOuts(outs);
}
public void addOutput(Output out) {
controller.addOutput(out);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
index 87c1f19..f801207 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
@@ -1,246 +1,242 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JButton;
-import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bilib.component.PanelImage;
import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import deconvolutionlab.Lab;
import fft.FFTPanel;
import signal.SignalCollector;
public class SystemPanel extends JPanel implements ActionListener, MouseListener {
private JPanel cards;
private String[] rates = new String[] { "1 s.", "0.5 s.", "0.2 s.", "0.1 s.", "10 s.", "5 s.", "2 s." };
private JButton bnRate = new JButton("1 s.");
private JButton bnClear = new JButton("Clear");
private Timer timer = new Timer();
private TimerTask updater = new Updater();
private MemoryMeter memory;
private ProcessorMeter processor;
private SignalMeter signal;
private FFTMeter fft;
private JavaMeter java;
private FileMeter file;
private int width = Constants.widthGUI;
private static SystemPanel instance;
private int rate = 0;
private static JFrame frame;
private ArrayList<AbstractMeter> meters = new ArrayList<AbstractMeter>();
public static SystemPanel getInstance(JFrame parent) {
if (instance == null) {
instance = new SystemPanel();
}
frame = parent;
return instance;
}
private SystemPanel() {
memory = new MemoryMeter();
processor = new ProcessorMeter();
signal = new SignalMeter();
fft = new FFTMeter();
java = new JavaMeter();
file = new FileMeter();
meters.add(memory);
meters.add(processor);
meters.add(signal);
meters.add(fft);
meters.add(java);
meters.add(file);
// Panel meters on top
JPanel meters = new JPanel(new GridLayout(2, 3));
meters.add(file);
meters.add(memory);
meters.add(processor);
meters.add(java);
meters.add(signal);
meters.add(fft);
bnClear.setToolTipText("Clear all the entries");
bnRate.setToolTipText("Choose the rate of refreshing the information");
JPanel pan = new JPanel(new GridLayout(2, 1));
pan.add(bnRate);
pan.add(bnClear);
restart();
// Panel Compact
PanelImage pnCompact = new PanelImage("celegans.jpg");
pnCompact.setPreferredSize(new Dimension(width, 20));
// Panel cards, compact is visible
cards = new JPanel(new CardLayout());
cards.add("collapse", pnCompact);
cards.add(signal.getName(), SignalCollector.getPanel(width, 200));
cards.add(memory.getName(), memory.getPanel(width, 200));
cards.add(processor.getName(), processor.getPanel(width, 200));
cards.add(fft.getName(), new FFTPanel(width, 200));
cards.add(java.getName(), java.getPanel(width, 200));
cards.add(file.getName(), file.getPanel(width, 200));
cards.setVisible(false);
JPanel top = new JPanel(new BorderLayout());
top.add(meters, BorderLayout.CENTER);
top.add(pan, BorderLayout.EAST);
setLayout(new BorderLayout());
add(top, BorderLayout.NORTH);
add(cards, BorderLayout.CENTER);
bnClear.addActionListener(this);
signal.addMouseListener(this);
memory.addMouseListener(this);
processor.addMouseListener(this);
java.addMouseListener(this);
file.addMouseListener(this);
fft.addMouseListener(this);
bnRate.addActionListener(this);
setMinimumSize(new Dimension(width, 70));
bnClear.setEnabled(signal.isExpanded());
Rectangle rect = Config.getDialog("System.Frame");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnRate) {
rate++;
if (rate >= rates.length)
rate = 0;
bnRate.setText(rates[rate]);
restart();
}
if (e.getSource() == bnClear) {
SignalCollector.clear();
}
}
public void update() {
for(AbstractMeter meter : meters)
meter.update();
}
public void restart() {
long refreshTime = (long) (NumFormat.parseNumber(bnRate.getText(), 1) * 1000);
if (updater != null) {
updater.cancel();
updater = null;
}
updater = new Updater();
timer.schedule(updater, 0, refreshTime);
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() instanceof AbstractMeter) {
AbstractMeter meter = (AbstractMeter) e.getSource();
if (meter.isExpanded()) {
meter.collapse();
cards.setVisible(false);
}
else for(AbstractMeter m : meters) {
if (m.isExpanded())
m.collapse();
meter.expand();
cards.setVisible(true);
}
((CardLayout) (cards.getLayout())).show(cards, meter.getName());
}
bnClear.setEnabled(signal.isExpanded());
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java b/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java
index db3459f..2722015 100644
--- a/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.java
+++ b/DeconvolutionLab2/src/signal/factory/AxialDiffractionSimulation.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 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";
+ return "AxialDiffractionSimulation";
}
@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/CubeSphericalBeads.java b/DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
index 4214275..aa55cfd 100644
--- a/DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
+++ b/DeconvolutionLab2/src/signal/factory/CubeSphericalBeads.java
@@ -1,113 +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 CubeSphericalBeads extends SignalFactory {
private double radius = 3.0;
private double slope = 0.5;
private double spacing = 8.0;
private double border = 8.0;
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 "Cube of Spherical Beads";
+ return "CubeSphericalBeads";
}
@Override
public String[] getParametersName() {
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, border };
}
@Override
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/DirectionalDerivative.java b/DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
index ef6e451..a5de257 100644
--- a/DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
+++ b/DeconvolutionLab2/src/signal/factory/DirectionalDerivative.java
@@ -1,86 +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 DirectionalDerivative extends SignalFactory {
private double vx = 1.0;
private double vy = 1.0;
private double vz = 0.0;
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 "Directional Derivative";
+ return "Directional-Derivative";
}
@Override
public String[] getParametersName() {
return new String[] {"Direction in X", "Direction in Y", "Direction in Z"};
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
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[] {vx, vy, vz};
}
@Override
public void fill(RealSignal signal) {
AbstractFFT fft = FFT.createDefaultFFT(Monitors.createDefaultMonitor(), nx, ny, nz);
ComplexSignal C = ComplexSignalFactory.directionalDerivative(nx, ny, nz, vx, vy, vz);
RealSignal s = fft.inverse(C).circular().times((float)amplitude);
signal.copy(s);
}
}
diff --git a/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java b/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
index 1d64521..362864c 100644
--- a/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
+++ b/DeconvolutionLab2/src/signal/factory/DirectionalMotionBlur.java
@@ -1,106 +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.RealSignal;
public class DirectionalMotionBlur extends SignalFactory {
private double sigma = 3.0;
private double direction = 30.0;
private double elongation = 30.0;
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 "Direction Motion Blur";
+ return "Direction-Motion-Blur";
}
@Override
public String[] getParametersName() {
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 cosa = Math.cos(Math.toRadians(direction));
double sina = Math.sin(Math.toRadians(direction));
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/DoubleConeWave.java b/DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
index 0f5ad20..013ae97 100644
--- a/DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
+++ b/DeconvolutionLab2/src/signal/factory/DoubleConeWave.java
@@ -1,95 +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 DoubleConeWave extends SignalFactory {
private double aperture = 60;
private double periodTopZ = 5;
private double periodCenterZ = 15;
private double attenuation = 10;
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 Cone Wave";
+ return "DoubleConeWave";
}
@Override
public String[] getParametersName() {
return new String[] { "Aperture", "Period TopZ", "Period CenterZ", "Attenuation" };
}
@Override
public void setParameters(double[] parameters) {
if (parameters.length >= 1)
this.aperture = parameters[0];
if (parameters.length >= 2)
this.periodTopZ = parameters[1];
if (parameters.length >= 3)
this.periodCenterZ = parameters[2];
if (parameters.length >= 4)
this.attenuation = parameters[3];
}
@Override
public double[] getParameters() {
return new double[] {aperture, periodTopZ, periodCenterZ, attenuation};
}
@Override
public void fill(RealSignal signal) {
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/SignalFactory.java b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
index cb5d407..31981a0 100644
--- a/DeconvolutionLab2/src/signal/factory/SignalFactory.java
+++ b/DeconvolutionLab2/src/signal/factory/SignalFactory.java
@@ -1,274 +1,275 @@
/*
* 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 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;
int np = factory.getParameters().length;
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 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 DoubleConeWave(60, 5, 15, 10));
list.add(new DoubleHelix(3, 30, 10));
list.add(new Gaussian(3, 3, 3));
list.add(new Impulse());
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(30));
return list;
}
public static ArrayList<SignalFactory> getImages() {
ArrayList<SignalFactory> list = new ArrayList<SignalFactory>();
list.add(new Cube(10, 1));
+ list.add(new CubeSphericalBeads(3, 0.5, 8, 16));
list.add(new Sphere(10, 1));
list.add(new Constant());
list.add(new Cross(1, 1, 30));
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 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 DoubleConeWave(60, 5, 15, 10));
list.add(new DoubleHelix(3, 30, 10));
list.add(new Gaussian(3, 3, 3));
list.add(new Impulse());
list.add(new Laplacian());
list.add(new Sinc(3, 3, 3));
list.add(new Sphere(10, 1));
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 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;
}
}
}

Event Timeline