Page MenuHomec4science

No OneTemporary

File Metadata

Created
Thu, Dec 19, 09:09
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 94713ca..f98f514 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,77 +1,77 @@
-#DeconvolutionLab2
-#DeconvolutionLab2
-#Wed Feb 01 12:36:36 CET 2017
+#DeconvolutionLab2 [Beta 1]
+#DeconvolutionLab2 [Beta 1]
+#Wed Feb 01 21:16:58 CET 2017
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW+.iterations=10
Algorithm.LW+.step=1.0
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=0.1
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
-Algorithm.algorithm=Convolution
+Algorithm.algorithm=Regularized Inverse Filter
Border.apoxy=Uniform
Border.apoz=Uniform
Border.extxy=0
Border.extz=0
Border.normalization=1
Border.padxy=None
Border.padz=None
Controller.constraint.enable=false
Controller.constraint.snapshot=1
-Controller.constraint.value=Non-negativity
+Controller.constraint.value=No
Controller.reference.enable=false
Controller.reference.snapshot=1
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.snapshot=1
Controller.residu.value=0.01
Controller.savestats.enable=false
Controller.savestats.snapshot=1
Controller.savestats.value=Stats
Controller.showstats.enable=false
Controller.showstats.snapshot=1
Controller.showstats.value=Stats
-DeconvolutionLab.MainDialog.location.h=737
-DeconvolutionLab.MainDialog.location.w=453
-DeconvolutionLab.MainDialog.location.x=39
-DeconvolutionLab.MainDialog.location.y=67
+DeconvolutionLab.MainDialog.location.h=579
+DeconvolutionLab.MainDialog.location.w=573
+DeconvolutionLab.MainDialog.location.x=5
+DeconvolutionLab.MainDialog.location.y=23
Fourier.dim=XYZ
Fourier.epsilon=1E-6
-Fourier.fft=JTransforms
-Image.image.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
-Image.image.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
-Language.headless=Launch (with control panel)
+Fourier.fft=Academic
+Image.image.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+Image.image.row1=resolution;directory;/Users/dsage/Desktop/DeconvolutionLab2-Course/resolution;
+Image.image.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+Language.headless=Run (Headless)
Language.language=Command line
-Main.path=/Users/sage/Desktop
-Monitoring.monitor=console
-Monitoring.path=current
-Monitoring.time.value=3600
-Monitoring.time=no limit
-Monitoring.verbose=log
-Output.output.row0=mip;Noname;;;;\u2713;\u2713;null
-Output.output.row1=ortho @2;Noname;;;;\u2713;\u2713;null
-Output.output.selected=ortho @2;Noname;;;;\u2713;\u2713;null
-PSF.psf.row0=DoG;synthetic;DoG 100.0 0.0 3.0 4.0 size 128 128 32 ;null
-PSF.psf.selected=DoG;synthetic;DoG 100.0 0.0 3.0 4.0 size 128 128 32 ;null
+Monitor.monitor=console table
+Monitor.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
+Monitor.time.value=3600
+Monitor.time=no limit
+Monitor.verbose=log
+Output.output.row0=ortho;Noname;;;;\u2713;\u2713;
+Output.output.selected=ortho;Noname;;;;\u2713;\u2713;
+PSF.psf.row0=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;
+PSF.psf.row1=Defocus;synthetic;Defocus 100.0 0.0 3.0 10.0 10.0 size 3 3 100 ;
+PSF.psf.selected=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index f0514fb..f2d1dd2 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,27 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="DeconvolutionLab2" default="build" basedir=".">
<property name="imagej" location="../../ImageJ/plugins"/>
<property name="fiji" location="../../Fiji-deconv.app/plugins"/>
<target name="build">
<mkdir dir="bin"/>
<copy todir="bin"><fileset dir="ij"></fileset></copy>
<copy file="plugins.config" toDir="bin" />
- <mkdir dir="dist"/>
- <zip destfile="dist/DeconvolutionLab2-src.zip" basedir="src" />
- <zip destfile="dist/DeconvolutionLab2-cls.zip" basedir="bin" />
- <jar destfile="dist/DeconvolutionLab_2.jar" basedir="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>
- <copy toDir="${fiji}" file="dist/DeconvolutionLab_2.jar" />
+ <copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
- <copy toDir="${imagej}" file="dist/DeconvolutionLab_2.jar" />
+ <copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
</target>
</project>
\ No newline at end of file
diff --git a/DeconvolutionLab2/dist/DeconvolutionLab2-cls.zip b/DeconvolutionLab2/dist/DeconvolutionLab2-cls.zip
index 1c9b469..72c7d52 100644
Binary files a/DeconvolutionLab2/dist/DeconvolutionLab2-cls.zip and b/DeconvolutionLab2/dist/DeconvolutionLab2-cls.zip differ
diff --git a/DeconvolutionLab2/dist/DeconvolutionLab2-src.zip b/DeconvolutionLab2/dist/DeconvolutionLab2-src.zip
index 274d0aa..5d6208e 100644
Binary files a/DeconvolutionLab2/dist/DeconvolutionLab2-src.zip and b/DeconvolutionLab2/dist/DeconvolutionLab2-src.zip differ
diff --git a/DeconvolutionLab2/dist/DeconvolutionLab_2.jar b/DeconvolutionLab2/dist/DeconvolutionLab_2.jar
index a596be2..6d7c2fc 100644
Binary files a/DeconvolutionLab2/dist/DeconvolutionLab_2.jar and b/DeconvolutionLab2/dist/DeconvolutionLab_2.jar differ
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index 493db2b..dc11b21 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.java
@@ -1,96 +1,93 @@
import java.io.File;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
-import deconvolutionlab.dialog.MainDialog;
+import deconvolutionlab.dialog.LabDialog;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2 {
public static String ack = Constants.name + " " + Constants.version + " " + Constants.copyright;
public static void main(String arg[]) {
System.out.println(ack);
Lab.getInstance(Platform.STANDALONE);
if (arg.length == 0) {
lab(arg);
return;
}
String flag = arg[0].trim().toLowerCase();
- if (flag.equals("help")) {
+ if (flag.equalsIgnoreCase("help")) {
help();
return;
}
- if (flag.toLowerCase().equals("lab")) {
+ if (flag.equalsIgnoreCase("lab")) {
lab(arg);
}
- if (flag.toLowerCase().equals("fft")) {
+ if (flag.equalsIgnoreCase("fft")) {
Lab.checkFFT(Monitors.createDefaultMonitor());
}
- if (flag.toLowerCase().equals("run")) {
+ if (flag.equalsIgnoreCase("run")) {
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
- new Deconvolution(cmd).deconvolve();
+ new Deconvolution(cmd).deconvolve(true);
}
- if (flag.toLowerCase().equals("launch")) {
+ if (flag.equalsIgnoreCase("launch")) {
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
- new Deconvolution(cmd).launch("");
+ new Deconvolution(cmd).launch("", true);
}
-
- System.exit(0);
-
}
private static void lab(String arg[]) {
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
if (arg.length >= 2) {
String filename = arg[1].trim();
File file = new File(filename);
if (file.exists())
if (file.isFile())
if (file.canRead())
config = filename;
}
Config.getInstance(config);
- MainDialog dialog = new MainDialog();
+ LabDialog dialog = new LabDialog();
dialog.setVisible(true);
}
private static void help() {
System.out.println("More info:" + Constants.url);
System.out.println("Syntax:");
System.out.println("java -jar DeconvolutionLab_2.jar lab [config.txt]");
System.out.println("java -jar DeconvolutionLab_2.jar run {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar fft");
System.out.println("java -jar DeconvolutionLab_2.jar info");
System.out.println("java -jar DeconvolutionLab_2.jar help");
System.out.println("{command} is the full command line for running a deconvolution");
System.out.print("Keywords of {command}: ");
for (String keyword : Command.keywords)
System.out.print(keyword + " ");
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
deconvolutionlab.Lab.getInstance(Platform.STANDALONE);
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
Config.getInstance(config);
- new Deconvolution(cmd).deconvolve();
+ new Deconvolution(cmd).deconvolve(false);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
index fe8b70c..33a8d1c 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
@@ -1,24 +1,24 @@
import java.io.File;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
-import deconvolutionlab.dialog.MainDialog;
+import deconvolutionlab.dialog.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Launch implements PlugIn {
@Override
public void run(String arg) {
Lab.getInstance(Platform.IMAGEJ);
String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
Config.getInstance(config);
if (Macro.getOptions() == null)
- new MainDialog().setVisible(true);
+ new LabDialog().setVisible(true);
else
- new Deconvolution(Macro.getOptions()).launch("");
+ new Deconvolution(Macro.getOptions()).launch("", false);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
index 086fd20..0462b41 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
@@ -1,24 +1,24 @@
import java.io.File;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
-import deconvolutionlab.dialog.MainDialog;
+import deconvolutionlab.dialog.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Run implements PlugIn {
@Override
public void run(String arg) {
Lab.getInstance(Platform.IMAGEJ);
String config = IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config";
Config.getInstance(config);
if (Macro.getOptions() == null)
- new MainDialog().setVisible(true);
+ new LabDialog().setVisible(true);
else
- new Deconvolution(Macro.getOptions()).deconvolve();
+ new Deconvolution(Macro.getOptions()).deconvolve(false);
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
index a89fa89..f25419c 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
@@ -1,94 +1,94 @@
package course;
import ij.plugin.PlugIn;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2_Course_Bigradient implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + File.separator;
private String res = root + "Results" + File.separator + "bigradient" + File.separator;
private String data = root + "Data" + File.separator + "bigradient" + File.separator;
public DeconvolutionLab2_Course_Bigradient() {
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "TRIF").mkdir();
new File(res + "RIF").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW-ITER").mkdir();
new File(res + "LW+").mkdir();
new File(res + "LW+-ITER").mkdir();
new File(res + "RL").mkdir();
new File(res + "RL-ITER").mkdir();
new File(res + "RLTV").mkdir();
new File(res + "RLTV-ITER").mkdir();
new File(res + "FISTA").mkdir();
new File(res + "FISTA-ITER").mkdir();
String psf = " -psf file " + data + "psf.tif -reference " + data + "ref.tif ";
String noisy = " -image file convnoise.tif";
- new Deconvolution("-image file " + data + "ref.tif" + psf + " -algorithm SIM 0 1 1 -out stack convnoise -out stack conbnoise_8 rescaled byte noshow").deconvolve();
+ new Deconvolution("-image file " + data + "ref.tif" + psf + " -algorithm SIM 0 1 1 -out stack convnoise -out stack conbnoise_8 rescaled byte noshow").deconvolve(false);
- new Deconvolution(noisy + psf + " -algorithm NIF -out stack NIF").deconvolve();
- new Deconvolution(noisy + psf + " -algorithm DIV -out stack DIV").deconvolve();
+ new Deconvolution(noisy + psf + " -algorithm NIF -out stack NIF").deconvolve(false);
+ new Deconvolution(noisy + psf + " -algorithm DIV -out stack DIV").deconvolve(false);
for(int i=0; i<=3; i++) {
double p = Math.pow(5, i-10);
String name = "RIF" + String.format("%02d", i);
- new Deconvolution(noisy + psf + " -algorithm RIF " + p + out("RIF" + File.separator, name)).deconvolve();
+ new Deconvolution(noisy + psf + " -algorithm RIF " + p + out("RIF" + File.separator, name)).deconvolve(false);
}
for(int i=0; i<=3; i++) {
double p = Math.pow(5, i-10);
String name = "TRIF" + String.format("%02d", i);
- new Deconvolution(noisy + psf + " -algorithm TRIF " + p + out("TRIF" + File.separator, name)).deconvolve();
+ new Deconvolution(noisy + psf + " -algorithm TRIF " + p + out("TRIF" + File.separator, name)).deconvolve(false);
}
String lw = " -algorithm LW 20 1 -out mip @2 LW-ITER/I -showstats @1 LW";
- new Deconvolution(noisy + psf + lw).deconvolve();
+ new Deconvolution(noisy + psf + lw).deconvolve(false);
new File(res + "LW-ITER/I.tif").delete();
String lwp = " -algorithm LW+ 20 1 -out mip @2 LW+-ITER/I -showstats @1 LW+";
- new Deconvolution(noisy + psf + lwp).deconvolve();
+ new Deconvolution(noisy + psf + lwp).deconvolve(false);
new File(res + "LW+-ITER/I.tif").delete();
String rl = " -algorithm RL 20 -out mip @2 RL-ITER/I -showstats @1 RL";
- new Deconvolution(noisy + psf + rl).deconvolve();
+ new Deconvolution(noisy + psf + rl).deconvolve(false);
new File(res + "RL-ITER/I.tif").delete();
String rltv = " -algorithm RLRV 20 10 -out mip @2 RLTV-ITER/I -showstats @1 RLTV";
- new Deconvolution(noisy + psf + rltv).deconvolve();
+ new Deconvolution(noisy + psf + rltv).deconvolve(false);
new File(res + "RLTV-ITER/I.tif").delete();
String fista = " -algorithm FISTA 20 1 1 Spline3 3 -mip @2 FISTA-ITER/I -showstats @1 FISTA";
- new Deconvolution(noisy + psf + fista).deconvolve();
+ new Deconvolution(noisy + psf + fista).deconvolve(false);
new File(res + "FISTA-ITER/I.tif").delete();
}
private static String out(String root, String name) {
return "showstats " + root + name + " -savestats " + 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 871d82d..d9eb32d 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
@@ -1,108 +1,108 @@
package course;
// Course Version 2
import ij.plugin.PlugIn;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import signal.RealSignal;
import signal.factory.Cube;
import signal.factory.Gaussian;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2_Course_Border implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + File.separator;
private String res = root + "Results" + File.separator + "border" + File.separator;
public DeconvolutionLab2_Course_Border() {
Monitors monitors = Monitors.createDefaultMonitor();
new File(res).mkdir();
System.setProperty("user.dir", res);
int nx = 200;
int ny = 200;
int nz = 40;
RealSignal im = new Cube(22, .1).intensity(0, 100).center(0.25, 0.00, 0.05).generate(nx, ny, nz);
RealSignal i0 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.05, 0.05).generate(nx, ny, nz);
RealSignal i1 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.10, 0.05).generate(nx, ny, nz);
RealSignal i2 = new Cube(22, .1).intensity(0, 100).center(0.25, 0.15, 0.05).generate(nx, ny, nz);
im.max(i1.max(i2).max(i0));
RealSignal g = new Gaussian(10, 10, 10).intensity(0, 101).generate(nx, ny, nz);
Lab.save(monitors, im, res + "ref.tif");
Lab.save(monitors, g, res + "psf.tif");
String psf = " -psf file " + "psf.tif";
String ref = " -image file " + "ref.tif";
String cst = " -image synthetic constant 250 0 size 200 200 40";
String algo = " -algorithm CONV -out ortho REFo (64,32,16)";
- new Deconvolution(ref + " -psf synthetic impulse " + algo).deconvolve();
+ new Deconvolution(ref + " -psf synthetic impulse " + algo).deconvolve(false);
algo = " -algorithm CONV -stack CONV -out ortho CONVo rescaled byte (64,32,16) -out mip CONVp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 200 200 -out ortho PADo200 rescaled byte (64,32,16) -out mip PADp200 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 100 100 -out ortho PADo100 rescaled byte (64,32,16) -out mip PADp100 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 40 40 -out ortho PADo40 rescaled byte (64,32,16) -out mip PADp40 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 20 20 -out ortho PADo20 rescaled byte (64,32,16) -out mip PADp20 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 10 10 -out ortho PADo10 rescaled byte (64,32,16) -out mip PADp10 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad NO NO 5 5 -out ortho PADo2 rescaled byte (64,32,16) -out mip PADp2 rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -apo HANN HANN -out ortho HANNo rescaled byte (64,32,16) -out mip HANNp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -apo TUKEY TUKEY -out ortho TUKEYo rescaled byte (64,32,16) -out mip TUKEYp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV --pad NO NO 8 8 apo HANN HANN -out ortho PAD8_HANNo rescaled byte (64,32,16) -out mip PAD8_HANNp rescaled byte";
- new Deconvolution(ref + psf + algo).deconvolve();
+ new Deconvolution(ref + psf + algo).deconvolve(false);
algo = " -algorithm CONV -apo HANN HANN -out ortho HANN_CSTo rescaled byte -out mip HANN_CSTp rescaled byte";
- new Deconvolution(cst + psf + algo).deconvolve();
+ new Deconvolution(cst + psf + algo).deconvolve(false);
algo = " -algorithm CONV -apo TUKEY TUKEY -out ortho TUKEY_CSTo rescaled byte -out mip TUKEY_CSTp rescaled byte";
- new Deconvolution(cst + psf + algo).deconvolve();
+ new Deconvolution(cst + psf + algo).deconvolve(false);
algo = " -algorithm CONV -pad E2 E2 -out ortho PADpPower2FFTW rescaled byte (64,32,16) -out mip PADpPower2FFTW rescaled byte";
- new Deconvolution(cst + psf + algo + " -fft FFTW2 ").deconvolve();
- new Deconvolution(cst + psf + algo + " -fft Academic ").deconvolve();
- new Deconvolution(cst + psf + algo+ " -fft JTransforms ").deconvolve();
+ new Deconvolution(cst + psf + algo + " -fft FFTW2 ").deconvolve(false);
+ new Deconvolution(cst + psf + algo + " -fft Academic ").deconvolve(false);
+ new Deconvolution(cst + psf + algo + " -fft JTransforms ").deconvolve(false);
}
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_Resolution.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
index 19ca6bb..d47a9b4 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
@@ -1,81 +1,81 @@
package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.GridSpots;
public class DeconvolutionLab2_Course_Resolution implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + 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();
int nx = 128;
int ny = 128;
int nz = 128;
int spacing = 16;
RealSignal x = new GridSpots(3, 1, spacing).intensity(0, 10).generate(nx, ny, nz);
Lab.show(monitors, x, "reference");
Lab.save(monitors, x, res + "reference.tif");
String algo = " ";
String ground = " -image file reference.tif ";
String psf = " -psf file ../../Data/resolution/psf-bw-500.tif ";
//String psf = " -psf synthetic gaussian 100.0 0.0 1 1 1 size " + nx + " " + ny + " " + nz;
String signal = " -image file signal.tif -reference reference.tif -monitor table";
String paramout = " intact float (" + spacing + "," + spacing + "," + spacing + ")";
algo = " -algorithm CONV -showstats @3 PR -out stack PR -out ortho PRo ";
- new Deconvolution(ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve();
+ new Deconvolution(ground + "-reference reference.tif -psf synthetic impulse 100 0 size 128 128 128 " + algo).deconvolve(false);
algo = " -algorithm SIM 0 0.1 0 -showstats @3 SIM -out stack SIGNAL -out ortho SIGNALo ";
- new Deconvolution(ground + psf + algo).deconvolve();
+ new Deconvolution(ground + psf + algo).deconvolve(false);
algo = " -algorithm NIF -out ortho NIF " + paramout;
- new Deconvolution(signal + psf + algo).deconvolve();
+ new Deconvolution(signal + psf + algo).deconvolve(false);
algo = " -algorithm LW+ 17 1 -showstats @3 LW -out ortho @10 LW+/LW+" + paramout;
- new Deconvolution(signal + psf + algo).deconvolve();
+ new Deconvolution(signal + psf + algo).deconvolve(false);
for(int i=0; i<=15; i++) {
double p = Math.pow(10, i-15);
algo = " -algorithm RIF " + p + " -out ortho RIF/RIF" + String.format("%02d", i) + paramout;
- new Deconvolution(signal + psf + algo).deconvolve();
+ new Deconvolution(signal + psf + algo).deconvolve(false);
}
algo = " -algorithm LW 11 1 -showstats @3 LW -out ortho @10 LW/LW" + paramout;
- new Deconvolution(signal + psf + algo).deconvolve();
+ new Deconvolution(signal + psf + algo).deconvolve(false);
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Resolution();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Resolution();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
index fb46d9a..bdbc99e 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
@@ -1,159 +1,159 @@
package course;
import ij.plugin.PlugIn;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.factory.DoG;
import signal.factory.Gaussian;
import signal.factory.complex.ComplexSignalFactory;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.PlatformImager;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
public class DeconvolutionLab2_Course_SpectralAnaylsis implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + File.separator;
private String res = root + "Results" + File.separator + "star" + File.separator;
private String data = root + "Data" + File.separator + "star" + File.separator;
public DeconvolutionLab2_Course_SpectralAnaylsis() {
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "TRIF").mkdir();
new File(res + "TRIF-FILTER").mkdir();
new File(res + "RIF").mkdir();
new File(res + "RIF-FILTER").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW-ITER").mkdir();
new File(res + "LW+").mkdir();
new File(res + "LW+-ITER").mkdir();
new File(res + "RL").mkdir();
new File(res + "RL-ITER").mkdir();
new File(res + "NOISELESS").mkdir();
new File(res + "PERTURBATION").mkdir();
new File(res + "SIMULATION").mkdir();
new File(res + "ICTM").mkdir();
new File(res + "ICTM-ITER").mkdir();
Monitors monitors = Monitors.createDefaultMonitor();
int nx = 256;
int ny = 256;
int nz = 1;
String size = " size " + nx + " " + ny + " " + nz;
double noise = 0.04;
double poisson = 0.01;
double wiener = Math.sqrt(noise * 2.0 / Math.PI);
System.out.println("Wiener value " + wiener);
AbstractFFT fft = FFT.createDefaultFFT(monitors, nx, ny, nz);
ComplexSignal L = ComplexSignalFactory.laplacian(nx, ny, nz);
RealSignal laplacian = fft.inverse(L).circular().rescale(monitors);
Lab.save(monitors, laplacian, res + "laplacian.tif", PlatformImager.Type.BYTE);
RealSignal h = new DoG(2, 3.6).generate(nx, ny, nz);
h.times(0.7f);
h.plus(new Gaussian(1.5, 1.5, 1.5).generate(nx, ny, nz));
Lab.save(monitors, h, res + "psf.tif");
h.plus(new Gaussian(0.5, 0.5, 0.5).generate(nx, ny, nz));
Lab.save(monitors, h, res + "psfPerturbated.tif");
String psf = " -psf file psf.tif -fft FFTW2";
String impulse = " -psf synthetic impulse 100.0 0.0 " + size;
String image = " -image file " + data + "ref.tif";
String constant = " -image constant 0 0 " + size;
// Simulation
String algo = " -algorithm CONV " + out("CONV");
- new Deconvolution(psf + image + algo).deconvolve();
+ new Deconvolution(psf + image + algo).deconvolve(false);
algo = " -algorithm CONV " + out("CONV-PERTURBATED");
- new Deconvolution(psf + image + algo).deconvolve();
+ new Deconvolution(psf + image + algo).deconvolve(false);
ComplexSignal H = fft.transform(h);
ComplexSignal H2 = Operations.multiply(H, H);
ComplexSignal LP = ComplexSignalFactory.laplacian(nx, ny, nz);
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("SIM");
- new Deconvolution(psf + image + algo).deconvolve();
+ new Deconvolution(psf + image + algo).deconvolve(false);
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("NOISE");
- new Deconvolution(impulse + constant + algo).deconvolve();
+ new Deconvolution(impulse + constant + algo).deconvolve(false);
// No Noise
String nonoise = " -image file CONV.tif -psf file psfPerturbated.tif";
- new Deconvolution(nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve();
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E0 " + out("NOISELESS/NIF0")).deconvolve();
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-3 " + out("NOISELESS/NIF-1")).deconvolve();
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-6 " + out("NOISELESS/NIF-6")).deconvolve();
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-9 " + out("NOISELESS/NIF-9")).deconvolve();
- new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-12 " + out("NOISELESS/NIF-12")).deconvolve();
- new Deconvolution(nonoise + " -algorithm DIV " + out("NOISELESS/DIV")).deconvolve();
+ new Deconvolution(nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E0 " + out("NOISELESS/NIF0")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-3 " + out("NOISELESS/NIF-1")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-6 " + out("NOISELESS/NIF-6")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-9 " + out("NOISELESS/NIF-9")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm NIF -epsilon 1E-12 " + out("NOISELESS/NIF-12")).deconvolve(false);
+ new Deconvolution(nonoise + " -algorithm DIV " + out("NOISELESS/DIV")).deconvolve(false);
// Pertubatation
String pertubation = " -image file CONV.tif -psf file psfPerturbated.tif";
- new Deconvolution(pertubation + " -algorithm TRIF " + wiener + out("PERTURBATION/WIF")).deconvolve();
- new Deconvolution(pertubation + " -algorithm NIF " + out("PERTURBATION/NIF")).deconvolve();
- new Deconvolution(pertubation + " -algorithm DIV " + out("PERTURBATION/DIV")).deconvolve();
+ new Deconvolution(pertubation + " -algorithm TRIF " + wiener + out("PERTURBATION/WIF")).deconvolve(false);
+ new Deconvolution(pertubation + " -algorithm NIF " + out("PERTURBATION/NIF")).deconvolve(false);
+ new Deconvolution(pertubation + " -algorithm DIV " + out("PERTURBATION/DIV")).deconvolve(false);
// Noisy
String simulation = " -image file SIM.tif " + psf;
- new Deconvolution(simulation + " -algorithm TRIF " + wiener + out("SIMULATION/WIF")).deconvolve();
- new Deconvolution(simulation + " -algorithm NIF "+ out("SIMULATION/NIF")).deconvolve();
- new Deconvolution(simulation + " -algorithm DIV" + out("SIMULATION/DIV")).deconvolve();
+ new Deconvolution(simulation + " -algorithm TRIF " + wiener + out("SIMULATION/WIF")).deconvolve(false);
+ new Deconvolution(simulation + " -algorithm NIF "+ out("SIMULATION/NIF")).deconvolve(false);
+ new Deconvolution(simulation + " -algorithm DIV" + out("SIMULATION/DIV")).deconvolve(false);
algo = " -algorithm LW+ 100 0.5 -out mip @1 LW+-ITER/I ";
- new Deconvolution(simulation + algo + out("LW+/LW+")).deconvolve();
+ new Deconvolution(simulation + algo + out("LW+/LW+")).deconvolve(false);
new File(res + "LW+-ITER/I.tif").delete();
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "RIF/RIF" + String.format("%02d", i);
- new Deconvolution(simulation + " -algorithm RIF " + p + out(name)).deconvolve();
+ new Deconvolution(simulation + " -algorithm RIF " + p + out(name)).deconvolve(false);
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "RIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "TRIF/TRIF" + String.format("%02d", i);
- new Deconvolution(simulation + " -algorithm TRIF " + p + out(name)).deconvolve();
+ new Deconvolution(simulation + " -algorithm TRIF " + p + out(name)).deconvolve(false);
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "TRIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
algo = " -algorithm RL 100 -out mip @1 RL-ITER/I ";
- new Deconvolution(simulation + algo + out("RL/RL")).deconvolve();
+ new Deconvolution(simulation + algo + out("RL/RL")).deconvolve(false);
new File(res + "RL-ITER/I.tif").delete();
algo = " -algorithm ICTM 100 1.5 0.001 -out mip @1 ICTM-ITER/I ";
- new Deconvolution(simulation + algo + out("ICTM/ICTM")).deconvolve();
+ new Deconvolution(simulation + algo + out("ICTM/ICTM")).deconvolve(false);
new File(res + "ICTM-ITER/I.tif").delete();
}
private static String out(String name) {
return " -out stack " + name +
" -out stack " + name + "-BYTE rescaled byte noshow";
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 5d97694..8dfbc8a 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,572 +1,607 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JFrame;
+import javax.swing.JTabbedPane;
-import lab.tools.NumFormat;
-import signal.RealSignal;
-import signal.apodization.AbstractApodization;
-import signal.apodization.Apodization;
-import signal.apodization.UniformApodization;
-import signal.factory.SignalFactory;
-import signal.padding.Padding;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.OutputCollection;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
+import lab.tools.NumFormat;
+import signal.RealSignal;
+import signal.apodization.AbstractApodization;
+import signal.apodization.Apodization;
+import signal.apodization.UniformApodization;
+import signal.factory.SignalFactory;
+import signal.padding.Padding;
public class Deconvolution implements Runnable {
- private AbstractAlgorithm algo = null;
+ private AbstractAlgorithm algo = null;
- private String path;
- private Monitors monitors = Monitors.createDefaultMonitor();
- private Verbose verbose = Verbose.Log;
- private Controller controller;
+ private String path;
+ private Monitors monitors = Monitors.createDefaultMonitor();
+ private Verbose verbose = Verbose.Log;
+ private Controller controller;
private OutputCollection outs;
- private Padding padding = new Padding();
- private Apodization apodization = new Apodization();
- private double factorNormalization = 1.0;
+ private Padding padding = new Padding();
+ private Apodization apodization = new Apodization();
+ private double factorNormalization = 1.0;
private AbstractFFTLibrary fftlib;
- private String command = "";
- private boolean live = false;
+ private String command = "";
+ private boolean live = false;
- private ArrayList<String> results = new ArrayList<String>();
+ private ArrayList<String> results = new ArrayList<String>();
- private String name = "";
+ private String name = "";
+ private boolean exit = false;
public Deconvolution(String command) {
super();
monitors = Monitors.createDefaultMonitor();
this.command = command;
decode();
}
public void setCommand(String command) {
this.command = command;
decode();
}
public String getCommand() {
return command;
}
public Monitors getMonitors() {
if (monitors == null)
return Monitors.createDefaultMonitor();
return monitors;
}
- public void deconvolve() {
+ /**
+ * This method runs the deconvolution without graphical user interface.
+ *
+ * @param exit
+ * System.exit call is true
+ */
+ public void deconvolve(boolean exit) {
+ this.exit = exit;
+
+ for (AbstractMonitor monitor : monitors) {
+ if (monitor instanceof TableMonitor) {
+ String t = algo == null ? "Monitor " + name : name + " " + algo.getName();
+ JFrame frame = new JFrame(t);
+ frame.add(((TableMonitor) monitor).getPanel());
+ frame.pack();
+ frame.setVisible(true);
+ }
+ }
if (fftlib == null) {
run();
return;
}
if (!fftlib.isMultithreadable()) {
run();
return;
}
-
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
- public String getName() {
- return name;
- }
-
- public void launch(String job) {
+ /**
+ * This method runs the deconvolution with a graphical user interface.
+ *
+ * @param job
+ * Name of the job of deconvolution
+ * @param exit
+ * System.exit call is true
+ */
+ public void launch(String job, boolean exit) {
this.name = job;
- new DeconvolutionDialog(this);
- }
-
- public ArrayList<String> getDeconvolutionResults() {
- return results;
+ this.exit = exit;
+ DeconvolutionDialog d = new DeconvolutionDialog(this);
+ for (AbstractMonitor monitor : monitors) {
+ if (monitor instanceof TableMonitor) {
+ String t = algo == null ? "Monitor " + name : name + " " + algo.getName();
+ d.addTableMonitor(t, ((TableMonitor) monitor));
+ }
+ }
}
public void decode() {
algo = null;
path = System.getProperty("user.dir");
monitors = Monitors.createDefaultMonitor();
verbose = Verbose.Log;
controller = new Controller();
outs = new OutputCollection();
padding = new Padding();
apodization = new Apodization();
factorNormalization = 1.0;
fftlib = FFT.getLibraryByName("Academic");
live = false;
results = new ArrayList<String>();
ArrayList<Token> tokens = Command.parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-algorithm"))
algo = Command.decodeAlgorithm(token, controller);
if (token.keyword.equalsIgnoreCase("-monitor"))
monitors = Command.decodeMonitors(token);
if (token.keyword.equalsIgnoreCase("-verbose"))
verbose = Verbose.getByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current")) {
path = token.parameters;
}
if (token.keyword.equalsIgnoreCase("-fft"))
fftlib = FFT.getLibraryByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-pad"))
padding = Command.decodePadding(token);
if (token.keyword.equalsIgnoreCase("-apo"))
apodization = Command.decodeApodization(token);
if (token.keyword.equalsIgnoreCase("-norm"))
factorNormalization = Command.decodeNormalization(token);
if (token.keyword.equalsIgnoreCase("-constraint"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-time"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-residu"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-reference"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-savestats"))
Command.decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-showstats"))
Command.decodeController(token, controller);
if (token.keyword.equals("-out")) {
Output out = Command.decodeOut(token);
if (out != null)
outs.add(out);
}
}
if (name.equals("") && algo != null)
name = algo.getShortname();
+
}
public void setApodization(ArrayList<AbstractApodization> apos) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
if (apos.size() >= 1)
apoXY = apos.get(0);
if (apos.size() >= 2)
apoZ = apos.get(1);
this.apodization = new Apodization(apoXY, apoXY, apoZ);
}
@Override
public void run() {
live = true;
- ArrayList<JFrame> frames = new ArrayList<JFrame>();
- if (monitors != null) {
+ if (monitors != null)
monitors.setVerbose(verbose);
- for (AbstractMonitor monitor : monitors) {
- if (monitor instanceof TableMonitor) {
- JFrame frame = new JFrame("Monitor");
- frame.add(((TableMonitor) monitor).getPanel());
- frame.pack();
- frame.setVisible(true);
- frames.add(frame);
- }
- }
- }
+
results.add("Path: " + checkPath(path));
-
monitors.log("Path: " + checkPath(path));
+
RealSignal image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
+ if (exit)
+ System.exit(-101);
return;
}
monitors.log("Image: " + image.nx + " x " + image.ny + " x " + image.nz);
RealSignal y = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
+ if (exit)
+ System.exit(-102);
return;
}
monitors.log("PSF: " + psf.nx + " x " + psf.ny + " x " + psf.nz);
monitors.log("PSF: normalization " + (factorNormalization <= 0 ? "no" : factorNormalization));
RealSignal h = psf.changeSizeAs(y).normalize(factorNormalization);
if (algo == null) {
monitors.error("Algorithm: not valid");
+ if (exit)
+ System.exit(-103);
return;
}
if (controller == null) {
monitors.error("Controller: not valid");
+ if (exit)
+ System.exit(-104);
return;
}
- for (JFrame frame : frames)
- frame.setTitle(name + " (" + algo.getName() + ") ");
-
AbstractFFT fft;
if (fftlib != null)
fft = FFT.createFFT(monitors, fftlib, image.nx, image.ny, image.nz);
else
fft = FFT.createDefaultFFT(monitors, image.nx, image.ny, image.nz);
algo.setFFT(fft);
controller.setFFT(fft);
algo.setController(controller);
if (outs != null) {
outs.setPath(path);
controller.setOutputs(outs);
}
monitors.log("Algorithm: " + algo.getName());
RealSignal x = algo.run(monitors, y, h, true);
RealSignal result = padding.crop(monitors, x);
if (outs != null)
outs.executeFinal(monitors, result, controller);
live = false;
+
+ if (exit) {
+ System.out.println("End");
+ System.exit(0);
+ }
+
}
public ArrayList<String> recap() {
ArrayList<String> lines = new ArrayList<String>();
Token image = Command.extract(command, "-image");
if (image == null)
lines.add("<b>Image</b>: <span color=\"red\">keyword -image not found</span>");
else
lines.add("<b>Image</b>: " + image.parameters);
String norm = (factorNormalization < 0 ? " (no normalization)" : " (normalization to " + factorNormalization + ")");
Token psf = Command.extract(command, "-psf");
if (psf == null)
lines.add("<b>PSF</b>: <span color=\"red\">keyword -psf not found</span>");
else
lines.add("<b>PSF</b>: " + psf.parameters + norm);
if (algo == null) {
lines.add("<b>Algorithm</b>: <span color=\"red\">not valid</span>");
}
else {
Controller controller = algo.getController();
String con = ", " + controller.getConstraintAsString() + " constraint";
lines.add("<b>Algorithm</b>: " + algo.toString() + con);
lines.add("<b>Stopping Criteria</b>: " + controller.getStoppingCriteria(algo));
lines.add("<b>Reference</b>: " + controller.getReference());
lines.add("<b>Stats</b>: " + controller.getShowStats() + " " + controller.getSaveStats());
lines.add("<b>Padding</b>: " + padding.toString());
lines.add("<b>Apodization</b>: " + apodization.toString());
if (algo.getFFT() != null)
lines.add("<b>FFT</b>: " + algo.getFFT().getName());
}
lines.add("<b>Path</b>: " + path);
String m = "";
if (monitors != null) {
for (AbstractMonitor monitor : monitors)
m += monitor.getName() + " ";
}
String v = "";
if (verbose != null)
v = "(" + verbose.name().toLowerCase() + ")";
lines.add("<b>Monitor</b>:" + m + " " + v);
if (outs == null)
lines.add("<b>Outputs</b>: not valid");
else
lines.addAll(outs.getInformation());
return lines;
}
public ArrayList<String> checkAlgo() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal psf = openPSF();
if (psf == null) {
lines.add("No valid PSF");
return lines;
}
if (algo == null) {
lines.add("No valid algorithm");
return lines;
}
Controller controller = algo.getController();
RealSignal y = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal h = psf.changeSizeAs(y).normalize(factorNormalization);
int iter = controller.getIterationMax();
algo.getController().setIterationMax(1);
RealSignal x = algo.run(monitors, y, h, true);
Lab.show(monitors, x, "Estimate after 1 iteration");
lines.add("Time: " + NumFormat.seconds(controller.getTimeNano()));
lines.add("Peak Memory: " + controller.getMemoryAsString());
controller.setIterationMax(iter);
return lines;
}
public ArrayList<String> checkImage() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal signal = padding.pad(monitors, getApodization().apodize(monitors, image));
lines.add("<b>Image</b>");
lines.add("Original size " + image.dimAsString() + " padded to " + signal.dimAsString());
lines.add("Original: " + formatStats(image));
lines.add("Preprocessing: " + formatStats(signal));
Lab.show(monitors, signal, "Image");
return lines;
}
public ArrayList<String> checkPSF() {
ArrayList<String> lines = new ArrayList<String>();
RealSignal image = openImage();
if (image == null) {
lines.add("No valid input image");
return lines;
}
if (padding == null) {
lines.add("No valid padding");
return lines;
}
if (apodization == null) {
lines.add("No valid apodization");
return lines;
}
RealSignal psf = openPSF();
if (psf == null) {
lines.add("No valid PSF");
return lines;
}
RealSignal signal = padding.pad(monitors, getApodization().apodize(monitors, image));
RealSignal h = psf.changeSizeAs(signal);
lines.add("<b>PSF</b>");
lines.add("Original size " + psf.dimAsString() + " padded to " + h.dimAsString());
String e = NumFormat.nice(h.getEnergy());
h.normalize(factorNormalization);
lines.add("Original: " + formatStats(psf));
lines.add("Preprocessing: " + formatStats(h));
lines.add("Energy = " + e + " and after normalization=" + NumFormat.nice(h.getEnergy()));
Lab.show(monitors, h, "Padded and Normalized PSF");
return lines;
}
+ public ArrayList<String> getDeconvolutionResults() {
+ return results;
+ }
+
+ public String getName() {
+ return name;
+ }
+
public boolean isLive() {
return live;
}
public void abort() {
live = false;
algo.getController().abort();
}
public Padding getPadding1() {
return padding;
}
public Apodization getApodization() {
return apodization;
}
public OutputCollection getOuts() {
return outs;
}
public AbstractAlgorithm getAlgo() {
return algo;
}
public String getPath() {
return path;
}
public String checkPath(String path) {
File dir = new File(path);
if (dir.exists()) {
if (dir.isDirectory()) {
if (dir.canWrite())
return path + " (writable)";
else
return path + " (non-writable)";
}
else {
return path + " (non-directory)";
}
}
else {
return path + " (not-valid)";
}
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
return getImage(monitors, token);
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
return getImage(monitors, token);
}
private RealSignal getImage(Monitors monitors, Token token) {
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
if (arg.equalsIgnoreCase("synthetic")) {
String parts[] = cmd.split(" ");
if (parts.length <= 0)
return null;
String shape = parts[0];
for (String name : SignalFactory.getAllName()) {
if (shape.equalsIgnoreCase(name.toLowerCase())) {
double params[] = Command.parseNumeric(cmd);
SignalFactory factory = SignalFactory.getFactoryByName(shape);
if (factory == null)
return null;
double amplitude = params.length > 0 ? params[0] : 1;
double background = params.length > 1 ? params[1] : 0;
factory.intensity(background, amplitude);
int np = factory.getParameters().length;
double[] features = new double[np];
for (int i = 0; i < Math.min(np, params.length); i++)
features[i] = params[i + 2];
factory.setParameters(features);
int nx = params.length > np + 2 ? (int) Math.round(params[np + 2]) : 128;
int ny = params.length > np + 3 ? (int) Math.round(params[np + 3]) : 128;
int nz = params.length > np + 4 ? (int) Math.round(params[np + 4]) : 128;
double cx = params.length > np + 5 ? params[np + 5] : 0.5;
double cy = params.length > np + 6 ? params[np + 6] : 0.5;
double cz = params.length > np + 7 ? params[np + 7] : 0.5;
factory = factory.center(cx, cy, cz);
RealSignal x = factory.generate(nx, ny, nz);
return x;
}
}
}
if (arg.equalsIgnoreCase("file") || arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
RealSignal signal = null;
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.open(monitors, path + File.separator + cmd);
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.open(monitors, cmd);
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
return signal;
}
if (arg.equalsIgnoreCase("platform")) {
return Lab.getImager().create(cmd);
}
return null;
}
private static String formatStats(RealSignal x) {
float stats[] = x.getStats();
String s = " mean=" + NumFormat.nice(stats[0]);
s += " stdev=" + NumFormat.nice(stats[1]);
s += " min=" + NumFormat.nice(stats[3]);
s += " max=" + NumFormat.nice(stats[2]);
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 9cb9d33..0eaa65e 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,265 +1,271 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
-import ij.gui.GUI;
-
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
+import javax.swing.JTabbedPane;
import javax.swing.JToolBar;
import javax.swing.text.BadLocationException;
-import lab.component.HTMLPane;
-import lab.system.SystemBar;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.StatusMonitor;
+import deconvolutionlab.monitor.TableMonitor;
+import ij.gui.GUI;
+import lab.component.HTMLPane;
+import lab.system.SystemBar;
public class DeconvolutionDialog extends JDialog implements ActionListener, Runnable, KeyListener {
- private JButton bnStart = new JButton("Run");
- private JButton bnQuit = new JButton("Quit");
- private JButton bnRecap = new JButton("Recap");
- private JButton bnImage = new JButton("Check Image");
- private JButton bnPSF = new JButton("Check PSF");
- private JButton bnAlgo = new JButton("Check Algo");
- private JButton bnHelp = new JButton("Help");
- // private JTabbedPane tab = new JTabbedPane();
+ private JButton bnStart = new JButton("Run");
+ private JButton bnQuit = new JButton("Quit");
+ private JButton bnRecap = new JButton("Recap");
+ private JButton bnImage = new JButton("Check Image");
+ private JButton bnPSF = new JButton("Check PSF");
+ private JButton bnAlgo = new JButton("Check Algo");
+ private JButton bnHelp = new JButton("Help");
+ private JTabbedPane tab = new JTabbedPane();
private HTMLPane pnCommand;
private HTMLPane pnResume;
- private JButton job = null;
- private Thread thread = null;
+ private JButton job = null;
+ private Thread thread = null;
private Deconvolution deconvolution;
public DeconvolutionDialog(Deconvolution deconvolution) {
super(new JFrame(), deconvolution.getName() + " " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()));
this.deconvolution = deconvolution;
JProgressBar status = new JProgressBar();
deconvolution.getMonitors().add(new StatusMonitor(status));
pnCommand = new HTMLPane("Monaco", 100, 100);
pnCommand.append("p", deconvolution.getCommand());
pnResume = new HTMLPane("Verdana", 600, 150);
+ tab.add("Resume", pnResume.getPane());
+
pnCommand.setEditable(true);
pnCommand.addKeyListener(this);
JPanel bn = new JPanel();
bn.setLayout(new GridLayout(1, 5));
bn.setBorder(BorderFactory.createEtchedBorder());
bn.add(bnRecap);
bn.add(bnImage);
bn.add(bnPSF);
bn.add(bnAlgo);
bn.add(bnStart);
status.setAlignmentX(JLabel.CENTER_ALIGNMENT);
status.setBorder(BorderFactory.createLoweredBevelBorder());
JToolBar statusBar = new JToolBar();
statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
statusBar.setFloatable(false);
statusBar.setLayout(new BorderLayout());
statusBar.add(bnHelp, BorderLayout.WEST);
statusBar.add(status, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
bottom.add(bn);
bottom.add(new SystemBar(200));
bottom.add(statusBar);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(pnCommand.getPane(), BorderLayout.NORTH);
panel.add(bottom, BorderLayout.SOUTH);
- panel.add(pnResume.getPane(), BorderLayout.CENTER);
+ panel.add(tab, BorderLayout.CENTER);
add(panel);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnPSF.addActionListener(this);
bnImage.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
bnHelp.addActionListener(this);
setMinimumSize(new Dimension(200, 400));
pack();
GUI.center(this);
setVisible(true);
print(deconvolution.recap());
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnStart) {
if (thread == null) {
job = bnStart;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
- if (deconvolution != null) deconvolution.abort();
+ if (deconvolution != null)
+ deconvolution.abort();
}
}
else if (e.getSource() == bnRecap) {
if (thread == null) {
job = bnRecap;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnImage) {
if (thread == null) {
job = bnImage;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnPSF) {
if (thread == null) {
job = bnPSF;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnAlgo) {
if (thread == null) {
job = bnAlgo;
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnQuit) {
dispose();
}
- else if (e.getSource() == bnHelp) Lab.help();
+ else if (e.getSource() == bnHelp)
+ Lab.help();
}
@Override
public void run() {
bnRecap.setEnabled(false);
bnAlgo.setEnabled(false);
bnPSF.setEnabled(false);
bnImage.setEnabled(false);
bnStart.setText("Stop");
String command = pnCommand.getText();
- System.out.println(">>> " + command);
deconvolution.setCommand(command);
if (job == bnStart) {
- // tab.setSelectedIndex(1);
+ // tab.setSelectedIndex(1);
print(deconvolution.recap());
deconvolution.run();
print(deconvolution.getDeconvolutionResults());
}
else if (job == bnRecap) {
- // tab.setSelectedIndex(0);
+ tab.setSelectedIndex(0);
print(deconvolution.recap());
}
else if (job == bnImage) {
- // tab.setSelectedIndex(0);
+ tab.setSelectedIndex(0);
print(deconvolution.checkImage());
}
else if (job == bnPSF) {
- // tab.setSelectedIndex(0);
+ tab.setSelectedIndex(0);
print(deconvolution.checkPSF());
}
else if (job == bnAlgo) {
- // tab.setSelectedIndex(0);
+ tab.setSelectedIndex(0);
print(deconvolution.checkAlgo());
}
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
bnStart.setText("Start");
thread = null;
}
private void print(ArrayList<String> lines) {
pnResume.clear();
for (String line : lines)
pnResume.append("p", line);
}
+ public void addTableMonitor(String title, TableMonitor tm) {
+ tab.add(title, tm.getPanel());
+ }
+
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
int len = pnCommand.getDocument().getLength();
- String command;
- command = pnCommand.getDocument().getText(0, len);
- System.out.println(">>> " + command);
+ String command = pnCommand.getDocument().getText(0, len);
deconvolution.setCommand(command);
print(deconvolution.recap());
}
catch (BadLocationException e1) {
e1.printStackTrace();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index 9847abd..7a8c629 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,172 +1,181 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import signal.Operations;
-import signal.RealSignal;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
+import signal.Operations;
+import signal.RealSignal;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
- protected RealSignal y = null;
- protected RealSignal h = null;
+ protected RealSignal y = null;
+ protected RealSignal h = null;
protected RealSignal reference = null;
protected Controller controller = null;
- protected AbstractFFT fft = null;
-
+ protected AbstractFFT fft = null;
+
public AbstractAlgorithm() {
this.controller = new Controller();
}
public abstract String getName();
+
public abstract String getShortname();
+
public abstract boolean isRegularized();
+
public abstract boolean isStepControllable();
+
public abstract boolean isIterative();
+
public abstract boolean isWaveletsBased();
+
public abstract void setParameters(double[] params);
+
public abstract double getRegularizationFactor();
+
public abstract double getStepFactor();
+
public abstract double[] getParameters();
+
public abstract double[] getDefaultParameters();
public RealSignal run(Monitors monitors, RealSignal image, RealSignal psf, boolean threaded) {
String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
monitors.log(getShortname() + " is starting (" + iterations + ")");
y = image.duplicate();
h = psf.duplicate();
controller.setMonitors(monitors);
controller.start(y);
h = Operations.circularShift(h);
if (fft == null)
fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
else
fft.init(monitors, y.nx, y.ny, y.nz);
monitors.log(getShortname() + " data ready");
-
+
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortname() + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
controller.finish(x);
monitors.log(getName() + " is finished");
return x;
}
public AbstractFFT getFFT() {
return fft;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
controller.setAlgorithm(getName());
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
- public void setWavelets(String waveletsName) {
+ public void setWavelets(String waveletsName) {
}
-
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
- s += (isRegularized() ? ", &lambda=" + getRegularizationFactor() : "") ;
- s += (isStepControllable() ? ", &gamma=" + getStepFactor() : "") ;
+ s += (isRegularized() ? ", &lambda=" + getRegularizationFactor() : "");
+ s += (isStepControllable() ? ", &gamma=" + getStepFactor() : "");
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithmPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithmPanel.java
index d964304..5c6b1b1 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithmPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithmPanel.java
@@ -1,25 +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 deconvolution.algorithm;
import javax.swing.JPanel;
public abstract class AbstractAlgorithmPanel {
public abstract JPanel getPanelParameters();
public abstract String getCommand();
public abstract String getName();
public abstract String getShortname();
public abstract String getDocumentation();
public boolean isNamed(String name) {
if (name.equals(getShortname().toLowerCase()))
return true;
if (name.equals(getName().toLowerCase()))
return true;
return false;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
index f655e53..632ec12 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
@@ -1,135 +1,135 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.ArrayList;
public class Algorithm {
private static ArrayList<AbstractAlgorithmPanel> list;
-
+
static {
list = new ArrayList<AbstractAlgorithmPanel>();
list.add(new RegularizedInverseFilterPanel());
list.add(new TikhonovRegularizationInverseFilterPanel());
list.add(new NaiveInverseFilterPanel());
list.add(new FISTAPanel());
list.add(new ISTAPanel());
list.add(new LandweberPanel());
list.add(new LandweberPositivityPanel());
list.add(new RichardsonLucyPanel());
list.add(new RichardsonLucyTVPanel());
list.add(new TikhonovMillerPanel());
list.add(new ICTMPanel());
list.add(new VanCittertPanel());
list.add(new IdentityPanel());
list.add(new ConvolutionPanel());
list.add(new SimulationPanel());
- list.add(new NonStabilizedDivisionPanel());
+ list.add(new NonStabilizedDivisionPanel());
}
-
+
public static ArrayList<AbstractAlgorithmPanel> getAvailableAlgorithms() {
return list;
}
public static AbstractAlgorithm getDefaultAlgorithm() {
return new Identity();
}
-
+
public static AbstractAlgorithm createAlgorithm(String name) {
if (name == null)
return getDefaultAlgorithm();
String n = name.trim().toLowerCase();
int i = 0;
-
+
if (list.get(i++).isNamed(n))
return new RegularizedInverseFilter(0.1);
if (list.get(i++).isNamed(n))
return new TikhonovRegularizationInverseFilter(1.0);
if (list.get(i++).isNamed(n))
return new NaiveInverseFilter();
if (list.get(i++).isNamed(n))
return new FISTA(10, 1, 1, "Haar", 3);
if (list.get(i++).isNamed(n))
return new ISTA(10, 1, 1, "Haar", 3);
if (list.get(i++).isNamed(n))
return new Landweber(10, 1);
if (list.get(i++).isNamed(n))
return new LandweberPositivity(10, 1);
if (list.get(i++).isNamed(n))
return new RichardsonLucy(10);
if (list.get(i++).isNamed(n))
return new RichardsonLucyTV(10, 1);
if (list.get(i++).isNamed(n))
return new TikhonovMiller(10, 1, 0.1);
if (list.get(i++).isNamed(n))
return new ICTM(10, 1, 0.1);
if (list.get(i++).isNamed(n))
return new VanCittert(10, 1);
if (list.get(i++).isNamed(n))
return new Identity();
if (list.get(i++).isNamed(n))
return new Convolution();
if (list.get(i++).isNamed(n))
return new Simulation(0, 1, 0);
if (list.get(i++).isNamed(n))
return new NonStabilizedDivision();
return getDefaultAlgorithm();
}
- public static AbstractAlgorithmPanel getPanel(String name) {
+ public static AbstractAlgorithmPanel getPanel(String name) {
for (AbstractAlgorithmPanel panel : getAvailableAlgorithms()) {
if (panel.getShortname().equals(name.trim()))
return panel;
if (panel.getName().equals(name.trim()))
return panel;
-
+
}
return null;
}
- public static ArrayList<String> getShortnames() {
+ public static ArrayList<String> getShortnames() {
ArrayList<String> list = new ArrayList<String>();
for (AbstractAlgorithmPanel algo : getAvailableAlgorithms()) {
list.add(algo.getShortname());
}
return list;
}
public static String getDocumentation(String name) {
for (AbstractAlgorithmPanel algo : getAvailableAlgorithms()) {
if (name.equals(algo.getName()))
return algo.getDocumentation();
}
return "Unknown Algorithm";
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index eb04bd4..f7859cd 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,381 +1,381 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.Timer;
import java.util.TimerTask;
+import deconvolution.Deconvolution;
+import deconvolutionlab.Lab;
+import deconvolutionlab.OutputCollection;
+import deconvolutionlab.monitor.Monitors;
+import fft.AbstractFFT;
+import fft.FFT;
import lab.system.SystemUsage;
import lab.tools.NumFormat;
import signal.Assessment;
import signal.ComplexSignal;
import signal.Constraint;
import signal.RealSignal;
import signal.Signal;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Lab;
-import deconvolutionlab.OutputCollection;
-import deconvolutionlab.monitor.Monitors;
-import fft.AbstractFFT;
-import fft.FFT;
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 doShowStats = false;
- private boolean doSaveStats = false;
- private boolean abort = false;
-
- private int snapshotResidu = 0;
- private int snapshotReference = 0;
- private int snapshotConstraint = 0;
- private int snapshotSaveStats = 0;
- private int snapshotShowStats = 0;
-
- private double timeStarting = 0;
- private double memoryStarting = 0;
- private double residu = Double.MAX_VALUE;
- private int iterations = 0;
- private double memoryPeak = 0;
- private double snr = 0;
- private double psnr = 0;
-
- private Constraint.Mode constraint = Constraint.Mode.NO;
- private OutputCollection outs = null;
- private String referenceName = "";
- private String showstatsName = "";
- private String savestatsName = "";
- private RealSignal refImage;
- private RealSignal prevImage;
- private RealSignal x;
-
- private Timer timer;
- private AbstractFFT fft;
-
- private String algo = "";
- private float statsInput[];
-
- private Monitors monitors = new Monitors();
+ 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 doShowStats = false;
+ private boolean doSaveStats = false;
+ private boolean abort = false;
+
+ private int snapshotResidu = 0;
+ private int snapshotReference = 0;
+ private int snapshotConstraint = 0;
+ private int snapshotSaveStats = 0;
+ private int snapshotShowStats = 0;
+
+ private double timeStarting = 0;
+ private double memoryStarting = 0;
+ private double residu = Double.MAX_VALUE;
+ private int iterations = 0;
+ private double memoryPeak = 0;
+ private double snr = 0;
+ private double psnr = 0;
+
+ private Constraint.Mode constraint = Constraint.Mode.NO;
+ private OutputCollection outs = null;
+ private String referenceName = "";
+ private String showstatsName = "";
+ private String savestatsName = "";
+ private RealSignal refImage;
+ private RealSignal prevImage;
+ private RealSignal x;
+
+ private Timer timer;
+ private AbstractFFT fft;
+
+ private String algo = "";
+ private float statsInput[];
+
+ private Monitors monitors = new Monitors();
public Controller() {
constraint = Constraint.Mode.NO;
doResidu = false;
doTime = false;
doReference = false;
doConstraint = false;
doShowStats = false;
doSaveStats = false;
}
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
public void setAlgorithm(String algo) {
this.algo = algo;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
public int getIterationMax() {
return iterationsMax;
}
public void setIterationMax(int iterationsMax) {
this.iterationsMax = iterationsMax;
}
public void setTimeStop(double timeMax) {
this.doTime = true;
this.timeMax = timeMax * 1e9;
}
public void setResiduStop(int snapshot, double residuMin) {
this.doResidu = true;
this.snapshotResidu = snapshot;
this.residuMin = residuMin;
}
public void setReference(int snapshot, String referenceName) {
this.doReference = true;
this.snapshotReference = snapshot;
this.referenceName = referenceName;
}
public void setConstraint(int snapshot, Constraint.Mode constraint) {
this.doConstraint = true;
this.snapshotConstraint = snapshot;
this.constraint = constraint;
}
public void setSaveStats(int snapshot, String name) {
this.doSaveStats = true;
this.snapshotSaveStats = snapshot;
this.savestatsName = name;
}
public void setShowStats(int snapshot, String name) {
this.doShowStats = true;
this.snapshotShowStats = snapshot;
this.showstatsName = name;
}
public void setOutputs(OutputCollection outs) {
this.outs = outs;
}
public void start(RealSignal x) {
this.x = x;
statsInput = x.getStats();
iterations = 0;
timer = new Timer();
timer.schedule(new Updater(), 0, 100);
timeStarting = System.nanoTime();
memoryStarting = SystemUsage.getHeapUsed();
Signal.bytes = 0;
if (doConstraint && x != null)
Constraint.setModel(x);
if (doReference && snapshotReference >= 1) {
refImage = new Deconvolution("-image file " + referenceName).openImage();
if (refImage == null)
monitors.error("Impossible to load the reference image " + referenceName);
else
monitors.log("Reference image loaded");
}
if (doShowStats || doSaveStats)
if (monitors != null)
Lab.firstStats(monitors, showstatsName, this, doShowStats, doSaveStats);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
boolean res = doResidu && snapshotResidu >= 1 ? (iterations % snapshotResidu == 0) : false;
boolean con = doConstraint && snapshotConstraint >= 1 ? (iterations % snapshotConstraint == 0) : false;
boolean ref = doReference && snapshotReference >= 1 ? (iterations % snapshotReference == 0) : false;
boolean sav = doSaveStats && snapshotSaveStats >= 1 ? (iterations % snapshotSaveStats == 0) : false;
boolean shw = doShowStats && snapshotShowStats >= 1 ? (iterations % snapshotShowStats == 0) : false;
boolean out = outs == null ? false : outs.hasShow(iterations);
if (con || res || ref || sav || shw || out) {
if (fft == null)
fft = FFT.createDefaultFFT(monitors, X.nx, X.ny, X.nz);
x = new RealSignal(X.nx, X.ny, X.nz, false);
fft.inverse(X, x);
return ends(x);
}
return ends((RealSignal) null);
}
public boolean ends(RealSignal x) {
this.x = x;
boolean res = doResidu && snapshotResidu >= 1 ? (iterations % snapshotResidu == 0) : false;
boolean con = doConstraint && snapshotConstraint >= 1 ? (iterations % snapshotConstraint == 0) : false;
boolean ref = doReference && snapshotReference >= 1 ? (iterations % snapshotReference == 0) : false;
boolean sav = doSaveStats && snapshotSaveStats >= 1 ? (iterations % snapshotSaveStats == 0) : false;
boolean shw = doShowStats && snapshotShowStats >= 1 ? (iterations % snapshotShowStats == 0) : false;
if (con || res || ref)
compute(iterations, x, con, res, ref);
if (sav || shw)
Lab.nextStats(monitors, showstatsName, this, sav, shw);
if (outs != null)
outs.executeIterative(monitors, x, this);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
double timeElapsed = getTimeNano();
boolean stopIter = (iterations >= iterationsMax);
boolean stopTime = doTime && (timeElapsed >= timeMax);
boolean stopResd = doResidu && (residu <= residuMin);
monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed) + " Memory: " + NumFormat.bytes(Signal.bytes));
String prefix = "Stopped>> by ";
if (abort)
monitors.log(prefix + "abort");
if (stopIter)
monitors.log(prefix + "iteration " + iterations + " > " + iterationsMax);
if (stopTime)
monitors.log(prefix + "time " + timeElapsed + " > " + timeMax);
if (stopResd)
monitors.log(prefix + "residu " + NumFormat.nice(residu) + " < " + NumFormat.nice(residuMin));
return abort | stopIter | stopTime | stopResd;
}
public void finish(RealSignal x) {
this.x = x;
boolean ref = doReference;
boolean con = doConstraint;
boolean res = doResidu;
if (con || res || ref)
compute(iterations, x, con, res, ref);
if (doShowStats || doSaveStats)
Lab.lastStats(monitors, savestatsName, this, doShowStats, doSaveStats);
monitors.log("Time: " + NumFormat.seconds(getTimeNano()) + " Peak:" + getMemoryAsString());
if (timer != null)
timer.cancel();
}
private void compute(int iterations, RealSignal x, boolean con, boolean res, boolean ref) {
if (x == null)
return;
if (con && constraint != null)
new Constraint(monitors).apply(x, constraint);
if (ref && refImage != null) {
String s = "";
psnr = Assessment.psnr(x, refImage);
snr = Assessment.snr(x, refImage);
s += " PSNR: " + NumFormat.nice(psnr);
s += " SNR: " + NumFormat.nice(snr);
monitors.log("@" + iterations + " " + s);
}
residu = Double.MAX_VALUE;
if (res && prevImage != null) {
residu = Assessment.relativeResidu(x, prevImage);
prevImage = x.duplicate();
monitors.log("@" + iterations + " Residu: " + NumFormat.nice(residu));
}
}
public String[] stats(String name) {
float params[] = null;
if (x != null)
params = x.getStats();
String[] row = new String[15];
row[0] = name;
row[1] = algo;
row[2] = "" + iterations;
row[3] = (params == null ? "-" : "" + params[0]);
row[4] = (params == null ? "-" : "" + params[1]);
row[5] = (params == null ? "-" : "" + params[2]);
row[6] = (params == null ? "-" : "" + params[3]);
row[7] = (params == null ? "-" : "" + params[4]);
row[8] = (params == null ? "-" : "" + params[5]);
row[9] = NumFormat.seconds(getTimeNano());
row[10] = NumFormat.bytes(SystemUsage.getHeapUsed());
row[11] = NumFormat.bytes(memoryPeak);
row[12] = doReference ? NumFormat.nice(psnr) : "n/a";
row[13] = doReference ? NumFormat.nice(snr) : "n/a";
row[14] = doResidu ? NumFormat.nice(residu) : "n/a";
return row;
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
public Constraint.Mode getConstraint() {
return constraint;
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
if (constraint == Constraint.Mode.NO)
return "no";
else
return constraint.name().toLowerCase();
}
public String getReference() {
return doReference ? referenceName : "no ground-truth";
}
public String getShowStats() {
return doShowStats ? showstatsName : "no stats";
}
public String getSaveStats() {
return doSaveStats ? savestatsName : "no stats";
}
public String getStoppingCriteria(AbstractAlgorithm algo) {
String stop = algo.isIterative() ? " iterations limit=" + getIterationMax() + " " : ", ";
stop += doTime ? ", time limit=" + NumFormat.nice(timeMax * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
public float[] getStatsInput() {
return statsInput;
}
public double getMemory() {
return memoryPeak - memoryStarting;
}
public String getMemoryAsString() {
return NumFormat.bytes(getMemory());
}
public int getIterations() {
return iterations;
}
private void update() {
memoryPeak = Math.max(memoryPeak, SystemUsage.getHeapUsed());
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Convolution.java b/DeconvolutionLab2/src/deconvolution/algorithm/Convolution.java
index ac32605..1317644 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Convolution.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Convolution.java
@@ -1,110 +1,109 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class Convolution extends AbstractAlgorithm implements Callable<RealSignal> {
public Convolution() {
super();
}
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = Operations.multiply(H, Y);
RealSignal x = fft.inverse(X);
return x;
}
@Override
public String getName() {
return "Convolution";
}
-
+
@Override
public String getShortname() {
return "CONV";
}
-
+
@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[] getParameters() {
return new double[] {};
}
-
+
@Override
public double[] getDefaultParameters() {
return new double[] {};
}
-
-
+
@Override
public double getRegularizationFactor() {
return 0.0;
}
-
+
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
index cd1453a..90294ef 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
@@ -1,41 +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 deconvolution.algorithm;
import javax.swing.JPanel;
import lab.component.GridPanel;
public class ConvolutionPanel extends AbstractAlgorithmPanel {
-
+
private Convolution algo = new Convolution();
-
+
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
-
+
@Override
public String getCommand() {
return "";
}
-
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
@Override
public String getDocumentation() {
- String s = "";
+ String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm is only used for simulation. It convolves the input image with the PSF.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java b/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java
index 463a8ec..acfcbca 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/FISTA.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 deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
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;
-
+
+ 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) {
super();
controller.setIterationMax(iter);
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);
-
+
ComplexSignal Z = G.duplicate();
- RealSignal x = fft.inverse(G);
+ RealSignal x = fft.inverse(G);
RealSignal s = x.duplicate();
RealSignal z = x.duplicate();
-
- RealSignal xprev = fft.inverse(G);
+
+ RealSignal xprev = fft.inverse(G);
float pk1 = 1f;
float pk0 = 1f;
- float threshold = (float)(lambda*gamma*0.5);
+ float threshold = (float) (lambda * gamma * 0.5);
RealSignal buffer = y.duplicate();
- while(!controller.ends(x)) {
+ 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);
+ pk1 = (1f + (float) Math.sqrt(1f + 4f * pk0 * pk0)) * 0.5f;
+ update(xprev, x, (pk0 - 1f) / pk1, s);
}
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;
- }
+ 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 "FISTA";
}
@Override
public String getShortname() {
return "FISTA";
}
@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) {
+ 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]));
+ controller.setIterationMax((int) Math.round(params[0]));
if (params.length > 1)
- gamma = (float)params[1];
+ gamma = (float) params[1];
if (params.length > 2)
- lambda = (float)params[2];
+ lambda = (float) params[2];
if (params.length > 3)
- scale = (int)params[3];
+ scale = (int) params[3];
}
-
+
@Override
public double[] getDefaultParameters() {
- return new double[] {10, 1, 0.1};
+ return new double[] { 10, 1, 0.1 };
}
-
+
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax(), gamma, lambda};
+ return new double[] { controller.getIterationMax(), gamma, lambda };
}
@Override
public double getRegularizationFactor() {
return lambda;
}
-
+
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
index 86d0e31..271d542 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
@@ -1,136 +1,165 @@
+/*
+ * 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
public class FISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
- private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
- private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
- private RegularizationPanel reg;
- private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
- private JComboBox<String> cmbScale = new JComboBox<String>(new String[] {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"});
+ private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
+ private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
+ private RegularizationPanel reg;
+ private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
+ private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
+
+ private FISTA algo = new FISTA(10, 1, 0.1, "Haar", 3);
- private FISTA algo = new FISTA(10, 1, 0.1, "Haar", 3);
-
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
- double[] params = algo.getDefaultParameters();
-
+ double[] params = algo.getDefaultParameters();
+
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
-
+
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
-
+
pn.place(2, 0, 5, 1, reg);
-
+
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
- double gamma = spnStep.get();
+ double gamma = spnStep.get();
double lambda = reg.getValue();
- String waveletsName = (String)cmbWav.getSelectedItem();
- int scale = Integer.parseInt((String)cmbScale.getSelectedItem());
- return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " "+ waveletsName + " " + scale;
+ String waveletsName = (String) cmbWav.getSelectedItem();
+ int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
+ return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
- }
-
+ }
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
-
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java b/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
index 10b47fb..7e7a7b8 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ICTM.java
@@ -1,136 +1,135 @@
/*
* 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.factory.complex.ComplexSignalFactory;
public class ICTM extends AbstractAlgorithm implements Callable<RealSignal> {
-
- private double gamma = 1.0;
- private double lambda = 1.0;
-
+
+ private double gamma = 1.0;
+ private double lambda = 1.0;
+
public ICTM(int iter, double gamma, double lambda) {
super();
controller.setIterationMax(iter);
controller.setConstraint(1, 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);
+ ComplexSignal L2 = Operations.multiplyConjugate(lambda * gamma, L, L);
A.minus(L2);
ComplexSignal G = Operations.multiplyConjugate(gamma, H, Y);
ComplexSignal X = G.duplicate();
controller.setConstraint(1, Constraint.Mode.NONNEGATIVE);
- while(!controller.ends(X)) {
+ while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
RealSignal x = fft.inverse(X);
return x;
}
-
+
@Override
public String getName() {
return "Iterative Contraint Tikhonov-Miller";
}
@Override
public String getShortname() {
return "ICTM";
}
@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]));
+ controller.setIterationMax((int) Math.round(params[0]));
if (params.length > 1)
- gamma = (float)params[1];
+ gamma = (float) params[1];
if (params.length > 2)
- lambda = (float)params[2];
+ lambda = (float) params[2];
}
-
+
@Override
public double[] getDefaultParameters() {
- return new double[] {10, 1, 0.1};
+ return new double[] { 10, 1, 0.1 };
}
-
+
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax(), gamma, lambda};
+ return new double[] { controller.getIterationMax(), gamma, lambda };
}
-
@Override
public double getRegularizationFactor() {
return lambda;
}
-
+
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
index 185733b..7f210c3 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
@@ -1,114 +1,143 @@
+/*
+ * 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
public class ICTMPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
-
+
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
- private RegularizationPanel reg;
+ private RegularizationPanel reg;
+
+ private ICTM algo = new ICTM(10, 0.1, 1);
- private ICTM algo = new ICTM(10, 0.1, 1);
-
@Override
public JPanel getPanelParameters() {
- double[] params = algo.getDefaultParameters();
+ double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
-
+
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
-
+
pn.place(2, 0, 5, 1, reg);
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
-
@Override
public String getCommand() {
- double gamma = spnStep.get();
+ double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
- }
-
+ }
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
-
+
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
-
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
index 7b56017..8ffd206 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
@@ -1,134 +1,165 @@
+/*
+ * 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
public class ISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
- private RegularizationPanel reg;
+ private RegularizationPanel reg;
private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
private ISTA algo = new ISTA(0, 1, 0.1, "Haar", 3);
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
double lambda = reg.getValue();
String waveletsName = (String) cmbWav.getSelectedItem();
int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
- }
-
+ }
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
index 58007d3..d90764a 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
@@ -1,41 +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 deconvolution.algorithm;
import javax.swing.JPanel;
import lab.component.GridPanel;
public class IdentityPanel extends AbstractAlgorithmPanel {
-
+
private Identity algo = new Identity();
-
+
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
-
+
@Override
public String getCommand() {
return "";
}
-
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
@Override
public String getDocumentation() {
- String s = "";
+ String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm does nothing. It returns the input image.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java b/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
index 7aac84c..693166d 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Landweber.java
@@ -1,129 +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/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class Landweber extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
public Landweber(int iter, double gamma) {
super();
controller.setIterationMax(iter);
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();
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
RealSignal x = fft.inverse(X);
return x;
}
@Override
public String getName() {
return "Landweber";
}
@Override
public String getShortname() {
return "LW";
}
@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]));
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[] { controller.getIterationMax(), gamma };
}
+
@Override
public double getRegularizationFactor() {
return 0.0;
}
-
+
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
index fc3f87e..66af4d4 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
@@ -1,78 +1,109 @@
+/*
+ * 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 javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
-public class LandweberPanel extends AbstractAlgorithmPanel implements ChangeListener{
+public class LandweberPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
- private Landweber algo = new Landweber(10, 1);
+ private Landweber algo = new Landweber(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
-
+
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
-
+
pn.place(2, 0, "<html><span \"nowrap\"><b>Regularization</b></span></html>");
pn.place(2, 1, 4, 1, "<html><span \"nowrap\">No regularization</i></span></html>");
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
- double gamma = spnStep.get();
+ double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
- }
-
+ }
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
index d00878c..4c888cf 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivity.java
@@ -1,133 +1,133 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Constraint;
import signal.Operations;
import signal.RealSignal;
public class LandweberPositivity extends AbstractAlgorithm implements Callable<RealSignal> {
private double gamma = 1.0;
public LandweberPositivity(int iter, double gamma) {
super();
controller.setIterationMax(iter);
controller.setConstraint(1, 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(1, Constraint.Mode.NONNEGATIVE);
while (!controller.ends(X)) {
X.times(A);
X.plus(G);
}
RealSignal x = fft.inverse(X);
return x;
}
@Override
public String getName() {
return "Landweber+Positivity";
}
@Override
public String getShortname() {
return "LW+";
}
@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]));
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[] { controller.getIterationMax(), gamma };
}
-
+
@Override
public double getRegularizationFactor() {
return 0.0;
}
-
+
@Override
public double getStepFactor() {
return gamma;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
index 658a33e..cc103bc 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
@@ -1,79 +1,109 @@
+/*
+ * 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 javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
public class LandweberPositivityPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
- private LandweberPositivity algo = new LandweberPositivity(10, 1);
+ private LandweberPositivity algo = new LandweberPositivity(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
-
+
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
-
+
pn.place(2, 0, "<html><span \"nowrap\"><b>Regularization</b></span></html>");
pn.place(2, 1, 4, 1, "<html><span \"nowrap\">No regularization</i></span></html>");
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
-
@Override
public String getCommand() {
int iter = spnIter.get();
- double gamma = spnStep.get();
+ double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
- }
-
+ }
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilter.java b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilter.java
index 200e329..089b7c2 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilter.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilter.java
@@ -1,109 +1,109 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class NaiveInverseFilter extends AbstractAlgorithm implements Callable<RealSignal> {
public NaiveInverseFilter() {
super();
}
-
+
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = Operations.divideStabilized(Y, H);
RealSignal x = fft.inverse(X);
return x;
}
-
+
@Override
public String getShortname() {
return "NIF";
}
@Override
public String getName() {
return "Naive Inverse Filter";
}
@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/NaiveInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
index 7ac093c..aad48fe 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
@@ -1,46 +1,76 @@
+/*
+ * 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 javax.swing.JPanel;
import lab.component.GridPanel;
public class NaiveInverseFilterPanel extends AbstractAlgorithmPanel {
-
+
private NaiveInverseFilter algo = new NaiveInverseFilter();
-
+
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
-
+
@Override
public String getCommand() {
return "";
}
-
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
index 141acde..94c4421 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivision.java
@@ -1,109 +1,109 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class 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);
RealSignal x = fft.inverse(X);
return x;
}
@Override
public String getName() {
return "Non Stablized Division";
}
@Override
public String getShortname() {
return "DIV";
}
@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/NonStabilizedDivisionPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
index 775db9a..40cd77e 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
@@ -1,46 +1,76 @@
+/*
+ * 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 javax.swing.JPanel;
import lab.component.GridPanel;
public class NonStabilizedDivisionPanel extends AbstractAlgorithmPanel {
private NonStabilizedDivision algo = new NonStabilizedDivision();
-
+
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
-
+
@Override
public String getCommand() {
return "";
}
-
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilter.java b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilter.java
index db028b1..16211c6 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilter.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilter.java
@@ -1,123 +1,122 @@
/*
* 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.factory.complex.ComplexSignalFactory;
public class RegularizedInverseFilter extends AbstractAlgorithm implements Callable<RealSignal> {
private double lambda = 0.001;
-
+
public RegularizedInverseFilter(double lambda) {
super();
this.lambda = lambda;
}
@Override
public RealSignal call() {
- ComplexSignal Y = fft.transform(y);
- ComplexSignal H = fft.transform(h);
+ ComplexSignal Y = fft.transform(y);
+ ComplexSignal H = fft.transform(h);
ComplexSignal H2 = Operations.multiply(H, H);
- ComplexSignal L = ComplexSignalFactory.laplacian(Y.nx, Y.ny, Y.nz);
+ ComplexSignal L = ComplexSignalFactory.laplacian(Y.nx, Y.ny, Y.nz);
ComplexSignal L2 = Operations.multiply(lambda, L, L);
ComplexSignal FA = Operations.add(H2, L2);
- ComplexSignal FT = Operations.divideStabilized(H, FA);
- ComplexSignal X = Operations.multiply(Y, FT);
+ ComplexSignal FT = Operations.divideStabilized(H, FA);
+ ComplexSignal X = Operations.multiply(Y, FT);
RealSignal x = fft.inverse(X);
return x;
}
-
+
@Override
public String getName() {
return "Regularized Inverse Filter";
}
@Override
public String getShortname() {
return "RIF";
}
-
+
@Override
public boolean isRegularized() {
return true;
}
@Override
public boolean isStepControllable() {
return false;
}
@Override
public boolean isIterative() {
return false;
}
-
+
@Override
public boolean isWaveletsBased() {
return false;
}
-
+
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
- lambda = (float)params[0];
+ lambda = (float) params[0];
}
-
+
@Override
public double[] getDefaultParameters() {
- return new double[] {0.1};
+ return new double[] { 0.1 };
}
-
+
@Override
public double[] getParameters() {
- return new double[] {lambda};
+ return new double[] { lambda };
}
-
-
+
@Override
public double getRegularizationFactor() {
return lambda;
}
-
+
@Override
public double getStepFactor() {
return 0;
}
-
+
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
index 1e7a7d0..826279b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
@@ -1,84 +1,115 @@
+/*
+ * 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.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
public class RegularizedInverseFilterPanel extends AbstractAlgorithmPanel implements KeyListener, ChangeListener {
-
- private RegularizationPanel reg;
- private RegularizedInverseFilter algo = new RegularizedInverseFilter(0.1);
-
+
+ private RegularizationPanel reg;
+ private RegularizedInverseFilter algo = new RegularizedInverseFilter(0.1);
+
@Override
public JPanel getPanelParameters() {
- double[] params = algo.getDefaultParameters();
+ double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
-
+
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
-
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
-
+
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
- }
-
+ }
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
index 5b7ba9d..b98a130 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucy.java
@@ -1,126 +1,126 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
public class RichardsonLucy extends AbstractAlgorithm implements Callable<RealSignal> {
public RichardsonLucy(int iter) {
super();
controller.setIterationMax(iter);
}
-
+
// x(k+1) = x(k) *. Hconj * ( y /. H x(k))
@Override
public RealSignal call() {
ComplexSignal H = fft.transform(h);
ComplexSignal U = new ComplexSignal(y.nx, y.ny, y.nz);
RealSignal x = y.duplicate();
RealSignal p = y.duplicate();
RealSignal u = y.duplicate();
- while(!controller.ends(x)) {
+ 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);
+ x.times(u);
}
return x;
}
-
+
@Override
public String getName() {
return "Richardson-Lucy";
}
-
+
@Override
public String getShortname() {
return "RL";
}
@Override
public boolean isRegularized() {
return false;
}
@Override
public boolean isStepControllable() {
return false;
}
-
+
@Override
public boolean isIterative() {
return true;
}
-
+
@Override
public boolean isWaveletsBased() {
return false;
}
-
+
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
- controller.setIterationMax((int)Math.round(params[0]));
+ controller.setIterationMax((int) Math.round(params[0]));
}
-
+
@Override
public double[] getDefaultParameters() {
- return new double[] {10};
+ return new double[] { 10 };
}
-
+
@Override
public double[] getParameters() {
- return new double[] {controller.getIterationMax()};
+ return new double[] { controller.getIterationMax() };
}
-
+
@Override
public double getRegularizationFactor() {
return 0.0;
}
-
+
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
index 54a78fd..f15c342 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
@@ -1,61 +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 deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeInteger;
import deconvolution.Command;
import deconvolutionlab.Config;
+import lab.component.GridPanel;
+import lab.component.SpinnerRangeInteger;
public class RichardsonLucyPanel extends AbstractAlgorithmPanel implements ChangeListener {
-
+
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
- private RichardsonLucy algo = new RichardsonLucy(10);
-
+ private RichardsonLucy algo = new RichardsonLucy(10);
+
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
spnIter.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return "" + spnIter.get();
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
-
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
index 70d89d8..a4fbe82 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
@@ -1,99 +1,129 @@
+/*
+ * 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
public class RichardsonLucyTVPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
- private RegularizationPanel reg;
+ private RegularizationPanel reg;
+
+ private RichardsonLucyTV algo = new RichardsonLucyTV(10, 0.1);
- private RichardsonLucyTV algo = new RichardsonLucyTV(10, 0.1);
-
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
- reg = new RegularizationPanel(params[1]);
+ reg = new RegularizationPanel(params[1]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
- pn.place(1, 2, spnIter);
- pn.place(2, 0, 3, 1, reg);
+ pn.place(1, 2, spnIter);
+ pn.place(2, 0, 3, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
return pn;
}
-
+
@Override
public String getCommand() {
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(lambda);
}
-
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
-
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
index 8e82648..19dce0f 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
@@ -1,84 +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 deconvolution.algorithm;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.JTextField;
-import lab.component.GridPanel;
import deconvolution.Command;
import deconvolutionlab.Config;
+import lab.component.GridPanel;
public class SimulationPanel extends AbstractAlgorithmPanel implements KeyListener {
-
+
private JTextField txtMean;
private JTextField txtStdev;
private JTextField txtPoisson;
- private Simulation algo = new Simulation(0, 0, 0);
-
+ private Simulation algo = new Simulation(0, 0, 0);
+
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
- txtMean = new JTextField(""+ params[0], 5);
- txtStdev = new JTextField(""+ params[1], 5);
- txtPoisson = new JTextField(""+ params[2], 5);
-
+ txtMean = new JTextField("" + params[0], 5);
+ txtStdev = new JTextField("" + params[1], 5);
+ txtPoisson = new JTextField("" + params[2], 5);
+
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html>Gaussian (Mean)</html>");
pn.place(1, 2, txtMean);
pn.place(2, 0, "<html>Gaussian (Stdev)</html>");
pn.place(2, 2, txtStdev);
pn.place(3, 0, "<html>Poisson</html>");
pn.place(3, 2, txtPoisson);
txtMean.addKeyListener(this);
txtStdev.addKeyListener(this);
txtPoisson.addKeyListener(this);
Config.register("Algorithm." + algo.getShortname(), "gaussian.mean", txtMean, params[0]);
Config.register("Algorithm." + algo.getShortname(), "gaussian.stdev", txtStdev, params[1]);
Config.register("Algorithm." + algo.getShortname(), "poisson", txtPoisson, params[2]);
return pn;
}
-
+
@Override
public String getCommand() {
- return txtMean.getText() + " " + txtStdev.getText() + " " + txtPoisson.getText();
+ return txtMean.getText() + " " + txtStdev.getText() + " " + txtPoisson.getText();
}
@Override
- public void keyTyped(KeyEvent e) {
- Command.command();
- }
+ public void keyTyped(KeyEvent e) {
+ Command.command();
+ }
@Override
- public void keyPressed(KeyEvent e) {
- Command.command();
- }
+ public void keyPressed(KeyEvent e) {
+ Command.command();
+ }
@Override
- public void keyReleased(KeyEvent e) {
- Command.command();
- }
+ public void keyReleased(KeyEvent e) {
+ Command.command();
+ }
-
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
- String s = "";
+ String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm is only used for simulation. It convolves the input image with the PSF and adds some noise.</p>";
return s;
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
index 117ef36..62179db 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
@@ -1,113 +1,142 @@
+/*
+ * 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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
-public class TikhonovMillerPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
+public class TikhonovMillerPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
- private RegularizationPanel reg;
+ private RegularizationPanel reg;
+
+ private TikhonovMiller algo = new TikhonovMiller(10, 1, 0.1);
- private TikhonovMiller algo = new TikhonovMiller(10, 1, 0.1);
-
@Override
public JPanel getPanelParameters() {
- double[] params = algo.getDefaultParameters();
+ double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
-
+
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
-
@Override
public String getCommand() {
double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
- }
-
+ }
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
-
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
index fa85274..ff6c72d 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
@@ -1,92 +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.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.RegularizationPanel;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
public class TikhonovRegularizationInverseFilterPanel extends AbstractAlgorithmPanel implements ActionListener, ChangeListener, KeyListener {
-
- private RegularizationPanel reg;
- private TikhonovRegularizationInverseFilter algo = new TikhonovRegularizationInverseFilter(0.1);
-
+
+ private RegularizationPanel reg;
+ private TikhonovRegularizationInverseFilter algo = new TikhonovRegularizationInverseFilter(0.1);
+
@Override
public JPanel getPanelParameters() {
- double[] params = algo.getDefaultParameters();
+ double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
-
+
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
-
+
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
-
+
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
- }
+ }
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
index ec2ff25..996b573 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
@@ -1,75 +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 deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolutionlab.Config;
+import deconvolutionlab.Constants;
import lab.component.GridPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
-import deconvolution.Command;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
public class VanCittertPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
- private VanCittert algo = new VanCittert(10, 1);
-
+ private VanCittert algo = new VanCittert(10, 1);
+
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
-
+
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
-
+
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
- double gamma = spnStep.get();
+ double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
- }
-
+ }
+
@Override
public String getName() {
return algo.getName();
}
@Override
public String getShortname() {
return algo.getShortname();
}
-
+
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Constants.java b/DeconvolutionLab2/src/deconvolutionlab/Constants.java
index faf23f5..97dc944 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Constants.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Constants.java
@@ -1,65 +1,65 @@
/*
* 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.Dimension;
public class Constants {
- public static String name = "DeconvolutionLab2";
+ public static String name = "DeconvolutionLab2 [Beta 1]";
public static String copyright = "\u00A9 2010-2017. Biomedical Imaging Group, EPFL.";
public static String url = "http://bigwww.epfl.ch/deconvolution/";
public static String reference =
"D. Sage, L. Donati, F. Soulez, D. Fortun, A. Seitz, R. Guiet, C. Vonesch, M Unser " +
"DeconvolutionLab2 : An open-source software for deconvolution microscopy " +
"Methods, 2017.";
public static String version = "(Beta 24.01.2017)";
public static String authors =
"Daniel Sage, " +
"Cédric Vonesch, " +
"Guillaume Schmit, " +
"Pierre Besson, " +
"Raquel Terrés Cristofani, " +
"Alessandra Griffa";
public static String help =
"<h1>" + name + "</h1>" +
"<h2>" + version + "</h2>";
public static int widthGUI = 500;
public static Dimension dimParameters = new Dimension(88, 25);
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java b/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java
index 185d73b..cd5d8c9 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabImageSelector.java
@@ -1,140 +1,147 @@
package deconvolutionlab;
-import ij.ImagePlus;
-import ij.WindowManager;
-import ij.gui.GUI;
-
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
+import ij.ImagePlus;
+import ij.WindowManager;
+import ij.gui.GUI;
+
public class LabImageSelector extends PlatformImageSelector {
@Override
public boolean isSelectable() {
return true;
}
@Override
public String getSelectedImage() {
Dialog dialog = new Dialog();
dialog.setVisible(true);
if (dialog.wasCancel())
return "";
return dialog.getName();
}
public class Dialog extends JDialog implements ActionListener, WindowListener {
private JList<String> list;
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String name = "";
public Dialog() {
super(new JFrame(), "Image Selection");
+
+ JPanel bn = new JPanel(new GridLayout(1, 2));
+ bn.add(bnCancel);
+ bn.add(bnOK);
+
+ JPanel panel = new JPanel(new BorderLayout());
int[] ids = WindowManager.getIDList();
- DefaultListModel listModel = new DefaultListModel();
- if (list != null)
+
+ if (ids != null) {
+ DefaultListModel listModel = new DefaultListModel();
+ list = new JList(listModel);
for (int id : ids) {
ImagePlus idp = WindowManager.getImage(id);
if (idp != null) {
((DefaultListModel) listModel).addElement(idp.getTitle());
}
}
-
- list = new JList(listModel);
- list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- JScrollPane listScroller = new JScrollPane(list);
- listScroller.setPreferredSize(new Dimension(250, 80));
- JPanel bn = new JPanel(new GridLayout(1, 2));
- bn.add(bnCancel);
- bn.add(bnOK);
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(listScroller, BorderLayout.CENTER);
+ list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ JScrollPane listScroller = new JScrollPane(list);
+ listScroller.setPreferredSize(new Dimension(250, 80));
+ panel.add(listScroller, BorderLayout.CENTER);
+ }
+ else {
+ panel.add(new JLabel("No open images."));
+ }
panel.add(bn, BorderLayout.SOUTH);
- panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
@Override
public void actionPerformed(ActionEvent e) {
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
if (e.getSource() == bnCancel) {
cancel = true;
name = "";
dispose();
return;
}
else if (e.getSource() == bnOK) {
cancel = false;
name = (String) list.getSelectedValue();
dispose();
}
}
public String getName() {
return name;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
name = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index 3b662a2..41e5c88 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,311 +1,335 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
+import deconvolution.algorithm.Controller;
+import deconvolutionlab.monitor.Monitors;
import lab.tools.NumFormat;
import signal.Constraint;
import signal.RealSignal;
-import deconvolution.algorithm.Controller;
-import deconvolutionlab.monitor.Monitors;
public class Output {
public enum View {
STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE
};
public enum Dynamic {
INTACT, RESCALED, NORMALIZED, CLIPPED
};
private int px = 0;
private int py = 0;
private int pz = 0;
private boolean center = true;
private String name = "";
private boolean save = true;
private boolean show = true;
private View view = View.STACK;
private PlatformImager.Type type = PlatformImager.Type.FLOAT;
private Dynamic dynamic = Dynamic.INTACT;
private int frequency = 0;
- private String path = "";
-
+ private String path = "";
+
public Output(View view, int frequency, String param) {
String[] tokens = param.trim().split(" ");
this.view = view;
this.frequency = frequency;
this.name = "";
this.center = true;
this.save = true;
this.show = true;
for (int i = 0; i < tokens.length; i++) {
boolean found = false;
String p = tokens[i].trim().toLowerCase();
if (p.startsWith("@")) {
found = true;
}
if (p.startsWith("noshow")) {
show = false;
found = true;
}
if (p.startsWith("nosave")) {
save = false;
found = true;
}
for (Dynamic d : Dynamic.values()) {
if (p.toLowerCase().equals(d.name().toLowerCase())) {
dynamic = d;
found = true;
}
}
for (View v : View.values()) {
if (p.toLowerCase().equals(v.name().toLowerCase())) {
view = v;
found = true;
}
}
for (PlatformImager.Type t : PlatformImager.Type.values()) {
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]);
+ 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] + " ";
+ if (!found)
+ name += tokens[i] + " ";
name = name.trim();
}
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, PlatformImager.Type type, boolean center) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = center;
this.frequency = frequency;
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, PlatformImager.Type type, int px, int py, int pz) {
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;
+ if (frequency == 0)
+ return false;
return iterations % frequency == 0;
}
public View getView() {
return view;
}
public String getName() {
return name;
}
-
+
public void setPath1(String path) {
this.path = path;
}
public int extractFrequency(String param) {
String line = param.trim();
- if (!line.startsWith("@")) line = "@0 " + line;
+ if (!line.startsWith("@"))
+ line = "@0 " + line;
String parts[] = line.split(" ");
if (parts.length >= 1) {
return (int) Math.round(NumFormat.parseNumber(parts[0], 0));
}
return 0;
}
public void setKeypoint(int px, int py, int pz) {
this.px = px;
this.py = py;
this.pz = pz;
this.center = false;
}
public String[] getAsString() {
String t = (type == PlatformImager.Type.FLOAT ? "" : type.name().toLowerCase());
String 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, "" };
}
-
public void execute(Monitors monitors, RealSignal signal, Controller controller, boolean live) {
- if (signal == null) return;
+ if (signal == null)
+ return;
String title = name;
if (controller != null && live) {
if (controller.getIterations() > 0) {
title += "@" + controller.getIterations();
}
}
RealSignal x = null;
Constraint constraint = new Constraint(monitors);
switch (dynamic) {
case RESCALED:
x = signal.duplicate();
constraint.rescaled(x, 0, 255);
break;
case CLIPPED:
x = signal.duplicate();
float[] stats = controller.getStatsInput();
- if (stats != null) constraint.clipped(x, stats[1], stats[2]);
+ if (stats != null)
+ constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
float[] stats1 = controller.getStatsInput();
- if (stats1 != null) constraint.normalized(x, stats1[0], stats1[3]);
+ if (stats1 != null)
+ constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
String filename = path + File.separator + title + ".tif";
String key = name + "-" + type.name() + "-" + view.name() + "-" + dynamic.name() + "-" + (px + py + pz);
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);
+ 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);
+ if (show && !live)
+ Lab.show(monitors, slice, title, type);
+ if (save && !live)
+ Lab.save(monitors, slice, filename, type);
}
break;
case ORTHO:
orthoview(monitors, x, title, filename, live, key);
break;
case FIGURE:
figure(monitors, x, title, filename, live, key);
break;
case MIP:
mip(monitors, x, title, filename, live, key);
break;
case PLANAR:
planar(monitors, x, title, filename, live, key);
break;
default:
break;
}
}
private void mip(Monitors monitors, RealSignal signal, String title, String filename, boolean live, String key) {
RealSignal plane = signal.createMIP();
- if (show && live) Lab.appendShowLive(monitors, key, plane, title, type);
- if (show && !live) Lab.show(monitors, plane, title, type);
- if (save) Lab.save(monitors, plane, filename, type);
+ if (show && live)
+ Lab.appendShowLive(monitors, key, 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, String key) {
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) Lab.appendShowLive(monitors, key, plane, title, type);
- if (show && !live) Lab.show(monitors, plane, title, type);
- if (save) Lab.save(monitors, plane, filename, type);
+ if (show && live)
+ Lab.appendShowLive(monitors, key, 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, String key) {
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) Lab.appendShowLive(monitors, key, plane, title, type);
- if (show && !live) Lab.show(monitors, plane, title, type);
- if (save) Lab.save(monitors, plane, filename, type);
+ if (show && live)
+ Lab.appendShowLive(monitors, key, 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, String key) {
RealSignal plane = signal.createMontage();
- if (show && live) Lab.appendShowLive(monitors, key, plane, title, type);
- if (show && !live) Lab.show(monitors, plane, title, type);
- if (save) Lab.save(monitors, plane, filename, type);
+ if (show && live)
+ Lab.appendShowLive(monitors, key, plane, title, type);
+ if (show && !live)
+ Lab.show(monitors, plane, title, type);
+ if (save)
+ Lab.save(monitors, plane, filename, type);
}
@Override
public String toString() {
String t = type.name().toLowerCase();
String v = view.name().toLowerCase();
String d = dynamic.name().toLowerCase();
String f = frequency > 0 ? " every " + frequency + " iterations" : "";
String k = (center ? "" : " keypoint = (" + px + "," + py + "," + pz + ")");
return v + " " + name + " format = (" + d + ", " + t + ") " + k + f;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java b/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
index 884d38b..65a34a8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/OutputCollection.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 deconvolutionlab;
import java.util.ArrayList;
-import signal.RealSignal;
import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.Monitors;
+import signal.RealSignal;
public class OutputCollection {
-
+
private ArrayList<Output> list = new ArrayList<Output>();
-
+
public void setPath(String path) {
- for(Output out : list)
+ for (Output out : list)
out.setPath1(path);
}
-
+
public void add(Output out) {
if (out != null) {
list.add(out);
}
}
-
+
public boolean hasShow(int iterations) {
boolean flag = false;
for (Output out : list)
flag = flag | out.is(iterations);
return flag;
}
-
+
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
- for(Output out : list)
+ for (Output out : list)
if (out != null)
out.execute(monitors, signal, controller, false);
}
-
+
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller) {
- for(Output out : list)
+ for (Output out : list)
if (out != null)
out.execute(monitors, signal, controller, true);
}
public ArrayList<String> getInformation() {
ArrayList<String> lines = new ArrayList<String>();
for (Output out : list) {
if (out == null)
lines.add("ERR>" + list.size());
else
lines.add("" + out.toString());
}
return lines;
}
-
+
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Platform.java b/DeconvolutionLab2/src/deconvolutionlab/Platform.java
index 45dec63..52df21f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Platform.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Platform.java
@@ -1,76 +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 deconvolutionlab;
-import imagej.IJImager;
-
import java.util.ArrayList;
+import imagej.IJImager;
import plugins.sage.deconvolutionlab.IcyImager;
-import deconvolutionlab.monitor.Monitors;
public enum Platform {
-
+
IMAGEJ, ICY, STANDALONE, MATLAB;
-
+
public static ArrayList<PlatformImager> getImagers() {
ArrayList<PlatformImager> imagers = new ArrayList<PlatformImager>();
try {
PlatformImager imager = new IJImager();
if (imager != null) {
imagers.add(imager);
}
}
- catch(NoClassDefFoundError ex) {
+ catch (NoClassDefFoundError ex) {
}
try {
PlatformImager imager = new IcyImager();
if (imager != null) {
imagers.add(imager);
}
}
- catch(NoClassDefFoundError ex) {
+ catch (NoClassDefFoundError ex) {
}
-
+
imagers.add(new LabImager());
return imagers;
}
-
+
public static ArrayList<String> getNameImagers() {
ArrayList<PlatformImager> imagers = getImagers();
ArrayList<String> names = new ArrayList<String>();
- for(PlatformImager imager : imagers)
+ for (PlatformImager imager : imagers)
names.add(imager.getName());
return names;
}
};
diff --git a/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java b/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java
index d8a746d..279a9de 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/PlatformImageSelector.java
@@ -1,7 +1,39 @@
+/*
+ * 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;
public abstract class PlatformImageSelector {
-
+
public abstract String getSelectedImage();
+
public abstract boolean isSelectable();
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
index b5f8e74..ad5bec2 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
@@ -1,158 +1,156 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
-import ij.gui.GUI;
-
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 lab.component.GridPanel;
-import lab.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.modules.BatchModule;
+import ij.gui.GUI;
+import lab.component.GridPanel;
+import lab.component.HTMLPane;
public class BatchDialog extends JDialog implements ActionListener, WindowListener {
- private JTextField txt = new JTextField("job", 10);
+ private JTextField txt = new JTextField("job", 10);
private HTMLPane pnCommand;
- private JButton bnAdd = new JButton("Add Job");
- private JButton bnCancel = new JButton("Cancel");
+ private JButton bnAdd = new JButton("Add Job");
+ private JButton bnCancel = new JButton("Cancel");
private BatchModule module;
public BatchDialog(BatchModule module) {
super(new JFrame(), "Batch");
-
+
this.module = module;
-
+
txt.setText("job" + module.getCountJob());
-
+
Deconvolution deconvolution = new Deconvolution(Command.command());
pnCommand = new HTMLPane("Monaco", 300, 100);
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();
+ pack();
addWindowListener(this);
GUI.center(this);
setModal(true);
setVisible(true);
setMinimumSize(new Dimension(400, 300));
-
+
}
private void addJob() {
module.addJob(txt.getText(), pnCommand.getText());
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnAdd) {
addJob();
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
return;
}
else if (e.getSource() == bnCancel) {
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
addJob();
dispose();
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
-
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/MainDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
similarity index 91%
rename from DeconvolutionLab2/src/deconvolutionlab/dialog/MainDialog.java
rename to DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
index 833b3bc..2652188 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/MainDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
@@ -1,384 +1,365 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
-import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.JProgressBar;
import javax.swing.JTabbedPane;
-import javax.swing.JTextField;
-import javax.swing.JToolBar;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import lab.component.PanelImage;
-import lab.system.SystemPanel;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
import deconvolutionlab.modules.MonitoringModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
-import deconvolutionlab.monitor.AbstractMonitor;
-import deconvolutionlab.monitor.StatusMonitor;
+import lab.component.PanelImage;
+import lab.system.SystemPanel;
-public class MainDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
+public class LabDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnClose = new JButton("Close");
private JButton bnQuit = new JButton("Quit");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnSystem = new JButton("System");
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
private MonitoringModule monitoring;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelProgra;
private GroupedModulePanel panelAbout;
- //private JProgressBar status = new JProgressBar();
-
private AbstractModule modules[];
- public MainDialog() {
+ public LabDialog() {
super(new JFrame(), Constants.name);
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
monitoring = new MonitoringModule(false);
doDialog();
modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, monitoring };
Command.active(modules, command, language);
Command.command();
addWindowListener(this);
addComponentListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
- setMinimumSize(new Dimension(400, 400));
+ setMinimumSize(new Dimension(500, 500));
Config.registerFrame("DeconvolutionLab", "MainDialog", this);
pack();
setVisible(true);
Config.load();
sizeModule();
Command.command();
image.update();
psf.update();
output.update();
}
private void doDialog() {
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelProgra = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
PanelImage bottom = new PanelImage("celegans.jpg");
bottom.setLayout(new GridLayout(1, 7));
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
bottom.setBorder(b2);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnQuit);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
- /*
- status.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- status.setBorder(BorderFactory.createLoweredBevelBorder());
- JToolBar statusBar = new JToolBar();
- statusBar.setBorder(BorderFactory.createEmptyBorder());
- statusBar.setFloatable(false);
- statusBar.setLayout(new BorderLayout());
- statusBar.add(bnHelp, BorderLayout.WEST);
- statusBar.add(status, BorderLayout.CENTER);
- statusBar.add(bnQuit, BorderLayout.EAST);
- */
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Programming", panelProgra);
tab.add("About", panelAbout);
tab.addChangeListener(this);
JPanel base = new JPanel(new BorderLayout());
base.add(bottom, BorderLayout.CENTER);
//base.add(statusBar, BorderLayout.SOUTH);
add(tab, BorderLayout.CENTER);
add(base, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnHelp.addActionListener(this);
bnQuit.addActionListener(this);
bnSystem.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp) {
Lab.help();
}
else if (e.getSource() == bnSystem) {
SystemPanel.show(400, 400);
}
else if (e.getSource() == bnClose) {
Config.store();
close();
dispose();
}
else if (e.getSource() == bnQuit) {
close();
dispose();
}
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
new BatchDialog(batch);
}
else if (e.getSource() == bnLaunch) {
- new Deconvolution(Command.command()).launch("");
+ new Deconvolution(Command.command()).launch("", false);
}
else if (e.getSource() == bnRun) {
- new Deconvolution(Command.command()).deconvolve();
+ new Deconvolution(Command.command()).deconvolve(false);
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
list.add(monitoring);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
list.add(border);
list.add(fourier);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(command);
list.add(language);
list.add(batch);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
Config.store();
close();
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
private void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
bnQuit.removeActionListener(this);
removeWindowListener(this);
}
@Override
public void dispose() {
super.dispose();
if (Lab.getPlatform() == Platform.STANDALONE) System.exit(0);
}
@Override
public void componentResized(ComponentEvent e) {
sizeModule();
}
@Override
public void componentMoved(ComponentEvent e) {
}
@Override
public void componentShown(ComponentEvent e) {
sizeModule();
}
@Override
public void componentHidden(ComponentEvent e) {
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0) sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1) sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2) sizePanel(panelProgra);
if (tab.getSelectedIndex() == 3) sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 60;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 17bf32d..73a8615 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,236 +1,235 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
-import ij.gui.GUI;
-
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeInteger;
import deconvolutionlab.Output;
-import deconvolutionlab.PlatformImager;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
+import deconvolutionlab.PlatformImager;
+import ij.gui.GUI;
+import lab.component.GridPanel;
+import lab.component.SpinnerRangeInteger;
public class OutputDialog extends JDialog implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Snapshot");
private Output out;
private View view;
private GridPanel pnOrtho;
public OutputDialog(View view) {
super(new JFrame(), "Output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
GridPanel pn = new GridPanel(view.name());
pn.place(0, 0, "Name");
pn.place(0, 1, 2, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(2, 2, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(5, 2, lblIter);
}
pn.place(6, 0, 3, 1, chkShow);
pn.place(7, 0, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(7, 0, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
pack();
GUI.center(this);
setModal(true);
setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
dispose();
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
PlatformImager.Type type = PlatformImager.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
dispose();
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
index cbd334e..a936e05 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
@@ -1,227 +1,226 @@
/*
* 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 ij.gui.GUI;
-
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import ij.gui.GUI;
import lab.component.GridPanel;
public class PatternDialog extends JDialog implements ActionListener, WindowListener, KeyListener {
- private JTextField txt = new JTextField("");
- private JLabel lblDir = new JLabel("");
- private JLabel lbl1 = new JLabel(".tif (only tif files)");
- private JLabel lbl2 = new JLabel("Empty to take all files");
- private JLabel lblCount = new JLabel("count files");
+ private JTextField txt = new JTextField("");
+ private JLabel lblDir = new JLabel("");
+ private JLabel lbl1 = new JLabel(".tif (only tif files)");
+ private JLabel lbl2 = new JLabel("Empty to take all files");
+ private JLabel lblCount = new JLabel("count files");
- private JButton bnCount = new JButton("Count");
- private JButton bnOK = new JButton("OK");
- private JButton bnCancel = new JButton("Cancel");
- private boolean cancel = false;
+ private JButton bnCount = new JButton("Count");
+ private JButton bnOK = new JButton("OK");
+ private JButton bnCancel = new JButton("Cancel");
+ private boolean cancel = false;
- private File file;
- private String command = "";
- private String name = "";
+ private File file;
+ private String command = "";
+ private String name = "";
public PatternDialog(File file) {
super(new JFrame(), "Pattern");
lblDir.setText(file.getAbsolutePath());
lblDir.setBorder(BorderFactory.createEtchedBorder());
lbl1.setBorder(BorderFactory.createEtchedBorder());
lbl2.setBorder(BorderFactory.createEtchedBorder());
lblCount.setBorder(BorderFactory.createEtchedBorder());
this.file = file;
GridPanel pn = new GridPanel(true, 5);
pn.place(0, 0, "Directory");
pn.place(0, 1, lblDir);
pn.place(1, 0, "Pattern");
pn.place(1, 1, txt);
pn.place(2, 0, "Example 1");
pn.place(2, 1, lbl1);
pn.place(3, 0, "Example 2");
pn.place(3, 1, lbl2);
pn.place(4, 0, "Count");
pn.place(4, 1, lblCount);
GridPanel bn = new GridPanel(false);
bn.place(11, 0, bnCancel);
bn.place(11, 1, bnCount);
bn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnCount.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
txt.addKeyListener(this);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.CENTER);
panel.add(bn, BorderLayout.SOUTH);
add(panel);
pack();
update();
-
+
addWindowListener(this);
GUI.center(this);
setModal(true);
-
+
}
private void update() {
command = "";
name = "";
if (file == null)
return;
if (!file.exists())
return;
if (!file.isDirectory())
return;
String list[] = file.list();
int count = 0;
int n = list.length;
String regex = txt.getText().trim();
Pattern pattern = Pattern.compile(regex);
for (int i = 0; i < n; i++)
if (pattern.matcher(list[i]).find())
count++;
if (!regex.trim().equals(""))
- command = file.getAbsolutePath() + " pattern " + regex;
- else
+ command = file.getAbsolutePath() + " pattern " + regex;
+ else
command = file.getAbsolutePath();
name = file.getName();
lblCount.setText("" + n + " files in dir, " + count + " matched files");
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnCount) {
update();
}
else if (e.getSource() == bnCancel) {
bnCount.removeActionListener(this);
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
txt.removeKeyListener(this);
dispose();
cancel = true;
command = "";
name = "";
-
+
return;
}
else if (e.getSource() == bnOK) {
update();
bnCount.removeActionListener(this);
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
txt.removeKeyListener(this);
dispose();
cancel = false;
}
}
public String getCommand() {
return command;
}
-
+
public String getDirName() {
return name;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
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) {
}
@Override
- public void keyTyped(KeyEvent e) {
- }
+ public void keyTyped(KeyEvent e) {
+ }
@Override
- public void keyPressed(KeyEvent e) {
- }
+ public void keyPressed(KeyEvent e) {
+ }
@Override
- public void keyReleased(KeyEvent e) {
- update();
- }
+ public void keyReleased(KeyEvent e) {
+ update();
+ }
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
index 06f86b1..bf68e73 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
@@ -1,313 +1,312 @@
/*
* 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 ij.gui.GUI;
-
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
+import ij.gui.GUI;
import lab.component.GridPanel;
import lab.component.SpinnerRangeDouble;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class SyntheticDialog extends JDialog implements ActionListener, WindowListener {
private SpinnerRangeDouble spnSignal = new SpinnerRangeDouble(100, -999999, 999999, 1);
private SpinnerRangeDouble spnBackground = new SpinnerRangeDouble(0, -999999, 999999, 1);
private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(32, 1, 9999, 1);
private SpinnerRangeDouble spnCenterX = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterY = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterZ = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnParameter1 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter2 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter3 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private JLabel lbl1 = new JLabel("Parameters 1 of the shape");
private JLabel lbl2 = new JLabel("Parameters 2 of the shape");
private JLabel lbl3 = new JLabel("Parameters 3 of the shape");
private JComboBox<String> cmbShapes;
private JButton bnShow = new JButton("Show");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String shape;
private String command;
public SyntheticDialog(ArrayList<SignalFactory> list) {
super(new JFrame(), "Synthetic");
String[] cmb = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
cmb[i] = list.get(i).getName();
}
cmbShapes = new JComboBox<String>(cmb);
-
+
GridPanel pnIntensity = new GridPanel("Intensity", 3);
pnIntensity.place(1, 0, "Signal Intensity");
pnIntensity.place(1, 1, spnSignal);
pnIntensity.place(2, 0, "Background Intensity");
pnIntensity.place(2, 1, spnBackground);
-
+
GridPanel pnSize = new GridPanel("Dimension", 3);
pnSize.place(1, 0, "Width [pixels] (nx)");
pnSize.place(1, 1, spnWidth);
pnSize.place(2, 0, "Height [pixels] (ny)");
pnSize.place(2, 1, spnHeight);
pnSize.place(3, 0, "Number of Slices (nz)");
pnSize.place(3, 1, spnSlices);
GridPanel pnCenter = new GridPanel("Center", 3);
pnCenter.place(4, 0, "Center [% of nx] (cx)");
pnCenter.place(4, 1, spnCenterX);
pnCenter.place(5, 0, "Center [% of ny] (cy)");
pnCenter.place(5, 1, spnCenterY);
pnCenter.place(7, 0, "Center [% of nz] (cz)");
pnCenter.place(7, 1, spnCenterZ);
GridPanel pnParams = new GridPanel("Specific Parameters", 3);
pnParams.place(8, 0, lbl1);
pnParams.place(8, 1, spnParameter1);
pnParams.place(9, 0, lbl2);
pnParams.place(9, 1, spnParameter2);
pnParams.place(10, 0, lbl3);
pnParams.place(10, 1, spnParameter3);
- GridPanel pn = new GridPanel(false);
+ GridPanel pn = new GridPanel(false);
pn.place(0, 0, 3, 1, cmbShapes);
pn.place(1, 0, 3, 1, pnIntensity);
pn.place(2, 0, 3, 1, pnParams);
pn.place(3, 0, 3, 1, pnSize);
pn.place(4, 0, 3, 1, pnCenter);
pn.place(11, 0, bnCancel);
pn.place(11, 1, bnShow);
pn.place(11, 2, bnOK);
-
+
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnShow.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
cmbShapes.addActionListener(this);
add(pn);
pack();
updateInterface();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void updateInterface() {
- SignalFactory factory = SignalFactory.get((String)cmbShapes.getSelectedItem());
+ SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
String labels[] = factory.getParametersName();
lbl1.setVisible(false);
lbl2.setVisible(false);
lbl3.setVisible(false);
if (labels.length >= 1) {
lbl1.setVisible(true);
lbl1.setText(labels[0]);
}
if (labels.length >= 2) {
lbl2.setVisible(true);
lbl2.setText(labels[1]);
}
if (labels.length >= 3) {
lbl3.setVisible(true);
lbl3.setText(labels[2]);
}
double params[] = factory.getParameters();
spnParameter1.setVisible(false);
spnParameter2.setVisible(false);
spnParameter3.setVisible(false);
if (params.length >= 1) {
spnParameter1.setVisible(true);
spnParameter1.set(params[0]);
}
if (params.length >= 2) {
spnParameter2.setVisible(true);
spnParameter2.set(params[1]);
}
if (params.length >= 3) {
spnParameter3.setVisible(true);
spnParameter3.set(params[2]);
}
pack();
-
+
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnShow) {
- SignalFactory factory = SignalFactory.get((String)cmbShapes.getSelectedItem());
+ SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
double params[] = factory.getParameters();
factory.setParameters(params);
factory.center(spnCenterX.get(), spnCenterX.get(), spnCenterX.get());
RealSignal signal = factory.generate(spnWidth.get(), spnWidth.get(), spnWidth.get());
Lab.show(Monitors.createDefaultMonitor(), signal, factory.getName());
}
if (e.getSource() == cmbShapes) {
updateInterface();
}
if (e.getSource() == bnCancel) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
if (e.getSource() == bnOK) {
int nx = spnWidth.get();
int ny = spnHeight.get();
int nz = spnSlices.get();
- shape = (String)cmbShapes.getSelectedItem();
+ shape = (String) cmbShapes.getSelectedItem();
command = shape + " " + spnSignal.get() + " " + spnBackground.get() + " ";
SignalFactory factory = SignalFactory.get(shape);
int n = factory.getParameters().length;
if (n >= 1) {
command += "" + spnParameter1.get();
if (n >= 2)
command += " " + spnParameter2.get();
if (n >= 3)
command += " " + spnParameter3.get();
command += " ";
}
command += " size " + nx + " " + ny + " " + nz + " ";
if (spnCenterX.get() != 0.5 || spnCenterY.get() != 0.5 || spnCenterZ.get() != 0.5) {
double cx = Math.round(spnCenterX.get() * 1000000) / 1000000.0;
double cy = Math.round(spnCenterY.get() * 1000000) / 1000000.0;
double cz = Math.round(spnCenterZ.get() * 1000000) / 1000000.0;
- command += " center " + cx + " " + cy + " " + cz + " ";
+ command += " center " + cx + " " + cy + " " + cz + " ";
}
dispose();
cancel = false;
}
}
public void setParameters(String name, String parameters) {
double params[] = NumFormat.parseNumbers(parameters);
cmbShapes.setSelectedItem(name);
SignalFactory factory = SignalFactory.getFactoryByName(name);
if (factory == null)
return;
int np = factory.getParameters().length;
if (params.length > 0)
spnSignal.set(params[0]);
if (params.length > 1)
spnBackground.set(params[1]);
- if (params.length > 2+np)
- spnWidth.set((int)params[2+np]);
- if (params.length > 3+np)
- spnHeight.set((int)params[3+np]);
- if (params.length > 4+np)
- spnSlices.set((int)params[4+np]);
- if (params.length > 5+np)
- spnCenterX.set(params[5+np]);
- if (params.length > 6+np)
- spnCenterY.set(params[6+np]);
- if (params.length > 7+np)
- spnCenterZ.set(params[7+np]);
-
- if (np >= 1 && params.length > 2+np)
+ 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)
+ if (np >= 2 && params.length > 3 + np)
spnParameter2.set(params[3]);
- if (np >= 3 && params.length > 4+np)
+ if (np >= 3 && params.length > 4 + np)
spnParameter3.set(params[4]);
}
-
+
public String getShapeName() {
return shape;
}
public String getCommand() {
return command;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
index 5793445..ca832f1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
@@ -1,78 +1,78 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
import lab.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
public class AboutModule extends AbstractModule {
public AboutModule(boolean expanded) {
super("About", "", "Help", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
-
+
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p", Constants.copyright);
html.append("p", "<b>Reference:</b> " + Constants.reference);
html.append("h3", "<b>Authors:</b> " + Constants.authors);
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
return panel;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (getAction1Button() == e.getSource())
Lab.help();
}
-
+
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
index a70fa0f..7fc18a6 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
@@ -1,219 +1,221 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public abstract class AbstractModule extends JPanel implements ActionListener {
private JButton bnTitle;
private JButton bnSynopsis;
- private JButton bnAction1 = new JButton();
- private JButton bnAction2 = new JButton();
+ private JButton bnAction1 = new JButton();
+ private JButton bnAction2 = new JButton();
private JLabel lblCommand;
private JButton bnExpand;
private CardLayout card = new CardLayout();
private JPanel space = new JPanel(card);
private boolean expanded = false;
private GroupedModulePanel mpns;
private JPanel pnExpanded;
private JPanel pnCollapsed;
private String name;
private String key;
public AbstractModule(String name, String key, String action1, String action2, boolean expanded) {
this.name = name;
this.key = key;
pnCollapsed = buildCollapsedPanel();
pnExpanded = buildExpandedPanel();
setLayout(new BorderLayout());
this.expanded = expanded;
bnTitle = new JButton("<html><b>" + name + "</b></html>");
bnTitle.setHorizontalAlignment(SwingConstants.LEFT);
- bnTitle.setPreferredSize(new Dimension(180, 20));
+ bnTitle.setPreferredSize(new Dimension(160, 20));
bnTitle.setMaximumSize(new Dimension(250, 20));
bnTitle.setMinimumSize(new Dimension(120, 20));
bnTitle.addActionListener(this);
bnSynopsis = new JButton("");
bnSynopsis.setHorizontalAlignment(SwingConstants.LEFT);
bnSynopsis.setPreferredSize(new Dimension(200, 20));
bnSynopsis.addActionListener(this);
bnExpand = new JButton("\u25BA");
bnExpand.setPreferredSize(new Dimension(40, 20));
bnExpand.setMaximumSize(new Dimension(40, 20));
bnExpand.setMinimumSize(new Dimension(40, 20));
bnExpand.addActionListener(this);
JPanel tool0 = new JPanel(new BorderLayout());
JPanel tool1 = new JPanel(new BorderLayout());
tool1.add(bnExpand, BorderLayout.WEST);
tool1.add(bnTitle, BorderLayout.EAST);
tool0.add(tool1, BorderLayout.WEST);
tool0.add(bnSynopsis, BorderLayout.CENTER);
JPanel toola = null;
if (!action1.equals("")) {
bnAction1.setText(action1);
bnAction1.setPreferredSize(new Dimension(50, 20));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction1, BorderLayout.WEST);
}
if (!action2.equals("")) {
bnAction2.setText(action2);
bnAction2.setPreferredSize(new Dimension(50, 20));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction2, BorderLayout.EAST);
}
- if (toola != null)
+ if (toola != null)
tool0.add(toola, BorderLayout.EAST);
-
+
space.add(pnExpanded, "expand");
space.add(pnCollapsed, "collapse");
add(tool0, BorderLayout.NORTH);
add(space, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (expanded)
expand();
else
collapse();
setPreferredSize(pnCollapsed.getPreferredSize());
}
public JPanel buildCollapsedPanel() {
JPanel panel = new JPanel(new BorderLayout());
lblCommand = new JLabel("");
lblCommand.setBorder(BorderFactory.createEtchedBorder());
lblCommand.setHorizontalAlignment(SwingConstants.LEFT);
lblCommand.setPreferredSize(new Dimension(500, 30));
panel.add(lblCommand, BorderLayout.NORTH);
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/modules/AlgorithmModule.java
index 9b83f24..4e2162e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
@@ -1,143 +1,143 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import lab.component.HTMLPane;
import deconvolution.Command;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
public AlgorithmModule(boolean expanded) {
super("Algorithm", "-algorithm", "", "", expanded);
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : panels)
cmb.addItem(panel.getName());
cmb.addActionListener(this);
}
@Override
public String getCommand() {
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
String cmd = "-algorithm " + algo.getShortname() + " " + algo.getCommand();
String synopsis = name;
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmb = new JComboBox<String>();
JPanel pnc = new JPanel();
pnc.add(cmb);
doc = new HTMLPane(100, 1000);
cards = new JPanel(new CardLayout());
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
- for (AbstractAlgorithmPanel panel : panels) {
+ for (AbstractAlgorithmPanel panel : panels) {
JScrollPane scroll = new JScrollPane(panel.getPanelParameters());
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cards.add(panel.getName(), scroll);
}
cmb.setMaximumRowCount(panels.size());
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
control.add(cmb);
control.add(cards);
-
+
doc.append("h1", "Documentation");
-
+
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.NORTH);
panel.add(doc.getPane(), BorderLayout.CENTER);
- //cmb.addActionListener(this);
+ // cmb.addActionListener(this);
Config.register(getName(), "algorithm", cmb, Algorithm.getDefaultAlgorithm());
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb) {
doc.clear();
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
doc.append(algo.getDocumentation());
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, name);
}
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
index f366b99..7e08089 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
@@ -1,190 +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 deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
- private JButton bnScript;
- private JButton bnRunAll;
- private JButton bnRunJob;
- private JButton bnLaunchAll;
- private JButton bnLaunchJob;
+ private JButton bnScript;
+ private JButton bnRunAll;
+ private JButton bnRunJob;
+ private JButton bnLaunchAll;
+ private JButton bnLaunchJob;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
-
- bnScript = new JButton("Create Script (not yet implemented)");
- bnRunAll = new JButton("Run All Jobs");
- bnRunJob = new JButton("Run Selected Jobs");
- bnLaunchAll = new JButton("Launch All Jobs");
- bnLaunchJob = new JButton("Launch Selected Jobs");
+ bnScript = new JButton("Create Script (not yet implemented)");
+ bnRunAll = new JButton("Run All Jobs");
+ bnRunJob = new JButton("Run Selected Jobs");
+ bnLaunchAll = new JButton("Launch All Jobs");
+ bnLaunchJob = new JButton("Launch Selected Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
+
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnScript);
pn.add(bnRunAll);
pn.add(bnRunJob);
pn.add(bnLaunchAll);
pn.add(bnLaunchJob);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
-
+
bnScript.addActionListener(this);
bnRunAll.addActionListener(this);
bnRunJob.addActionListener(this);
bnLaunchAll.addActionListener(this);
bnLaunchJob.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnRunJob) {
int rows[] = table.getSelectedRows();
- for(int row : rows) {
- new Deconvolution(table.getCell(row, 1)).deconvolve();
- }
+ for (int row : rows) {
+ new Deconvolution(table.getCell(row, 1)).deconvolve(false);
+ }
}
else if (e.getSource() == bnLaunchJob) {
int rows[] = table.getSelectedRows();
- for(int row : rows) {
- new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0));
- }
+ for (int row : rows) {
+ new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0), false);
+ }
}
else if (e.getSource() == bnRunAll) {
- for(int row=0; row<table.getRowCount(); row++) {
- new Deconvolution(table.getCell(row, 1)).deconvolve();
- }
+ for (int row = 0; row < table.getRowCount(); row++) {
+ new Deconvolution(table.getCell(row, 1)).deconvolve(false);
+ }
}
else if (e.getSource() == bnLaunchAll) {
- for(int row=0; row<table.getRowCount(); row++) {
- new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0));
- }
+ for (int row = 0; row < table.getRowCount(); row++) {
+ new Deconvolution(table.getCell(row, 1)).launch(table.getCell(row, 0), false);
+ }
}
-
}
-
+
private void update() {
setSynopsis("" + table.getRowCount() + " jobs");
}
public int getCountJob() {
return table.getRowCount();
}
public void addJob(String name, String command) {
table.append(new String[] { name, command, "" });
update();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 2) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
}
update();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
index ad7b25c..18bf0ac 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
@@ -1,304 +1,304 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolution.Deconvolution;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.HTMLPane;
import lab.component.SpinnerRangeInteger;
import lab.tools.NumFormat;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
-import deconvolution.Command;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Config;
public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbNormalization;
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
private HTMLPane info;
private boolean build = false;
public BorderModule(boolean expanded) {
super("Border", "", "Test", "Default", expanded);
}
@Override
public String getCommand() {
AbstractPadding pxy = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding paz = Padding.getByName((String) cmbPadZ.getSelectedItem());
AbstractApodization axy = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apz = Apodization.getByName((String) cmbApoZ.getSelectedItem());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
String extXY = (ext ? "" + spnExtensionXY.get() : "") + " ";
String extZ = ext ? "" + spnExtensionZ.get() : "";
String cmd = "";
if (!(pxy instanceof NoPadding) || !(paz instanceof NoPadding) || spnExtensionXY.get() > 0 || spnExtensionZ.get() > 0)
cmd += " -pad " + pxy.getShortname() + " " + paz.getShortname() + " " + extXY + extZ;
if (!(axy instanceof UniformApodization) || !(apz instanceof UniformApodization))
cmd += " -apo " + axy.getShortname() + " " + apz.getShortname() + " ";
if (cmbNormalization.getSelectedIndex() != 0)
cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
info = new HTMLPane(100, 100);
cmbPadXY = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbPadZ = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbApoXY = new JComboBox<String>(Apodization.getApodizationsAsArray());
cmbApoZ = new JComboBox<String>(Apodization.getApodizationsAsArray());
spnExtensionXY = new SpinnerRangeInteger(0, 0, 99999, 1);
spnExtensionZ = new SpinnerRangeInteger(0, 0, 99999, 1);
cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
GridPanel pnBorder = new GridPanel("Border Artifact Cancelation", 3);
pnBorder.place(0, 2, "Lateral (XY)");
pnBorder.place(0, 4, "Axial (Z)");
pnBorder.place(2, 0, "Apodization");
pnBorder.place(2, 2, cmbApoXY);
pnBorder.place(2, 4, cmbApoZ);
pnBorder.place(3, 0, "Padding Extension");
pnBorder.place(3, 2, spnExtensionXY);
pnBorder.place(3, 4, spnExtensionZ);
pnBorder.place(4, 0, "Padding Constraint");
pnBorder.place(4, 2, cmbPadXY);
pnBorder.place(4, 4, cmbPadZ);
pnBorder.place(5, 0, "PSF Normalization");
pnBorder.place(5, 2, cmbNormalization);
pnBorder.place(5, 4, "1, recommended");
JScrollPane scroll1 = new JScrollPane(pnBorder);
scroll1.setBorder(BorderFactory.createEmptyBorder());
scroll1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
control.add(scroll1);
control.add(info.getPane());
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
cmbNormalization.addActionListener(this);
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
build = true;
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
testInfo();
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
cmbPadXY.setSelectedIndex(0);
cmbPadZ.setSelectedIndex(0);
cmbApoXY.setSelectedIndex(0);
cmbApoZ.setSelectedIndex(0);
spnExtensionXY.set(0);
spnExtensionZ.set(0);
cmbNormalization.setSelectedIndex(0);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
update();
return;
}
if (e.getSource() == getAction1Button()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getAction1Button().setEnabled(false);
getAction2Button().setEnabled(false);
info.clear();
info.append("p", "Test running...");
info.clear();
ArrayList<String> lines = new Deconvolution(Command.command()).checkImage();
for (String line : lines)
info.append("p", line);
ArrayList<String> linesPSF = new Deconvolution(Command.command()).checkPSF();
for (String line : linesPSF)
info.append("p", line);
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
testInfo();
update();
}
@Override
public void close() {
cmbNormalization.removeActionListener(this);
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
}
private void testInfo() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (build)
info();
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
private Padding getPadding() {
AbstractPadding padXY = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding padZ = Padding.getByName((String) cmbPadZ.getSelectedItem());
int extXY = spnExtensionXY.get();
int extZ = spnExtensionZ.get();
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
private Apodization getApodization() {
AbstractApodization apoXY = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apoZ = Apodization.getByName((String) cmbApoZ.getSelectedItem());
return new Apodization(apoXY, apoXY, apoZ);
}
private void info() {
int nx = 600;
int ny = 400;
int nz = 100;
RealSignal image = new Deconvolution(Command.command()).openImage();
if (image != null) {
nx = image.nx;
ny = image.ny;
nz = image.nz;
}
try {
info.clear();
}
catch (Exception ex) {
}
int[] p = getPadding().pad(nx, ny, nz);
String in = "[" + nx + " x" + ny + " x " + nz + "]";
String out = "[" + p[0] + " x" + p[1] + " x " + p[2] + "]";
String bin = NumFormat.bytes(nx * ny * nz * 4);
String pout = NumFormat.bytes(p[0] * p[1] * p[2] * 4);
if (info != null) {
info.append("p", "Input size: " + in + " (" + bin + ")");
info.append("p", "Padded size: " + out + " (" + pout + ")");
double lost = getApodization().estimateLostEnergy(10);
info.append("p", "Estimation of lost energy by apodization: " + (lost * 100) + "%");
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
index c3c8978..f1d9ee4 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
@@ -1,124 +1,124 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.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 lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
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() {
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);
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/modules/ControllerModule.java
index fb5da06..cc09c44 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
@@ -1,308 +1,308 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import deconvolution.Command;
+import deconvolution.Deconvolution;
+import deconvolutionlab.Config;
import lab.component.GridPanel;
import lab.component.SpinnerRangeInteger;
import lab.tools.Files;
import signal.Constraint;
-import deconvolution.Command;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Config;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtSaveStats;
private JTextField txtShowStats;
private JComboBox<String> cmbConstraint;
private JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkConstraint;
private JCheckBox chkSaveStats;
private JCheckBox chkShowStats;
private SpinnerRangeInteger snapshotResidu;
private SpinnerRangeInteger snapshotConstraint;
private SpinnerRangeInteger snapshotReference;
private SpinnerRangeInteger snapshotSaveStats;
private SpinnerRangeInteger snapshotShowStats;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
int sr = snapshotResidu.get();
int sc = snapshotConstraint.get();
int sg = snapshotReference.get();
int ss = snapshotSaveStats.get();
int sd = snapshotShowStats.get();
if (chkConstraint.isSelected())
cmd += "-constraint " + (sc > 1 ? "@" + sc + " ": "") + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + (sg > 1 ? "@" + sg + " " : "") + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + (sr > 1 ? "@" + sr + " " : "") + txtResidu.getText() + " ";
if (chkSaveStats.isSelected())
cmd += "-savestats " + (ss > 1 ? "@" + ss + " " : "") + txtSaveStats.getText() + " ";
if (chkShowStats.isSelected())
cmd += "-showstats " + (sd > 1 ? "@" + sd + " " : "") + txtShowStats.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
snapshotResidu = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
snapshotConstraint = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
snapshotReference = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
snapshotSaveStats = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
snapshotShowStats = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
chkConstraint = new JCheckBox("Constraint");
chkResidu = new JCheckBox("Residu Minimun");
chkReference = new JCheckBox("Reference");
chkSaveStats = new JCheckBox("Save Stats");
chkShowStats = new JCheckBox("Show Stats");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtSaveStats = new JTextField("stats");
txtShowStats = new JTextField("stats");
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true);
pn.place(1, 0, chkResidu);
pn.place(1, 1, txtResidu);
pn.place(1, 2, snapshotResidu);
pn.place(4, 0, chkConstraint);
pn.place(4, 1, cmbConstraint);
pn.place(4, 2, snapshotConstraint);
pn.place(5, 0, chkSaveStats);
pn.place(5, 1, txtSaveStats);
pn.place(5, 2, snapshotSaveStats);
pn.place(6, 0, chkShowStats);
pn.place(6, 1, txtShowStats);
pn.place(6, 2, snapshotShowStats);
pn.place(7, 0, chkReference);
pn.place(7, 1, txtReference);
pn.place(7, 2, snapshotReference);
pn.place(8, 0, "Ground-truth file");
pn.place(8, 1, bnBrowse);
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
pn.setBorder(BorderFactory.createCompoundBorder(b1, b2));
JScrollPane scroll = new JScrollPane(pn);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.NORTH);
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkSaveStats.addChangeListener(this);
chkShowStats.addChangeListener(this);
snapshotResidu.addChangeListener(this);
snapshotConstraint.addChangeListener(this);
snapshotReference.addChangeListener(this);
snapshotShowStats.addChangeListener(this);
snapshotSaveStats.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtSaveStats.addKeyListener(this);
txtShowStats.addKeyListener(this);
cmbConstraint.addActionListener(this);
getAction1Button().addActionListener(this);
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "constraint.enable", chkConstraint, false);
Config.register(getName(), "showstats.enable", chkShowStats, false);
Config.register(getName(), "savestats.enable", chkSaveStats, false);
Config.register(getName(), "reference.value", txtReference, "");
Config.register(getName(), "residu.value", txtResidu, "0.01");
Config.register(getName(), "showstats.value", txtShowStats, "Stats");
Config.register(getName(), "savestats.value", txtSaveStats, "Stats");
Config.register(getName(), "constraint.value", cmbConstraint, "No");
Config.register(getName(), "residu.snapshot", snapshotResidu, "1");
Config.register(getName(), "reference.snapshot", snapshotConstraint, "1");
Config.register(getName(), "constraint.snapshot", snapshotReference, "1");
Config.register(getName(), "showstats.snapshot", snapshotShowStats, "1");
Config.register(getName(), "savestats.snapshot", snapshotSaveStats, "1");
return panel;
}
private void update() {
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkReference.isSelected() ? 1 : 0);
count += (chkConstraint.isSelected() ? 1 : 0);
count += (chkSaveStats.isSelected() ? 1 : 0);
count += (chkShowStats.isSelected() ? 1 : 0);
setSynopsis("" + count + (count >= 2 ? " controls" : " control "));
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
Deconvolution deconvolution = new Deconvolution(Command.command());
File file = Files.browseFile(deconvolution.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkSaveStats.removeChangeListener(this);
chkShowStats.removeChangeListener(this);
snapshotResidu.removeChangeListener(this);
snapshotConstraint.removeChangeListener(this);
snapshotReference.removeChangeListener(this);
snapshotShowStats.removeChangeListener(this);
snapshotSaveStats.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkConstraint.setSelected(false);
chkShowStats.setSelected(false);
chkSaveStats.setSelected(false);
txtReference.setText("");
txtResidu.setText("0.01");
txtShowStats.setText("Stats");
txtSaveStats.setText("Stats");
cmbConstraint.setSelectedIndex(0);
snapshotResidu.set(1);
snapshotConstraint.set(1);
snapshotReference.set(1);
snapshotShowStats.set(1);
snapshotSaveStats.set(1);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkSaveStats.addChangeListener(this);
chkShowStats.addChangeListener(this);
snapshotResidu.addChangeListener(this);
snapshotConstraint.addChangeListener(this);
snapshotReference.addChangeListener(this);
snapshotShowStats.addChangeListener(this);
snapshotSaveStats.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);
chkShowStats.removeChangeListener(this);
chkSaveStats.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
index 018934b..3dc93d5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
@@ -1,197 +1,199 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.component.GridPanel;
import lab.component.HTMLPane;
import lab.tools.NumFormat;
import signal.Signal;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import fft.AbstractFFTLibrary;
import fft.FFT;
public class FFTModule extends AbstractModule implements ActionListener, ChangeListener {
- private HTMLPane info;
+ private HTMLPane info;
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbType;
private JComboBox<String> cmbSep;
private JComboBox<String> cmbEpsilon;
-
+
private CustomizedTable table;
-
+
public FFTModule(boolean expanded) {
super("Fourier", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbFFT.getSelectedIndex() != 0)
cmd += " -fft " + (String) cmbFFT.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
-
+
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 120, false));
columns.add(new CustomizedColumn("Installed", String.class, 120, false));
columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
table = new CustomizedTable(columns, true);
table.setRowSelectionAllowed(false);
-
+
info = new HTMLPane(100, 100);
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbType = new JComboBox<String>(new String[] { "float" });
cmbSep = new JComboBox<String>(new String[] { "XYZ" });
- cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12"});
+ cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
cmbEpsilon.setSelectedItem("1E-6");
GridPanel pnNumeric = new GridPanel(false, 3);
pnNumeric.place(3, 0, new JLabel("FFT Fourier Library"));
pnNumeric.place(3, 1, cmbFFT);
pnNumeric.place(6, 0, new JLabel("FFT Dimension"));
pnNumeric.place(6, 1, cmbSep);
pnNumeric.place(7, 0, new JLabel("<html>Machine Epsilon &epsilon;</html>"));
pnNumeric.place(7, 1, cmbEpsilon);
pnNumeric.place(8, 0, new JLabel("Data Type"));
pnNumeric.place(8, 1, cmbType);
JScrollPane scroll2 = new JScrollPane(pnNumeric);
scroll2.setBorder(BorderFactory.createEmptyBorder());
scroll2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel control = new JPanel(new BorderLayout());
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
-
+
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
control.add(scroll2, BorderLayout.NORTH);
control.add(info.getPane(), BorderLayout.CENTER);
control.add(table.getPane(80, 80), BorderLayout.SOUTH);
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.CENTER);
-
+
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
Config.register(getName(), "dim", cmbSep, "XYZ");
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
cmbEpsilon.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
fillInstallation();
return panel;
}
private void fillInstallation() {
-
+
ArrayList<AbstractFFTLibrary> libs = FFT.getLibraries();
- for(AbstractFFTLibrary lib : libs) {
+ for (AbstractFFTLibrary lib : libs) {
String name = lib.getLibraryName();
String installed = lib.isInstalled() ? " Yes" : "No";
String location = lib.getLocation();
- table.append(new String[] {name, installed, location});
+ table.append(new String[] { name, installed, location });
}
+ AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
+ info.clear();
+ info.append("p", fftlib.getLicence());
}
-
+
private void update() {
setCommand(getCommand());
- Signal.epsilon = NumFormat.parseNumber( (String) cmbEpsilon.getSelectedItem(), 1e-6);
-
+ Signal.epsilon = NumFormat.parseNumber((String) cmbEpsilon.getSelectedItem(), 1e-6);
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmbFFT || e.getSource() == cmbSep) {
AbstractFFTLibrary fftlib = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
info.clear();
info.append("p", fftlib.getLicence());
}
-
+
if (e.getSource() == getAction1Button()) {
cmbFFT.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
cmbFFT.setSelectedIndex(0);
cmbType.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
cmbEpsilon.addActionListener(this);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java b/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
index 63c5da7..3281aa1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/GroupedModulePanel.java
@@ -1,102 +1,102 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
-import deconvolutionlab.dialog.MainDialog;
+import deconvolutionlab.dialog.LabDialog;
public class GroupedModulePanel extends JPanel {
private ArrayList<AbstractModule> modules;
- private MainDialog parent;
+ private LabDialog parent;
private Dimension min;
- public GroupedModulePanel(ArrayList<AbstractModule> modules, MainDialog parent) {
+ public GroupedModulePanel(ArrayList<AbstractModule> modules, LabDialog parent) {
this.modules = modules;
this.parent = parent;
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
int minWidth = 0;
int minHeight = 0;
for (AbstractModule mpn : modules) {
mpn.setMultipleModulePanel(this);
add(mpn);
Dimension dim = mpn.getCollapsedPanel().getPreferredSize();
minWidth = Math.max(minWidth, dim.width);
minHeight += dim.height;
}
min = new Dimension(minWidth, minHeight);
}
public Dimension getMinimumSize() {
return min;
}
public void organize() {
parent.sizeModule();
}
public ArrayList<AbstractModule> getModules() {
return modules;
}
public Dimension getVisibleSize(Dimension goal) {
int height = 0;
for (AbstractModule mpn : modules) {
height += mpn.getPreferredSize().height;
}
if (height > goal.height) {
return new Dimension(goal.width, height);
}
else {
ArrayList<AbstractModule> visibles = new ArrayList<AbstractModule>();
for (AbstractModule mpn : modules) {
if (mpn.isExpanded())
visibles.add(mpn);
}
if (visibles.size() > 0) {
int supp = (goal.height - height) / visibles.size();
for (AbstractModule mpn : modules) {
Dimension dim = mpn.getPreferredSize();
mpn.setPreferredSize(new Dimension(dim.width, dim.height + supp));
}
}
return new Dimension(goal.width, goal.height);
}
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index 9f481b8..d3a6253 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,339 +1,339 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.Files;
-import signal.RealSignal;
-import signal.factory.SignalFactory;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.ImageSelector;
import deconvolutionlab.Lab;
import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
+import lab.component.CustomizedColumn;
+import lab.component.CustomizedTable;
+import lab.tools.Files;
+import signal.RealSignal;
+import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
- super("Image", "-image", "Open", "Show", expanded);
+ super("Image", "-image", "Select", "Show", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
-
+
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
- else
+ else
setSynopsis("");
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
+ Deconvolution deconvolution = new Deconvolution(Command.command());
file(deconvolution.getPath());
}
else if (e.getSource() == bnDirectory) {
- Deconvolution deconvolution = new Deconvolution(Command.command());
+ Deconvolution deconvolution = new Deconvolution(Command.command());
dir(deconvolution.getPath());
}
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button())
display();
update();
}
public void platform() {
PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
String name = selector.getSelectedImage();
if (name != null)
if (name != "")
- table.insert(new String[] {name, "platform", name, "" });
+ table.insert(new String[] { name, "platform", name, "" });
}
-
+
private void file(String path) {
File file = Files.browseFile(path);
- if (file == null)
+ if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
- if (file == null)
+ if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
dlg.setVisible(true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
dlg.setVisible(true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
-
+
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
System.out.println("edit " + row + " " + name);
- for(SignalFactory factory : SignalFactory.getAll()) {
+ for (SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
- return;
+ return;
}
String filename = table.getCell(row, 1).trim();
- System.out.println("edit " + row + " " + filename + " " + new File(filename).exists() + " " +new File(filename).isDirectory());
+ System.out.println("edit " + row + " " + filename + " " + new File(filename).exists() + " " + new File(filename).isDirectory());
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display() {
int row = table.getSelectedRow();
if (row < 0)
return;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int row = table.getSelectedRow();
RealSignal x = new Deconvolution(getCommand()).openImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
-
+
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
index 76bd47d..b7631ba 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
@@ -1,163 +1,163 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JComboBox;
import javax.swing.JPanel;
-import lab.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Token;
import deconvolutionlab.Config;
+import lab.component.HTMLPane;
public class LanguageModule extends AbstractModule implements ActionListener {
private HTMLPane language;
private JComboBox<String> cmb;
private JComboBox<String> gui;
public LanguageModule(boolean expanded) {
super("Language", "", "", "", expanded);
}
@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)" });
JPanel pn = new JPanel(new FlowLayout());
pn.add(cmb);
pn.add(gui);
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));
language.clear();
return panel;
}
@Override
public void expand() {
super.expand();
update();
}
-
+
public void update() {
if (cmb.getSelectedIndex() == 0) {
language.clear();
String mode = "java -jar DeconvolutionLab_2.jar ";
if (gui.getSelectedIndex() == 0)
- mode += " Run ";
+ mode += " Run ";
else
- mode += " Launch " ;
+ mode += " Launch ";
language.append("p", mode + Command.command());
}
else if (cmb.getSelectedIndex() == 1) {
language.clear();
language.append("p", imagej(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 2) {
language.clear();
String text = "Java code, not yet implemented";
language.append("p", text);
}
else if (cmb.getSelectedIndex() == 3) {
language.clear();
String text = "Matlab code, not yet implemented";
language.append("p", text);
}
}
@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 imagej(boolean headless) {
String macro = "<p>// Macro generated by DeconvolutionLab2 </p>";
macro += "<p>// " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()) + " </p>";
String param = "<p>parameters = \"\"</p>";
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() + "\" </p>";
else if (token.keyword.equals("-psf"))
psf = "<p>psf = \" -psf " + token.parameters.trim() + "\" </p>";
else if (token.keyword.equals("-algorithm"))
algo = "<p>algorithm = \" -algorithm " + token.parameters.trim() + "\" </p>";
else
param += "<p>parameters += \" " + token.keyword + " " + token.parameters.trim() + "\" </p>";
}
-
+
String option = macro + image + psf + algo + param;
String cmd = "";
- if (headless)
+ if (headless)
cmd = "<p>run(\"DeconvolutionLab2 Run\", image + psf + algorithm + parameters)</p>";
else
cmd = "<p>run(\"DeconvolutionLab2 Launch\", image + psf + algorithm + parameters)</p>";
-
+
return option + cmd;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
index dc66ac8..7176066 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
@@ -1,88 +1,88 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
-import lab.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
+import lab.component.HTMLPane;
public class LicenceModule extends AbstractModule {
public LicenceModule(boolean expanded) {
super("Licence", "", "", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p",
"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);
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/MonitoringModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java
index 86d2a00..e167fa8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/MonitoringModule.java
@@ -1,199 +1,211 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
-import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BoxLayout;
import javax.swing.JButton;
+import javax.swing.JCheckBox;
import javax.swing.JComboBox;
-import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
-import lab.component.GridPanel;
-import lab.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
-import deconvolutionlab.Lab;
+import lab.component.GridPanel;
+import lab.tools.Files;
public class MonitoringModule extends AbstractModule implements ActionListener, KeyListener {
- private JTextField txtTime;
- private JTextField txtPath;
- private JButton bnBrowse;
- private JLabel lblTime;
- private JLabel lblPath;
+ private JTextField txtTime;
+ private JTextField txtPath;
+ private JButton bnBrowse;
private JComboBox<String> cmbTime;
private JComboBox<String> cmbPath;
private JComboBox<String> cmbVerbose;
- private JComboBox<String> cmbMonitor;
+ private JCheckBox chkDisableTable;
+ private JCheckBox chkDisableConsole;
+ private JCheckBox chkDisableDisplay;
+ private JCheckBox chkDisableMultithreading;
public MonitoringModule(boolean expanded) {
super("Monitor", "", "", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
+ boolean t = chkDisableTable.isSelected();
+ boolean c = chkDisableConsole.isSelected();
+ boolean d = chkDisableDisplay.isSelected();
+ boolean m = chkDisableMultithreading.isSelected();
if (cmbPath.getSelectedIndex() != 0)
cmd += " -path " + txtPath.getText();
if (cmbTime.getSelectedIndex() != 0)
cmd += " -time " + txtTime.getText();
- if (cmbMonitor.getSelectedIndex() != 0)
- cmd += " -monitor " + cmbMonitor.getSelectedItem();
- if (cmbVerbose.getSelectedIndex() != 0)
- cmd += " -verbose " + cmbVerbose.getSelectedItem();
+ if (c || t || d || m)
+ cmd += " -disable " + (t ? "monitor " : "") +
+ (c ? "console " : "") + (d ? "display " : "") + (m ? "multithreading " : "");
+ if (cmbVerbose.getSelectedIndex() != 0) {
+ String parts[] = ((String)cmbVerbose.getSelectedItem()).split(" ");
+ cmd += " -verbose " + parts[1];
+ }
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
- cmbTime = new JComboBox<String>(new String[] { "no limit", "specify ..." });
- cmbPath = new JComboBox<String>(new String[] { "current", "specify ..." });
- cmbVerbose = new JComboBox<String>(new String[] { "log", "quiet ", "prolix", "mute" });
- cmbMonitor = new JComboBox<String>(new String[] { "console", "table ", "console table", "no" });
+ cmbTime = new JComboBox<String>(new String[] { "No time limitation", "Specify limit (s) ..." });
+ cmbPath = new JComboBox<String>(new String[] { "Current", "Specify ..." });
+ cmbVerbose = new JComboBox<String>(new String[] { "Verbose: log", "Verbose: quiet ", "Verbose: prolix", "Verbose: mute" });
+ chkDisableTable = new JCheckBox("Monitor");
+ chkDisableConsole = new JCheckBox("Console");
+ chkDisableDisplay = new JCheckBox("Display");
+ chkDisableMultithreading = new JCheckBox("Multithreading");
- lblTime = new JLabel("seconds");
- lblPath = new JLabel("Working directory");
txtTime = new JTextField("3600");
txtPath = new JTextField("...", 30);
bnBrowse = new JButton("Browse");
- GridPanel pn = new GridPanel(true, 3);
- pn.place(0, 0, "Path");
+ GridPanel pn = new GridPanel("Output Directory", 3);
pn.place(0, 1, cmbPath);
pn.place(0, 2, bnBrowse);
pn.place(1, 0, 4, 1, txtPath);
-
- GridPanel pn2 = new GridPanel(true, 3);
- pn2.place(3, 0, "Time");
- pn2.place(3, 1, cmbTime);
- pn2.place(3, 2, txtTime);
- pn2.place(3, 3, "seconds");
-
- pn2.place(4, 0, "Monitor");
- pn2.place(4, 1, cmbMonitor);
-
- pn2.place(4, 2, "Verbose");
- pn2.place(4, 3, cmbVerbose);
+ GridPanel pn2 = new GridPanel("Settings", 3);
+ pn2.place(2, 0, cmbTime);
+ pn2.place(2, 1, txtTime);
+ pn2.place(2, 3, cmbVerbose);
+
+ GridPanel pn3 = new GridPanel("Disable", 3);
+ pn3.place(4, 0, chkDisableTable);
+ pn3.place(4, 1, chkDisableConsole);
+ pn3.place(4, 2, chkDisableDisplay);
+ pn3.place(4, 3, chkDisableMultithreading);
+
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(pn);
panel.add(pn2);
-
+ panel.add(pn3);
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
Config.register(getName(), "path", cmbPath, cmbPath.getItemAt(0));
- Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
Config.register(getName(), "time", cmbTime, cmbTime.getItemAt(0));
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "path", txtPath, new File(System.getProperty("user.dir")).getAbsolutePath());
+ Config.register(getName(), "disable.table", chkDisableTable, "false");
+ Config.register(getName(), "disable.console", chkDisableConsole, "false");
+ Config.register(getName(), "disable.display", chkDisableDisplay, "false");
+ Config.register(getName(), "disable.multithreading", chkDisableMultithreading, "false");
cmbVerbose.addActionListener(this);
cmbPath.addActionListener(this);
- cmbMonitor.addActionListener(this);
cmbTime.addActionListener(this);
+ chkDisableTable.addActionListener(this);
+ chkDisableConsole.addActionListener(this);
+ chkDisableDisplay.addActionListener(this);
+ chkDisableMultithreading.addActionListener(this);
txtTime.addKeyListener(this);
bnBrowse.addActionListener(this);
txtPath.addKeyListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
setSynopsis(txtPath.getText());
if (cmbPath != null) {
boolean b = cmbPath.getSelectedIndex() != 0;
bnBrowse.setEnabled(b);
txtPath.setEnabled(b);
- lblPath.setEnabled(b);
}
if (txtTime != null) {
boolean b = cmbTime.getSelectedIndex() != 0;
txtTime.setEnabled(b);
- lblTime.setEnabled(b);
}
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtPath.setText(f.getAbsolutePath());
}
}
if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
-
+
}
update();
}
@Override
public void close() {
- cmbMonitor.removeActionListener(this);
+ chkDisableTable.removeActionListener(this);
+ chkDisableConsole.removeActionListener(this);
+ chkDisableDisplay.removeActionListener(this);
+ chkDisableMultithreading.removeActionListener(this);
cmbVerbose.removeActionListener(this);
cmbTime.removeActionListener(this);
txtTime.removeActionListener(this);
txtPath.removeKeyListener(this);
bnBrowse.removeActionListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index 2934399..fde611d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
@@ -1,341 +1,341 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.ImageSelector;
import deconvolutionlab.Lab;
import deconvolutionlab.PlatformImageSelector;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
- super("PSF", "-psf", "Open", "Show", expanded);
+ super("PSF", "-psf", "Select", "Show", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else
setSynopsis("");
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile) {
Deconvolution deconvolution = new Deconvolution(Command.command());
file(deconvolution.getPath());
}
else if (e.getSource() == bnDirectory) {
Deconvolution deconvolution = new Deconvolution(Command.command());
dir(deconvolution.getPath());
}
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button())
display();
update();
}
public void platform() {
PlatformImageSelector selector = new ImageSelector(Lab.getPlatform()).getImageSelector();
String name = selector.getSelectedImage();
if (name != null)
if (name != "")
table.insert(new String[] {name, "platform", name, "" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
dlg.setVisible(true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
dlg.setVisible(true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
System.out.println("edit " + row + " " + name);
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
System.out.println("edit " + row + " " + filename + " " + new File(filename).exists() + " " +new File(filename).isDirectory());
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display() {
int row = table.getSelectedRow();
if (row < 0)
return;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int row = table.getSelectedRow();
RealSignal x = new Deconvolution(getCommand() + " -nodisplay -nomonitor").openImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
index 298e4c5..2206ae1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
@@ -1,179 +1,179 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import lab.component.CustomizedColumn;
import lab.component.CustomizedTable;
public class TableMonitor implements AbstractMonitor, ActionListener {
private CustomizedTable table;
private JButton bnClear = new JButton("Clear");
private JButton bnProlix = new JButton("Prolix");
private JButton bnVerbose = new JButton("verbose");
private JButton bnQuiet = new JButton("Quiet");
private JButton bnMute = new JButton("Mute");
private HashMap<Long, Color> colors = new HashMap<Long, Color>();
private JPanel panel;
public TableMonitor(int width, int height) {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("#", Long.class, 60, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 3 * 60), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(60);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.getColumnModel().getColumn(1).setMaxWidth(100);
table.getColumnModel().getColumn(1).setMinWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMinWidth(100);
RowRenderer renderer = new RowRenderer();
for (int i = 0; i < 4; i++)
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
-
+ /*
JToolBar tool = new JToolBar();
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 3));
tool.add(bnClear);
tool.add(new JLabel(""));
tool.add(new JLabel(""));
tool.add(bnProlix);
tool.add(bnVerbose);
tool.add(bnQuiet);
tool.add(bnMute);
-
+ */
JPanel main = new JPanel(new BorderLayout());
- main.add(tool, BorderLayout.NORTH);
+ //main.add(tool, BorderLayout.NORTH);
main.add(scroll, BorderLayout.CENTER);
bnClear.addActionListener(this);
bnVerbose.addActionListener(this);
bnQuiet.addActionListener(this);
bnProlix.addActionListener(this);
bnMute.addActionListener(this);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public JPanel getPanel() {
return panel;
}
public void show(String title) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public void add(Message message) {
String msg[] = message.formatArray();
int n = msg.length;
Object[] row = new Object[n + 1];
row[0] = message.getID();
for (int i = 0; i < n; i++)
row[i + 1] = msg[i];
table.append(row);
Verbose level = message.getLevel();
Color c = new Color(0, 0, 0);
if (level == Verbose.Prolix)
c = new Color(255, 0, 0);
else if (level == Verbose.Quiet)
c = new Color(200, 200, 0);
colors.put(new Long(message.getID()), c);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnClear) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
}
@Override
public String getName() {
return "table";
}
class RowRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row >= 0) {
Long id = (Long) model.getValueAt(row, 0);
Color color = colors.get(id);
c.setForeground(color);
}
return c;
}
}
}
diff --git a/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java b/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
index 568d428..51829bb 100644
--- a/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
+++ b/DeconvolutionLab2/src/fft/jtransforms/JTransformsLibrary.java
@@ -1,79 +1,79 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package fft.jtransforms;
import fft.AbstractFFTLibrary;
public class JTransformsLibrary extends AbstractFFTLibrary {
public JTransformsLibrary() {
try {
Class.forName("edu.emory.mathcs.jtransforms.fft.FloatFFT_3D");
Class.forName("edu.emory.mathcs.jtransforms.fft.FloatFFT_1D");
Class.forName("edu.emory.mathcs.jtransforms.fft.FloatFFT_2D");
installed = true;
}
catch (ClassNotFoundException 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" + "<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.";
+ 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.";
}
}
diff --git a/DeconvolutionLab2/src/imagej/IJImageSelector.java b/DeconvolutionLab2/src/imagej/IJImageSelector.java
index f2ad068..14e6f6f 100644
--- a/DeconvolutionLab2/src/imagej/IJImageSelector.java
+++ b/DeconvolutionLab2/src/imagej/IJImageSelector.java
@@ -1,140 +1,147 @@
package imagej;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import deconvolutionlab.PlatformImageSelector;
import ij.ImagePlus;
import ij.WindowManager;
import ij.gui.GUI;
public class IJImageSelector extends PlatformImageSelector {
@Override
public boolean isSelectable() {
return true;
}
@Override
public String getSelectedImage() {
Dialog dialog = new Dialog();
dialog.setVisible(true);
if (dialog.wasCancel())
return "";
return dialog.getName();
}
public class Dialog extends JDialog implements ActionListener, WindowListener {
private JList<String> list;
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String name = "";
public Dialog() {
super(new JFrame(), "Image Selection");
+
+ JPanel bn = new JPanel(new GridLayout(1, 2));
+ bn.add(bnCancel);
+ bn.add(bnOK);
+
+ JPanel panel = new JPanel(new BorderLayout());
int[] ids = WindowManager.getIDList();
- DefaultListModel listModel = new DefaultListModel();
- if (list != null)
+
+ if (ids != null) {
+ DefaultListModel listModel = new DefaultListModel();
+ list = new JList(listModel);
for (int id : ids) {
ImagePlus idp = WindowManager.getImage(id);
if (idp != null) {
((DefaultListModel) listModel).addElement(idp.getTitle());
}
}
-
- list = new JList(listModel);
- list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- JScrollPane listScroller = new JScrollPane(list);
- listScroller.setPreferredSize(new Dimension(250, 80));
- JPanel bn = new JPanel(new GridLayout(1, 2));
- bn.add(bnCancel);
- bn.add(bnOK);
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(listScroller, BorderLayout.CENTER);
+ list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ JScrollPane listScroller = new JScrollPane(list);
+ listScroller.setPreferredSize(new Dimension(250, 80));
+ panel.add(listScroller, BorderLayout.CENTER);
+ }
+ else {
+ panel.add(new JLabel("No open images."));
+ }
panel.add(bn, BorderLayout.SOUTH);
- panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
@Override
public void actionPerformed(ActionEvent e) {
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
if (e.getSource() == bnCancel) {
cancel = true;
name = "";
dispose();
return;
}
else if (e.getSource() == bnOK) {
cancel = false;
name = (String) list.getSelectedValue();
dispose();
}
}
public String getName() {
return name;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
name = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
}
diff --git a/DeconvolutionLab2/src/imagej/IJImager.java b/DeconvolutionLab2/src/imagej/IJImager.java
index f2dedd1..ac671b5 100644
--- a/DeconvolutionLab2/src/imagej/IJImager.java
+++ b/DeconvolutionLab2/src/imagej/IJImager.java
@@ -1,215 +1,221 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package imagej;
-import java.util.ArrayList;
import java.util.HashMap;
import deconvolutionlab.PlatformImager;
import ij.ImagePlus;
import ij.ImageStack;
import ij.WindowManager;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
public class IJImager extends PlatformImager {
- private static HashMap<String, ImagePlus> images = new HashMap<String, ImagePlus>();
- private static HashMap<String, ImageStack> stacks = new HashMap<String, ImageStack>();
+ private static HashMap<String, ImagePlus> images = new HashMap<String, ImagePlus>();
+ private static HashMap<String, ImageStack> stacks = new HashMap<String, ImageStack>();
public static RealSignal create(ImagePlus imp) {
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
RealSignal signal = new RealSignal(nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
- }
+ }
@Override
public RealSignal create() {
return build(WindowManager.getCurrentImage());
}
@Override
public RealSignal create(String name) {
ImagePlus imp = WindowManager.getImage(name);
if (imp == null)
imp = WindowManager.getCurrentImage();
return build(imp);
}
@Override
public RealSignal open(String filename) {
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
return build(imp);
}
@Override
public void show(RealSignal signal, String title) {
show(signal, title, PlatformImager.Type.FLOAT);
}
@Override
public void show(RealSignal signal, String title, PlatformImager.Type type) {
- show(signal, title, type, signal.nz/2);
+ show(signal, title, type, signal.nz / 2);
}
@Override
public void show(RealSignal signal, String title, PlatformImager.Type type, int z) {
ImagePlus imp = build(signal, type);
if (imp != null) {
imp.setTitle(title);
int nz = imp.getStackSize();
imp.show();
imp.setSlice(Math.max(1, Math.min(nz, z)));
imp.getProcessor().resetMinAndMax();
}
}
@Override
public void appendShowLive(String key, RealSignal signal, String title) {
appendShowLive(key, signal, title, PlatformImager.Type.FLOAT);
}
@Override
public void appendShowLive(String key, RealSignal signal, String title, PlatformImager.Type type) {
ImagePlus imp = build(signal, type);
ImagePlus image = images.get(key);
ImageStack stack = stacks.get(key);
if (image == null || stack == null) {
stack = new ImageStack(signal.nx, signal.ny);
stack.addSlice(imp.getProcessor());
image = new ImagePlus(key, stack);
image.show();
images.put(key, image);
stacks.put(key, stack);
}
else {
stack.addSlice(imp.getProcessor());
image.setStack(stack);
}
image.updateAndDraw();
image.setSlice(image.getStack().getSize());
image.getProcessor().resetMinAndMax();
}
@Override
public void save(RealSignal signal, String filename) {
save(signal, filename, PlatformImager.Type.FLOAT);
}
@Override
public void save(RealSignal signal, String filename, PlatformImager.Type type) {
ImagePlus imp = build(signal, type);
if (imp != null) {
if (imp.getStackSize() == 1) {
new FileSaver(imp).saveAsTiff(filename);
}
else {
new FileSaver(imp).saveAsTiffStack(filename);
}
}
}
-
+
@Override
- public void show(ComplexSignal signal, String title) {
+ public void show(ComplexSignal signal, String title) {
show(signal, title, ComplexComponent.MODULE);
}
@Override
- public void show(ComplexSignal signal, String title, ComplexComponent complex) {
+ public void show(ComplexSignal signal, String title, ComplexComponent complex) {
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
- switch(complex) {
- case REAL: plane = signal.getRealXY(k); break;
- case IMAGINARY: plane = signal.getImagXY(k); break;
- case MODULE: plane = signal.getModuleXY(k); break;
- default: plane = signal.getModuleXY_dB(k);
+ switch (complex) {
+ case REAL:
+ plane = signal.getRealXY(k);
+ break;
+ case IMAGINARY:
+ plane = signal.getImagXY(k);
+ break;
+ case MODULE:
+ plane = signal.getModuleXY(k);
+ break;
+ default:
+ plane = signal.getModuleXY_dB(k);
}
stack.addSlice(new FloatProcessor(signal.nx, signal.ny, plane));
}
new ImagePlus(title, stack).show();
}
-
+
private RealSignal build(ImagePlus imp) {
if (imp == null)
return null;
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
RealSignal signal = new RealSignal(nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
}
-
+
private ImagePlus build(RealSignal signal, PlatformImager.Type type) {
if (signal == null)
return null;
-
+
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
ImageProcessor ip = new FloatProcessor(signal.nx, signal.ny, signal.getXY(k));
- switch(type) {
- case BYTE:
- stack.addSlice(ip.convertToByteProcessor(false));
- break;
- case SHORT:
- stack.addSlice(ip.convertToShortProcessor(false));
- break;
- case FLOAT:
- stack.addSlice(ip);
- default:
- break;
+ switch (type) {
+ case BYTE:
+ stack.addSlice(ip.convertToByteProcessor(false));
+ break;
+ case SHORT:
+ stack.addSlice(ip.convertToShortProcessor(false));
+ break;
+ case FLOAT:
+ stack.addSlice(ip);
+ default:
+ break;
}
}
return new ImagePlus("", stack);
}
-
+
@Override
public String getName() {
return "ImageJ";
}
}
diff --git a/DeconvolutionLab2/src/lab/system/SystemBar.java b/DeconvolutionLab2/src/lab/system/SystemBar.java
index 117f72d..6a47847 100644
--- a/DeconvolutionLab2/src/lab/system/SystemBar.java
+++ b/DeconvolutionLab2/src/lab/system/SystemBar.java
@@ -1,88 +1,88 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package lab.system;
import java.awt.BorderLayout;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.BoxLayout;
import javax.swing.JToolBar;
public class SystemBar extends JToolBar {
private Timer timer = new Timer();
private TimerTask updater = new Updater();
private SystemHeap heap;
private SystemCPU load;
public SystemBar(int refreshTime) {
super("System Bar");
setFloatable(false);
heap = new SystemHeap();
load = new SystemCPU();
restart(refreshTime);
setLayout(new BorderLayout());
setFloatable(true);
- setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
- add(heap);
- add(load);
+ setLayout(new BorderLayout());
+ add(heap, BorderLayout.CENTER);
+ add(load, BorderLayout.EAST);
}
public void update() {
heap.repaint();
load.repaint();
}
public void restart(int refreshTime) {
if (updater != null) {
updater.cancel();
updater = null;
}
updater = new Updater();
timer.schedule(updater, 0, refreshTime);
}
public void close() {
timer.cancel();
timer = null;
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}

Event Timeline