Page MenuHomec4science

No OneTemporary

File Metadata

Created
Sun, Feb 16, 20:50
diff --git a/DeconvolutionLab2/.classpath b/DeconvolutionLab2/.classpath
index da27baf..646093d 100644
--- a/DeconvolutionLab2/.classpath
+++ b/DeconvolutionLab2/.classpath
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="var" path="ICY_HOME/icy.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="ij"/>
- <classpathentry kind="lib" path="lib/jtransforms.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index 47aa668..cab7984 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,81 +1,80 @@
#DeconvolutionLab2 [Beta 2]
#DeconvolutionLab2 [Beta 2]
-#Mon Mar 20 09:47:20 CET 2017
+#Sun Mar 26 18:45:42 CEST 2017
Algorithm.BVLS.iterations=10
Algorithm.BVLS.step=1.0
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.NNLS.iterations=10
Algorithm.NNLS.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=1.000E-18
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
-Algorithm.algorithm=Fast Iterative Shrinkage-Thresholding [FISTA]
+Algorithm.algorithm=Regularized Inverse Filter
Border.apoxy=Hamming
Border.apoz=Uniform
Border.extxy=1
Border.extz=0
Border.padxy=None
Border.padz=None
Computation.dim=XYZ
Computation.epsilon=1E-6
Computation.fft=Fastest
Computation.normalization=1
Controller.constraint.enable=false
Controller.constraint.value=no
Controller.itmax.enable=true
Controller.reference.enable=false
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.value=0.01
Controller.time.enable=false
Controller.time.value=3600
DeconvolutionLab.MainDialog.location.h=780
DeconvolutionLab.MainDialog.location.w=500
DeconvolutionLab.MainDialog.location.x=141
DeconvolutionLab.MainDialog.location.y=51
Image.image.row0=active;platform;active;\u232B
Image.image.row1=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row2=Applications;directory;/users/dsage/Applications;\u232B
Image.image.row3=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;\u232B
Image.image.row4=lib;directory;/Users/dsage/git/deconvolution/DeconvolutionLab2/lib;\u232B
Image.image.selected=active;platform;active;\u232B
Language.headless=Run (Headless)
Language.job=Job
Language.language=Java
Output.output.row0=ortho;OR2;;;;\u2713;\u2713;\u232B
Output.output.selected=ortho;OR2;;;;\u2713;\u2713;\u232B
-PSF.psf.row0=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
-PSF.psf.row1=Chrome Apps.localized;directory;/users/dsage/applications/Chrome Apps.localized;\u232B
-PSF.psf.row2=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
-PSF.psf.selected=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
+PSF.psf.row0=Chrome Apps.localized;directory;/users/dsage/applications/Chrome Apps.localized;\u232B
+PSF.psf.row1=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
+PSF.psf.selected=FI1.tif;file;/Users/dsage/git/deconvolution/DeconvolutionLab2/FI1.tif;\u232B
Running.Directory=/Users/dsage/Applications
Running.Display=no
Running.Monitor=console table
Running.Multithreading=yes
Running.Path=specify
Running.Stats=show
Running.System=no
Running.Verbose=log
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index 8894410..c512b7d 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,31 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="DeconvolutionLab2" default="build" basedir=".">
<property name="imagej" location="${user.home}/Desktop/ImageJ/plugins" />
<property name="fiji" location="${user.home}/Desktop/Fiji-deconv.app/plugins" />
<property name="matlab" location="/Applications/MATLAB_R2014b.app/java/" />
+ <property name="doc" location="${user.home}/Desktop/doc/" />
+
+ <property name="javadoc.header" value="&lt;h3&gt;DeconvolutionLab2&lt;/h3&gt;&#09;v1.0" />
+ <property name="javadoc.footer" value="&lt;h4&gt;DeconvolutionLab2&lt;/h4&gt;&#09;&lt;script&gt; var tStamp=new Date(); document.write(tStamp.toUTCString()); &lt;/script&gt;" />
+ <property name="javadoc.bottom" value='Copyright &amp;copy; &lt;script&gt; var currYear=new Date(); document.write(currYear.getFullYear()); &lt;/script&gt;, Biomedical Imaging Group, EPFL, Lausanne, Switzerland. All rights reserved.' />
<target name="build">
+ <mkdir dir="${doc}" />
<mkdir dir="bin" />
<copy todir="bin">
<fileset dir="ij">
</fileset>
</copy>
<copy file="plugins.config" toDir="bin" />
<zip destfile="../DeconvolutionLab2-src.zip" basedir="src" />
<zip destfile="../DeconvolutionLab2-cls.zip" basedir="bin" />
<jar destfile="../DeconvolutionLab_2.jar" basedir="bin">
<manifest>
<attribute name="Main-Class" value="DeconvolutionLab2" />
<attribute name="Class-Path" value="ij.jar jtransforms.jar" />
</manifest>
</jar>
+ <javadoc destdir="${doc}"
+ author="true"
+ version="true"
+ overview="${basedir}/overview.html"
+ windowtitle="DeconvolutionLab2">
+ <fileset dir="src">
+ <include name="**/*.java" />
+ <exclude name="**/fft/**" />
+ <exclude name="**/jfftw/**" />
+ </fileset>
+ <header><![CDATA[${javadoc.header}]]></header>
+ <footer><![CDATA[${javadoc.footer}]]></footer>
+ <bottom><![CDATA[${javadoc.bottom}]]></bottom>
+ </javadoc>
<copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
<copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
<copy toDir="${imagej}" file="../DeconvolutionLab_2.jar" />
</target>
</project>
diff --git a/DeconvolutionLab2/src/DL2.java b/DeconvolutionLab2/src/DL2.java
index 8cd3758..ec123d7 100644
--- a/DeconvolutionLab2/src/DL2.java
+++ b/DeconvolutionLab2/src/DL2.java
@@ -1,252 +1,252 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import deconvolution.Deconvolution;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import ij.ImagePlus;
import ij.WindowManager;
import matlab.Converter;
import signal.RealSignal;
/**
* This class allows Matlab interface for DeconvolutionLab2
*
* A Matlab 3D variable in converted to a RealSignal and vice-versa.
*
* @author sage
*
*/
public class DL2 {
public static void lab() {
- Lab.init(Imaging.Platform.MATLAB, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.MATLAB, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
LabDialog dlg = new LabDialog();
Lab.setVisible(dlg, false);
}
public static void run(String command) {
new Deconvolution("Matlab", command).deconvolve();
}
public static void launch(String command) {
new Deconvolution("Matlab", command).launch();
}
public static Object get(String image) {
ImagePlus imp = WindowManager.getCurrentImage();
if (imp != null)
return Converter.get(imp);
return null;
}
public static Object run(Object arrayImage, Object arrayPSF, String algo) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -image platform input -psf platform psf -algorithm " + algo;
Deconvolution d = new Deconvolution("Matlab", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static void help() {
Lab.help();
}
public static void clear() {
int ids[] = WindowManager.getIDList();
for(int id : ids) {
ImagePlus imp = WindowManager.getImage(id);
if (imp != null)
imp.close();
}
}
public static Object DIV(Object arrayImage, Object arrayPSF) {
return DIV(arrayImage, arrayPSF, "");
}
public static Object DIV(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm DIV " + options;
Deconvolution d = new Deconvolution("Matlab DIV", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object CONV(Object arrayImage, Object arrayPSF) {
return CONV(arrayImage, arrayPSF, "");
}
public static Object CONV(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm CONV " + options;
Deconvolution d = new Deconvolution("Matlab CONV", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object NIF(Object arrayImage, Object arrayPSF) {
return NIF(arrayImage, arrayPSF, "");
}
public static Object NIF(Object arrayImage, Object arrayPSF, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm NIF " + options;
Deconvolution d = new Deconvolution("Matlab NIF", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object TRIF(Object arrayImage, Object arrayPSF, double regularizationFactor) {
return TRIF(arrayImage, arrayPSF, regularizationFactor, "");
}
public static Object TRIF(Object arrayImage, Object arrayPSF, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm TRIF " + regularizationFactor + " " + options;
Deconvolution d = new Deconvolution("Matlab TRIF", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RIF(Object arrayImage, Object arrayPSF, double regularizationFactor) {
return RIF(arrayImage, arrayPSF, regularizationFactor, "");
}
public static Object RIF(Object arrayImage, Object arrayPSF, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RIF " + regularizationFactor + " " + options;
Deconvolution d = new Deconvolution("Matlab RIF", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RL(Object arrayImage, Object arrayPSF, double itmax) {
return RL(arrayImage, arrayPSF, itmax, "");
}
public static Object RL(Object arrayImage, Object arrayPSF, double itmax, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RL " + itmax + " " + options;
Deconvolution d = new Deconvolution("Matlab RL", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object RLTV(Object arrayImage, Object arrayPSF, double itmax, double regularizationFactor) {
return RLTV(arrayImage, arrayPSF, itmax, regularizationFactor, "");
}
public static Object RLTV(Object arrayImage, Object arrayPSF, double itmax, double regularizationFactor, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm RLTV " + itmax + " " + regularizationFactor + " " + options;
Deconvolution d = new Deconvolution("Matlab RLTV", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object LW(Object arrayImage, Object arrayPSF, double itmax, double gamma) {
return LW(arrayImage, arrayPSF, itmax, gamma, "");
}
public static Object LW(Object arrayImage, Object arrayPSF, double itmax, double gamma, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm LW " + itmax + " " + gamma + " " + options;
Deconvolution d = new Deconvolution("Matlab LW", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object NNLS(Object arrayImage, Object arrayPSF, double itmax, double gamma) {
return NNLS(arrayImage, arrayPSF, itmax, gamma, "");
}
public static Object NNLS(Object arrayImage, Object arrayPSF, double itmax, double gamma, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm NNLS " + itmax + " " + options;
Deconvolution d = new Deconvolution("Matlab NNLS", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object BVLS(Object arrayImage, Object arrayPSF, double itmax, double gamma) {
return BVLS(arrayImage, arrayPSF, itmax, gamma, "");
}
public static Object BVLS(Object arrayImage, Object arrayPSF, double itmax, double gamma, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm BVLS " + itmax + " " + options;
Deconvolution d = new Deconvolution("Matlab BVLS", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object TM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda) {
return TM(arrayImage, arrayPSF, itmax, gamma, lambda, "");
}
public static Object TM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm TM " + itmax + " " + gamma + " " + lambda + " " + options;
Deconvolution d = new Deconvolution("Matlab TM", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
public static Object ICTM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda) {
return ICTM(arrayImage, arrayPSF, itmax, gamma, lambda, "");
}
public static Object ICTM(Object arrayImage, Object arrayPSF, double itmax, double gamma, double lambda, String options) {
RealSignal image = Converter.createRealSignal(arrayImage);
RealSignal psf = Converter.createRealSignal(arrayPSF);
String command = " -algorithm ICTM " + itmax + " " + gamma + " " + lambda + " " + options;
Deconvolution d = new Deconvolution("Matlab ICTM", command);
RealSignal result = d.deconvolve(image, psf);
return Converter.createObject(result);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index 693f8a5..e854461 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.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/>.
*/
import java.io.File;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
-import deconvolutionlab.Imaging;
-import deconvolutionlab.Imaging.Platform;
+import deconvolutionlab.Imager;
+import deconvolutionlab.Imager.Platform;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2 {
public static String ack = Constants.name + " " + Constants.version + " " + Constants.copyright;
public static void main(String arg[]) {
System.out.println(ack);
Lab.init(Platform.STANDALONE);
if (arg.length == 0) {
System.out.println("Starting lab");
lab(arg);
return;
}
String flag = arg[0].trim().toLowerCase();
if (flag.equalsIgnoreCase("help")) {
System.out.println("Starting help");
help();
return;
}
else if (flag.equalsIgnoreCase("lab")) {
System.out.println("Starting lab");
lab(arg);
}
else if (flag.equalsIgnoreCase("fft")) {
System.out.println("Starting fft");
Lab.checkFFT(Monitors.createDefaultMonitor());
}
else if (flag.equalsIgnoreCase("run")) {
System.out.println("Starting run");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Run", cmd, Deconvolution.Finish.KILL).deconvolve();
}
else if (flag.equalsIgnoreCase("launch")) {
System.out.println("Starting launch");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Launch", cmd, Deconvolution.Finish.KILL).launch();
}
else
System.out.println("" + flag + " command not found");
}
private static void lab(String arg[]) {
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
if (arg.length >= 2) {
String filename = arg[1].trim();
File file = new File(filename);
if (file.exists())
if (file.isFile())
if (file.canRead())
config = filename;
}
Lab.init(Platform.STANDALONE, config);
LabDialog dialog = new LabDialog();
dialog.setVisible(true);
}
public static void help() {
System.out.println("More info:" + Constants.url);
System.out.println("Syntax:");
System.out.println("java -jar DeconvolutionLab_2.jar lab");
System.out.println("java -jar DeconvolutionLab_2.jar run {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar launch {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar fft");
System.out.println("java -jar DeconvolutionLab_2.jar info");
System.out.println("java -jar DeconvolutionLab_2.jar help");
System.out.println("{command} is the full command line for running a deconvolution");
System.out.println("Keywords of {command}: ");
for (String keyword : Command.keywords)
System.out.println("\t" + keyword);
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
- Lab.init(Imaging.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
new Deconvolution("CommandLine", cmd).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java b/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
index c83d1cf..141022c 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_FFT.java
@@ -1,44 +1,44 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_FFT implements PlugIn {
@Override
public void run(String arg) {
- Lab.init(Imaging.Platform.IMAGEJ);
+ Lab.init(Imager.Platform.IMAGEJ);
Lab.checkFFT(Monitors.createDefaultMonitor());
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Help.java b/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
index 9b96214..22ff1ab 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Help.java
@@ -1,43 +1,43 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Help implements PlugIn {
@Override
public void run(String arg) {
- Lab.init(Imaging.Platform.IMAGEJ);
+ Lab.init(Imager.Platform.IMAGEJ);
Lab.help();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java b/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
index 0b1b749..88d8d5f 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Lab.java
@@ -1,48 +1,48 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import ij.IJ;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Lab implements PlugIn {
@Override
public void run(String arg) {
- Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
LabDialog dlg = new LabDialog();
Lab.setVisible(dlg, false);
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
index e387cd7..3fed0c2 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Launch.java
@@ -1,54 +1,54 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import deconvolution.Deconvolution;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Launch implements PlugIn {
@Override
public void run(String arg) {
- Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
if (Macro.getOptions() == null) {
LabDialog dlg = new LabDialog();
Lab.setVisible(dlg, false);
}
else
new Deconvolution("Macro", Macro.getOptions()).launch();
}
}
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
index 431fca0..507b7bc 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2_Run.java
@@ -1,54 +1,54 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import deconvolution.Deconvolution;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import ij.IJ;
import ij.Macro;
import ij.plugin.PlugIn;
public class DeconvolutionLab2_Run implements PlugIn {
@Override
public void run(String arg) {
- Lab.init(Imaging.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.IMAGEJ, IJ.getDirectory("plugins") + File.separator + "DeconvolutionLab2.config");
if (Macro.getOptions() == null) {
LabDialog dlg = new LabDialog();
Lab.setVisible(dlg, false);
}
else
new Deconvolution("Run", Macro.getOptions()).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/bilib/tools/WebBrowser.java b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
index f3838c3..e516788 100644
--- a/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
+++ b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
@@ -1,63 +1,61 @@
/*
* 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 bilib.tools;
import java.awt.Desktop;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class WebBrowser {
public static boolean open(String url) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL(url).toURI());
return true;
}
catch (Exception e) {
e.printStackTrace();
}
}
-
JFrame frame = new JFrame("Help");
JLabel lbl = new JLabel(url);
frame.add(lbl);
frame.pack();
- frame.setVisible(true);
-
+ frame.setVisible(true);
return false;
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
index a186c0e..9a85f11 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_Course_SpectralAnaylsis.java
@@ -1,190 +1,190 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package course;
import java.io.File;
import javax.swing.filechooser.FileSystemView;
import deconvolution.Deconvolution;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
import ij.plugin.PlugIn;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.factory.DoG;
import signal.factory.Gaussian;
import signal.factory.complex.ComplexSignalFactory;
public class DeconvolutionLab2_Course_SpectralAnaylsis implements PlugIn {
private String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath() + File.separator + "Desktop";
private String root = desktop + File.separator + "Deconvolution" + File.separator;
private String res = root + "results" + File.separator + "star" + File.separator;
private String data = root + "data" + File.separator + "star" + File.separator;
public DeconvolutionLab2_Course_SpectralAnaylsis() {
new File(res).mkdir();
System.setProperty("user.dir", res);
new File(res + "TRIF").mkdir();
new File(res + "TRIF-FILTER").mkdir();
new File(res + "RIF").mkdir();
new File(res + "RIF-FILTER").mkdir();
new File(res + "LW").mkdir();
new File(res + "LW-ITER").mkdir();
new File(res + "LW+").mkdir();
new File(res + "LW+-ITER").mkdir();
new File(res + "RL").mkdir();
new File(res + "RL-ITER").mkdir();
new File(res + "NOISELESS").mkdir();
new File(res + "PERTURBATION").mkdir();
new File(res + "SIMULATION").mkdir();
new File(res + "ICTM").mkdir();
new File(res + "ICTM-ITER").mkdir();
Monitors monitors = Monitors.createDefaultMonitor();
int nx = 256;
int ny = 256;
int nz = 1;
String size = " size " + nx + " " + ny + " " + nz;
double noise = 0.04;
double poisson = 0.01;
double wiener = Math.sqrt(noise * 2.0 / Math.PI);
System.out.println("Wiener value " + wiener);
AbstractFFT fft = FFT.createDefaultFFT(monitors, nx, ny, nz);
ComplexSignal L = ComplexSignalFactory.laplacian(nx, ny, nz);
RealSignal laplacian = fft.inverse(L).circular().rescale(monitors);
- Lab.save(monitors, laplacian, res + "laplacian.tif", Imaging.Type.BYTE);
+ Lab.save(monitors, laplacian, res + "laplacian.tif", Imager.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("run", psf + image + algo).deconvolve();
algo = " -algorithm CONV " + out("CONV-PERTURBATED");
new Deconvolution("run", psf + image + algo).deconvolve();
ComplexSignal H = fft.transform(h);
ComplexSignal H2 = Operations.multiply(H, H);
ComplexSignal LP = ComplexSignalFactory.laplacian(nx, ny, nz);
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("SIM");
new Deconvolution("run", psf + image + algo).deconvolve();
algo = " -algorithm SIM " + (6*noise) + " " + noise + " " + poisson + " " + out("NOISE");
new Deconvolution("run", impulse + constant + algo).deconvolve();
// No Noise
String nonoise = " -image file CONV.tif -psf file psfPerturbated.tif";
new Deconvolution("run", nonoise + " -algorithm TRIF " + wiener + out("NOISELESS/WIF")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E0 " + out("NOISELESS/NIF0")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-3 " + out("NOISELESS/NIF-1")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-6 " + out("NOISELESS/NIF-6")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-9 " + out("NOISELESS/NIF-9")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm NIF -epsilon 1E-12 " + out("NOISELESS/NIF-12")).deconvolve();
new Deconvolution("run", nonoise + " -algorithm DIV " + out("NOISELESS/DIV")).deconvolve();
// Pertubatation
String pertubation = " -image file CONV.tif -psf file psfPerturbated.tif";
new Deconvolution("run", pertubation + " -algorithm TRIF " + wiener + out("PERTURBATION/WIF")).deconvolve();
new Deconvolution("run", pertubation + " -algorithm NIF " + out("PERTURBATION/NIF")).deconvolve();
new Deconvolution("run", pertubation + " -algorithm DIV " + out("PERTURBATION/DIV")).deconvolve();
// Noisy
String simulation = " -image file SIM.tif " + psf;
new Deconvolution("run", simulation + " -algorithm TRIF " + wiener + out("SIMULATION/WIF")).deconvolve();
new Deconvolution("run", simulation + " -algorithm NIF "+ out("SIMULATION/NIF")).deconvolve();
new Deconvolution("run", simulation + " -algorithm DIV" + out("SIMULATION/DIV")).deconvolve();
algo = " -algorithm LW+ 100 0.5 -out mip @1 LW+-ITER/I ";
new Deconvolution("run", simulation + algo + out("LW+/LW+")).deconvolve();
new File(res + "LW+-ITER/I.tif").delete();
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "RIF/RIF" + String.format("%02d", i);
new Deconvolution("run", simulation + " -algorithm RIF " + p + out(name)).deconvolve();
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "RIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
for(int i=0; i<=20; i++) {
double p = Math.pow(5, i-12);
String name = "TRIF/TRIF" + String.format("%02d", i);
new Deconvolution("run", simulation + " -algorithm TRIF " + p + out(name)).deconvolve();
RealSignal fa = fft.inverse(Operations.add(H2, Operations.multiply(p, LP, LP))).circular();
Lab.save(monitors, fa, res + "TRIF-FILTER/RIF" + String.format("%02d", i) + ".tif");
}
algo = " -algorithm RL 100 -out mip @1 RL-ITER/I ";
new Deconvolution("run", simulation + algo + out("RL/RL")).deconvolve();
new File(res + "RL-ITER/I.tif").delete();
algo = " -algorithm ICTM 100 1.5 0.001 -out mip @1 ICTM-ITER/I ";
new Deconvolution("run", simulation + algo + out("ICTM/ICTM")).deconvolve();
new File(res + "ICTM-ITER/I.tif").delete();
}
private static String out(String name) {
return " -out stats " + name +
" -out stack " + name + " noshow -out ortho " + name + "-BYTE rescaled byte noshow";
}
public static void main(String arg[]) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_Course_SpectralAnaylsis();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index bdfa307..ebafedf 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,268 +1,269 @@
/*
* 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 bilib.tools.NumFormat;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h;
/**
* The controller takes the control of the algorithm, in particular to do
* some operations at the starting, at every iteration and at the end.
*/
protected Controller controller;
/** This is the FFT used. */
protected AbstractFFT fft ;
protected Monitors monitors;
protected AbstractFFTLibrary fftlib;
protected boolean threaded;
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint;
public AbstractAlgorithm() {
this.controller = new Controller();
monitors = Monitors.createDefaultMonitor();
fftlib = FFT.getFastestFFT();
optimizedMemoryFootprint = true;
threaded = true;
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract String[] getShortnames();
public abstract double getMemoryFootprintRatio();
public abstract int getComplexityNumberofFFT();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract void setParameters(double[] params);
public abstract double getRegularizationFactor();
public abstract double getStepFactor();
public abstract double[] getParameters();
public abstract double[] getDefaultParameters();
public RealSignal run(RealSignal image, RealSignal psf) {
return run(image, psf, new Padding(), new Apodization(), 1);
}
public RealSignal run(RealSignal image, RealSignal psf, Padding pad, Apodization apo) {
return run(image, psf, pad, apo, 1);
}
public RealSignal run(RealSignal image, RealSignal psf, Padding pad, Apodization apo, double norm) {
if (image == null)
return null;
if (psf == null)
return null;
if (fftlib != null)
fft = FFT.createFFT(monitors, fftlib, image.nx, image.ny, image.nz);
else
fft = FFT.createDefaultFFT(monitors, image.nx, image.ny, image.nz);
controller.setFFT(fft);
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
monitors.log(getShortnames()[0] + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
controller.start(y);
h.circular();
if (fft == null)
fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
else
fft.init(monitors, y.nx, y.ny, y.nz);
monitors.log(getShortnames()[0] + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortnames()[0] + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
x.setName("x");
controller.finish(x);
monitors.log(getName() + " is finished");
SignalCollector.free(y);
SignalCollector.free(h);
RealSignal result = pad.crop(monitors, x);
SignalCollector.free(x);
+ result.setName("Output of " + this.getShortnames()[0]);
return result;
}
public Monitors getMonitors() {
return monitors;
}
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
public AbstractFFT getFFT() {
return fft;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void setFFT(AbstractFFTLibrary fftlib) {
this.fftlib = fftlib;
}
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for (int i = 0; i < p.length; i++)
if (i == p.length - 1)
param += p[i];
else
param += p[i] + ", ";
return param;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Imaging.java b/DeconvolutionLab2/src/deconvolutionlab/Imager.java
similarity index 86%
rename from DeconvolutionLab2/src/deconvolutionlab/Imaging.java
rename to DeconvolutionLab2/src/deconvolutionlab/Imager.java
index 5947a2d..d3c86f3 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Imaging.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Imager.java
@@ -1,97 +1,97 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.util.ArrayList;
import javax.swing.JDialog;
import imagej.IJImager;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-public abstract class Imaging {
+public abstract class Imager {
public enum Type {FLOAT, SHORT, BYTE};
public enum Platform {IMAGEJ, ICY, STANDALONE, MATLAB};
public class ContainerImage {
public Object object;
}
public abstract void setVisible(JDialog dialog, boolean modal);
public abstract Platform getPlatform();
- public abstract RealSignal create();
- public abstract RealSignal create(String name);
+ public abstract RealSignal getActiveImage();
+ public abstract RealSignal getImageByName(String name);
public abstract ContainerImage createContainer(String title);
public abstract void show(ComplexSignal signal, String title, ComplexComponent complex);
- public abstract void show(RealSignal signal, String title, Imaging.Type type, int z);
+ public abstract void show(RealSignal signal, String title, Imager.Type type, int z);
public abstract void append(ContainerImage container, RealSignal signal, String title, Type type);
public abstract void save(RealSignal signal, String filename, Type type);
public abstract RealSignal open(String filename);
public abstract String getName();
public abstract String getSelectedImage();
public abstract boolean isSelectable();
- public static ArrayList<Imaging> getImagings() {
- ArrayList<Imaging> imagings = new ArrayList<Imaging>();
+ public static ArrayList<Imager> getImagings() {
+ ArrayList<Imager> imagings = new ArrayList<Imager>();
try {
- Imaging imaging = new IJImager();
+ Imager imaging = new IJImager();
if (imaging != null) {
imagings.add(imaging);
}
}
catch (NoClassDefFoundError ex) {
}
try {
- Imaging imaging = new IcyImager();
+ Imager imaging = new IcyImager();
if (imaging != null) {
imagings.add(imaging);
}
}
catch (NoClassDefFoundError ex) {
}
return imagings;
}
public static ArrayList<String> getImagingByName() {
- ArrayList<Imaging> imagings = getImagings();
+ ArrayList<Imager> imagings = getImagings();
ArrayList<String> names = new ArrayList<String>();
- for (Imaging imaging : imagings)
+ for (Imager imaging : imagings)
names.add(imaging.getName());
return names;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index 44433ba..71510bd 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,354 +1,526 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
import java.util.regex.Pattern;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import bilib.tools.NumFormat;
import bilib.tools.WebBrowser;
-import deconvolutionlab.Imaging.ContainerImage;
+import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import imagej.IJImager;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.SignalFactory;
import signal.factory.Sphere;
+/**
+ * This class contains a collection of useful static methods to manage all the
+ * peripherical aspects of the deconvolution, such as load, display, or save an
+ * image.
+ * <p>
+ * At the construction of the class, the config is loaded. In practice, any
+ * deconvolution program has to start with Lab.init(Platform).
+ *
+ * @author Daniel Sage
+ *
+ */
+
public class Lab {
- private static Imaging imaging;
- private static ArrayList<JFrame> frames;
- private static ArrayList<JDialog> dialogs;
+ private static Imager imaging;
+ private static ArrayList<JFrame> frames;
+ private static ArrayList<JDialog> dialogs;
static {
frames = new ArrayList<JFrame>();
dialogs = new ArrayList<JDialog>();
imaging = new IJImager();
Config.init(System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
- public static Imaging.Platform getPlatform() {
- return imaging.getPlatform();
- }
-
- public static void init(Imaging.Platform p) {
- init(p, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ /**
+ * Initializes the Lab with a give platform.
+ *
+ * @param platform
+ * The platform is ImageJ, ICY, or Matlab.
+ */
+ public static void init(Imager.Platform platform) {
+ init(platform, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
- public static void init(Imaging.Platform platform, String config) {
+ /**
+ * Initializes the Lab with a give platform and a given configuration file
+ *
+ * @param platform
+ * @param configFilename
+ */
+ public static void init(Imager.Platform platform, String configFilename) {
switch (platform) {
case IMAGEJ:
imaging = new IJImager();
break;
case ICY:
imaging = new IcyImager();
break;
default:
imaging = new IJImager();
break;
}
-
- Config.init(System.getProperty("user.dir")+File.separator+"DeconvolutionLab2.config");
+
+ Config.init(configFilename);
}
+ /**
+ * Returns the platform.
+ *
+ * @return
+ */
+ public static Imager.Platform getPlatform() {
+ return imaging.getPlatform();
+ }
+
+ /**
+ * Open a web page on the DeconvolutionLab2.
+ */
public static void help() {
WebBrowser.open(Constants.url);
}
+ /**
+ * Checks the installed FFT libraries on a small (40, 30, 20) signal.
+ *
+ * @param monitors
+ */
public static void checkFFT(Monitors monitors) {
-
ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
- for (int k = 1; k <= 3; k++)
- for (AbstractFFTLibrary library : libraries) {
- RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
- double chrono = System.nanoTime();
- AbstractFFT fft = library.getDefaultFFT();
- fft.init(monitors, y.nx, y.ny, y.nz);
- RealSignal x = fft.inverse(fft.transform(y));
- chrono = System.nanoTime() - chrono;
- double residu = y.getEnergy() - x.getEnergy();
- monitors.log(fft.getName() + " Test " + k);
- monitors.log("\t residu of reconstruction: " + residu);
- monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
- }
+ for (AbstractFFTLibrary library : libraries) {
+ RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
+ double chrono = System.nanoTime();
+ AbstractFFT fft = library.getDefaultFFT();
+ fft.init(monitors, y.nx, y.ny, y.nz);
+ RealSignal x = fft.inverse(fft.transform(y));
+ chrono = System.nanoTime() - chrono;
+ double residu = y.getEnergy() - x.getEnergy();
+ monitors.log("\t residu of reconstruction: " + residu);
+ monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
+ }
}
public static ContainerImage createContainer(Monitors monitors, String title) {
monitors.log("Create Live Real Signal " + title);
return imaging.createContainer(title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title) {
- imaging.append(container, signal, title, Imaging.Type.FLOAT);
+ imaging.append(container, signal, title, Imager.Type.FLOAT);
monitors.log("Add Live Real Signal " + title);
}
- public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imaging.Type type) {
+ public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imager.Type type) {
imaging.append(container, signal, title, type);
monitors.log("Add Live Real Signal " + title);
}
+ /**
+ * Displays a the module of complex signal.
+ *
+ * @param monitors
+ * @param signal
+ * @param title
+ */
public static void show(Monitors monitors, ComplexSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, ComplexComponent.MODULE);
}
- public static void show(Monitors monitors, ComplexSignal signal, String title, ComplexComponent complex) {
+ /**
+ * Displays a real 3D signal a z-stack of images.
+ *
+ * @param signal
+ */
+ public static void show(RealSignal signal) {
if (signal == null) {
- monitors.error("Show " + title + " this image does not exist.");
return;
}
- monitors.log("Show Real Signal " + title);
- imaging.show(signal, title, complex);
+ imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
}
+ /**
+ * Displays a real 3D signal a z-stack of images.
+ *
+ * @param monitors
+ * @param signal
+ */
+ public static void show(Monitors monitors, RealSignal signal) {
+ if (signal == null) {
+ monitors.error("This image does not exist.");
+ return;
+ }
+ monitors.log("Show Real Signal " + signal.name);
+ imaging.show(signal, signal.name, Imager.Type.FLOAT, signal.nz / 2);
+ }
+
+ /**
+ * Displays a real 3D signal a z-stack of images.
+ *
+ * @param monitors
+ * @param signal
+ * @param title
+ */
public static void show(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
- imaging.show(signal, title, Imaging.Type.FLOAT, signal.nz / 2);
- }
-
- public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type) {
+ imaging.show(signal, title, Imager.Type.FLOAT, signal.nz / 2);
+ }
+
+ /**
+ * Displays a real 3D signal a z-stack of images using a given type.
+ *
+ * @param monitors
+ * @param signal
+ * @param title
+ * @param type
+ */
+ public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, signal.nz / 2);
}
- public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type, int z) {
+ /**
+ * Displays a real 3D signal a z-stack of images using a given type and
+ * shows the slice number z.
+ *
+ * @param monitors
+ * @param signal
+ * @param title
+ * @param type
+ * @param z
+ */
+ public static void show(Monitors monitors, RealSignal signal, String title, Imager.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, z);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
- imaging.save(signal, filename, Imaging.Type.FLOAT);
+ imaging.save(signal, filename, Imager.Type.FLOAT);
monitors.log("Save Real Signal " + filename);
}
- public static void save(Monitors monitors, RealSignal signal, String filename, Imaging.Type type) {
+ public static void save(Monitors monitors, RealSignal signal, String filename, Imager.Type type) {
imaging.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
-
public static RealSignal createSynthetic(Monitors monitors, String cmd) {
RealSignal signal = SignalFactory.createFromCommand(cmd);
if (signal == null)
monitors.error("Unable to create " + cmd);
else
monitors.log("Create " + cmd);
return signal;
}
+ /**
+ * Return the active image.
+ *
+ * @param monitors
+ * @return
+ */
+ public static RealSignal getImage() {
+ return getImager().getActiveImage();
+ }
+
+ /**
+ * Return an image from the platform with a specified name.
+ *
+ * @param monitors
+ * @return
+ */
+ public static RealSignal getImage(String name) {
+ return getImager().getImageByName(name);
+ }
+
+ /**
+ * Return an image from the platform with a specified name.
+ *
+ * @param monitors
+ * @param name
+ * @return
+ */
public static RealSignal getImage(Monitors monitors, String name) {
- RealSignal signal = getImager().create(name);
+ RealSignal signal = getImager().getImageByName(name);
if (signal == null)
monitors.error("Unable to get " + name);
else
monitors.log("Load " + name);
return signal;
}
+ /**
+ * Open an image from the disk.
+ *
+ * @param monitors
+ * @param filename
+ * @return
+ */
+ public static RealSignal openFile(String filename) {
+ return imaging.open(filename);
+ }
+
+ /**
+ * Open an image from the disk.
+ *
+ * @param monitors
+ * @param filename
+ * @return
+ */
public static RealSignal openFile(Monitors monitors, String filename) {
RealSignal signal = imaging.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
+ /**
+ * Open a series of image from a directory.
+ *
+ * @param path
+ * @return
+ */
+ public static RealSignal openDir(String path) {
+ return openDir(Monitors.createDefaultMonitor(), path);
+ }
+
+ /**
+ * Open a series of image from a directory.
+ *
+ * @param monitors
+ * @param path
+ * @return
+ */
public static RealSignal openDir(Monitors monitors, String path) {
-
String parts[] = path.split(" pattern ");
String dirname = path;
String regex = "";
if (parts.length == 2) {
dirname = parts[0].trim();
regex = parts[1].trim();
}
File file = new File(dirname + File.separator);
if (!file.isDirectory()) {
monitors.error("Dir " + dirname + " is not a directory.");
return null;
}
String[] list = file.list();
ArrayList<RealSignal> slices = new ArrayList<RealSignal>();
int nx = 0;
int ny = 0;
Pattern pattern = Pattern.compile(regex);
for (String filename : list) {
if (pattern.matcher(filename).find()) {
RealSignal slice = imaging.open(dirname + File.separator + filename);
if (slice != null) {
slices.add(slice);
nx = Math.max(nx, slice.nx);
ny = Math.max(ny, slice.ny);
monitors.log("Image " + path + File.separator + filename + " is loaded.");
}
}
else {
monitors.error("Error in loading image " + path + File.separator + filename);
}
}
int nz = slices.size();
if (nz <= 0) {
monitors.error("Dir " + path + " do no contain valid images.");
return null;
}
RealSignal signal = new RealSignal(file.getName(), nx, ny, nz);
for (int z = 0; z < slices.size(); z++)
signal.setSlice(z, slices.get(z));
return signal;
}
+ public static void showOrthoview(RealSignal signal, String title, int hx, int hy, int hz) {
+ if (signal == null) {
+ return;
+ }
+ imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
+ }
+
public static void showOrthoview(Monitors monitors, RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
- imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.Type.FLOAT, 0);
+ imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
+ public static void showOrthoview(RealSignal signal) {
+ if (signal == null) {
+ return;
+ }
+ int hx = signal.nx / 2;
+ int hy = signal.ny / 2;
+ int hz = signal.nz / 2;
+ imaging.show(signal.createOrthoview(hx, hy, hz), signal.name, Imager.Type.FLOAT, 0);
+ }
+
public static void showOrthoview(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
- imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.Type.FLOAT, 0);
+ imaging.show(signal.createOrthoview(hx, hy, hz), title, Imager.Type.FLOAT, 0);
}
+ public static void showMIP(RealSignal signal) {
+ if (signal == null) {
+ return;
+ }
+ imaging.show(signal.createMIP(), signal.name, Imager.Type.FLOAT, 0);
+ }
+
public static void showMIP(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show MIP " + title + " this image does not exist.");
return;
}
- imaging.show(signal.createMIP(), title, Imaging.Type.FLOAT, 0);
+ imaging.show(signal.createMIP(), title, Imager.Type.FLOAT, 0);
}
- public static void showMontage(Monitors monitors, RealSignal signal, String title) {
+ public static void showPlanar(RealSignal signal) {
if (signal == null) {
- monitors.error("Show Montage " + title + " this image does not exist.");
return;
}
- imaging.show(signal.createMontage(), title, Imaging.Type.FLOAT, 0);
+ imaging.show(signal.createMontage(), signal.name, Imager.Type.FLOAT, 0);
}
-
+
+ public static void showPlanar(Monitors monitors, RealSignal signal, String title) {
+ if (signal == null) {
+ monitors.error("Show Planar " + title + " this image does not exist.");
+ return;
+ }
+ imaging.show(signal.createMontage(), title, Imager.Type.FLOAT, 0);
+ }
+/*
public static RealSignal create(Monitors monitors, String name) {
RealSignal signal = imaging.create(name);
if (signal != null)
monitors.log("Created the real signal " + name + " " + signal.toString());
else
monitors.error("Impossible to create the real signal " + name);
return signal;
}
public static RealSignal create(Monitors monitors) {
RealSignal signal = imaging.create();
if (signal != null)
monitors.log("Created the real signal from the active window " + signal.toString());
else
monitors.error("Impossible to create the real signal from the active window");
return signal;
}
-
- public static Imaging getImager() {
+*/
+ public static Imager getImager() {
return imaging;
}
public static String getActiveImage() {
if (imaging.isSelectable())
return imaging.getSelectedImage();
return "";
}
-
+
public static void setVisible(JDialog dialog, boolean modal) {
if (dialog == null)
return;
dialogs.add(dialog);
imaging.setVisible(dialog, modal);
}
-
+
public static void setVisible(JPanel panel, String name, int x, int y) {
JFrame frame = new JFrame(name);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocation(x, y);
frame.setVisible(true);
frames.add(frame);
}
public static void setVisible(JFrame frame) {
frames.add(frame);
frame.setVisible(true);
}
-
+
public static void close() {
- for(JFrame frame : frames)
+ for (JFrame frame : frames)
if (frame != null)
frame.dispose();
- for(JDialog dialog : dialogs)
+ for (JDialog dialog : dialogs)
if (dialog != null)
dialog.dispose();
}
-
-
-
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabDialog.java b/DeconvolutionLab2/src/deconvolutionlab/LabDialog.java
index acac0b2..e2da2a5 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabDialog.java
@@ -1,145 +1,145 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.system.SystemInfo;
public class LabDialog extends JDialog implements ComponentListener, ActionListener, WindowListener {
private LabPanel panel;
private JButton bnClose = new JButton("Close");
public LabDialog() {
super(new JFrame(), Constants.name);
Config.registerFrame("DeconvolutionLab", "MainDialog", this);
panel = new LabPanel(bnClose);
getContentPane().add(panel);
pack();
addWindowListener(this);
addComponentListener(this);
bnClose.addActionListener(this);
Rectangle rect = Config.getDialog("DeconvolutionLab.MainDialog");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
if (rect.width > 0 && rect.height > 0)
setPreferredSize(new Dimension(rect.width, rect.height));
this.setMinimumSize(new Dimension(500, 400));
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnClose) {
Config.store();
SystemInfo.close();
panel.close();
dispose();
return;
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
panel.close();
Config.store();
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
@Override
public void dispose() {
super.dispose();
- if (Lab.getPlatform() == Imaging.Platform.STANDALONE)
+ if (Lab.getPlatform() == Imager.Platform.STANDALONE)
System.exit(0);
}
@Override
public void componentResized(ComponentEvent e) {
panel.sizeModule();
}
@Override
public void componentMoved(ComponentEvent e) {
Point p = this.getLocation();
p.x += this.getWidth();
DeconvolutionDialog.setLocationLaunch(p);
}
@Override
public void componentShown(ComponentEvent e) {
panel.sizeModule();
pack();
}
@Override
public void componentHidden(ComponentEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index d7106f7..05d9042 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,370 +1,370 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import bilib.tools.NumFormat;
import deconvolution.algorithm.Controller;
-import deconvolutionlab.Imaging.ContainerImage;
+import deconvolutionlab.Imager.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import signal.Constraint;
import signal.RealSignal;
public class Output {
public enum View {
STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE
};
public enum Dynamic {
INTACT, RESCALED, NORMALIZED, CLIPPED
};
private ContainerImage container = null;
private int px = 0;
private int py = 0;
private int pz = 0;
private boolean center = true;
private String name = "";
private boolean save = true;
private boolean show = true;
private View view = View.STACK;
- private Imaging.Type type = Imaging.Type.FLOAT;
+ private Imager.Type type = Imager.Type.FLOAT;
private Dynamic dynamic = Dynamic.INTACT;
private int frequency = 0;
private String path = "";
public Output(View view, int frequency, String param) {
String[] tokens = param.trim().split(" ");
this.view = view;
this.frequency = frequency;
this.name = "";
this.center = true;
this.save = true;
this.show = true;
this.container = Lab.createContainer(Monitors.createDefaultMonitor(), "");
for (int i = 0; i < tokens.length; i++) {
boolean found = false;
String p = tokens[i].trim().toLowerCase();
if (p.startsWith("@")) {
found = true;
}
if (p.startsWith("noshow")) {
show = false;
found = true;
}
if (p.startsWith("nosave")) {
save = false;
found = true;
}
for (Dynamic d : Dynamic.values()) {
if (p.toLowerCase().equals(d.name().toLowerCase())) {
dynamic = d;
found = true;
}
}
for (View v : View.values()) {
if (p.toLowerCase().equals(v.name().toLowerCase())) {
view = v;
found = true;
}
}
- for (Imaging.Type t : Imaging.Type.values()) {
+ for (Imager.Type t : Imager.Type.values()) {
if (p.toLowerCase().equals(t.name().toLowerCase())) {
type = t;
found = true;
}
}
if (p.startsWith("(") && p.endsWith(")")) {
double pos[] = NumFormat.parseNumbers(p);
if (pos.length > 0)
px = (int) Math.round(pos[0]);
if (pos.length > 1)
py = (int) Math.round(pos[1]);
if (pos.length > 2)
pz = (int) Math.round(pos[2]);
found = true;
center = false;
}
if (!found)
name += tokens[i] + " ";
name = name.trim();
}
}
- public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.Type type, boolean center) {
+ public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, boolean center) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = center;
this.frequency = frequency;
}
- public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.Type type, int px, int py, int pz) {
+ public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imager.Type type, int px, int py, int pz) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = false;
this.px = px;
this.py = py;
this.pz = pz;
this.frequency = frequency;
}
public boolean is(int iterations) {
if (frequency == 0)
return false;
return iterations % frequency == 0;
}
public View getView() {
return view;
}
public String getName() {
return name;
}
public void setPath(String path) {
this.path = path;
}
public int extractFrequency(String param) {
String line = param.trim();
if (!line.startsWith("@"))
line = "@0 " + line;
String parts[] = line.split(" ");
if (parts.length >= 1) {
return (int) Math.round(NumFormat.parseNumber(parts[0], 0));
}
return 0;
}
public void setKeypoint(int px, int py, int pz) {
this.px = px;
this.py = py;
this.pz = pz;
this.center = false;
}
public String[] getAsString() {
- String t = (type == Imaging.Type.FLOAT ? "" : type.name().toLowerCase());
+ String t = (type == Imager.Type.FLOAT ? "" : type.name().toLowerCase());
String d = (dynamic == Dynamic.INTACT ? "" : dynamic.name().toLowerCase());
String k = "";
if (!center)
k = " (" + px + "," + py + "," + pz + ")";
else
k = "";
String sa = save ? "\u2713" : "";
String sh = show ? "\u2713" : "";
String fr = frequency > 0 ? " @" + frequency : "";
return new String[] { view.name().toLowerCase() + fr, name, d, t, k, sh, sa, "\u232B" };
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, true, false, false, 0);
}
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, false, false, true, 0);
}
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
execute(monitors, signal, controller, false, true, false, iter);
}
public void execute(Monitors monitors, RealSignal signal, Controller controller, boolean start, boolean live, boolean finish, int iter) {
if (signal == null)
return;
String title = name;
if (live)
if (!is(iter))
return;
if (controller != null && live) {
if (controller.getIterations() > 0) {
title += "@" + controller.getIterations();
}
}
RealSignal x = null;
Constraint constraint = new Constraint(monitors);
switch (dynamic) {
case RESCALED:
x = signal.duplicate();
constraint.rescaled(x, 0, 255);
break;
case CLIPPED:
x = signal.duplicate();
float[] stats = controller.getStatsInput();
if (stats != null)
constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
float[] stats1 = controller.getStatsInput();
if (stats1 != null)
constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
String filename = path + File.separator + title + ".tif";
switch (view) {
case STACK:
if (show && !live)
Lab.show(monitors, x, title, type, (center ? x.nz / 2 : pz));
if (save && !live)
Lab.save(monitors, x, filename, type);
break;
case SERIES:
for (int k = 0; k < x.nz; k++) {
RealSignal slice = x.getSlice(k);
if (show && !live)
Lab.show(monitors, slice, title, type);
if (save && !live)
Lab.save(monitors, slice, filename, type);
}
break;
case ORTHO:
if (!start)
orthoview(monitors, x, title, filename, live);
break;
case FIGURE:
if (!start)
figure(monitors, x, title, filename, live);
break;
case MIP:
if (!start)
mip(monitors, x, title, filename, live);
break;
case PLANAR:
if (!start)
planar(monitors, x, title, filename, live);
break;
default:
break;
}
}
private void mip(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMIP();
if (show && live) {
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void orthoview(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createOrthoview(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void figure(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createFigure(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void planar(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMontage();
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
@Override
public String toString() {
String t = type.name().toLowerCase();
String v = view.name().toLowerCase();
String d = dynamic.name().toLowerCase();
String f = frequency > 0 ? " every " + frequency + " iterations" : "";
String k = (center ? "" : " keypoint = (" + px + "," + py + "," + pz + ")");
return v + " " + name + " format = (" + d + ", " + t + ") " + k + f;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 4b2c6fb..399ca5e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,274 +1,274 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.HTMLPane;
import bilib.component.SpinnerRangeInteger;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
import ij.gui.GUI;
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("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputDialog(View view) {
super(new JFrame(), "Create a new output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, 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(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 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);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
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);
}
@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()];
- Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
+ Imager.Type type = Imager.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;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
index 74797b5..6be394f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
@@ -1,267 +1,267 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import bilib.component.GridPanel;
import bilib.component.HTMLPane;
import bilib.component.SpinnerRangeInteger;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
public class OutputPanel extends JPanel 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("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputPanel(View view) {
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, 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(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 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);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
}
@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) {
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
- Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
+ Imager.Type type = Imager.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);
}
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;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index 34fe784..1e9e5b0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,353 +1,353 @@
/*
* 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 bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
- super("Image", "-image", (Lab.getPlatform() == Imaging.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
+ super("Image", "-image", (Lab.getPlatform() == Imager.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
- if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
+ if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
deconvolution.openImage();
if (stack) {
RealSignal x = deconvolution.getImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.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/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index 18594ca..43d9f18 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 bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
super("PSF", "-psf", "", "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
- if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
+ if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
- if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
+ if (Lab.getPlatform() == Imager.Platform.IMAGEJ)
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.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/imagej/IJImager.java b/DeconvolutionLab2/src/imagej/IJImager.java
index e20549c..02107a1 100644
--- a/DeconvolutionLab2/src/imagej/IJImager.java
+++ b/DeconvolutionLab2/src/imagej/IJImager.java
@@ -1,350 +1,350 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package 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.Imaging;
+import deconvolutionlab.Imager;
import ij.ImagePlus;
import ij.ImageStack;
import ij.WindowManager;
import ij.gui.GUI;
import ij.io.FileSaver;
import ij.io.Opener;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-public class IJImager extends Imaging {
+public class IJImager extends Imager {
@Override
public Platform getPlatform() {
- return Imaging.Platform.IMAGEJ;
+ return Imager.Platform.IMAGEJ;
}
@Override
public void setVisible(JDialog dialog, boolean modal) {
if (modal) {
dialog.setModal(modal);
GUI.center(dialog);
}
dialog.pack();
dialog.setVisible(true);
}
public static RealSignal create(ImagePlus imp) {
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
RealSignal signal = new RealSignal("ij-" + imp.getTitle(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
}
@Override
- public RealSignal create() {
+ public RealSignal getActiveImage() {
return build(WindowManager.getCurrentImage());
}
@Override
- public RealSignal create(String name) {
+ public RealSignal getImageByName(String name) {
ImagePlus imp = null;
if (name.equalsIgnoreCase("active"))
imp = WindowManager.getCurrentImage();
else
imp = WindowManager.getImage(name);
if (imp == null)
imp = WindowManager.getCurrentImage();
return build(imp);
}
@Override
public RealSignal open(String filename) {
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
if (imp == null)
return null;
return build(imp);
}
@Override
- public void show(RealSignal signal, String title, Imaging.Type type, int z) {
+ public void show(RealSignal signal, String title, Imager.Type type, int z) {
ImagePlus imp = build(signal, type);
if (imp != null) {
imp.setTitle(title);
int nz = imp.getStackSize();
imp.show();
imp.setSlice(Math.max(1, Math.min(nz, z)));
imp.getProcessor().resetMinAndMax();
}
}
public ContainerImage createContainer(String title) {
return new ContainerImage();
}
@Override
- public void append(ContainerImage container, RealSignal signal, String title, Imaging.Type type) { ImagePlus cont = (ImagePlus) container.object;
+ public void append(ContainerImage container, RealSignal signal, String title, Imager.Type type) { ImagePlus cont = (ImagePlus) container.object;
if (container.object == null) {
ImageStack stack = new ImageStack(signal.nx, signal.ny);
stack.addSlice(build(signal, type).getProcessor());
stack.addSlice(build(signal, type).getProcessor());
container.object = new ImagePlus(title, stack);
((ImagePlus)container.object).show();
}
else {
cont.getStack().addSlice(build(signal, type).getProcessor());
cont.setSlice(cont.getStack().getSize());
cont.updateAndDraw();
cont.getProcessor().resetMinAndMax();
}
}
@Override
- public void save(RealSignal signal, String filename, Imaging.Type type) {
+ public void save(RealSignal signal, String filename, Imager.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, ComplexComponent complex) {
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
switch (complex) {
case REAL:
plane = signal.getRealXY(k);
break;
case IMAGINARY:
plane = signal.getImagXY(k);
break;
case MODULE:
plane = signal.getModuleXY(k);
break;
default:
plane = signal.getModuleXY_dB(k);
}
stack.addSlice(new FloatProcessor(signal.nx, signal.ny, plane));
}
new ImagePlus(title, stack).show();
}
private RealSignal build(ImagePlus imp) {
if (imp == null)
return null;
int nx = imp.getWidth();
int ny = imp.getHeight();
int nz = imp.getStackSize();
RealSignal signal = new RealSignal("ij-" + imp.getTitle(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
ImageProcessor ip = imp.getStack().getProcessor(k + 1).convertToFloat();
signal.setXY(k, (float[]) ip.getPixels());
}
return signal;
}
- private ImagePlus build(RealSignal signal, Imaging.Type type) {
+ private ImagePlus build(RealSignal signal, Imager.Type type) {
if (signal == null)
return null;
ImageStack stack = new ImageStack(signal.nx, signal.ny);
for (int k = 0; k < signal.nz; k++) {
ImageProcessor ip = new FloatProcessor(signal.nx, signal.ny, signal.getXY(k));
switch (type) {
case BYTE:
stack.addSlice(ip.convertToByteProcessor(false));
break;
case SHORT:
stack.addSlice(ip.convertToShortProcessor(false));
break;
case FLOAT:
stack.addSlice(ip);
default:
break;
}
}
return new ImagePlus("", stack);
}
@Override
public String getName() {
return "ImageJ";
}
@Override
public boolean isSelectable() {
return true;
}
@Override
public String getSelectedImage() {
Dialog dialog = new Dialog();
dialog.setVisible(true);
if (dialog.wasCancel())
return "";
return dialog.getName();
}
public class Dialog extends JDialog implements ActionListener, WindowListener {
private JList<String> list;
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String name = "";
public Dialog() {
super(new JFrame(), "Image Selection");
JPanel bn = new JPanel(new GridLayout(1, 2));
bn.add(bnCancel);
bn.add(bnOK);
JPanel panel = new JPanel(new BorderLayout());
int[] ids = WindowManager.getIDList();
if (ids != null) {
DefaultListModel listModel = new DefaultListModel();
list = new JList(listModel);
for (int id : ids) {
ImagePlus idp = WindowManager.getImage(id);
if (idp != null) {
((DefaultListModel) listModel).addElement(idp.getTitle());
}
}
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
JScrollPane listScroller = new JScrollPane(list);
listScroller.setPreferredSize(new Dimension(250, 80));
panel.add(listScroller, BorderLayout.CENTER);
}
else {
panel.add(new JLabel("No open images."));
}
panel.add(bn, BorderLayout.SOUTH);
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
@Override
public void actionPerformed(ActionEvent e) {
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
if (e.getSource() == bnCancel) {
cancel = true;
name = "";
dispose();
return;
}
else if (e.getSource() == bnOK) {
cancel = false;
name = (String) list.getSelectedValue();
dispose();
}
}
public String getName() {
return name;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
name = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
index 4d5690b..2266eec 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Deconvolutionlab2.java
@@ -1,48 +1,48 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package plugins.sage.deconvolutionlab;
import java.io.File;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import icy.plugin.abstract_.PluginActionable;
public class Deconvolutionlab2 extends PluginActionable {
@Override
public void run() {
- Lab.init(Imaging.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
new DeconvolutionLabIcyFrame();
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
index 7a865c7..2825e66 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
@@ -1,227 +1,227 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package plugins.sage.deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JDialog;
import javax.swing.JFrame;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import icy.file.Saver;
import icy.gui.frame.IcyFrameEvent;
import icy.gui.frame.IcyFrameListener;
import icy.image.IcyBufferedImage;
import icy.imagej.ImageJUtil;
import icy.main.Icy;
import icy.sequence.Sequence;
import icy.type.DataType;
import icy.type.collection.array.Array1DUtil;
import ij.ImagePlus;
import ij.io.Opener;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-public class IcyImager extends Imaging {
+public class IcyImager extends Imager {
@Override
public Platform getPlatform() {
- return Imaging.Platform.ICY;
+ return Imager.Platform.ICY;
}
@Override
public void setVisible(JDialog dialog, boolean modal) {
/*
IcyFrame icf = new IcyFrame();
icf.addFrameListener(this);
icf.setTitle(dialog.getTitle());
//dialog.setModal(modal);
icf.add(dialog.getContentPane());
//icf.add(panel);
icf.toFront();
icf.addToDesktopPane();
icf.setVisible(true);
*/
//Lab.setVisible(dialog, true);
dialog.pack();
dialog.setLocation(30, 30);
dialog.setVisible(true);
}
public static RealSignal create(Sequence seq) {
int nx = seq.getSizeX();
int ny = seq.getSizeY();
int nz = seq.getSizeZ();
RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
@Override
- public RealSignal create() {
+ public RealSignal getActiveImage() {
return build(Icy.getMainInterface().getActiveSequence());
}
@Override
- public RealSignal create(String name) {
+ public RealSignal getImageByName(String name) {
ArrayList<Sequence> sequences = Icy.getMainInterface().getSequences(name);
for(Sequence sequence : sequences)
if (sequence.getName().equals(name))
return build(sequence);
return null;
}
@Override
public RealSignal open(String filename) {
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
Sequence seq = ImageJUtil.convertToIcySequence(imp, null);
return build(seq);
}
@Override
public void show(ComplexSignal signal, String title, ComplexComponent complex) {
Sequence sequence = new Sequence();
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
switch(complex) {
case REAL: plane = signal.getRealXY(k); break;
case IMAGINARY: plane = signal.getImagXY(k); break;
case MODULE: plane = signal.getModuleXY(k); break;
default: plane = signal.getModuleXY_dB(k);
}
IcyBufferedImage image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.FLOAT);
Array1DUtil.floatArrayToSafeArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, k, image);
}
sequence.setName(title);
Icy.getMainInterface().addSequence(sequence);
}
@Override
- public void save(RealSignal signal, String filename, Imaging.Type type) {
+ public void save(RealSignal signal, String filename, Imager.Type type) {
Sequence sequence = build(signal, type);
File file = new File(filename);
Saver.save(sequence, file, false, true);
}
private RealSignal build(Sequence seq) {
int nx = seq.getSizeX();
int ny = seq.getSizeY();
int nz = seq.getSizeZ();
RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
- private Sequence build(RealSignal signal, Imaging.Type type) {
+ private Sequence build(RealSignal signal, Imager.Type type) {
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
Sequence sequence = new Sequence();
for (int z = 0; z < nz; z++) {
- if (type == Imaging.Type.SHORT) {
+ if (type == Imager.Type.SHORT) {
short[] plane = Array1DUtil.arrayToShortArray(signal.data[z], false);
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.USHORT);
Array1DUtil.shortArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
- else if (type == Imaging.Type.BYTE) {
+ else if (type == Imager.Type.BYTE) {
byte[] plane = Array1DUtil.arrayToByteArray(signal.data[z]);
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.UBYTE);
Array1DUtil.byteArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
else {
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.FLOAT);
Array1DUtil.floatArrayToSafeArray(signal.data[z], image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
}
return sequence;
}
@Override
public String getName() {
return "Icy";
}
@Override
public ContainerImage createContainer(String title) {
// TODO Auto-generated method stub
return null;
}
@Override
public void append(ContainerImage container, RealSignal signal, String title, Type type) {
// TODO Auto-generated method stub
}
@Override
public void show(RealSignal signal, String title, Type type, int z) {
Sequence sequence = build(signal, type);
sequence.setName(title);
Icy.getMainInterface().addSequence(sequence);
}
@Override
public String getSelectedImage() {
return null;
}
@Override
public boolean isSelectable() {
return false;
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java
index d6feda5..855d303 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/Test.java
@@ -1,29 +1,29 @@
package plugins.sage.deconvolutionlab;
import java.io.File;
-import deconvolutionlab.Imaging;
+import deconvolutionlab.Imager;
import deconvolutionlab.Lab;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
import icy.gui.frame.IcyFrame;
import icy.plugin.abstract_.PluginActionable;
public class Test extends PluginActionable {
@Override
public void run() {
- Lab.init(Imaging.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
+ Lab.init(Imager.Platform.ICY, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
IcyFrame icf = new IcyFrame();
icf.add(new OutputDialog(View.FIGURE).getContentPane());
icf.pack();
icf.toFront();
icf.addToDesktopPane();
icf.setVisible(true);
//icf.setResizable(true);
}
}
diff --git a/DeconvolutionLab2/src/signal/RealSignal.java b/DeconvolutionLab2/src/signal/RealSignal.java
index cfa0428..445437b 100644
--- a/DeconvolutionLab2/src/signal/RealSignal.java
+++ b/DeconvolutionLab2/src/signal/RealSignal.java
@@ -1,652 +1,705 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package signal;
import java.awt.image.BufferedImage;
import deconvolutionlab.monitor.Monitors;
public class RealSignal extends Signal implements SignalListener {
private BufferedImage preview;
public RealSignal(String name, int nx, int ny, int nz) {
super(name, nx, ny, nz);
this.data = new float[nz][];
int step = Math.max(1, nz / SignalCollector.NOTIFICATION_RATE);
notify(name, 0);
for (int k = 0; k < nz; k++) {
data[k] = new float[nx * ny];
if (k % step == 0)
notify(name, k * 100.0 / nz);
}
notify(name, 100);
SignalCollector.alloc(this);//name, nx, ny, ny, false);
}
@Override
public void notify(String name, double progress) {
SignalCollector.setProgress(progress);
}
public void copy(RealSignal source) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = source.data[k][i];
}
}
public void setSignal(RealSignal signal) {
int sx = signal.nx;
int mx = Math.min(nx, signal.nx);
int my = Math.min(ny, signal.ny);
int mz = Math.min(nz, signal.nz);
for (int i = 0; i < mx; i++)
for (int j = 0; j < my; j++)
for (int k = 0; k < mz; k++)
data[k][i + nx * j] = signal.data[k][i + sx * j];
}
public void getSignal(RealSignal signal) {
int sx = signal.nx;
int mx = Math.min(nx, signal.nx);
int my = Math.min(ny, signal.ny);
int mz = Math.min(nz, signal.nz);
for (int i = 0; i < mx; i++)
for (int j = 0; j < my; j++)
for (int k = 0; k < mz; k++)
signal.data[k][i + sx * j] = data[k][i + nx * j];
}
/**
* Applies a soft threshold (in-place processing)
*
* @param inferiorLimit
* @param superiorLimit
* @return the instance of the calling object
*/
public RealSignal thresholdSoft(float inferiorLimit, float superiorLimit) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
if (data[k][i] <= inferiorLimit)
data[k][i] += inferiorLimit;
else if (data[k][i] >= superiorLimit)
data[k][i] -= superiorLimit;
else
data[k][i] = 0f;
}
return this;
}
/**
* Multiplies by a signal pixelwise (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal times(RealSignal factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] *= factor.data[k][i];
}
return this;
}
/**
* Multiplies by a scalar factor (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal times(float factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] *= factor;
}
return this;
}
/**
* Adds a signal pixelwise (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal plus(RealSignal factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] += factor.data[k][i];
}
return this;
}
/**
* Subtracts by a signal pixelwise (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal minus(RealSignal factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] -= factor.data[k][i];
}
return this;
}
/**
* Adds a scalar term (in-place processing)
*
* @param term
* @return the instance of the calling object
*/
public RealSignal plus(float term) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] += term;
}
return this;
}
/**
* Takes the maximum (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal max(RealSignal factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = Math.max(data[k][i], factor.data[k][i]);
}
return this;
}
/**
* Takes the minimum (in-place processing)
*
* @param factor
* @return the instance of the calling object
*/
public RealSignal min(RealSignal factor) {
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
data[k][i] = Math.min(data[k][i], factor.data[k][i]);
}
return this;
}
public double[][][] get3DArrayAsDouble() {
double[][][] ar = new double[nx][ny][nz];
for (int k = 0; k < nz; k++) {
float[] s = data[k];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
ar[i][j][k] = s[i + j * nx];
}
}
return ar;
}
public void set3DArrayAsDouble(double[][][] real) {
for (int k = 0; k < nz; k++) {
float[] s = data[k];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
s[i + j * nx] = (float) real[i][j][k];
}
}
}
public RealSignal duplicate() {
RealSignal out = new RealSignal("copy(" + name + ")", nx, ny, nz);
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
System.arraycopy(data[k], 0, out.data[k], 0, nxy);
return out;
}
public float getEnergy() {
int nxy = nx * ny;
float energy = 0.f;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
energy += data[k][i];
return energy;
}
public float[] getStats() {
int nxy = nx * ny;
float min = Float.MAX_VALUE;
float max = -Float.MAX_VALUE;
double norm1 = 0.0;
double norm2 = 0.0;
double mean = 0.0;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
float v = data[k][i];
max = Math.max(max, v);
min = Math.min(min, v);
mean += v;
norm1 += (v > 0 ? v : -v);
norm2 += v * v;
}
mean = mean / (nz * nxy);
norm1 = norm1 / (nz * nxy);
norm2 = Math.sqrt(norm2 / (nz * nxy));
double stdev = 0.0;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
stdev += (data[k][i] - mean) * (data[k][i] - mean);
}
stdev = Math.sqrt(stdev / (nz * nxy));
return new float[] { (float) mean, min, max, (float) stdev, (float) norm1, (float) norm2 };
}
public float[] getExtrema() {
int nxy = nx * ny;
float min = Float.MAX_VALUE;
float max = -Float.MAX_VALUE;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++) {
float v = data[k][i];
max = Math.max(max, v);
min = Math.min(min, v);
}
return new float[] { min, max };
}
public RealSignal normalize(double to) {
if (to == 0)
return this;
int nxy = nx * ny;
float sum = 0f;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
sum += data[k][i];
if (sum != 0f) {
double r = to / sum;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
data[k][i] *= r;
}
return this;
}
public void setSlice(int z, RealSignal slice) {
int mx = slice.nx;
int my = slice.ny;
for (int j = 0; j < Math.min(ny, my); j++)
for (int i = 0; i < Math.min(nx, mx); i++)
data[z][i + nx * j] = slice.data[0][i + mx * j];
}
public RealSignal getSlice(int z) {
RealSignal slice = new RealSignal(name + "_z=" + z, nx, ny, 1);
for (int j = 0; j < nx * ny; j++)
slice.data[0][j] = data[z][j];
return slice;
}
public void multiply(double factor) {
for (int k = 0; k < nz; k++)
for (int i = 0; i < nx * ny; i++)
data[k][i] *= factor;
}
public float[] getInterleaveXYZAtReal() {
float[] interleave = new float[2 * nz * nx * ny];
for (int k = 0; k < nz; k++)
for (int j = 0; j < ny; j++)
for (int i = 0; i < nx; i++)
interleave[2 * (k * nx * ny + j * nx + i)] = data[k][i + j * nx];
return interleave;
}
public void setInterleaveXYZAtReal(float[] interleave) {
for (int k = 0; k < nz; k++)
for (int j = 0; j < ny; j++)
for (int i = 0; i < nx; i++)
data[k][i + nx * j] = interleave[(k * nx * ny + j * nx + i) * 2];
}
public float[] getInterleaveXYAtReal(int k) {
float real[] = new float[nx * ny * 2];
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + j * nx;
real[2 * index] = data[k][index];
}
return real;
}
public void setInterleaveXYAtReal(int k, float real[]) {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int index = i + j * nx;
data[k][index] = real[2 * index];
}
}
public float[] getXYZ() {
int nxy = nx * ny;
float[] d = new float[nz * nx * ny];
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
d[k * nxy + i] = data[k][i];
return d;
}
public void setXYZ(float[] data) {
if (nx * ny * nz != data.length)
return;
int nxy = nx * ny;
for (int k = 0; k < nz; k++)
for (int i = 0; i < nxy; i++)
this.data[k][i] = data[k * nxy + i];
}
public float[] getXY(int k) {
return data[k];
}
public void setXY(int k, float slice[]) {
data[k] = slice;
}
public float[] getX(int j, int k) {
float line[] = new float[nx];
for (int i = 0; i < nx; i++)
line[i] = data[k][i + j * nx];
return line;
}
public float[] getZ(int i, int j) {
float line[] = new float[nz];
int index = i + j * nx;
for (int k = 0; k < nz; k++)
line[k] = data[k][index];
return line;
}
public float[] getY(int i, int k) {
float line[] = new float[ny];
for (int j = 0; j < ny; j++)
line[j] = data[k][i + j * nx];
return line;
}
public void setX(int j, int k, float line[]) {
for (int i = 0; i < nx; i++)
data[k][i + j * nx] = line[i];
}
public void setY(int i, int k, float line[]) {
for (int j = 0; j < ny; j++)
data[k][i + j * nx] = line[j];
}
public void setZ(int i, int j, float line[]) {
int index = i + j * nx;
for (int k = 0; k < nz; k++)
data[k][index] = line[k];
}
public void clip(float min, float max) {
for (int k = 0; k < nz; k++)
for (int j = 0; j < ny * nx; j++)
if (data[k][j] < min)
data[k][j] = min;
else if (data[k][j] > max)
data[k][j] = max;
}
public void fill(float constant) {
for (int k = 0; k < nz; k++)
for (int j = 0; j < ny * nx; j++)
data[k][j] = constant;
}
public RealSignal changeSizeAs(RealSignal model) {
return size(model.nx, model.ny, model.nz);
}
public RealSignal size(int mx, int my, int mz) {
String n = "resize(" + name + ")";
int ox = (mx - nx) / 2;
int oy = (my - ny) / 2;
int oz = (mz - nz) / 2;
RealSignal signal = new RealSignal(n, mx, my, mz);
int vx = Math.min(nx, mx);
int vy = Math.min(ny, my);
int vz = Math.min(nz, mz);
for (int k = 0; k < vz; k++)
for (int j = 0; j < vy; j++)
for (int i = 0; i < vx; i++) {
int pi = ox >= 0 ? i + ox : i;
int qi = ox >= 0 ? i : i - ox;
int pj = oy >= 0 ? j + oy : j;
int qj = oy >= 0 ? j : j - oy;
int pk = oz >= 0 ? k + oz : k;
int qk = oz >= 0 ? k : k - oz;
signal.data[pk][pi + pj * mx] = data[qk][qi + qj * nx];
}
return signal;
}
public RealSignal createOrthoview() {
return createOrthoview(nx / 2, ny / 2, nz / 2);
}
public RealSignal createOrthoview(int hx, int hy, int hz) {
String n = "ortho(" + name + ")";
int vx = nx + nz;
int vy = ny + nz;
RealSignal view = new RealSignal(n, vx, vy, 1);
hx = Math.min(nx - 1, Math.max(0, hx));
hy = Math.min(ny - 1, Math.max(0, hy));
hz = Math.min(nz - 1, Math.max(0, hz));
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
view.data[0][x + vx * y] = data[hz][x + nx * y];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++)
view.data[0][nx + z + vx * y] = data[z][hx + nx * y];
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++)
view.data[0][x + vx * (ny + z)] = data[z][x + nx * hy];
return view;
}
public RealSignal createFigure(int hx, int hy, int hz) {
String n = "figure(" + name + ")";
int vx = nx + nz + 4;
int vy = ny + 2;
float max = this.getExtrema()[1];
RealSignal view = new RealSignal(n, vx, vy, 1);
for (int i = 0; i < vx * vy; i++)
view.data[0][i] = max;
hx = Math.min(nx - 1, Math.max(0, hx));
hy = Math.min(ny - 1, Math.max(0, hy));
hz = Math.min(nz - 1, Math.max(0, hz));
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
view.data[0][x + 1 + vx * (y + 1)] = data[hz][x + nx * y];
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++)
view.data[0][nx + 3 + z + vx * (y + 1)] = data[z][hx + nx * y];
return view;
}
public RealSignal createMIP() {
String n = "mip(" + name + ")";
int vx = nx + nz + 1;
int vy = ny + nz + 1;
RealSignal view = new RealSignal(n, vx, vy, 1);
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
for (int k = 0; k < nz; k++) {
int index = x + vx * y;
view.data[0][index] = Math.max(view.data[0][index], data[k][x + nx * y]);
}
for (int z = 0; z < nz; z++)
for (int y = 0; y < ny; y++)
for (int x = 0; x < nx; x++) {
int index = nx + 1 + z + vx * y;
view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
}
for (int z = 0; z < nz; z++)
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++) {
int index = x + vx * (ny + 1 + z);
view.data[0][index] = Math.max(view.data[0][index], data[z][x + nx * y]);
}
return view;
}
public RealSignal createMontage() {
String n = "planar(" + name + ")";
int nr = (int) Math.sqrt(nz);
int nc = (int) Math.ceil(nz / nr) + 1;
int w = nx * nr;
int h = ny * nc;
RealSignal view = new RealSignal(n, w, h, 1);
for (int k = 0; k < nz; k++) {
int col = k % nr;
int row = k / nr;
int offx = col * nx;
int offy = row * ny;
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
view.data[0][x + offx + w * (y + offy)] = data[k][x + nx * y];
}
return view;
}
public RealSignal circular() {
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++)
setZ(i, j, rotate(getZ(i, j)));
for (int i = 0; i < nx; i++)
for (int k = 0; k < nz; k++)
setY(i, k, rotate(getY(i, k)));
for (int j = 0; j < ny; j++)
for (int k = 0; k < nz; k++)
setX(j, k, rotate(getX(j, k)));
return this;
}
public RealSignal rescale(Monitors monitors) {
new Constraint(monitors).rescaled(this, 0, 255);
return this;
}
public float[] rotate(float[] buffer) {
int len = buffer.length;
if (len <= 1)
return buffer;
int count = 0;
int offset = 0;
int start = len / 2;
while (count < len) {
int index = offset;
float tmp = buffer[index];
int index2 = (start + index) % len;
while (index2 != offset) {
buffer[index] = buffer[index2];
count++;
index = index2;
index2 = (start + index) % len;
}
buffer[index] = tmp;
count++;
offset++;
}
return buffer;
}
@Override
public String toString() {
return "Real Signal [" + nx + ", " + ny + ", " + nz + "]";
}
public BufferedImage preview() {
if (preview != null)
return preview;
int nxy = nx*ny;
float[] pixels = new float[nx*ny];
for (int i = 0; i < nxy; i++)
for (int k = 0; k < nz; k++) {
pixels[i] = Math.max(pixels[i], data[k][i]);
}
float max = -Float.MAX_VALUE;
float min = Float.MAX_VALUE;
for (int i = 0; i < nxy; i++) {
if (pixels[i] > max)
max = pixels[i];
if (pixels[i] < min)
min = pixels[i];
}
float a = 255f / Math.max(max-min, (float)Operations.epsilon);
preview = new BufferedImage(nx, ny, BufferedImage.TYPE_INT_ARGB);
int alpha = (255 << 24);
for (int i = 0; i < nx; i++)
for (int j = 0; j < ny; j++) {
int v = (int)(a*(pixels[i+j*nx] - min));
preview.setRGB(i, j, alpha | (v << 16) | (v << 8) | v);
}
return preview;
}
+ public RealSignal log10() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)Math.log10(data[k][i]);
+ }
+ return this;
+ }
+
+ public RealSignal log() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)Math.log(data[k][i]);
+ }
+ return this;
+ }
+
+ public RealSignal exp() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)Math.exp(data[k][i]);
+ }
+ return this;
+ }
+
+ public RealSignal abs() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)Math.abs(data[k][i]);
+ }
+ return this;
+ }
+
+ public RealSignal sqrt() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)Math.sqrt(data[k][i]);
+ }
+ return this;
+ }
+
+ public RealSignal sqr() {
+ int nxy = nx * ny;
+ for (int k = 0; k < nz; k++)
+ for (int i = 0; i < nxy; i++) {
+ data[k][i] = (float)(data[k][i]*data[k][i]);
+ }
+ return this;
+ }
}

Event Timeline