Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96326715
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 25, 08:17
Size
40 KB
Mime Type
application/octet-stream
Expires
Fri, Dec 27, 08:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23170996
Attached To
R2075 deconvolution
View Options
diff --git a/DeconvolutionLab2/plugins.config b/DeconvolutionLab2/plugins.config
index 02104d2..0b36b23 100644
--- a/DeconvolutionLab2/plugins.config
+++ b/DeconvolutionLab2/plugins.config
@@ -1,13 +1,20 @@
# Name: DeconvolutionLab 2
# Daniel Sage
# Biomedical Imaging Group
# Ecole Polytechnique Federale de Lausanne (EPFL), Lausanne, Switzerland
# Date: 11 July 2016
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Lab", DeconvolutionLab2_
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Launch", DeconvolutionLab2_Launch
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Run", DeconvolutionLab2_Run
Plugins>DeconvolutionLab2, "DeconvolutionLab2 FFT", DeconvolutionLab2_FFT
Plugins>DeconvolutionLab2, "DeconvolutionLab2 Help", DeconvolutionLab2_Help
+
+Plugins>DeconvolutionLab2>Course, "Bigradient", DeconvolutionLab2_Course_Bigradient
+Plugins>DeconvolutionLab2>Course, "Border", DeconvolutionLab2_Course_Border
+Plugins>DeconvolutionLab2>Course, "Noise", DeconvolutionLab2_Course_Noise
+Plugins>DeconvolutionLab2>Course, "Resolution", DeconvolutionLab2_Course_Resolution
+Plugins>DeconvolutionLab2>Course, "SpectralAnaylsis", DeconvolutionLab2_Course_SpectralAnaylsis
+
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
new file mode 100644
index 0000000..a89fa89
--- /dev/null
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Bigradient.java
@@ -0,0 +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(noisy + psf + " -algorithm NIF -out stack NIF").deconvolve();
+ new Deconvolution(noisy + psf + " -algorithm DIV -out stack DIV").deconvolve();
+
+ for(int i=0; i<=3; i++) {
+ double p = Math.pow(5, i-10);
+ String name = "RIF" + String.format("%02d", i);
+ new Deconvolution(noisy + psf + " -algorithm RIF " + p + out("RIF" + File.separator, name)).deconvolve();
+ }
+ 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();
+ }
+
+ String lw = " -algorithm LW 20 1 -out mip @2 LW-ITER/I -showstats @1 LW";
+ new Deconvolution(noisy + psf + lw).deconvolve();
+ 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 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 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 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 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/DeconvolutionLab2_Course_Border.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
similarity index 98%
rename from DeconvolutionLab2/src/DeconvolutionLab2_Course_Border.java
rename to DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
index 3b9572d..871d82d 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Course_Border.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Border.java
@@ -1,106 +1,108 @@
+package course;
// Course Version 2
+import ij.plugin.PlugIn;
+
import java.io.File;
import javax.swing.filechooser.FileSystemView;
-import deconvolution.Deconvolution;
-import deconvolutionlab.Lab;
-import deconvolutionlab.monitor.Monitors;
-import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.Cube;
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();
+ 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();
algo = " -algorithm CONV -stack CONV -out ortho CONVo rescaled byte (64,32,16) -out mip CONVp rescaled byte";
new Deconvolution(ref + psf + algo).deconvolve();
algo = " -algorithm CONV -pad NO NO 200 200 -out ortho PADo200 rescaled byte (64,32,16) -out mip PADp200 rescaled byte";
new Deconvolution(ref + psf + algo).deconvolve();
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();
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();
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();
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();
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();
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();
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();
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();
algo = " -algorithm CONV -apo HANN HANN -out ortho HANN_CSTo rescaled byte -out mip HANN_CSTp rescaled byte";
new Deconvolution(cst + psf + algo).deconvolve();
algo = " -algorithm CONV -apo TUKEY TUKEY -out ortho TUKEY_CSTo rescaled byte -out mip TUKEY_CSTp rescaled byte";
new Deconvolution(cst + psf + algo).deconvolve();
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();
- */
+
}
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/DeconvolutionLab2_Course_Noise.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
similarity index 97%
rename from DeconvolutionLab2/src/DeconvolutionLab2_Course_Noise.java
rename to DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
index 312ae5a..10b28b8 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Course_Noise.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Noise.java
@@ -1,66 +1,67 @@
+package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
import signal.RealSignal;
import signal.factory.Cube;
public class DeconvolutionLab2_Course_Noise implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "DeconvolutionLab2-Course" + File.separator;
private String res = root + "Results" + File.separator + "noise" + File.separator;
public DeconvolutionLab2_Course_Noise() {
Monitors monitors = Monitors.createDefaultMonitor();
- new File(res).mkdir();
+ new File(res).mkdir();
System.setProperty("user.dir", res);
-
+
int nx = 560;
int ny = 120;
int nz = 1;
String size = " size " + nx + " " + ny + " " + nz;
RealSignal im = new Cube(50, 0.25).intensity(0, 100).center(0.2, 0.5, 0).generate(nx, ny, nz);
RealSignal i1 = new Cube(50, 0.25).intensity(0, 70).center(0.4, 0.5, 0).generate(nx, ny, nz);
RealSignal i2 = new Cube(50, 0.25).intensity(0, 40).center(0.6, 0.5, 0).generate(nx, ny, nz);
RealSignal i3 = new Cube(50, 0.25).intensity(0, 10).center(0.8, 0.5, 0).generate(nx, ny, nz);
im.plus(i1);
im.plus(i2);
im.plus(i3);
Lab.show(monitors, im, "im.tif");
Lab.save(monitors, im, res + "im.tif");
String psf = " -psf synthetic impulse 1 0 " + size;
String image = " -image file im.tif";
// Simulation
String name = "SIM m 0 s 50 p 0";
String out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
new Deconvolution(psf + image + " -algorithm " + name + out).run();
name = "SIM m 0 s 00 p 150";
out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
new Deconvolution(psf + image + " -algorithm " + name + out).run();
name = "SIM m 0 s 15 p 30";
out = " -stack " + name + " -out stack " + name + "-BYTE rescaled byte noshow";
new Deconvolution(psf + image + " -algorithm " + name + out).run();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Noise();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Noise();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Course_Resolution.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
similarity index 96%
rename from DeconvolutionLab2/src/DeconvolutionLab2_Course_Resolution.java
rename to DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
index 1073ae2..19ca6bb 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Course_Resolution.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_Resolution.java
@@ -1,80 +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();
algo = " -algorithm SIM 0 0.1 0 -showstats @3 SIM -out stack SIGNAL -out ortho SIGNALo ";
new Deconvolution(ground + psf + algo).deconvolve();
algo = " -algorithm NIF -out ortho NIF " + paramout;
new Deconvolution(signal + psf + algo).deconvolve();
algo = " -algorithm LW+ 17 1 -showstats @3 LW -out ortho @10 LW+/LW+" + paramout;
new Deconvolution(signal + psf + algo).deconvolve();
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();
}
algo = " -algorithm LW 11 1 -showstats @3 LW -out ortho @10 LW/LW" + paramout;
new Deconvolution(signal + psf + algo).deconvolve();
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_Resolution();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_Resolution();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
new file mode 100644
index 0000000..fb46d9a
--- /dev/null
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
@@ -0,0 +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();
+
+ algo = " -algorithm CONV " + out("CONV-PERTURBATED");
+ new Deconvolution(psf + image + algo).deconvolve();
+ ComplexSignal H = fft.transform(h);
+ ComplexSignal H2 = Operations.multiply(H, H);
+ ComplexSignal LP = ComplexSignalFactory.laplacian(nx, ny, nz);
+
+ algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("SIM");
+ new Deconvolution(psf + image + algo).deconvolve();
+
+ algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("NOISE");
+ new Deconvolution(impulse + constant + algo).deconvolve();
+
+ // No Noise
+ String nonoise = " -image file CONV.tif -psf file psfPerturbated.tif";
+ new Deconvolution(nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve();
+ 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();
+
+ // 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();
+
+ // 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();
+
+ algo = " -algorithm LW+ 100 0.5 -out mip @1 LW+-ITER/I ";
+ new Deconvolution(simulation + algo + out("LW+/LW+")).deconvolve();
+ new File(res + "LW+-ITER/I.tif").delete();
+
+ for(int i=0; i<=20; i++) {
+ double p = Math.pow(5, i-12);
+ String name = "RIF/RIF" + String.format("%02d", i);
+ new Deconvolution(simulation + " -algorithm RIF " + p + out(name)).deconvolve();
+ 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();
+ 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 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 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 901130a..5d97694 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,567 +1,572 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* 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 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;
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 = "";
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() {
- /*
- * if (fftlib == null) { run(); return; } if
- * (!fftlib.isMultithreadable()) { run(); return; }
- */
+
+ 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.name = job;
new DeconvolutionDialog(this);
}
public ArrayList<String> getDeconvolutionResults() {
return results;
}
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) {
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);
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");
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");
return;
}
if (controller == null) {
monitors.error("Controller: not valid");
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;
}
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 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;
}
}
Event Timeline
Log In to Comment