Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90782656
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Nov 4, 17:21
Size
131 KB
Mime Type
application/octet-stream
Expires
Wed, Nov 6, 17:21 (2 d)
Engine
blob
Format
Raw Data
Handle
22133992
Attached To
R2075 deconvolution
View Options
diff --git a/DeconvolutionLab2/build.xml b/DeconvolutionLab2/build.xml
index e34ad38..bcc1407 100644
--- a/DeconvolutionLab2/build.xml
+++ b/DeconvolutionLab2/build.xml
@@ -1,48 +1,47 @@
<?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="<h3>DeconvolutionLab2</h3>	v1.0" />
<property name="javadoc.footer" value="<h4>DeconvolutionLab2</h4>	<script> var tStamp=new Date(); document.write(tStamp.toUTCString()); </script>" />
<property name="javadoc.bottom" value='Copyright &copy; <script> var currYear=new Date(); document.write(currYear.getFullYear()); </script>, 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 todir="bin"><fileset dir="jtransforms"></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" />
</manifest>
</jar>
<copy toDir="${fiji}" file="../DeconvolutionLab_2.jar" />
<copy toDir="${matlab}" file="../DeconvolutionLab_2.jar" />
<copy toDir="${imagej}" file="../DeconvolutionLab_2.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>
</target>
</project>
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 58071d2..aef8c8f 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,409 +1,408 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.io.File;
import signal.RealSignal;
import signal.SignalCollector;
import bilib.tools.NumFormat;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.output.Output;
/**
* This class is the main class to run deconvolution with or without user interface.
*
* All the parameters are given in the command line (String variable command).
*
* @author Daniel Sage
*
*/
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
private Algorithm algo = null;
private Controller controller = new Controller();
private String command = "";
private Features report = new Features();
private String name = "";
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
private boolean embeddedStats = false;
public Deconvolution(String name, String command) {
this.name = name;
this.finish = Finish.DIE;
setCommand(command);
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
}
public void setCommand(String command) {
this.command = command;
controller = Command.decodeController(command);
algo = Command.decodeAlgorithm(command);
algo.setController(controller);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortnames()[0];
}
public RealSignal deconvolve() {
return deconvolve(image, psf);
}
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
Lab.setVisible(((TableMonitor)monitor).getPanel(), "Monitor of " + name, 10, 10);
if (controller.getFFT() == null) {
run();
return deconvolvedImage;
}
if (!controller.getFFT().isMultithreadable()) {
run();
return deconvolvedImage;
}
if (controller.isMultithreading()) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
return deconvolvedImage;
}
/**
* This method runs the deconvolution with a graphical user interface.
*/
public void launch() {
embeddedStats = true;
dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this);
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
Monitors monitors = controller.getMonitors();
report.add("Path", controller.toStringPath());
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
if (psf == null)
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
report.add("FFT", controller.getFFT().getName());
report.add("Algorithm", algo.getName());
if (embeddedStats) {
TableMonitor tableMonitor = null;
for(AbstractMonitor monitor : controller.getMonitors())
if (monitor instanceof TableMonitor)
tableMonitor = (TableMonitor)monitor;
if (controller.getStats().getMode() == Stats.Mode.SHOW || controller.getStats().getMode() == Stats.Mode.SHOWSAVE) {
controller.getStats().setEmbeddedInFrame(embeddedStats);
dialog.addStats(controller.getStats());
}
if (tableMonitor != null) {
dialog.addMonitor(tableMonitor);
}
}
algo.setController(controller);
deconvolvedImage = algo.run(image, psf);
report.add("End", NumFormat.time(System.nanoTime() - chrono));
if (finish == Finish.KILL) {
System.out.println("End");
System.exit(0);
}
if (finish == Finish.DIE)
die();
}
public void close() {
if (dialog != null)
dialog.dispose();
SignalCollector.free(image);
SignalCollector.free(psf);
SignalCollector.free(deconvolvedImage);
algo = null;
image = null;
psf = null;
deconvolvedImage = null;
System.gc();
}
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
CommandToken image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
double norm = controller.getNormalizationPSF();
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
CommandToken psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReferenceName());
features.add("Constraint", controller.getConstraintAsString());
features.add("Padding", controller.getPadding().toString());
features.add("Apodization", controller.getApodization().toString());
features.add("FFT", controller.getFFT() == null ? "null" : controller.getFFT().getName());
}
features.add("Path", controller.getPath());
String s = "[" + controller.getVerbose().name() + "] ";
for(AbstractMonitor monitor : controller.getMonitors())
s+= monitor.getName() + " ";
features.add("Monitor", s);
if (controller.getStats() != null)
features.add("Stats", controller.getStats().toStringStats());
- features.add("Running", controller.toStringRunning());
for (Output out : controller.getOuts())
features.add("Output " + out.getName(), out.toString());
controller.getMonitors().log("Recap deconvolution parameters");
return features;
}
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
public void abort() {
algo.getController().abort();
}
public RealSignal openImage() {
CommandToken token = Command.extract(command, "-image");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
image = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
controller.getMonitors().log("Open image " + arg + " " + cmd);
return image;
}
public RealSignal openPSF() {
CommandToken token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
psf = createRealSignal(controller.getMonitors(), arg, cmd, controller.getPath());
controller.getMonitors().log("Open PSF " + arg + " " + cmd);
return psf;
}
private static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
if (arg.equalsIgnoreCase("synthetic")) {
signal = Lab.createSynthetic(monitors, cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = Lab.getImage(monitors, cmd);
}
if (arg.equalsIgnoreCase("file")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isFile())
signal = Lab.openFile(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isFile())
signal = Lab.openFile(monitors, cmd);
}
}
}
if (arg.equalsIgnoreCase("dir") || arg.equalsIgnoreCase("directory")) {
File file = new File(path + File.separator + cmd);
if (file != null) {
if (file.isDirectory())
signal = Lab.openDir(monitors, path + File.separator + cmd);
}
if (signal == null) {
File local = new File(cmd);
if (local != null) {
if (local.isDirectory())
signal = Lab.openDir(monitors, cmd);
}
}
}
return signal;
}
public void setAlgorithm(Algorithm algo) {
this.algo = algo;
}
public Algorithm getAlgorithm() {
return algo;
}
public void setController(Controller controller) {
this.controller = controller;
}
public Controller getController() {
return controller;
}
public RealSignal getOutput() {
return deconvolvedImage;
}
public RealSignal getImage() {
return image;
}
public RealSignal getPSF() {
return psf;
}
public Features getDeconvolutionReports() {
return report;
}
public String getName() {
return name;
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public String getCommand() {
return command;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index e48c73d..39e7448 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,386 +1,392 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JToolBar;
import bilib.component.BorderToggledButton;
import bilib.component.PanelImage;
import deconvolution.capsule.AlgorithmCapsule;
import deconvolution.capsule.ImageCapsule;
import deconvolution.capsule.PSFCapsule;
import deconvolution.capsule.RecapCapsule;
import deconvolution.capsule.ReportCapsule;
+import deconvolution.capsule.ResourcesCapsule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
+import deconvolutionlab.system.RuntimeInfoPanel;
public class DeconvolutionDialog extends JDialog implements WindowListener, ActionListener, Runnable {
public enum State {
NOTDEFINED, READY, RUN, FINISH
};
public enum Module {
ALL, RECAP, IMAGE, PSF, ALGO, RUN
};
- private JButton bnStart = new JButton("Run");
- private JButton bnStop = new JButton("Stop");
- private JButton bnReset = new JButton("Reset");
- private JButton bnHelp = new JButton("Help");
- private JButton bnQuit = new JButton("Quit");
-
- private BorderToggledButton bnRecap = new BorderToggledButton("Recap");
- private BorderToggledButton bnImage = new BorderToggledButton("Image");
- private BorderToggledButton bnPSF = new BorderToggledButton("PSF");
- private BorderToggledButton bnAlgo = new BorderToggledButton("Algorithm");
+ private JButton bnStart = new JButton("Run");
+ private JButton bnStop = new JButton("Stop");
+ private JButton bnReset = new JButton("Reset");
+ private JButton bnHelp = new JButton("Help");
+ private JButton bnQuit = new JButton("Quit");
+
+ private BorderToggledButton bnRecap = new BorderToggledButton("Recap");
+ private BorderToggledButton bnResources = new BorderToggledButton("Resources");
+ private BorderToggledButton bnImage = new BorderToggledButton("Image");
+ private BorderToggledButton bnPSF = new BorderToggledButton("PSF");
+ private BorderToggledButton bnAlgo = new BorderToggledButton("Algorithm");
private BorderToggledButton bnReport = new BorderToggledButton("Report");
private BorderToggledButton bnMonitor = new BorderToggledButton("Monitor");
- private BorderToggledButton bnStats = new BorderToggledButton("Stats");
- JToolBar tool = new JToolBar();
+ private BorderToggledButton bnStats = new BorderToggledButton("Stats");
+ private JToolBar tool = new JToolBar();
- private Thread thread = null;
+ private Thread thread = null;
- private Deconvolution deconvolution;
- private JProgressBar progress = new JProgressBar();
+ private Deconvolution deconvolution;
+ private JProgressBar progress = new JProgressBar();
- public static Point location = new Point(0, 0);
+ public static Point location = new Point(0, 0);
- private JPanel cards = new JPanel(new CardLayout());
+ private JPanel cards = new JPanel(new CardLayout());
- private boolean flagMonitor = false;
- private boolean flagStats = false;
+ private boolean flagMonitor = false;
+ private boolean flagStats = false;
- private ImageCapsule image;
- private PSFCapsule psf;
- private RecapCapsule recap;
+ private ImageCapsule image;
+ private PSFCapsule psf;
+ private RecapCapsule recap;
private AlgorithmCapsule algorithm;
- private ReportCapsule report;
+ private ReportCapsule report;
+ private ResourcesCapsule resources;
public DeconvolutionDialog(Module module, Deconvolution deconvolution) {
super(new JFrame(), deconvolution.getName());
this.deconvolution = deconvolution;
image = new ImageCapsule(deconvolution);
psf = new PSFCapsule(deconvolution);
recap = new RecapCapsule(deconvolution);
algorithm = new AlgorithmCapsule(deconvolution);
report = new ReportCapsule(deconvolution);
+ resources = new ResourcesCapsule(deconvolution);
+ RuntimeInfoPanel info = new RuntimeInfoPanel(250);
// Panel status bar on bottom
progress.setAlignmentX(JLabel.CENTER_ALIGNMENT);
progress.setBorder(BorderFactory.createLoweredBevelBorder());
JToolBar statusBar = new JToolBar();
statusBar.setBorder(BorderFactory.createLoweredBevelBorder());
statusBar.setFloatable(false);
statusBar.setLayout(new BorderLayout());
- statusBar.add(bnHelp, BorderLayout.WEST);
+ statusBar.add(info, BorderLayout.WEST);
statusBar.add(progress, BorderLayout.CENTER);
statusBar.add(bnQuit, BorderLayout.EAST);
// Panel bottom
JPanel bottom = new JPanel();
bottom.setLayout(new BoxLayout(bottom, BoxLayout.PAGE_AXIS));
// Panel buttons
if (module == Module.ALL) {
PanelImage buttons = new PanelImage("celegans.jpg");
buttons.setLayout(new FlowLayout());
buttons.setBorder(BorderFactory.createEtchedBorder());
buttons.add(bnReset);
buttons.add(bnStop);
buttons.add(bnStart);
bottom.add(buttons);
}
bottom.add(statusBar);
// Panel Image
- cards.add(recap.getName(), recap.getPane());
- cards.add(image.getName(), image.getPane());
- cards.add(psf.getName(), psf.getPane());
- cards.add(algorithm.getName(), algorithm.getPane());
- cards.add(report.getName(), report.getPane());
+ cards.add(recap.getID(), recap.getPane());
+ cards.add(resources.getID(), resources.getPane());
+ cards.add(image.getID(), image.getPane());
+ cards.add(psf.getID(), psf.getPane());
+ cards.add(algorithm.getID(), algorithm.getPane());
+ cards.add(report.getID(), report.getPane());
// Panel Main
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(cards, BorderLayout.CENTER);
panel.add(bottom, BorderLayout.SOUTH);
// Panel tool with all buttons
if (module == Module.ALL) {
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 6));
tool.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tool.add(bnRecap);
+ tool.add(bnResources);
+ tool.add(bnAlgo);
tool.add(bnImage);
tool.add(bnPSF);
- tool.add(bnAlgo);
tool.add(bnReport);
panel.add(tool, BorderLayout.NORTH);
}
add(panel);
bnReset.addActionListener(this);
bnQuit.addActionListener(this);
bnStart.addActionListener(this);
bnStop.addActionListener(this);
bnHelp.addActionListener(this);
bnImage.addActionListener(this);
+ bnResources.addActionListener(this);
bnPSF.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
bnReport.addActionListener(this);
this.addWindowListener(this);
setMinimumSize(new Dimension(Constants.widthGUI, 400));
setPreferredSize(new Dimension(Constants.widthGUI, 400));
pack();
Config.registerFrame("DeconvolutionLab", "DeconvolutionDialog", this);
Rectangle rect = Config.getDialog("DeconvolutionLab.DeconvolutionDialog");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
bnStop.setEnabled(false);
if (module == Module.ALL) {
toggle(bnRecap);
recap.update();
}
if (module == Module.IMAGE) {
toggle(bnImage);
- image.update();
+ image.update();
}
if (module == Module.PSF) {
toggle(bnPSF);
psf.update();
}
if (module == Module.ALGO) {
toggle(bnAlgo);
algorithm.update();
}
if (module == Module.RECAP) {
toggle(bnRecap);
recap.update();
}
}
@Override
public void actionPerformed(ActionEvent e) {
-
if (e.getSource() == bnStart) {
if (flagMonitor)
toggle(bnMonitor);
else if (flagStats)
toggle(bnStats);
if (thread == null) {
thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
}
else if (e.getSource() == bnStop) {
toggle(bnReport);
if (deconvolution != null)
deconvolution.abort();
}
+ else if (e.getSource() == bnResources) {
+ toggle(bnResources);
+ resources.update();
+ }
else if (e.getSource() == bnImage) {
toggle(bnImage);
image.update();
}
else if (e.getSource() == bnPSF) {
toggle(bnPSF);
psf.update();
}
else if (e.getSource() == bnAlgo) {
toggle(bnAlgo);
algorithm.update();
}
else if (e.getSource() == bnRecap) {
toggle(bnRecap);
recap.update();
}
else if (e.getSource() == bnReport) {
toggle(bnReport);
report.update();
}
else if (e.getSource() == bnReset) {
toggle(bnRecap);
bnStart.setEnabled(true);
}
else if (e.getSource() == bnQuit) {
deconvolution.close();
deconvolution = null;
dispose();
}
else if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnMonitor)
toggle(bnMonitor);
else if (e.getSource() == bnStats)
toggle(bnStats);
-
+
addProgress();
}
@Override
public void run() {
- //bnRecap.setEnabled(false);
- //bnImage.setEnabled(false);
- //bnPSF.setEnabled(false);
- //bnAlgo.setEnabled(false);
bnStart.setEnabled(false);
bnStop.setEnabled(true);
-
+
deconvolution.setCommand(recap.getCommand());
addProgress();
deconvolution.run();
toggle(bnReport);
-
+
bnStop.setEnabled(false);
report.update();
- //bnRecap.setEnabled(true);
- //bnAlgo.setEnabled(true);
- //bnPSF.setEnabled(true);
- //bnImage.setEnabled(true);
thread = null;
}
private void addProgress() {
- Monitors monitors = deconvolution.getController().getMonitors();
+ Monitors monitors = deconvolution.getController().getMonitors();
boolean found = false;
- for(AbstractMonitor monitor : monitors) {
+ for (AbstractMonitor monitor : monitors) {
if (monitor instanceof StatusMonitor)
found = true;
}
if (!found) {
monitors.add(new StatusMonitor(progress));
deconvolution.getController().setMonitors(monitors);
}
}
+
public void addStats(Stats stats) {
if (stats != null) {
cards.add("Stats", stats.getPanel());
tool.add(bnStats);
pack();
bnStats.addActionListener(this);
}
}
-
+
public void addMonitor(TableMonitor tableMonitor) {
if (tableMonitor != null) {
cards.add("Monitor", tableMonitor.getPanel());
tool.add(bnMonitor);
pack();
bnMonitor.addActionListener(this);
}
}
public static void setLocationLaunch(Point l) {
location = l;
}
private void toggle(BorderToggledButton bn) {
((CardLayout) (cards.getLayout())).show(cards, bn.getText());
bnRecap.setSelected(false);
+ bnResources.setSelected(false);
bnImage.setSelected(false);
bnPSF.setSelected(false);
bnAlgo.setSelected(false);
bnMonitor.setSelected(false);
bnStats.setSelected(false);
bnReport.setSelected(false);
bn.setSelected(true);
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
deconvolution.close();
deconvolution = null;
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Features.java b/DeconvolutionLab2/src/deconvolution/Features.java
index ab814dd..e47c310 100644
--- a/DeconvolutionLab2/src/deconvolution/Features.java
+++ b/DeconvolutionLab2/src/deconvolution/Features.java
@@ -1,47 +1,46 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.util.ArrayList;
public class Features extends ArrayList<String[]>{
public Features() {
super();
}
-
public void add(String feature, String value) {
add(new String[] {feature, value});
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
index e7e5310..9c889bd 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Algorithm.java
@@ -1,479 +1,478 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.ArrayList;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
import bilib.tools.NumFormat;
import deconvolution.Stats;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.output.Output;
import deconvolutionlab.system.SystemInfo;
import fft.AbstractFFT;
import fft.FFT;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class Algorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h;
protected boolean threaded;
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint;
protected int iterMax = 0;
protected AbstractFFT fft;
protected Controller controller;
public Algorithm() {
setController(new Controller());
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public Algorithm(Controller controller) {
this.controller = controller;
optimizedMemoryFootprint = true;
threaded = true;
fft = FFT.getFastestFFT().getDefaultFFT();
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract String[] getShortnames();
public abstract double getMemoryFootprintRatio();
public abstract int getComplexityNumberofFFT();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract Algorithm 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) {
String sn = getShortnames()[0];
String algoParam = sn + "(" + getParametersAsString() + ")";
- if (controller.isSystem())
- SystemInfo.activate();
+ //if (controller.isSystem())
+ // SystemInfo.activate();
Padding pad = controller.getPadding();
Apodization apo = controller.getApodization();
double norm = controller.getNormalizationPSF();
controller.setAlgoName(algoParam);
fft = controller.getFFT();
controller.setIterationsMax(iterMax);
if (image == null)
return null;
if (psf == null)
return null;
// Prepare the controller and the outputs
-
Monitors monitors = controller.getMonitors();
monitors.setVerbose(controller.getVerbose());
monitors.log("Path: " + controller.toStringPath());
monitors.log("Algorithm: " + getName());
// Prepare the signal and the PSF
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? iterMax + " iterations" : "direct");
controller.setIterationsMax(iterMax);
monitors.log(sn + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
controller.start(y);
h.circular();
// FFT
fft.init(monitors, y.nx, y.ny, y.nz);
controller.setFFT(fft);
monitors.log(sn + " data ready");
monitors.log(algoParam);
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
SignalCollector.free(y);
SignalCollector.free(h);
x.setName("x");
RealSignal result = pad.crop(monitors, x);
controller.finish(result);
monitors.log(getName() + " is finished");
SignalCollector.free(x);
if (controller.isDisplayFinal())
Lab.show(monitors, result, "Final Display of " + sn);
result.setName("Out of " + algoParam);
monitors.log("End of " + sn + " in " + NumFormat.seconds(controller.getTimeNano()) + " and " + controller.getMemoryAsString());
return result;
}
public Algorithm noPopup() {
return this.disableDisplayFinal().disableSystem();
}
public Algorithm setController(Controller controller) {
this.controller = controller;
return this;
}
public Controller getController() {
return controller;
}
public int getIterationsMax() {
return iterMax;
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public double getResidu() {
return controller.getResidu();
}
public double getSNR() {
return controller.getSNR();
}
public double getPSNR() {
return controller.getPSNR();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + iterMax + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for (int i = 0; i < p.length; i++)
if (i == p.length - 1)
param += NumFormat.nice(p[i]);
else
param += NumFormat.nice(p[i]) + ", ";
return param;
}
public AbstractFFT getFFT() {
return controller.getFFT();
}
public Algorithm setFFT(AbstractFFT fft) {
this.fft = fft;
controller.setFFT(fft);
return this;
}
public String getPath() {
return controller.getPath();
}
public Algorithm setPath(String path) {
controller.setPath(path);
return this;
}
public boolean isSystem() {
return controller.isSystem();
}
public Algorithm enableSystem() {
controller.setSystem(true);
return this;
}
public Algorithm disableSystem() {
controller.setSystem(false);
return this;
}
public boolean isMultithreading() {
return controller.isMultithreading();
}
public Algorithm enableMultithreading() {
controller.setMultithreading(true);
return this;
}
public Algorithm disableMultithreading() {
controller.setMultithreading(false);
return this;
}
public boolean isDisplayFinal() {
return controller.isDisplayFinal();
}
public Algorithm enableDisplayFinal() {
controller.setDisplayFinal(true);
return this;
}
public Algorithm disableDisplayFinal() {
controller.setDisplayFinal(false);
return this;
}
public double getNormalizationPSF() {
return controller.getNormalizationPSF();
}
public Algorithm setNormalizationPSF(double normalizationPSF) {
controller.setNormalizationPSF(normalizationPSF);
return this;
}
public double getEpsilon() {
return controller.getEpsilon();
}
public Algorithm setEpsilon(double epsilon) {
controller.setEpsilon(epsilon);
return this;
}
public Padding getPadding() {
return controller.getPadding();
}
public Algorithm setPadding(Padding padding) {
controller.setPadding(padding);
return this;
}
public Apodization getApodization() {
return controller.getApodization();
}
public Algorithm setApodization(Apodization apodization) {
controller.setApodization(apodization);
return this;
}
public Monitors getMonitors() {
return controller.getMonitors();
}
public Algorithm setMonitors(Monitors monitors) {
controller.setMonitors(monitors);
return this;
}
public Verbose getVerbose() {
return controller.getVerbose();
}
public Algorithm setVerbose(Verbose verbose) {
controller.setVerbose(verbose);
return this;
}
public Constraint.Mode getConstraint() {
return controller.getConstraint();
}
public Algorithm setConstraint(Constraint.Mode constraint) {
controller.setConstraint(constraint);
return this;
}
public Stats getStats() {
return controller.getStats();
}
public Algorithm setStats(Stats stats) {
controller.setStats(stats);
return this;
}
public Algorithm showStats() {
controller.setStats(new Stats(Stats.Mode.SHOW));
return this;
}
public Algorithm saveStats(Stats stats) {
controller.setStats(new Stats(Stats.Mode.SAVE));
return this;
}
public Algorithm setStats() {
controller.setStats(new Stats(Stats.Mode.SHOWSAVE));
return this;
}
public double getResiduMin() {
return controller.getResiduMin();
}
public Algorithm setResiduMin(double residuMin) {
controller.setResiduMin(residuMin);
return this;
}
public double getTimeLimit() {
return controller.getTimeLimit();
}
public Algorithm setTimeLimit(double timeLimit) {
controller.setTimeLimit(timeLimit);
return this;
}
public RealSignal getReference() {
return controller.getReference();
}
public Algorithm setReference(RealSignal ref) {
controller.setReference(ref);
return this;
}
public ArrayList<Output> getOuts() {
return controller.getOuts();
}
public Algorithm setOuts(ArrayList<Output> outs) {
controller.setOuts(outs);
return this;
}
public Algorithm addOutput(Output out) {
controller.addOutput(out);
return this;
}
public String getParametersToString() {
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += NumFormat.nice(param) + " ";
return s;
}
}
return "parameter-free";
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index fec111d..d15e831 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,676 +1,668 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.io.File;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import signal.Assessment;
import signal.ComplexSignal;
import signal.Constraint;
import signal.RealSignal;
import signal.apodization.Apodization;
import signal.padding.Padding;
import bilib.tools.Files;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Stats;
import deconvolutionlab.Constants;
import deconvolutionlab.monitor.AbstractMonitor;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.output.Output;
import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFT;
import fft.FFT;
/**
* This is an important class to manage all the common task of the algorithm.
* The method start() is called before at the starting of the algorithm. The
* method ends() is called at the end of every iterations for the iterative
* algorithm. It returns true if one the stopping criteria is true. The method
* finish() is called when the algorithm is completely terminated.
*
* A timer is started to get the peak memory.
*
* @author Daniel Sage
*
*/
public class Controller {
private String path;
private boolean system;
private boolean multithreading;
private boolean displayFinal;
private double normalizationPSF;
private double epsilon;
private Padding padding;
private Apodization apodization;
private ArrayList<Output> outs;
private Stats stats;
private Constraint.Mode constraintMode;
private double residuMin;
private double timeLimit;
private String referenceName;
private Monitors monitors;
private Verbose verbose;
private AbstractFFT fft;
private int iterationsMax = 100;
private boolean doResidu = false;
private boolean doTime = false;
private boolean doReference = false;
private boolean doConstraint = false;
private boolean abort = false;
private double timeStarting = 0;
private double memoryStarting = 0;
private double residu = Double.MAX_VALUE;
private int iterations = 0;
private double memoryPeak = 0;
private double snr = 0;
private double psnr = 0;
private RealSignal refImage;
private RealSignal prevImage;
private RealSignal x;
private Timer timer;
private String algoName = "";
/**
* Constructor.
*
* One controller is always instantiated for every run of a algorithm.
*/
public Controller() {
doResidu = false;
doTime = false;
doReference = false;
doConstraint = false;
timeStarting = System.nanoTime();
setPath(Files.getWorkingDirectory());
setSystem(true);
setMultithreading(true);
setDisplayFinal(true);
setFFT(FFT.getFastestFFT().getDefaultFFT());
setNormalizationPSF(1);
setEpsilon(1e-6);
setPadding(new Padding());
setApodization(new Apodization());
monitors = new Monitors();
monitors.add(new ConsoleMonitor());
monitors.add(new TableMonitor(Constants.widthGUI, 240));
setVerbose(Verbose.Log);
setStats(new Stats(Stats.Mode.NO));
setConstraint(Constraint.Mode.NO);
setResiduMin(-1);
setTimeLimit(-1);
setReference(null);
setOuts(new ArrayList<Output>());
}
public void setAlgoName(String algoName) {
this.algoName = algoName;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
public void setIterationsMax(int iterationsMax) {
this.iterationsMax = iterationsMax;
}
public boolean needSpatialComputation() {
return doConstraint || doResidu || doReference;
}
/**
* Call one time at the beginning of the algorithms
*
* @param x
* the input signal
*/
public void start(RealSignal x) {
this.x = x;
stats.show();
stats.addInput(x);
iterations = 0;
timer = new Timer();
timer.schedule(new Updater(), 0, 100);
timeStarting = System.nanoTime();
memoryStarting = SystemUsage.getHeapUsed();
if (doConstraint && x != null)
Constraint.setModel(x);
if (doReference && refImage == null) {
refImage = new Deconvolution("Reference", "-image file " + referenceName).openImage();
if (refImage == null)
monitors.error("Impossible to load the reference image " + referenceName);
else
monitors.log("Reference image loaded");
}
for (Output out : outs)
out.executeStarting(monitors, x, this);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
boolean out = false;
for (Output output : outs)
out = out | output.is(iterations);
if (doConstraint || doResidu || doReference || out) {
if (fft == null)
fft = FFT.createDefaultFFT(monitors, X.nx, X.ny, X.nz);
x = fft.inverse(X, x);
return ends(x);
}
return ends((RealSignal) null);
}
public boolean ends(RealSignal x) {
this.x = x;
if (doConstraint || doResidu || doReference)
compute(iterations, x, doConstraint, doResidu, doReference);
for (Output out : outs)
out.executeIterative(monitors, x, this, iterations);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
double timeElapsed = getTimeSecond();
boolean stopIter = (iterations >= iterationsMax);
boolean stopTime = doTime && (timeElapsed >= timeLimit);
boolean stopResd = doResidu && (residu <= residuMin);
monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed*1e9));
String pnsrText = doReference ? "" + psnr : "n/a";
String snrText = doReference ? "" + snr : "n/a";
String residuText = doResidu ? "" + residu : "n/a";
stats.add(x, iterations, NumFormat.seconds(getTimeNano()), pnsrText, snrText, residuText);
String prefix = "Stopped>> by ";
if (abort)
monitors.log(prefix + "abort");
if (stopIter)
monitors.log(prefix + "iteration " + iterations + " > " + iterationsMax);
if (stopTime)
monitors.log(prefix + "time " + timeElapsed + " > " + timeLimit);
if (stopResd)
monitors.log(prefix + "residu " + NumFormat.nice(residu) + " < " + NumFormat.nice(residuMin));
return abort | stopIter | stopTime | stopResd;
}
public void finish(RealSignal x) {
this.x = x;
boolean ref = doReference;
boolean con = doConstraint;
boolean res = doResidu;
if (con || res || ref)
compute(iterations, x, con, res, ref);
String pnsrText = doReference ? ""+psnr : "n/a";
String snrText = doReference ? ""+snr : "n/a";
String residuText = doResidu ? "" + residu : "n/a";
stats.addOutput(x, algoName, NumFormat.seconds(getTimeNano()), pnsrText, snrText, residuText);
stats.save(monitors, path);
for (Output out : outs)
out.executeFinal(monitors, x, this);
monitors.log("Time: " + NumFormat.seconds(getTimeNano()) + " Peak:" + getMemoryAsString());
if (timer != null)
timer.cancel();
}
private void compute(int iterations, RealSignal x, boolean con, boolean res, boolean ref) {
if (x == null)
return;
if (con && constraintMode != null)
new Constraint(monitors).apply(x, constraintMode);
if (ref && refImage != null) {
String s = "";
psnr = Assessment.psnr(x, refImage);
snr = Assessment.snr(x, refImage);
s += " PSNR: " + NumFormat.nice(psnr);
s += " SNR: " + NumFormat.nice(snr);
monitors.log("@" + iterations + " " + s);
}
residu = Double.MAX_VALUE;
if (res && prevImage != null) {
residu = Assessment.relativeResidu(x, prevImage);
prevImage = x.duplicate();
monitors.log("@" + iterations + " Residu: " + NumFormat.nice(residu));
}
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
public double getTimeSecond() {
return (System.nanoTime() - timeStarting) * 1e-9;
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
if (constraintMode == null)
return "null";
return constraintMode.name().toLowerCase();
}
public String getStoppingCriteriaAsString(Algorithm algo) {
String stop = algo.isIterative() ? "iterations limit=" + algo.getIterationsMax() + ", " : "direct, ";
stop += doTime ? ", time limit=" + NumFormat.nice(timeLimit * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
public double getMemory() {
return memoryPeak - memoryStarting;
}
public String getMemoryAsString() {
return NumFormat.bytes(getMemory());
}
public int getIterations() {
return iterations;
}
public double getSNR() {
return snr;
}
public double getPSNR() {
return psnr;
}
public double getResidu() {
return residu;
}
private void update() {
memoryPeak = Math.max(memoryPeak, SystemUsage.getHeapUsed());
}
public AbstractFFT getFFT() {
return fft;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path
* the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the system
*/
public boolean isSystem() {
return system;
}
/**
* @param system
* the system to set
*/
public void setSystem(boolean system) {
this.system = system;
}
/**
* @return the multithreading
*/
public boolean isMultithreading() {
return multithreading;
}
/**
* @param multithreading
* the multithreading to set
*/
public void setMultithreading(boolean multithreading) {
this.multithreading = multithreading;
}
/**
* @return the displayFinal
*/
public boolean isDisplayFinal() {
return displayFinal;
}
/**
* @param displayFinal
* the displayFinal to set
*/
public void setDisplayFinal(boolean displayFinal) {
this.displayFinal = displayFinal;
}
/**
* @return the normalizationPSF
*/
public double getNormalizationPSF() {
return normalizationPSF;
}
/**
* @param normalizationPSF
* the normalizationPSF to set
*/
public void setNormalizationPSF(double normalizationPSF) {
this.normalizationPSF = normalizationPSF;
}
/**
* @return the epsilon
*/
public double getEpsilon() {
return epsilon;
}
/**
* @param epsilon
* the epsilon to set
*/
public void setEpsilon(double epsilon) {
this.epsilon = epsilon;
}
/**
* @return the padding
*/
public Padding getPadding() {
return padding;
}
/**
* @param padding
* the padding to set
*/
public void setPadding(Padding padding) {
this.padding = padding;
}
/**
* @return the apodization
*/
public Apodization getApodization() {
return apodization;
}
/**
* @param apodization
* the apodization to set
*/
public void setApodization(Apodization apodization) {
this.apodization = apodization;
}
/**
* @return the monitors
*/
public Monitors getMonitors() {
if (monitors == null)
return Monitors.createDefaultMonitor();
return monitors;
}
/**
* @param monitors
* the monitors to set
*/
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
/**
* @return the verbose
*/
public Verbose getVerbose() {
return verbose;
}
/**
* @param verbose
* the verbose to set
*/
public void setVerbose(Verbose verbose) {
this.verbose = verbose;
}
public Constraint.Mode getConstraint() {
return constraintMode;
}
public void setConstraint(Constraint.Mode constraintMode) {
doConstraint = constraintMode != Constraint.Mode.NO;
this.constraintMode = constraintMode;
}
/**
* @return the stats
*/
public Stats getStats() {
return stats;
}
/**
* @param stats
* the stats to set
*/
public void setStats(Stats stats) {
this.stats = stats;
}
/**
* @return the residuMin
*/
public double getResiduMin() {
return residuMin;
}
/**
* @param residuMin
* the residuMin to set
*/
public void setResiduMin(double residuMin) {
doResidu = residuMin > 0;
this.residuMin = residuMin;
}
/**
* @return the timeLimit
*/
public double getTimeLimit() {
return timeLimit;
}
/**
* @param timeLimit
* the timeLimit to set
*/
public void setTimeLimit(double timeLimit) {
doTime = timeLimit > 0;
this.timeLimit = timeLimit;
}
/**
* @return the reference
*/
public String getReferenceName() {
return referenceName;
}
/**
* @param reference
* the reference to set
*/
public void setReferenceName(String referenceName) {
doReference = false;
if (referenceName == null)
return;
if (referenceName.equals(""))
return;
doReference = true;
this.referenceName = referenceName;
}
/**
* @return the reference
*/
public RealSignal getReference() {
return refImage;
}
/**
* @param reference
* the reference to set
*/
public void setReference(RealSignal refImage) {
doReference = false;
if (refImage == null)
return;
doReference = true;
this.refImage = refImage;
}
/**
* @return the outs
*/
public ArrayList<Output> getOuts() {
return outs;
}
/**
* @param outs
* the outs to set
*/
public void setOuts(ArrayList<Output> outs) {
this.outs = outs;
}
public void addOutput(Output out) {
this.outs.add(out);
}
public String toStringMonitor() {
String s = "[" + verbose.name().toLowerCase() + "] ";
for (AbstractMonitor monitor : monitors) {
s += "" + monitor.getName() + " ";
}
return s;
}
public Stats.Mode getStatsMode() {
return stats.getMode();
}
public void setStatsMode(Stats.Mode mode) {
this.stats = new Stats(mode);
}
- public String toStringRunning() {
- String s = "";
- s += "system " + (system ? "shown" : "hidden ");
- s += ", multithreading " + (multithreading ? "on" : "off ");
- s += ", display final " + (displayFinal ? "on " : "off ");
- return s;
- }
-
public String toStringPath() {
File dir = new File(path);
if (dir.exists()) {
if (dir.isDirectory()) {
if (dir.canWrite())
return path + " (writable)";
else
return path + " (non-writable)";
}
else {
return path + " (non-directory)";
}
}
else {
return path + " (not-valid)";
}
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java
index aab8f59..08180c8 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/AbstractCapsule.java
@@ -1,117 +1,117 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JFrame;
import javax.swing.JSplitPane;
import deconvolution.Deconvolution;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
public abstract class AbstractCapsule {
protected Deconvolution deconvolution;
protected JSplitPane split;
private AsynchronousTimer signalTimer;
private Timer timer = new Timer();
private int count = 0;
private Monitors monitors;
private String message = "";
public AbstractCapsule(Deconvolution deconvolution) {
this.deconvolution = deconvolution;
this.monitors = deconvolution.getMonitors();
}
public JSplitPane getPane() {
return split;
}
public void show(String name) {
JFrame frame = new JFrame(name);
update();
frame.getContentPane().add(split);
frame.pack();
Lab.setVisible(frame);
}
public abstract void update();
- public abstract String getName();
+ public abstract String getID();
public void stopAsynchronousTimer() {
if (monitors != null)
monitors.progress(message, 100);
if (signalTimer != null) {
signalTimer.cancel();
signalTimer = null;
}
}
public void startAsynchronousTimer(String message, long refreshTime) {
if (signalTimer != null) {
signalTimer.cancel();
signalTimer = null;
}
this.message = message;
signalTimer = new AsynchronousTimer(message);
timer.schedule(signalTimer, 0, refreshTime);
}
public void signal(String message) {
if (monitors != null)
monitors.progress(message, count += 2);
}
private class AsynchronousTimer extends TimerTask {
private String message;
public AsynchronousTimer(String message) {
this.message = message;
}
@Override
public void run() {
signal(message);
}
}
@Override
public void finalize() {
stopAsynchronousTimer();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
index fc58d92..388c04c 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/AlgorithmCapsule.java
@@ -1,183 +1,197 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
+import java.awt.Point;
+import java.awt.Rectangle;
+
import javax.swing.JSplitPane;
+import javax.swing.JViewport;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.SignalCollector;
import bilib.component.HTMLPane;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.AlgorithmList;
import deconvolution.algorithm.AlgorithmPanel;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
/**
* This class is a information module for the algorithm.
*
* @author Daniel Sage
*
*/
public class AlgorithmCapsule extends AbstractCapsule implements Runnable {
private CustomizedTable table;
private HTMLPane doc;
public AlgorithmCapsule(Deconvolution deconvolution) {
super(deconvolution);
- doc = new HTMLPane(100, 1000);
+ doc = new HTMLPane(100, 100);
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
- split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), doc.getPane());
+ split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getPane(100, 100), doc.getPane());
+ split.setDividerLocation(0.5);
}
@Override
public void update() {
if (doc == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
- split.setDividerLocation(300);
}
@Override
- public String getName() {
+ public String getID() {
return "Algorithm";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.getAlgorithm() == null) {
features.add("Algorithm", "No valid algorithm");
return;
}
Algorithm algo = deconvolution.getAlgorithm();
doc.clear();
String name = algo.getShortnames()[0];
AlgorithmPanel algoPanel = AlgorithmList.getPanel(name);
if (algoPanel != null)
doc.append(algoPanel.getDocumentation());
+ String p = algo.getParametersAsString();
+ features.add("<html><b>Parameters</b></html>", p.equals("") ? "Parameters free" : p);
+ features.add("Iteration", algo.isIterative() ? "" + algo.getIterationsMax() : "Direct");
+
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("Image", "No valid PSF");
return;
}
startAsynchronousTimer("Check Algorithm", 200);
AbstractFFT f = FFT.getFastestFFT().getDefaultFFT();
double Q = Math.sqrt(2);
if (deconvolution.image != null) {
int mx = deconvolution.image.nx;
int my = deconvolution.image.ny;
int mz = deconvolution.image.nz;
while (mx * my * mz > Math.pow(2, 15)) {
mx = (int)(mx / Q);
my = (int)(my / Q);
mz = (int)(mz / Q);
}
double N = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
double M = mx * my * mz;
double ratio = 1;
if (M != 0)
ratio = (N * Math.log(N)) / (M * Math.log(M));
double chrono = System.nanoTime();
RealSignal x = new RealSignal("test", mx, my, mz);
ComplexSignal c = new ComplexSignal("test", mx, my, mz);
f.init(Monitors.createDefaultMonitor(), mx, my, mz);
f.transform(x, c);
SignalCollector.free(x);
SignalCollector.free(c);
chrono = (System.nanoTime() - chrono);
- features.add("Small dataset", mx + "x" + my + "x" + mz);
- features.add("Elapsed time on small dataset", NumFormat.time(chrono) );
- chrono = chrono * ratio * algo.getComplexityNumberofFFT();
+ double chronoI = chrono * ratio * algo.getComplexityNumberofFFT();
- features.add("Estimated time for input dataset", NumFormat.time(chrono) );
+ features.add("<html><b>Estimation</b></html>", "");
+ features.add("Estimated time", NumFormat.time(chronoI) );
features.add("Estimated number of FFTs", "" + algo.getComplexityNumberofFFT());
+
+ features.add("<html><b>Run on tiny dataset</b></html>", mx + "x" + my + "x" + mz);
+ features.add("Elapsed time", NumFormat.time(chrono) );
}
else
features.add("Estimated time", "Error" );
double mem = (algo.getMemoryFootprintRatio() * deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz * 4);
- features.add("Estimated required memory", NumFormat.bytes(mem));
- features.add("Iterative", algo.isIterative() ? "" + algo.getIterationsMax() : "Direct");
+ features.add("Required memory", NumFormat.bytes(mem));
table.removeRows();
for (String[] feature : features)
table.append(feature);
+
+ Rectangle rect = table.getCellRect(0, 0, true);
+ Point pt = ((JViewport) table.getParent()).getViewPosition();
+ rect.setLocation(rect.x - pt.x, rect.y - pt.y);
+
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
index c1155a1..74511f0 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/ImageCapsule.java
@@ -1,152 +1,152 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import bilib.component.PanelImage;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
/**
* This class is a information module for the image source.
*
* @author Daniel Sage
*
*/
public class ImageCapsule extends AbstractCapsule implements Runnable {
private PanelImage pnImage;
private CustomizedTable table;
public ImageCapsule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
@Override
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] {"Image", "Waiting for loading ..."});
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
- public String getName() {
+ public String getID() {
return "Image";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
startAsynchronousTimer("Open image", 200);
float stati[] = deconvolution.image.getStats();
int sizi = deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal Image</b></html>", "");
features.add("Size", deconvolution.image.dimAsString() + " " + NumFormat.bytes(sizi*4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Extrema (min, max)", NumFormat.nice(stati[1]) + ", " + NumFormat.nice(stati[2]));
features.add("Energy (integral)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
Padding pad = deconvolution.getController().getPadding();
Apodization apo = deconvolution.getController().getApodization();
RealSignal signal = pad.pad(deconvolution.getMonitors(), deconvolution.image);
apo.apodize(deconvolution.getMonitors(), signal);
float stats[] = signal.getStats();
int sizs = signal.nx * signal.ny * signal.nz;
float totals = stats[0] * sizs;
double incpad = (double)((sizs-sizi)/sizi*100.0);
features.add("<html><b>Working Image</b></html>", "");
features.add("Size", signal.dimAsString() + " " + NumFormat.bytes(sizs*4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
features.add("Extrema (min, max)", NumFormat.nice(stats[1]) + ", " + NumFormat.nice(stats[2]));
features.add("Energy (integral)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size increase (pad.)", NumFormat.nice(incpad) + "%");
features.add("Energy lost (apo.)", NumFormat.nice((stats[5]-stati[5])/stati[5]*100));
SignalCollector.free(signal);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.image.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
index 4db52ab..733ad36 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/PSFCapsule.java
@@ -1,158 +1,158 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import bilib.component.PanelImage;
import bilib.table.CustomizedTable;
import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import signal.RealSignal;
import signal.SignalCollector;
/**
* This class is a information module for the PSF source.
*
* @author Daniel Sage
*
*/
public class PSFCapsule extends AbstractCapsule implements Runnable {
private PanelImage pnImage;
private CustomizedTable table;
public PSFCapsule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
@Override
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
table.append(new String[] { "PSF", "Waiting for loading ..." });
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
@Override
- public String getName() {
+ public String getID() {
return "PSF";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.image == null) {
startAsynchronousTimer("Open image", 200);
deconvolution.image = deconvolution.openImage();
stopAsynchronousTimer();
}
if (deconvolution.getController().getPadding() == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.getController().getApodization() == null) {
features.add("Apodization", "No valid apodization");
return;
}
if (deconvolution.psf == null) {
startAsynchronousTimer("Open PSF", 200);
deconvolution.psf = deconvolution.openPSF();
stopAsynchronousTimer();
}
if (deconvolution.psf == null) {
features.add("PSF", "No valid PSF");
return;
}
startAsynchronousTimer("Open PSF", 200);
float stati[] = deconvolution.psf.getStats();
int sizi = deconvolution.psf.nx * deconvolution.psf.ny * deconvolution.psf.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Orignal PSF</b></html>", "");
features.add("Size", deconvolution.psf.dimAsString() + " " + NumFormat.bytes(sizi * 4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Extrema (min, max)", NumFormat.nice(stati[1]) + ", " + NumFormat.nice(stati[2]));
features.add("Energy (integral)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
RealSignal h;
if (deconvolution.image == null) {
features.add("Image", "No valid input image to resize");
h = deconvolution.psf.duplicate();
}
else
h = deconvolution.psf.changeSizeAs(deconvolution.image);
h.normalize(deconvolution.getController().getNormalizationPSF());
float stats[] = h.getStats();
int sizs = h.nx * h.ny * h.nz;
float totals = stats[0] * sizs;
double incpad = (double)((sizs-sizi)/sizi*100.0);
features.add("<html><b>Working PSF</b></html>", "");
features.add("Size", h.dimAsString() + " " + NumFormat.bytes(sizs * 4));
features.add("Mean (stdev)", NumFormat.nice(stats[0]) + " (" + NumFormat.nice(stats[3]) + ")");
features.add("Extrema (min, max)", NumFormat.nice(stats[1]) + ", " + NumFormat.nice(stats[2]));
features.add("Energy (integral)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size increase (image)", NumFormat.nice(incpad) + "%");
features.add("Energy lost", NumFormat.nice((stats[5] - stati[5]) / stati[5] * 100));
SignalCollector.free(h);
table.removeRows();
for (String[] feature : features)
table.append(feature);
pnImage.setImage(deconvolution.psf.preview());
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
index 2a4d302..6d563e8 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/RecapCapsule.java
@@ -1,114 +1,126 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
+import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import java.util.ArrayList;
import javax.swing.JSplitPane;
+import javax.swing.JViewport;
import javax.swing.text.BadLocationException;
import bilib.component.HTMLPane;
+import bilib.table.CustomizedColumn;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
/**
* This class is a information module for a recapitulation of the command line.
*
* @author Daniel Sage
- *
+ *
*/
public class RecapCapsule extends AbstractCapsule implements KeyListener {
- private HTMLPane pnCommand;
- private CustomizedTable table;
+ private HTMLPane pnCommand;
+ private CustomizedTable table;
public RecapCapsule(Deconvolution deconvolution) {
super(deconvolution);
// Panel command
- pnCommand = new HTMLPane("Monaco", "#10FF10", "100020", 100, 100);
+ pnCommand = new HTMLPane("Monaco", "#10FF10", "100020", 80, 80);
pnCommand.append("p", deconvolution.getCommand());
pnCommand.setEditable(true);
pnCommand.addKeyListener(this);
- table = new CustomizedTable(new String[] { "Features", "Values" }, false);
- split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), pnCommand.getPane());
+
+ ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
+ columns.add(new CustomizedColumn("Feature", String.class, 150, false));
+ columns.add(new CustomizedColumn("Value", String.class, 550, false));
+
+ table = new CustomizedTable(columns, false);
+ split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getPane(200, 200), pnCommand.getPane());
}
-
+
@Override
public void update() {
if (table == null)
return;
startAsynchronousTimer("Recap", 200);
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
+ Rectangle rect = table.getCellRect(0, 0, true);
+ Point pt = ((JViewport) table.getParent()).getViewPosition();
+ rect.setLocation(rect.x - pt.x, rect.y - pt.y);
- split.setDividerLocation(0.5);
+ table.scrollRectToVisible(rect);
+ split.setDividerLocation(0.7);
split.repaint();
stopAsynchronousTimer();
}
public String getCommand() {
return pnCommand.getText();
}
-
+
@Override
- public String getName() {
+ public String getID() {
return "Recap";
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
try {
int len = pnCommand.getDocument().getLength();
String command = pnCommand.getDocument().getText(0, len);
deconvolution.setCommand(command);
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
}
catch (BadLocationException e1) {
e1.printStackTrace();
}
}
-
-
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java b/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
index 47e6fe4..d1d7f80 100644
--- a/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
+++ b/DeconvolutionLab2/src/deconvolution/capsule/ReportCapsule.java
@@ -1,88 +1,88 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.capsule;
import java.awt.Dimension;
import javax.swing.JSplitPane;
import bilib.component.PanelImage;
import bilib.table.CustomizedTable;
import deconvolution.Deconvolution;
import signal.RealSignal;
/**
* This class is a information module for report the output.
*
* @author Daniel Sage
*
*/
public class ReportCapsule extends AbstractCapsule {
private PanelImage pnImage;
private CustomizedTable table;
public ReportCapsule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new PanelImage();
table = new CustomizedTable(new String[] { "Output", "Values" }, false);
pnImage.setPreferredSize(new Dimension(300, 300));
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(300, 300), pnImage);
}
@Override
public void update() {
split.setDividerLocation(300);
if (pnImage == null)
return;
if (table == null)
return;
table.removeRows();
for (String[] feature : deconvolution.getDeconvolutionReports())
table.append(feature);
RealSignal image = deconvolution.getOutput();
if (image == null) {
- table.append(new String[] {"ERROR", "No open output"});
+ table.append(new String[] {"Output", "No yet run"});
return;
}
pnImage.setImage(image.preview());
for (String[] feature : deconvolution.checkOutput())
table.append(feature);
split.setDividerLocation(300);
}
@Override
- public String getName() {
+ public String getID() {
return "Report";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/module/ResourcesModule.java b/DeconvolutionLab2/src/deconvolutionlab/module/ResourcesModule.java
index 38bba70..388f92b 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/module/ResourcesModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/module/ResourcesModule.java
@@ -1,163 +1,176 @@
/*
* 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.module;
import java.awt.BorderLayout;
-import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
-import javax.swing.JCheckBox;
+import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.JToolBar;
import bilib.component.GridPanel;
import bilib.table.CustomizedColumn;
+import bilib.tools.NumFormat;
import deconvolution.algorithm.AlgorithmList;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.system.SystemInfo;
+import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFTLibrary;
import fft.FFT;
public class ResourcesModule extends AbstractModule implements ActionListener {
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbEpsilon;
private JComboBox<String> cmbMultithreading;
private JComboBox<String> cmbSystem;
+ private JLabel lblFile;
+ private JLabel lblJava;
+
+ private JButton bnSystem;
public ResourcesModule() {
- super("Resources", "", "System", "Default");
+ super("Resources", "", "", "Default");
}
@Override
public String getCommand() {
String cmd = " ";
if (cmbFFT.getSelectedIndex() != 0)
cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
if (cmbEpsilon.getSelectedIndex() != 6)
cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
if (cmbMultithreading.getSelectedIndex() != 0)
cmd += " -multithreading no";
if (cmbSystem.getSelectedIndex() != 0)
cmd += " -system no";
return cmd;
}
public void update() {
AbstractFFTLibrary library = FFT.getLibraryByName((String) cmbFFT.getSelectedItem());
setCommand(getCommand());
setSynopsis(library.getLibraryName());
}
@Override
public JPanel buildExpandedPanel() {
+
+ bnSystem = new JButton("Show Resources Panel");
+ lblJava = new JLabel("Version: " + System.getProperty("java.version"));
+ lblJava.setBorder(BorderFactory.createEtchedBorder());
+ double maxi = SystemUsage.getTotalSpace();
+ double used = maxi - SystemUsage.getAvailableSpace();
+
+ lblFile = new JLabel("Space: " + NumFormat.bytes(used));
+ lblFile.setBorder(BorderFactory.createEtchedBorder());
+
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
cmbEpsilon.setSelectedItem("1E-6");
cmbMultithreading = new JComboBox<String>(new String[] { "yes", "no" });
cmbSystem = new JComboBox<String>(new String[] { "yes", "no" });
-
+
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("FFT Library", String.class, 100, false));
columns.add(new CustomizedColumn("Installed", String.class, 40, false));
columns.add(new CustomizedColumn("Installation", String.class, Constants.widthGUI, false));
-
- GridPanel pn = new GridPanel(false, 2);
+
+ GridPanel pn = new GridPanel(false, 4);
pn.place(0, 0, new JLabel("fft"));
pn.place(0, 1, cmbFFT);
pn.place(0, 2, new JLabel("FFT Library"));
-
+
pn.place(1, 0, new JLabel("espilon"));
pn.place(1, 1, cmbEpsilon);
pn.place(1, 2, new JLabel("Machine epsilon"));
-
- pn.place(2, 0, new JLabel("multithreading"));
- pn.place(2, 1, cmbMultithreading);
- pn.place(2, 2, new JLabel("Activate multithreading"));
-
- pn.place(3, 0, new JLabel("system"));
- pn.place(3, 1, cmbSystem);
- pn.place(3, 2, new JLabel("Open system panel at each run"));
+
+ pn.place(2, 0, new JLabel("Java"));
+ pn.place(2, 1, 2, 1, lblJava);
+
+ pn.place(3, 0, new JLabel("File"));
+ pn.place(3, 1, 2, 1, lblFile);
+ pn.place(4, 1, 2, 1, bnSystem);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.CENTER);
-
+
Config.register(getName(), "fft", cmbFFT, AlgorithmList.getDefaultAlgorithm());
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
Config.register(getName(), "system", cmbSystem, cmbSystem.getItemAt(0));
cmbMultithreading.addActionListener(this);
cmbFFT.addActionListener(this);
cmbEpsilon.addActionListener(this);
cmbSystem.addActionListener(this);
getAction1Button().addActionListener(this);
- getAction2Button().addActionListener(this);
+ bnSystem.addActionListener(this);
+
update();
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
- cmbFFT.setSelectedIndex(0);;
+ cmbFFT.setSelectedIndex(0);
cmbEpsilon.setSelectedItem("1E-6");
cmbMultithreading.setSelectedIndex(0);
cmbSystem.setSelectedIndex(0);
}
- else if (e.getSource() == getAction1Button()) {
+ else if (e.getSource() == bnSystem)
SystemInfo.activate();
- }
update();
}
@Override
public void close() {
cmbSystem.removeActionListener(this);
cmbFFT.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
cmbMultithreading.removeActionListener(this);
getAction1Button().removeActionListener(this);
- getAction2Button().removeActionListener(this);
+ bnSystem.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
index 29f1912..0c528c1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
@@ -1,119 +1,114 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import bilib.table.CustomizedTable;
import deconvolutionlab.Constants;
public abstract class AbstractMeter extends JButton {
protected Color colorBackground = new Color(10, 10, 10, 30);
protected Color colorText = new Color(10, 10, 10);
protected Color colorHot = new Color(10, 10, 160, 30);
protected CustomizedTable table;
protected HashMap<String, Integer> features = new HashMap<String, Integer>();
protected boolean initialized = false;
protected String prefix = "\u25BA ";
protected boolean collapse = true;
- public AbstractMeter() {
- super("");
- int w = (int)(Constants.widthGUI/3.2);
- int h = 25;
+ public AbstractMeter(int width) {
+ super("");;
+ int h = 28;
setBorder(BorderFactory.createEtchedBorder());
- setPreferredSize(new Dimension(w, h));
- setMinimumSize(new Dimension(w, h));
+ setPreferredSize(new Dimension(width, h));
+ setMinimumSize(new Dimension(width, h));
table = new CustomizedTable(new String[] {"Tool", "Feature", "Value"}, false);
}
public boolean isExpanded() {
return !collapse;
}
public void collapse() {
collapse = true;
prefix = " \u25BA ";
}
public void expand() {
collapse = false;
prefix = " \u25BC ";
}
public JPanel getPanel(int width, int height) {
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(width, height), BorderLayout.CENTER);
setDetail();
initialized = true;
return panel;
}
public abstract String getMeterName();
public abstract void setDetail();
public void update() {
if (table == null)
return;
setDetail();
}
protected void add(int i, String row[]) {
if (initialized) {
int r = features.get(row[0]);
if (i>=0 && i<table.getRowCount())
table.setCell(r, 1, row[1]);
}
else {
table.append(row);
features.put(row[0], i);
}
}
-
protected String split(String name) {
String func = name.substring(3);
return func.replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2");
}
-
-
-
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
index cb07214..9b72139 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
@@ -1,59 +1,63 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import fft.FFT;
public class FFTMeter extends AbstractMeter {
+ public FFTMeter(int width) {
+ super(width);
+ }
+
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(colorText);
g.drawString(prefix + FFT.getFastestFFT().getLibraryName(), 10, 17);
}
@Override
public void update() {
repaint();
}
@Override
public String getMeterName() {
return "FFT";
}
@Override
public void setDetail() {
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
index 7b058f6..0d94ca1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
@@ -1,91 +1,96 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import java.io.File;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
import bilib.tools.NumFormat;
public class FileMeter extends AbstractMeter {
+ public FileMeter(int width) {
+ super(width);
+ }
+
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
double maxi = SystemUsage.getTotalSpace();
double used = maxi - SystemUsage.getAvailableSpace();
String space = NumFormat.bytes(used);
int w = getWidth();
g.setColor(colorBackground);
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
g.setColor(colorText);
g.drawString(prefix + space, 10, 17);
}
@Override
public void update() {
repaint();
}
@Override
public String getMeterName() {
return "File";
}
@Override
public void setDetail() {
File[] roots = File.listRoots();
int i=0;
add(i++, new String[] { "Properties", "java.class.path", System.getProperty("java.class.path") });
add(i++, new String[] { "Properties", "java.home", System.getProperty("java.home") });
add(i++, new String[] { "Properties", "user.dir", System.getProperty("user.dir") });
add(i++, new String[] { "Properties", "user.home", System.getProperty("user.home") });
add(i++, new String[] { "Properties", "user.name", System.getProperty("user.name") });
for (File root : roots) {
add(i++, new String[] { "FileSystem", "Root Path", root.getAbsolutePath() });
add(i++, new String[] { "FileSystem", "Total Space", NumFormat.bytes(root.getTotalSpace()) });
add(i++, new String[] { "FileSystem", "Usable Space", NumFormat.bytes(root.getUsableSpace()) });
}
ClassLoadingMXBean loader = ManagementFactory.getClassLoadingMXBean();
add(i++, new String[] { "ClassLoading", "Loaded Class", "" + loader.getLoadedClassCount() });
}
+
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
index 9820067..224b135 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
@@ -1,79 +1,83 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import bilib.tools.NumFormat;
public class JavaMeter extends AbstractMeter {
+ public JavaMeter(int width) {
+ super(width);
+ }
+
@Override
public void paintComponent(Graphics g) {
g.setColor(colorText);
g.drawString(prefix + "Java "+ System.getProperty("java.version") , 10, 17);
}
@Override
public void update() {
repaint();
}
@Override
public String getMeterName() {
return "Java";
}
@Override
public void setDetail() {
int i = 0;
add(i++, new String[] { "Properties", "OS", System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch") });
add(i++, new String[] { "Properties", "Java Version", System.getProperty("java.version") });
RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
add(i++, new String[] { "Runtime", "LibraryPath", rt.getLibraryPath() });
add(i++, new String[] { "Runtime", "Name", rt.getName() });
add(i++, new String[] { "Runtime", "VmVersion", rt.getVmVersion() });
for (int k = 0; k<rt.getInputArguments().size(); k++) {
String input = rt.getInputArguments().get(k);
add(i++, new String[] { "Runtime", "Input Arguments " + (k+1), input });
}
Runtime runt = Runtime.getRuntime();
add(i++, new String[] { "JVM", "Available processors", "" + runt.availableProcessors() });
add(i++, new String[] { "JVM", "Initial Memory (-Xms)", NumFormat.bytes(runt.freeMemory()) });
add(i++, new String[] { "JVM", "Maximum Memory (-Xmx)", NumFormat.bytes(runt.maxMemory()) });
add(i++, new String[] { "JVM", "Total Used Memory", NumFormat.bytes(runt.totalMemory()) });
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
index 86c79c2..b568079 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
@@ -1,101 +1,105 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import bilib.tools.NumFormat;
public class MemoryMeter extends AbstractMeter {
- private double peak;
+ private double peak = 0;
+
+ public MemoryMeter(int width) {
+ super(width);
+ }
public void reset() {
peak = 0;
}
@Override
public void update() {
repaint();
}
@Override
public void paintComponent(Graphics g) {
MemoryUsage mem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
double used = mem.getUsed();
double maxi = mem.getMax();
peak = Math.max(used, peak);
super.paintComponent(g);
int w = getWidth();
g.setColor(colorBackground);
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
int posp = (int)Math.round(w*peak/maxi);
String u = NumFormat.bytes(used);
g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
g.fillRect(0, 0, posp, 30);
g.setColor(colorText);
g.drawString(prefix + u, 10, 17);
}
@Override
public String getMeterName() {
return "Memory";
}
@Override
public void setDetail() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
MemoryUsage heapU = mem.getHeapMemoryUsage();
MemoryUsage nonhU = mem.getNonHeapMemoryUsage();
Runtime runt = Runtime.getRuntime();
int i = 0;
add(i++, new String[] { "JVM", "Initial Memory (-Xms)", NumFormat.bytes(runt.freeMemory()) });
add(i++, new String[] { "JVM", "Maximum Memory (-Xmx)", NumFormat.bytes(runt.maxMemory()) });
add(i++, new String[] { "JVM", "Total Used Memory", NumFormat.bytes(runt.totalMemory()) });
add(i++, new String[] { "Memory", "Heap Used", NumFormat.bytes(heapU.getUsed()) });
add(i++, new String[] { "Memory", "Heap Init", NumFormat.bytes(heapU.getInit()) });
add(i++, new String[] { "Memory", "Heap Max ", NumFormat.bytes(heapU.getMax()) });
add(i++, new String[] { "Memory", "NonHeap Used", NumFormat.bytes(nonhU.getUsed()) });
add(i++, new String[] { "Memory", "NonHeap Init", NumFormat.bytes(nonhU.getInit()) });
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
index ac1f84d..609a191 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
@@ -1,104 +1,108 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Color;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import bilib.tools.NumFormat;
public class ProcessorMeter extends AbstractMeter {
+ public ProcessorMeter(int width) {
+ super(width);
+ }
+
@Override
public void update() {
repaint();
}
@Override
public void paintComponent(Graphics g) {
double used = SystemUsage.getLoad();
double maxi = 100;
super.paintComponent(g);
int w = getWidth();
g.setColor(new Color(10, 10, 10, 30));
for(int i=0; i<w; i+=w/10)
g.drawLine(i, 0, i, 30);
int posu = (int)Math.round(w*used/maxi);
String u = String.format("%3.3f", used);
g.setColor(colorHot);
g.fillRect(0, 0, posu, 30);
g.setColor(colorText);
g.drawString(prefix + u + "%", 10, 17);
}
@Override
public String getMeterName() {
return "Processor";
}
@Override
public void setDetail() {
Runtime runt = Runtime.getRuntime();
int i = 0;
RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
add(i++, new String[] { "JVM", "Available processors", "" + runt.availableProcessors() });
add(i++, new String[] { "Runtime", "Uptime", "" + NumFormat.time(rt.getUptime()*1e6) });
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
for (Method method : os.getClass().getDeclaredMethods()) {
method.setAccessible(true);
if (method.getName().startsWith("get") && Modifier.isPublic(method.getModifiers())) {
try {
String name = split(method.getName());
if (name.contains("Size"))
add(i++, new String[] { "OS", name, NumFormat.bytes(Double.parseDouble(method.invoke(os).toString())) });
else if (name.contains("Time"))
add(i++, new String[] { "OS", name, NumFormat.time(Double.parseDouble(method.invoke(os).toString())) });
else if (name.contains("Load"))
add(i++, new String[] { "OS", name, NumFormat.nice(100 * Double.parseDouble(method.invoke(os).toString()))+"%" });
else
add(i++, new String[] { "OS", name, "" + method.invoke(os).toString() });
}
catch (Exception e) {
}
}
}
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
index 229ff4c..b216dd8 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SignalMeter.java
@@ -1,60 +1,64 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import signal.SignalCollector;
public class SignalMeter extends AbstractMeter {
+ public SignalMeter(int width) {
+ super(width);
+ }
+
@Override
public void paintComponent(Graphics g) {
g.setColor(colorText);
g.drawString(prefix + SignalCollector.sumarize(), 10, 17);
}
@Override
public void update() {
repaint();
}
@Override
public String getMeterName() {
return "Signals";
}
@Override
public void setDetail() {
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
index 2bf6d43..8cac7e0 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
@@ -1,287 +1,286 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
-import bilib.component.PanelImage;
+import signal.SignalCollector;
import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import fft.FFTPanel;
-import signal.SignalCollector;
public class SystemInfo extends JDialog implements WindowListener, ActionListener, MouseListener {
private JPanel cards;
private String[] rates = new String[] { "1 s.", "0.5 s.", "0.2 s.", "0.1 s.", "10 s.", "5 s.", "2 s." };
private JButton bnRate = new JButton("1 s.");
private JButton bnClear = new JButton("Clear");
private Timer timer = new Timer();
private TimerTask updater = new Updater();
private MemoryMeter memory;
private ProcessorMeter processor;
private SignalMeter signal;
private FFTMeter fft;
private JavaMeter java;
private FileMeter file;
private int width = Constants.widthGUI;
private static SystemInfo instance;
private int rate = 0;
private ArrayList<AbstractMeter> meters = new ArrayList<AbstractMeter>();
public static void activate() {
if (instance == null) {
instance = new SystemInfo();
Lab.setVisible(instance, false);
Config.registerFrame("System", "Frame", instance);
return;
}
if (!instance.isVisible())
Lab.setVisible(instance, false);
instance.toFront();
}
public static void close() {
if (instance == null)
return;
if (instance.isVisible())
instance.dispose();
}
private SystemInfo() {
super(new JFrame(), "DeconvolutionLab2 System");
-
- memory = new MemoryMeter();
- processor = new ProcessorMeter();
- signal = new SignalMeter();
- fft = new FFTMeter();
- java = new JavaMeter();
- file = new FileMeter();
+
+ memory = new MemoryMeter(width/3);
+ processor = new ProcessorMeter(width/3);
+ signal = new SignalMeter(width/3);
+ fft = new FFTMeter(width/3);
+ java = new JavaMeter(width/3);
+ file = new FileMeter(width/3);
meters.add(memory);
meters.add(processor);
meters.add(signal);
meters.add(fft);
meters.add(java);
meters.add(file);
// Panel meters on top
JPanel meters = new JPanel(new GridLayout(2, 3));
meters.add(file);
meters.add(memory);
meters.add(processor);
meters.add(java);
meters.add(signal);
meters.add(fft);
bnClear.setToolTipText("Clear all the entries");
bnRate.setToolTipText("Choose the rate of refreshing the information");
JPanel pan = new JPanel(new GridLayout(2, 1));
pan.add(bnRate);
pan.add(bnClear);
restart();
// Panel Compact
- PanelImage pnCompact = new PanelImage("celegans.jpg");
+ JPanel pnCompact = new JPanel();
pnCompact.setPreferredSize(new Dimension(width, 20));
// Panel cards, compact is visible
cards = new JPanel(new CardLayout());
cards.add("collapse", pnCompact);
cards.add(signal.getMeterName(), SignalCollector.getPanel(width, 200));
cards.add(memory.getMeterName(), memory.getPanel(width, 200));
cards.add(processor.getMeterName(), processor.getPanel(width, 200));
cards.add(fft.getMeterName(), new FFTPanel(width, 200));
cards.add(java.getMeterName(), java.getPanel(width, 200));
cards.add(file.getMeterName(), file.getPanel(width, 200));
cards.setVisible(false);
JPanel top = new JPanel(new BorderLayout());
top.add(meters, BorderLayout.CENTER);
top.add(pan, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(top, BorderLayout.NORTH);
panel.add(cards, BorderLayout.CENTER);
getContentPane().add(panel);
bnClear.addActionListener(this);
signal.addMouseListener(this);
memory.addMouseListener(this);
processor.addMouseListener(this);
java.addMouseListener(this);
file.addMouseListener(this);
fft.addMouseListener(this);
bnRate.addActionListener(this);
setMinimumSize(new Dimension(width, 70));
pack();
bnClear.setEnabled(signal.isExpanded());
Rectangle rect = Config.getDialog("System.Frame");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnRate) {
rate++;
if (rate >= rates.length)
rate = 0;
bnRate.setText(rates[rate]);
restart();
}
if (e.getSource() == bnClear) {
SignalCollector.clear();
}
pack();
}
public void update() {
for(AbstractMeter meter : meters)
meter.update();
}
public void restart() {
long refreshTime = (long) (NumFormat.parseNumber(bnRate.getText(), 1) * 1000);
if (updater != null) {
updater.cancel();
updater = null;
}
updater = new Updater();
timer.schedule(updater, 0, refreshTime);
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() instanceof AbstractMeter) {
AbstractMeter meter = (AbstractMeter) e.getSource();
if (meter.isExpanded()) {
meter.collapse();
cards.setVisible(false);
}
else for(AbstractMeter m : meters) {
if (m.isExpanded())
m.collapse();
meter.expand();
cards.setVisible(true);
}
((CardLayout) (cards.getLayout())).show(cards, meter.getMeterName());
pack();
}
bnClear.setEnabled(signal.isExpanded());
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
timer.cancel();
timer = null;
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
deleted file mode 100644
index 3871fad..0000000
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * DeconvolutionLab2
- *
- * Conditions of use: You are free to use this software for research or
- * educational purposes. In addition, we expect you to include adequate
- * citations and acknowledgments whenever you present or publish results that
- * are based on it.
- *
- * Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
- * Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
- * R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
- */
-
-/*
- * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
- *
- * This file is part of DeconvolutionLab2 (DL2).
- *
- * DL2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * DL2. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package deconvolutionlab.system;
-
-import java.awt.BorderLayout;
-import java.awt.CardLayout;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.Rectangle;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-
-import signal.SignalCollector;
-import bilib.component.PanelImage;
-import bilib.tools.NumFormat;
-import deconvolutionlab.Config;
-import deconvolutionlab.Constants;
-import fft.FFTPanel;
-
-public class SystemPanel extends JPanel implements ActionListener, MouseListener {
-
- private JPanel cards;
-
- private String[] rates = new String[] { "1 s.", "0.5 s.", "0.2 s.", "0.1 s.", "10 s.", "5 s.", "2 s." };
- private JButton bnRate = new JButton("1 s.");
- private JButton bnClear = new JButton("Clear");
-
- private Timer timer = new Timer();
- private TimerTask updater = new Updater();
-
- private MemoryMeter memory;
- private ProcessorMeter processor;
- private SignalMeter signal;
- private FFTMeter fft;
- private JavaMeter java;
- private FileMeter file;
-
- private int width = Constants.widthGUI;
-
- private static SystemPanel instance;
- private int rate = 0;
-
- private ArrayList<AbstractMeter> meters = new ArrayList<AbstractMeter>();
-
- public static SystemPanel getInstance(JFrame parent) {
- if (instance == null) {
- instance = new SystemPanel();
- }
- return instance;
- }
-
-
- private SystemPanel() {
- memory = new MemoryMeter();
- processor = new ProcessorMeter();
- signal = new SignalMeter();
- fft = new FFTMeter();
- java = new JavaMeter();
- file = new FileMeter();
- meters.add(memory);
- meters.add(processor);
- meters.add(signal);
- meters.add(fft);
- meters.add(java);
- meters.add(file);
-
- // Panel meters on top
- JPanel meters = new JPanel(new GridLayout(2, 3));
- meters.add(file);
- meters.add(memory);
- meters.add(processor);
- meters.add(java);
- meters.add(signal);
- meters.add(fft);
-
- bnClear.setToolTipText("Clear all the entries");
- bnRate.setToolTipText("Choose the rate of refreshing the information");
- JPanel pan = new JPanel(new GridLayout(2, 1));
- pan.add(bnRate);
- pan.add(bnClear);
-
- restart();
-
-
- // Panel Compact
- PanelImage pnCompact = new PanelImage("celegans.jpg");
- pnCompact.setPreferredSize(new Dimension(width, 20));
-
- // Panel cards, compact is visible
- cards = new JPanel(new CardLayout());
- cards.add("collapse", pnCompact);
- cards.add(signal.getName(), SignalCollector.getPanel(width, 200));
- cards.add(memory.getName(), memory.getPanel(width, 200));
- cards.add(processor.getName(), processor.getPanel(width, 200));
- cards.add(fft.getName(), new FFTPanel(width, 200));
- cards.add(java.getName(), java.getPanel(width, 200));
- cards.add(file.getName(), file.getPanel(width, 200));
-
- cards.setVisible(false);
- JPanel top = new JPanel(new BorderLayout());
- top.add(meters, BorderLayout.CENTER);
- top.add(pan, BorderLayout.EAST);
-
- setLayout(new BorderLayout());
- add(top, BorderLayout.NORTH);
- add(cards, BorderLayout.CENTER);
-
-
- bnClear.addActionListener(this);
- signal.addMouseListener(this);
- memory.addMouseListener(this);
- processor.addMouseListener(this);
- java.addMouseListener(this);
- file.addMouseListener(this);
- fft.addMouseListener(this);
- bnRate.addActionListener(this);
- setMinimumSize(new Dimension(width, 70));
-
- bnClear.setEnabled(signal.isExpanded());
- Rectangle rect = Config.getDialog("System.Frame");
- if (rect.x > 0 && rect.y > 0)
- setLocation(rect.x, rect.y);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
-
- if (e.getSource() == bnRate) {
- rate++;
- if (rate >= rates.length)
- rate = 0;
- bnRate.setText(rates[rate]);
- restart();
- }
-
- if (e.getSource() == bnClear) {
- SignalCollector.clear();
- }
- }
-
- public void update() {
- for(AbstractMeter meter : meters)
- meter.update();
- }
-
- public void restart() {
- long refreshTime = (long) (NumFormat.parseNumber(bnRate.getText(), 1) * 1000);
-
- if (updater != null) {
- updater.cancel();
- updater = null;
- }
- updater = new Updater();
- timer.schedule(updater, 0, refreshTime);
- }
-
- private class Updater extends TimerTask {
- @Override
- public void run() {
- update();
- }
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- if (e.getSource() instanceof AbstractMeter) {
- AbstractMeter meter = (AbstractMeter) e.getSource();
- if (meter.isExpanded()) {
- meter.collapse();
- cards.setVisible(false);
- }
- else for(AbstractMeter m : meters) {
- if (m.isExpanded())
- m.collapse();
- meter.expand();
- cards.setVisible(true);
- }
- ((CardLayout) (cards.getLayout())).show(cards, meter.getName());
-
- }
- bnClear.setEnabled(signal.isExpanded());
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
-
-}
Event Timeline
Log In to Comment