Page MenuHomec4science

No OneTemporary

File Metadata

Created
Wed, Dec 18, 18:20
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/DeconvolutionLab2/src/DeconvolutionLab2.java b/DeconvolutionLab2/src/DeconvolutionLab2.java
index ead7a4d..693f8a5 100644
--- a/DeconvolutionLab2/src/DeconvolutionLab2.java
+++ b/DeconvolutionLab2/src/DeconvolutionLab2.java
@@ -1,133 +1,133 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
import deconvolutionlab.Imaging;
import deconvolutionlab.Imaging.Platform;
import deconvolutionlab.Lab;
import deconvolutionlab.LabDialog;
import deconvolutionlab.monitor.Monitors;
public class DeconvolutionLab2 {
public static String ack = Constants.name + " " + Constants.version + " " + Constants.copyright;
public static void main(String arg[]) {
System.out.println(ack);
Lab.init(Platform.STANDALONE);
if (arg.length == 0) {
System.out.println("Starting lab");
lab(arg);
return;
}
String flag = arg[0].trim().toLowerCase();
if (flag.equalsIgnoreCase("help")) {
System.out.println("Starting help");
help();
return;
}
else if (flag.equalsIgnoreCase("lab")) {
System.out.println("Starting lab");
lab(arg);
}
else if (flag.equalsIgnoreCase("fft")) {
System.out.println("Starting fft");
Lab.checkFFT(Monitors.createDefaultMonitor());
}
else if (flag.equalsIgnoreCase("run")) {
System.out.println("Starting run");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Run", cmd, Deconvolution.Finish.KILL).deconvolve();
}
else if (flag.equalsIgnoreCase("launch")) {
System.out.println("Starting launch");
String cmd = "";
for (int i = 1; i < arg.length; i++)
cmd += arg[i] + " ";
new Deconvolution("Launch", cmd, Deconvolution.Finish.KILL).launch();
}
else
System.out.println("" + flag + " command not found");
}
private static void lab(String arg[]) {
String config = System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config";
if (arg.length >= 2) {
String filename = arg[1].trim();
File file = new File(filename);
if (file.exists())
if (file.isFile())
if (file.canRead())
config = filename;
}
Lab.init(Platform.STANDALONE, config);
LabDialog dialog = new LabDialog();
dialog.setVisible(true);
}
public static void help() {
System.out.println("More info:" + Constants.url);
System.out.println("Syntax:");
System.out.println("java -jar DeconvolutionLab_2.jar lab");
System.out.println("java -jar DeconvolutionLab_2.jar run {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar launch {command} ...");
System.out.println("java -jar DeconvolutionLab_2.jar fft");
System.out.println("java -jar DeconvolutionLab_2.jar info");
System.out.println("java -jar DeconvolutionLab_2.jar help");
System.out.println("{command} is the full command line for running a deconvolution");
- System.out.print("Keywords of {command}: ");
+ System.out.println("Keywords of {command}: ");
for (String keyword : Command.keywords)
- System.out.print(keyword + " ");
+ System.out.println("\t" + keyword);
}
public DeconvolutionLab2(String cmd) {
System.out.println("cmd: " + cmd);
Lab.init(Imaging.Platform.STANDALONE, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
new Deconvolution("CommandLine", cmd).deconvolve();
}
}
diff --git a/DeconvolutionLab2/src/lab/component/BorderToggledButton.java b/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
similarity index 94%
rename from DeconvolutionLab2/src/lab/component/BorderToggledButton.java
rename to DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
index 06a7f7d..5e1b91e 100644
--- a/DeconvolutionLab2/src/lab/component/BorderToggledButton.java
+++ b/DeconvolutionLab2/src/bilib/component/BorderToggledButton.java
@@ -1,22 +1,22 @@
-package lab.component;
+package bilib.component;
import java.awt.Insets;
import javax.swing.JButton;
public class BorderToggledButton extends JButton {
private String text = "";
public BorderToggledButton(String text) {
super(text);
this.text = text;
setMargin(new Insets(1, 1, 1, 1));
}
public void setSelected(boolean selected) {
if (selected)
setText("<html><b>" + text + "</b></html>");
else
setText(text);
}
}
diff --git a/DeconvolutionLab2/src/lab/component/CustomizedColumn.java b/DeconvolutionLab2/src/bilib/component/CustomizedColumn.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/component/CustomizedColumn.java
rename to DeconvolutionLab2/src/bilib/component/CustomizedColumn.java
index dbcb563..ecca2c4 100644
--- a/DeconvolutionLab2/src/lab/component/CustomizedColumn.java
+++ b/DeconvolutionLab2/src/bilib/component/CustomizedColumn.java
@@ -1,67 +1,67 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
public class CustomizedColumn {
public Class<?> classe;
public String header;
public int width;
public boolean editable;
public String[] choices; // Combobox
public String button; // Button
public String tooltip;
public CustomizedColumn(String header, Class<?> classe, int width, boolean editable) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = editable;
}
public CustomizedColumn(String header, Class<?> classe, int width, String[] choices, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = true;
this.choices = choices;
this.tooltip = tooltip;
}
public CustomizedColumn(String header, Class<?> classe, int width, String button, String tooltip) {
this.classe = classe;
this.header = header;
this.width = width;
this.editable = false;
this.button = button;
this.tooltip = tooltip;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/CustomizedTable.java b/DeconvolutionLab2/src/bilib/component/CustomizedTable.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/CustomizedTable.java
rename to DeconvolutionLab2/src/bilib/component/CustomizedTable.java
index 635144c..a53bf91 100644
--- a/DeconvolutionLab2/src/lab/component/CustomizedTable.java
+++ b/DeconvolutionLab2/src/bilib/component/CustomizedTable.java
@@ -1,298 +1,298 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
public class CustomizedTable extends JTable {
private JScrollPane pane = null;
private ArrayList<CustomizedColumn> columns;
public CustomizedTable(String headers[], boolean sortable) {
ArrayList<CustomizedColumn> colums = new ArrayList<CustomizedColumn>();
for (int i = 0; i < headers.length; i++)
colums.add(new CustomizedColumn(headers[i], String.class, 150, false));
create(colums);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
public CustomizedTable(ArrayList<CustomizedColumn> columns, boolean sortable) {
create(columns);
setAutoCreateRowSorter(sortable);
setRowHeight(20);
}
private void create(ArrayList<CustomizedColumn> column) {
columns = column;
DefaultTableModel model = new DefaultTableModel() {
@Override
public boolean isCellEditable(int row, int col) {
return columns.get(col).editable;
}
@Override
public Class<?> getColumnClass(int col) {
return columns.get(col).classe;
}
};
setModel(model);
int n = columns.size();
String headers[] = new String[n];
for (int col = 0; col < n; col++)
headers[col] = columns.get(col).header;
model.setColumnIdentifiers(headers);
setFillsViewportHeight(true);
for (int col = 0; col < n; col++) {
TableColumn tc = getColumnModel().getColumn(col);
tc.setPreferredWidth(columns.get(col).width);
if (columns.get(col).choices != null) {
JComboBox<String> cmb = new JComboBox<String>();
for (String p : columns.get(col).choices) {
cmb.addItem(p);
cmb.setToolTipText(columns.get(col).tooltip);
tc.setCellEditor(new DefaultCellEditor(cmb));
}
}
if (columns.get(col).button != null) {
ButtonRenderer bn = new ButtonRenderer();
bn.setToolTipText(columns.get(col).tooltip);
tc.setCellRenderer(bn);
}
}
getTableHeader().setReorderingAllowed(false);
}
public void setPreferredSize(int width, int height) {
if (pane != null)
pane.setPreferredSize(new Dimension(width, height));
}
public void removeRow(int row) {
if (row >= 0 && row < getRowCount())
((DefaultTableModel) getModel()).removeRow(row);
}
public void removeRows() {
while(getRowCount() > 0)
((DefaultTableModel) getModel()).removeRow(0);
}
public String[] getRow(int row) {
if (row >= 0) {
int ncol = getColumnCount();
String items[] = new String[ncol];
for (int col = 0; col < ncol; col++)
items[col] = (String) getModel().getValueAt(row, col);
return items;
}
return new String[1];
}
public String getCell(int row, int col) {
if (row >= 0 && col >= 0) {
return (String) getModel().getValueAt(row, col);
}
return "";
}
public void setCell(int row, int col, String value) {
if (row >= 0 && col >= 0) {
getModel().setValueAt(value, row, col);
}
}
public String getRowCSV(int row, String seperator) {
if (row >= 0) {
int ncol = getColumnCount();
String items = "";
for (int col = 0; col < ncol - 1; col++) {
if ((String) getModel().getValueAt(row, col) == null)
items += "" + seperator;
else
items += (String) getModel().getValueAt(row, col) + seperator;
}
if (ncol >= 1)
items += (String) getModel().getValueAt(row, ncol - 1);
return items;
}
return "";
}
public void saveCSV(String filename) {
File file = new File(filename);
try {
BufferedWriter buffer = new BufferedWriter(new FileWriter(file));
int nrows = getRowCount();
int ncols = getColumnCount();
String row = "";
for (int c = 0; c < columns.size(); c++)
row += columns.get(c).header + (c == columns.size() - 1 ? "" : ", ");
buffer.write(row + "\n");
for (int r = 0; r < nrows; r++) {
row = "";
for (int c = 0; c < ncols; c++)
row += this.getCell(r, c) + (c == ncols - 1 ? "" : ", ");
buffer.write(row + "\n");
}
buffer.close();
}
catch (IOException ex) {
}
}
public String getSelectedAtColumn(int col) {
int row = getSelectedRow();
if (row >= 0)
return (String) getModel().getValueAt(row, col);
else
return "";
}
public void setSelectedAtColumn(int col, String selection) {
int nrows = this.getRowCount();
for (int i = 0; i < nrows; i++) {
String name = (String) getModel().getValueAt(i, col);
if (name.equals(selection))
this.setRowSelectionInterval(i, i + 1);
}
}
public void append(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.addRow(row);
i = getRowCount() - 1;
if (i >= 0) {
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
}
catch (Exception e) {
}
repaint();
}
public void insert(Object[] row) {
DefaultTableModel model = (DefaultTableModel) getModel();
int i = 0;
try {
model.insertRow(0, row);
getSelectionModel().setSelectionInterval(i, i);
scrollRectToVisible(new Rectangle(getCellRect(i, 0, true)));
}
catch (Exception e) {
}
repaint();
}
@Override
public int getSelectedRow() {
int row = super.getSelectedRow();
if (row < 0) {
if (getRowCount() > 0) {
setRowSelectionInterval(0, 0);
row = super.getSelectedRow();
}
return row;
}
return row;
}
public void update(ArrayList<String[]> data) {
DefaultTableModel model = (DefaultTableModel) getModel();
model.getDataVector().removeAllElements();
for (String[] row : data)
model.addRow(row);
repaint();
}
public JScrollPane getPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
pane = new JScrollPane(this);
return pane;
}
public JScrollPane getMinimumPane(int width, int height) {
setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
setMinimumSize(new Dimension(width, height));
setShowVerticalLines(true);
setPreferredScrollableViewportSize(new Dimension(width, height));
setFillsViewportHeight(true);
return new JScrollPane(this);
}
public JFrame show(String title, int w, int h) {
JFrame frame = new JFrame(title);
frame.add(getPane(w, h));
frame.pack();
frame.setVisible(true);
return frame;
}
public class ButtonRenderer extends JButton implements TableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setText((String)value);
setMargin(new Insets(1, 1, 1, 1));
return this;
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/GridPanel.java b/DeconvolutionLab2/src/bilib/component/GridPanel.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/GridPanel.java
rename to DeconvolutionLab2/src/bilib/component/GridPanel.java
index aa38b3d..0f89435 100644
--- a/DeconvolutionLab2/src/lab/component/GridPanel.java
+++ b/DeconvolutionLab2/src/bilib/component/GridPanel.java
@@ -1,200 +1,200 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* This class extends the JPanel to create grid panel given the possibility to
* place Java components in an organized manner in the dialog box.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class GridPanel extends JPanel {
private static final long serialVersionUID = 1L;
private GridBagLayout layout = new GridBagLayout();
private GridBagConstraints constraint = new GridBagConstraints();
private int defaultSpace = 3;
/**
* Constructor.
*/
public GridPanel() {
super();
setLayout(layout);
setBorder(BorderFactory.createEtchedBorder());
}
/**
* Constructor.
*/
public GridPanel(int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
}
/**
* Constructor.
*/
public GridPanel(boolean border) {
super();
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
}
/**
* Constructor.
*/
public GridPanel(String title) {
super();
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
}
/**
* Constructor.
*/
public GridPanel(boolean border, int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
}
/**
* Constructor.
*/
public GridPanel(String title, int defaultSpace) {
super();
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
}
/**
* Specify the defaultSpace.
*/
public void setSpace(int defaultSpace) {
this.defaultSpace = defaultSpace;
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, String label) {
place(row, col, 1, 1, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, String label) {
place(row, col, 1, 1, space, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, String label) {
place(row, col, width, height, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, JComponent comp) {
place(row, col, 1, 1, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, JComponent comp) {
place(row, col, 1, 1, space, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, JComponent comp) {
place(row, col, width, height, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int space, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(space, space, space, space);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int spaceHorizontal, int spaceVertical, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(spaceVertical, spaceHorizontal, spaceHorizontal, spaceVertical);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
}
diff --git a/DeconvolutionLab2/src/lab/component/GridPanelImage.java b/DeconvolutionLab2/src/bilib/component/GridPanelImage.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/component/GridPanelImage.java
rename to DeconvolutionLab2/src/bilib/component/GridPanelImage.java
index 756681b..8ce6965 100644
--- a/DeconvolutionLab2/src/lab/component/GridPanelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/GridPanelImage.java
@@ -1,65 +1,65 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
/**
* This class extends the JPanel to create grid panel given the possibility to
* place Java components in an organized manner in the dialog box.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class GridPanelImage extends GridPanel {
private Image image;
public GridPanelImage(boolean border, int defaultSpace, String filename) {
super(border, defaultSpace);
image = ImageLoader.get(filename);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/GridToolbar.java b/DeconvolutionLab2/src/bilib/component/GridToolbar.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/GridToolbar.java
rename to DeconvolutionLab2/src/bilib/component/GridToolbar.java
index f479333..721e775 100644
--- a/DeconvolutionLab2/src/lab/component/GridToolbar.java
+++ b/DeconvolutionLab2/src/bilib/component/GridToolbar.java
@@ -1,246 +1,246 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JToolBar;
/**
* This class extends the JToolbar to create grid panel given the possibility to
* place Java components in an organized manner in the dialog box.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class GridToolbar extends JToolBar {
private GridBagLayout layout = new GridBagLayout();
private GridBagConstraints constraint = new GridBagConstraints();
private int defaultSpace = 3;
/**
* Constructor.
*/
public GridToolbar() {
super("Control");
setLayout(layout);
setBorder(BorderFactory.createEtchedBorder());
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border) {
super("Control");
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(String title) {
super(title);
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(int defaultSpace) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, int defaultSpace) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, int defaultSpace, boolean floatable) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(boolean border, boolean floatable) {
super("Control");
setLayout(layout);
if (border) {
setBorder(BorderFactory.createEtchedBorder());
}
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(String title, boolean floatable) {
super(title);
setLayout(layout);
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(int defaultSpace, boolean floatable) {
super("Control");
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createEtchedBorder());
setFloatable(floatable);
}
/**
* Constructor.
*/
public GridToolbar(String title, int defaultSpace) {
super(title);
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(false);
}
/**
* Constructor.
*/
public GridToolbar(String title, int defaultSpace, boolean floatable) {
super(title);
setLayout(layout);
this.defaultSpace = defaultSpace;
setBorder(BorderFactory.createTitledBorder(title));
setFloatable(floatable);
}
/**
* Specify the defaultSpace.
*/
public void setSpace(int defaultSpace) {
this.defaultSpace = defaultSpace;
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, String label) {
place(row, col, 1, 1, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, String label) {
place(row, col, 1, 1, space, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, String label) {
place(row, col, width, height, defaultSpace, new JLabel(label));
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, JComponent comp) {
place(row, col, 1, 1, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int space, JComponent comp) {
place(row, col, 1, 1, space, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, JComponent comp) {
place(row, col, width, height, defaultSpace, comp);
}
/**
* Place a component in the northwest of the cell.
*/
public void place(int row, int col, int width, int height, int space, JComponent comp) {
if (comp == null)
return;
constraint.gridx = col;
constraint.gridy = row;
constraint.gridwidth = width;
constraint.gridheight = height;
constraint.anchor = GridBagConstraints.NORTHWEST;
constraint.insets = new Insets(space, space, space, space);
constraint.fill = GridBagConstraints.HORIZONTAL;
layout.setConstraints(comp, constraint);
add(comp);
}
}
diff --git a/DeconvolutionLab2/src/lab/component/HTMLPane.java b/DeconvolutionLab2/src/bilib/component/HTMLPane.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/HTMLPane.java
rename to DeconvolutionLab2/src/bilib/component/HTMLPane.java
index c319bd5..49a0c9e 100644
--- a/DeconvolutionLab2/src/lab/component/HTMLPane.java
+++ b/DeconvolutionLab2/src/bilib/component/HTMLPane.java
@@ -1,141 +1,141 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Dimension;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
/**
* This class extends the Java JEditorPane to make a easy to use panel to
* display HTML information.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class HTMLPane extends JEditorPane {
private String html = "";
private String header = "";
private String footer = "";
private Dimension dim;
private String font = "verdana";
private String color = "#222222";
private String background = "#f8f8f8";
public HTMLPane() {
create();
}
public HTMLPane(String font) {
this.font = font;
create();
}
public HTMLPane(int width, int height) {
this.dim = new Dimension(width, height);
create();
}
public HTMLPane(String font, int width, int height) {
this.font = font;
this.dim = new Dimension(width, height);
create();
}
public HTMLPane(String font, String color, String background, int width, int height) {
this.font = font;
this.dim = new Dimension(width, height);
this.color = color;
this.background = background;
create();
}
@Override
public String getText() {
Document doc = this.getDocument();
try {
return doc.getText(0, doc.getLength());
}
catch (BadLocationException e) {
e.printStackTrace();
return getText();
}
}
public void clear() {
html = "";
append("");
}
private void create() {
header += "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n";
header += "<html><head>\n";
header += "<style>body {background-color:" + background + "; color:" + color + "; font-family: " + font + ";margin:4px}</style>\n";
header += "<style>h1 {color:#555555; font-size:1.0em; font-weight:bold; padding:1px; margin:1px;}</style>\n";
header += "<style>h2 {color:#333333; font-size:0.9em; font-weight:bold; padding:1px; margin:1px;}</style>\n";
header += "<style>h3 {color:#000000; font-size:0.9em; font-weight:italic; padding:1px; margin:1px;}</style>\n";
header += "<style>p {color:" + color + "; font-size:0.9em; padding:1px; margin:0px;}</style>\n";
header += "</head>\n";
header += "<body>\n";
footer += "</body></html>\n";
setEditable(false);
setContentType("text/html; charset=ISO-8859-1");
}
public void append(String content) {
html += content;
setText(header + html + footer);
if (dim != null) {
setPreferredSize(dim);
}
setCaretPosition(0);
}
public void append(String tag, String content) {
html += "<" + tag + ">" + content + "</" + tag + ">";
setText(header + html + footer);
if (dim != null) {
setPreferredSize(dim);
}
setCaretPosition(0);
}
public JScrollPane getPane() {
JScrollPane scroll = new JScrollPane(this, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setPreferredSize(dim);
return scroll;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/ImageLoader.java b/DeconvolutionLab2/src/bilib/component/ImageLoader.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/component/ImageLoader.java
rename to DeconvolutionLab2/src/bilib/component/ImageLoader.java
index 1efaec7..c6a3cef 100644
--- a/DeconvolutionLab2/src/lab/component/ImageLoader.java
+++ b/DeconvolutionLab2/src/bilib/component/ImageLoader.java
@@ -1,50 +1,50 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;
public class ImageLoader {
public static Image get(String filename) {
URL url = ImageLoader.class.getResource(filename);
if (url != null) {
ImageIcon img = new ImageIcon(url, "") ;
return img.getImage();
}
return null;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/JPanelImage.java b/DeconvolutionLab2/src/bilib/component/JPanelImage.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/component/JPanelImage.java
rename to DeconvolutionLab2/src/bilib/component/JPanelImage.java
index 595da29..909c542 100644
--- a/DeconvolutionLab2/src/lab/component/JPanelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/JPanelImage.java
@@ -1,82 +1,82 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
/**
* This class extends the JPanel to create grid panel given the possibility to
* place Java components in an organized manner in the dialog box.
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class JPanelImage extends JPanel {
private Image image;
public JPanelImage() {
super();
}
public JPanelImage(BufferedImage img) {
super();
image = img;
}
public JPanelImage(String filename) {
super();
image = ImageLoader.get(filename);
}
public void setImage(BufferedImage image) {
this.image = image;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/LabelImage.java b/DeconvolutionLab2/src/bilib/component/LabelImage.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/component/LabelImage.java
rename to DeconvolutionLab2/src/bilib/component/LabelImage.java
index 0baf2ce..c0b2aab 100644
--- a/DeconvolutionLab2/src/lab/component/LabelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/LabelImage.java
@@ -1,58 +1,58 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JLabel;
public class LabelImage extends JLabel {
private Image image;
public LabelImage(String filename, int width, int height, Color altColor) {
image = ImageLoader.get(filename);
setOpaque(true);
setBackground(altColor);
setPreferredSize(new Dimension(200, 60));
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null)
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
}
diff --git a/DeconvolutionLab2/src/lab/component/PanelImage.java b/DeconvolutionLab2/src/bilib/component/PanelImage.java
similarity index 97%
rename from DeconvolutionLab2/src/lab/component/PanelImage.java
rename to DeconvolutionLab2/src/bilib/component/PanelImage.java
index 88fb6be..8ee743b 100644
--- a/DeconvolutionLab2/src/lab/component/PanelImage.java
+++ b/DeconvolutionLab2/src/bilib/component/PanelImage.java
@@ -1,53 +1,53 @@
-package lab.component;
+package bilib.component;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.JPanel;
public class PanelImage extends JPanel {
private Image image;
private int w = -1;
private int h = -1;
public PanelImage(String filename) {
super();
image = ImageLoader.get(filename);
}
public PanelImage(int w, int h) {
super();
image = null;
this.w = w;
this.h = h;
}
public PanelImage(String filename, int w, int h) {
super();
image = ImageLoader.get(filename);
this.w = w;
this.h = h;
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image != null) {
if (w < 0)
g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
else {
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(image, (getWidth()-w)/2, 0, w, h, null);
}
}
else {
g.setColor(Color.DARK_GRAY);
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
diff --git a/DeconvolutionLab2/src/lab/component/RegularizationPanel.java b/DeconvolutionLab2/src/bilib/component/RegularizationPanel.java
similarity index 97%
rename from DeconvolutionLab2/src/lab/component/RegularizationPanel.java
rename to DeconvolutionLab2/src/bilib/component/RegularizationPanel.java
index ca423bf..452e89e 100644
--- a/DeconvolutionLab2/src/lab/component/RegularizationPanel.java
+++ b/DeconvolutionLab2/src/bilib/component/RegularizationPanel.java
@@ -1,83 +1,83 @@
-package lab.component;
+package bilib.component;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Hashtable;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
-import lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class RegularizationPanel extends JPanel {
private JSlider slider = new JSlider();
private JTextField txt = new JTextField(10);
private double base = Math.pow(10, 1. / 3.0);
private double logbase = Math.log(base);
public RegularizationPanel(double value) {
setLayout(new BorderLayout());
slider.setMinimum(-54);
slider.setMaximum(30);
slider.setPreferredSize(new Dimension(200, 40));
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
Hashtable<Integer, JLabel> labels = new Hashtable<Integer, JLabel>();
JLabel lbl0 = new JLabel("Off");
JLabel lbl1 = new JLabel("Low");
JLabel lbl2 = new JLabel("High");
JLabel lbl4 = new JLabel("1E-6");
JLabel lbl5 = new JLabel("1.0");
java.awt.Font font = lbl1.getFont();
java.awt.Font small = new java.awt.Font(font.getFamily(), font.getStyle(), font.getSize() - 3);
lbl0.setFont(small);
lbl1.setFont(small);
lbl2.setFont(small);
lbl4.setFont(small);
lbl5.setFont(small);
labels.put(-54, lbl0);
labels.put(-36, lbl1);
labels.put(-18, lbl4);
labels.put(0, lbl5);
labels.put(27, lbl2);
slider.setMinorTickSpacing(3);
// js.setSnapToTicks(true);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.setMajorTickSpacing(9);
slider.setLabelTable(labels);
add(new JLabel("<html>Reg. &lambda;</html>"), BorderLayout.WEST);
add(slider, BorderLayout.CENTER);
add(txt, BorderLayout.EAST);
}
public JSlider getSlider() {
return slider;
}
public JTextField getText() {
return txt;
}
public void updateFromSlider() {
double d = Math.pow(base, slider.getValue());
d = Math.min(d, Math.pow(base, slider.getMaximum()));
d = Math.max(d, Math.pow(base, slider.getMinimum()));
txt.setText(NumFormat.nice(d));
}
public void updateFromText() {
String typed = txt.getText();
double value = NumFormat.parseNumber(typed, 1);
int p = (int) Math.round(Math.log(Math.abs(value)) / logbase);
slider.setValue(p);
}
public double getValue() {
return Math.pow(base, slider.getValue());
}
}
diff --git a/DeconvolutionLab2/src/lab/component/SpinnerRangeDouble.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/SpinnerRangeDouble.java
rename to DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
index cb20367..73a1401 100644
--- a/DeconvolutionLab2/src/lab/component/SpinnerRangeDouble.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeDouble.java
@@ -1,197 +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 lab.component;
+package bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* double. It handles double type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeDouble extends JSpinner {
private SpinnerNumberModel model;
private double defValue;
private double minValue;
private double maxValue;
private double incValue;
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeDouble(double defValue, double minValue, double maxValue, double incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(double minValue, double maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
double value = get();
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Double def = new Double(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(double incValue) {
this.incValue = incValue;
Double def = (Double) getModel().getValue();
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public double getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(double value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Double(value));
}
/**
* Return the value with clipping the value in the range [min..max].
*/
public double get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
double ii = i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
double ii = i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
double ii = i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0.0;
}
public double getRangeMaximum() {
return maxValue;
}
public double getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/SpinnerRangeFloat.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/SpinnerRangeFloat.java
rename to DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
index 7a40eb0..0d59520 100644
--- a/DeconvolutionLab2/src/lab/component/SpinnerRangeFloat.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeFloat.java
@@ -1,197 +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 lab.component;
+package bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* float. It handles float type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeFloat extends JSpinner {
private SpinnerNumberModel model;
private float defValue;
private float minValue;
private float maxValue;
private float incValue;
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Float def = new Float(defValue);
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Double def = new Double(defValue);
Double min = new Double(minValue);
Double max = new Double(maxValue);
Double inc = new Double(incValue);
this.model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeFloat(float defValue, float minValue, float maxValue, float incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Float def = new Float(defValue);
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(float minValue, float maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
float value = get();
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Float def = new Float(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(float incValue) {
this.incValue = incValue;
Float def = (Float) getModel().getValue();
Float min = new Float(minValue);
Float max = new Float(maxValue);
Float inc = new Float(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public float getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(float value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Float(value));
}
/**
* Return the value without clipping the value in the range [min..max].
*/
public float get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
float ii = (float) i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
float ii = (float) i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
float ii = i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0f;
}
public float getRangeMaximum() {
return maxValue;
}
public float getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/SpinnerRangeInteger.java b/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/component/SpinnerRangeInteger.java
rename to DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
index f7fba0a..9c5558c 100644
--- a/DeconvolutionLab2/src/lab/component/SpinnerRangeInteger.java
+++ b/DeconvolutionLab2/src/bilib/component/SpinnerRangeInteger.java
@@ -1,196 +1,196 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.component;
+package bilib.component;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
/**
* This class extends the Java Swing JSpinner to make a easy to use spinner for
* integer. It handles int type. The size can be control by the number of
* visible chars or by a specific format (NumberEditor).
*
* @author Daniel Sage, Biomedical Imaging Group, EPFL, Lausanne, Switzerland.
*
*/
public class SpinnerRangeInteger extends JSpinner {
private SpinnerNumberModel model;
private int defValue;
private int minValue;
private int maxValue;
private int incValue;
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(7);
}
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue, String format) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
setEditor(new JSpinner.NumberEditor(this, format));
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(format.length());
}
/**
* Constructor.
*/
public SpinnerRangeInteger(int defValue, int minValue, int maxValue, int incValue, int visibleChars) {
super();
this.defValue = defValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.incValue = incValue;
Integer def = new Integer(defValue);
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
JFormattedTextField tf = ((JSpinner.DefaultEditor) getEditor()).getTextField();
tf.setColumns(visibleChars);
}
/**
* Set the format of the numerical value.
*/
public void setFormat(String format) {
setEditor(new JSpinner.NumberEditor(this, format));
}
/**
* Set the minimal and the maximal limit.
*/
public void setLimit(int minValue, int maxValue) {
this.minValue = minValue;
this.maxValue = maxValue;
int value = get();
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
defValue = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
Integer def = new Integer(defValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Set the incremental step.
*/
public void setIncrement(int incValue) {
this.incValue = incValue;
Integer def = (Integer) getModel().getValue();
Integer min = new Integer(minValue);
Integer max = new Integer(maxValue);
Integer inc = new Integer(incValue);
model = new SpinnerNumberModel(def, min, max, inc);
setModel(model);
}
/**
* Returns the incremental step.
*/
public int getIncrement() {
return incValue;
}
/**
* Set the value in the JSpinner with clipping in the range [min..max].
*/
public void set(int value) {
value = (value > maxValue ? maxValue : (value < minValue ? minValue : value));
model.setValue(new Integer(value));
}
/**
* Return the value without clipping the value in the range [min..max].
*/
public int get() {
if (model.getValue() instanceof Integer) {
Integer i = (Integer) model.getValue();
int ii = i.intValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Double) {
Double i = (Double) model.getValue();
int ii = (int) i.doubleValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
else if (model.getValue() instanceof Float) {
Float i = (Float) model.getValue();
int ii = (int) i.floatValue();
return (ii > maxValue ? maxValue : (ii < minValue ? minValue : ii));
}
return 0;
}
public int getRangeMaximum() {
return maxValue;
}
public int getRangeMinimum() {
return minValue;
}
}
diff --git a/DeconvolutionLab2/src/lab/component/celegans.jpg b/DeconvolutionLab2/src/bilib/component/celegans.jpg
similarity index 100%
rename from DeconvolutionLab2/src/lab/component/celegans.jpg
rename to DeconvolutionLab2/src/bilib/component/celegans.jpg
diff --git a/DeconvolutionLab2/src/lab/tools/Files.java b/DeconvolutionLab2/src/bilib/tools/Files.java
similarity index 97%
rename from DeconvolutionLab2/src/lab/tools/Files.java
rename to DeconvolutionLab2/src/bilib/tools/Files.java
index 3ae860f..423081a 100644
--- a/DeconvolutionLab2/src/lab/tools/Files.java
+++ b/DeconvolutionLab2/src/bilib/tools/Files.java
@@ -1,73 +1,71 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.tools;
+package bilib.tools;
import java.io.File;
import javax.swing.JFileChooser;
-import deconvolutionlab.Lab;
-
public class Files {
public static File browseFile(String path) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
File dir = new File(path);
if (dir.exists())
fc.setCurrentDirectory(dir);
int ret = fc.showOpenDialog(null);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = new File(fc.getSelectedFile().getAbsolutePath());
if (file.exists())
return file;
}
return null;
}
public static File browseDirectory(String path) {
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
File dir = new File(path);
if (dir.exists())
fc.setCurrentDirectory(dir);
int ret = fc.showOpenDialog(null);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = new File(fc.getSelectedFile().getAbsolutePath());
if (file.exists())
return file;
}
return null;
}
}
diff --git a/DeconvolutionLab2/src/lab/tools/NoiseGenerator.java b/DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/tools/NoiseGenerator.java
rename to DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java
index f810419..087f216 100644
--- a/DeconvolutionLab2/src/lab/tools/NoiseGenerator.java
+++ b/DeconvolutionLab2/src/bilib/tools/NoiseGenerator.java
@@ -1,63 +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 lab.tools;
+package bilib.tools;
import signal.RealSignal;
public class NoiseGenerator {
private static PsRandom rand = new PsRandom();
private NoiseGenerator() {
}
public void setSeed(long seed) {
rand.setSeed(seed);
}
public static void gaussian(RealSignal x, double mean, double sd) {
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
slice[j] += (float) rand.nextGaussian(mean, sd);
}
}
public static void poisson(RealSignal x, double mean) {
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
slice[j] += (float) rand.nextPoissonian(mean);
}
}
}
diff --git a/DeconvolutionLab2/src/lab/tools/NumFormat.java b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/tools/NumFormat.java
rename to DeconvolutionLab2/src/bilib/tools/NumFormat.java
index 01cfca4..cde37fa 100644
--- a/DeconvolutionLab2/src/lab/tools/NumFormat.java
+++ b/DeconvolutionLab2/src/bilib/tools/NumFormat.java
@@ -1,174 +1,174 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
-package lab.tools;
+package bilib.tools;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class NumFormat {
public static String[] floatRepresentation(double a) {
double[] base = { 10, 5, 3, 2 };
double min = Double.MAX_VALUE;
double mantisse = 0;
double exp = 1;
for (int i = 0; i < base.length; i++) {
double p = Math.log(a) / Math.log(base[i]);
double e = roundToNumberOfSignificantDigits(p, 3);
double b = Math.pow(base[i], e);
if (Math.abs(a-b) < min) {
mantisse = base[i];
exp = e;
min = Math.abs(a-b);
}
}
return new String[] { "" + mantisse, "" + exp };
}
public static double roundToNumberOfSignificantDigits(double num, int n) {
double maxPowerOfTen = Math.floor(Math.log10(Double.MAX_VALUE));
if (num == 0) {
return 0;
}
final double d = Math.ceil(Math.log10(num < 0 ? -num : num));
final int power = n - (int) d;
double firstMagnitudeFactor = 1.0;
double secondMagnitudeFactor = 1.0;
if (power > maxPowerOfTen) {
firstMagnitudeFactor = Math.pow(10.0, maxPowerOfTen);
secondMagnitudeFactor = Math.pow(10.0, (double) power - maxPowerOfTen);
}
else {
firstMagnitudeFactor = Math.pow(10.0, (double) power);
}
double toBeRounded = num * firstMagnitudeFactor;
toBeRounded *= secondMagnitudeFactor;
final long shifted = Math.round(toBeRounded);
double rounded = ((double) shifted) / firstMagnitudeFactor;
rounded /= secondMagnitudeFactor;
return rounded;
}
public static double parseNumber(String line, double def) {
double[] numbers = parseNumbers(line);
if (numbers.length >= 1)
return numbers[0];
else
return def;
}
public static double[] parseNumbers(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static String nice(double a) {
double b = Math.abs(a);
String n = a < 0 ? "-" : " ";
if (a == 0)
return "0.0";
if (b > 3000.0)
return String.format(n + "%6.3E", b);
if (b > 300.0)
return String.format(n + "%4.1f", b);
if (b > 30.0)
return String.format(n + "%3.2f", b);
if (b > 3.0)
return String.format(n + "%2.4f", b);
if (b > 0.003)
return String.format(n + "%1.4f", b);
return String.format(n + "%6.3E", b).trim();
}
public static String seconds(double ns) {
return String.format("%5.1f s", ns * 1e-9);
}
public static String time(double ns) {
if (ns < 3000.0)
return String.format("%3.2f ns", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f us", ns);
ns *= 0.001;
if (ns < 3000.0)
return String.format("%3.2f ms", ns);
ns *= 0.001;
if (ns < 3600.0 * 3)
return String.format("%3.2f s", ns);
ns /= 3600;
return String.format("%3.2f h", ns);
}
public static String bytes(double bytes) {
if (bytes < 3000)
return String.format("%3.0f", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Kb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Mb", bytes);
bytes /= 1024.0;
if (bytes < 3000)
return String.format("%3.1f Gb", bytes);
bytes /= 1024.0;
return String.format("%3.1f Tb", bytes);
}
public static String toPercent(String value) {
try {
return toPercent(Double.parseDouble(value));
}
catch (Exception ex) {
}
return value;
}
public static String toPercent(double value) {
return String.format("%5.3f", value * 100) + "%";
}
}
diff --git a/DeconvolutionLab2/src/lab/tools/PsRandom.java b/DeconvolutionLab2/src/bilib/tools/PsRandom.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/tools/PsRandom.java
rename to DeconvolutionLab2/src/bilib/tools/PsRandom.java
index 034a3ec..b5ef1ee 100644
--- a/DeconvolutionLab2/src/lab/tools/PsRandom.java
+++ b/DeconvolutionLab2/src/bilib/tools/PsRandom.java
@@ -1,971 +1,971 @@
/* Program PsRandom
*
* Class for obtaining a single decimal or binary pseudorandom number
* or a sequence of decimal or binary pseudorandom numbers
* Supplements the Java random class with the generation of
* of lorentzian, poissonian, logistic, student's t, pareto,
* exponential, gumbel, weibull, frechet, rayleigh,
* beta distribution, gamma distribution, erlang distribution,
* chi-square distribution, F-distribution, uniform,
* gaussian (normal) and correlated gaussian pseudo-random deviates
* and pseudorandom binary numbers (bits).
* Also offers a choice of Knuth or Park-Miller generation methods.
*
* Binary pseudorandom number calculations are adapted from
* the Numerical Recipes methods written in the C language
* based on the "primitive polynomials modulo 2" method:
* Numerical Recipes in C, The Art of Scientific Computing,
* W.H. Press, S.A. Teukolsky, W.T. Vetterling & B.P. Flannery,
* Cambridge University Press, 2nd Edition (1992) pp 296 - 300.
* (http://www.nr.com/).
*
* AUTHOR: Dr Michael Thomas Flanagan
* DATE: 22 April 2004
* UPDATE: 21 November 2006, 31 December 2006, 14 April 2007, 19 October 2007, 16-29 March 2008, 3 July 2008
* 19 September 2008, 28 September 2008, 13 and 18 October 2009, 12-24 July 2010, 8 July 2011, 7 March 2012
*
* DOCUMENTATION:
* See Michael Thomas Flanagan's Java library on-line web page:
* http://www.ee.ucl.ac.uk/~mflanaga/java/PsRandom.html
* http://www.ee.ucl.ac.uk/~mflanaga/java/
*
* Copyright (c) 2004 - 2009 Michael Thomas Flanagan
*
* PERMISSION TO COPY:
*
* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee,
* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
* and associated documentation or publications.
*
* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice, this list of conditions
* and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
*
* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
*
* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
* or its derivatives.
*
***************************************************************************************/
-package lab.tools;
+package bilib.tools;
import java.io.Serializable;
import java.util.Random;
public class PsRandom implements Serializable {
private static final long serialVersionUID = 1L; // serial version unique identifier
private long seed; // current seed value - updated after each generation of a pseudorandom bit
// initial seed supplied as either:
// i. as the current clock time (in milliseconds since 1970)
// (no argument given to the constructor)
// ii. by the user as the constructor argument
// method are available for resetting the value of the seed
private long initialSeed; // initial seed value
private int methodOptionDecimal = 1; // Method for calculating pseudorandom decimal numbers
// = 1 Method - Knuth - this class calls the Java Random class which
// implements this method
// See Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 1st edition 1988 p. 212, 2nd edition 1992 p283 for details
// This is the default option used in all methods in this class,
// Pseudorandom, generating a decimal random number, i.e. all but
// the methods to generate pseudorandom binary numbers.
// = 2 Method - Park and Miller random number generator with Bays-Durham shuffle
// after ran1 (Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 2nd edition 1992 p280.
private int methodOptionInteger = 1; // Method for calculating pseudorandom integer numbers
// = 1 Method - java Random nextInt(int(n)
// = 2 Method - next double scaled with rounding
// = 3 Method - next doubled scaled with flooring
private Random rr = null; // instance of java.util.Random if Knuth method (default method) used
private int methodOptionBinary = 1; // Method for calculating pseudorandom binary numbers
// = 1 Method - Primitive polynomials modulo 2 method - version 1
// This method is the more cumbersome one in terms of coding (see method 2 below)
// but more readily lends itself to a shift register hardware implementation
// = 2 Method - Primitive polynomials modulo 2 method - version 2
// This method is the more suited to software implementation (compare with method 1 above)
// but lends itself less readily to a shift register hardware implementation
// Method 1 is the default option
// Park and Miller constants and variables
private long ia = 16807L;
private long im = 2147483647L;
private double am = 1.0D/im;
private long iq = 127773L;
private long ir = 2836L;
private int ntab = 32;
private long ndiv = (1L + (im - 1L)/ntab);
private double eps = 1.2e-7;
private double rnmx = 1.0D - eps;
private long iy = 0L;
private long[] iv = new long[ntab];
// Box-Muller variables
private int iset = 0;
private double gset = 0.0D;
// Polynomial powers of 2 (used in calculation of psedorandom binary numbers)
// See header reference (Numerical Recipes) above for polynomials other than (18, 5, 2, 1, 0)
private long powTwo1 = 1;
private long powTwo2 = 2;
private long powTwo5 = 16;
private long powTwo18 = 131072;
private long mask = powTwo1 + powTwo2 + powTwo5;
// CONSTRUCTORS
// Seed taken from the clock
public PsRandom(){
this.seed = System.currentTimeMillis();
this.initialSeed = this.seed;
this.rr = new Random(this.seed);
}
// Seed supplied by user
public PsRandom(long seed){
this.seed = seed;
this.initialSeed = seed;
this.rr = new Random(this.seed);
}
// METHODS
// Resets the value of the seed
public void setSeed(long seed){
this.seed = seed;
if(this.methodOptionDecimal==1)rr = new Random(this.seed);
}
// Returns the initial value of the seed
public long getInitialSeed(){
return this.initialSeed;
}
// Returns the current value of the seed
public long getSeed(){
return this.seed;
}
// Resets the method of calculation of a pseudorandom decimal number
// argument = 1 -> Knuth; argument = 2 -> Parker-Miller
// Default option = 1
public void setMethodDecimal(int methodOpt){
if(methodOpt<1 || methodOpt>2)throw new IllegalArgumentException("Argument to PsRandom.setMethodDecimal must 1 or 2\nValue transferred was"+methodOpt);
this.methodOptionDecimal = methodOpt;
if(methodOpt==1)rr = new Random(this.seed);
}
// Return the pseudorandom decimal number method option; 1 = Method 1 (Knuth), 2= Method 2 (Parker-Miller)
public int getMethodDecimal(){
return this.methodOptionDecimal;
}
// Resets the method of calculation of a pseudorandom integer number
// argument = 1 -> Diego Moreira alternative 1; argument = 2 -> Diego Moreira alternative 2; 3 -> Java Random class method nextInt
// Default option = 1
public void setMethodInteger(int methodOpt){
if(methodOpt<1 || methodOpt>3)throw new IllegalArgumentException("Argument to PsRandom.setMethodInteger must 1, 2 or 3\nValue transferred was"+methodOpt);
this.methodOptionInteger = methodOpt;
}
// Return the pseudorandom integer number method option; 1 = Method 1 (Diego Moreira alternative 1), 2= Method 2 (Diego Moreira alternative 2), 2 = ; 3 -> Java Random class method nextInt
public int getMethodInteger(){
return this.methodOptionInteger;
}
// Resets the method of calculation of a pseudorandom binary number
// argument = 1 -> method 1; argument = 2 -> Method 2
// See above and Numerical Recipes reference (in program header) for method descriptions
// Default option = 1
public void setMethodBinary(int methodOpt){
if(methodOpt<1 || methodOpt>2)throw new IllegalArgumentException("Argument to PsRandom.setMethodBinary must 1 or 2\nValue transferred was"+methodOpt);
this.methodOptionBinary = methodOpt;
if(methodOpt==1)rr = new Random(this.seed);
}
// Return the binary pseudorandom number method option; 1 = Method 1, 2= Method 2
public int getMethodBinary(){
return this.methodOptionBinary;
}
// Returns a pseudorandom double between 0.0 and 1.0
public double nextDouble(){
if(this.methodOptionDecimal==1){
return this.rr.nextDouble();
}
else{
return this.parkMiller();
}
}
// Returns a pseudorandom double between 0.0 and top
public double nextDouble(double top){
return top*this.nextDouble();
}
// Returns a pseudorandom double between 0.0 and top
public double nextSquare(double top){
return top*Math.pow(nextDouble(), 2);
}
// Returns a pseudorandom double between bottom and top
public double nextDouble(double bottom, double top){
return (top - bottom)*this.nextDouble() + bottom;
}
// Returns an array, of length arrayLength, of pseudorandom doubles between 0.0 and 1.0
public double[] doubleArray(int arrayLength){
double[] array = new double[arrayLength];
for(int i=0; i<arrayLength; i++){
array[i] = this.nextDouble();
}
return array;
}
// Returns an array, of length arrayLength, of pseudorandom doubles between 0.0 and top
public double[] doubleArray(int arrayLength, double top){
double[] array = new double[arrayLength];
for(int i=0; i<arrayLength; i++){
array[i] = top*this.nextDouble();
}
return array;
}
// Returns an array, of length arrayLength, of pseudorandom doubles between bottom and top
public double[] doubleArray(int arrayLength, double bottom, double top){
double[] array = new double[arrayLength];
for(int i=0; i<arrayLength; i++){
array[i] = (top - bottom)*this.nextDouble() + bottom;
}
return array;
}
// Park and Miller random number generator with Bays-Durham shuffle
// after ran1 Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 2nd edition 1992 p280.
// return a pseudorandom number between 0.0 and 1.0
public double parkMiller(){
int jj = 0;
long kk = 0L;
double temp = 0.0D;
this.iy = 0L;
if(this.seed <= 0L || iy!=0){
if(-this.seed < 1){
this.seed = 1;
}
else{
this.seed = -this.seed;
}
for(int j=ntab+7; j>=0; j--){
kk = this.seed/iq;
this.seed = ia*( this.seed - kk*iq)- ir*kk;
if(this.seed < 0L) this.seed += im;
if (j < ntab) iv[j] = this.seed;
}
iy = iv[0];
}
kk = this.seed/iq;
this.seed = ia*(this.seed - kk*iq)-ir*kk;
if(this.seed < 0)this.seed += im;
jj = (int)(iy/ndiv);
iy = iv[jj];
iv[jj] = this.seed;
if((temp = am*iy) > rnmx){
return rnmx;
}
else{
return temp;
}
}
// Returns a pseudorandom bit
public int nextBit(){
if(this.methodOptionBinary==1){
return nextBitM1();
}
else{
return nextBitM2();
}
}
// Returns an array, of length arrayLength, of pseudorandom bits
public int[] bitArray(int arrayLength){
int[] bitarray = new int[arrayLength];
for(int i=0; i<arrayLength; i++){
bitarray[i]=nextBit();
}
return bitarray;
}
// Returns a pseudorandom bit - Method 1
// This method is the more cumbersome one in terms of coding (see method 2 below)
// but more readily lends itself to a shift register hardware implementation
public int nextBitM1(){
long newBit;
newBit = ((this.seed & this.powTwo18) >> 17L) ^ ((this.seed & this.powTwo5) >> 4L) ^ ((this.seed & this.powTwo2) >> 1L) ^ (this.seed & this.powTwo1);
this.seed=(this.seed << 1L) | newBit;
return (int) newBit;
}
// Returns a pseudorandom bit - Method 2
// This method is the more suited to software implementation (compare with method 1 above)
// but lends itself less readily to a shift register hardware implementation
public int nextBitM2(){
int randomBit = 0;
if((this.seed & this.powTwo18)<=0L){
this.seed = ((this.seed ^ this.mask) << 1L) | this.powTwo1;
randomBit = 1;
}
else{
this.seed <<= 1L;
randomBit = 0;
}
return randomBit;
}
// Returns a Gaussian (normal) random deviate
// mean = the mean, sd = standard deviation
public double nextGaussian(double mean, double sd){
double ran = 0.0D;
if(this.methodOptionDecimal==1){
ran=this.rr.nextGaussian();
}
else{
ran=this.boxMullerParkMiller();
}
ran = ran*sd+mean;
return ran;
}
// Returns a Gaussian (normal) random deviate
// mean = 0.0, sd = 1.0
public double nextGaussian(){
double ran = 0.0D;
if(this.methodOptionDecimal==1){
ran=this.rr.nextGaussian();
}
else{
ran=this.boxMullerParkMiller();
}
return ran;
}
public double nextNormal(double mean, double sd){
return nextGaussian(mean, sd);
}
public double nextNormal(){
return nextGaussian();
}
// Box-Muller normal deviate generator
// after gasdev (Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 2nd edition 1992 p289
// Uses Park and Miller method for generating pseudorandom numbers
double boxMullerParkMiller(){
double fac = 0.0D, rsq = 0.0D, v1 = 0.0D, v2 = 0.0D;
if (iset==0){
do {
v1=2.0*parkMiller()-1.0D;
v2=2.0*parkMiller()-1.0D;
rsq=v1*v1+v2*v2;
}while (rsq >= 1.0D || rsq == 0.0D);
fac=Math.sqrt(-2.0D*Math.log(rsq)/rsq);
gset=v1*fac;
iset=1;
return v2*fac;
}else{
iset=0;
return gset;
}
}
// Returns a Lorentzian pseudorandom deviate
// mu = the mean, gamma = half-height widthy
public double nextLorentzian (double mu, double gamma){
double ran = Math.tan((this.nextDouble()-0.5)*Math.PI);
ran = ran*gamma/2.0D+mu;
return ran;
}
// Returns an array of Lorentzian pseudorandom deviates
// mu = the mean, gamma = half-height width, n = length of array
public double[] lorentzianArray (double mu, double gamma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i]=Math.tan((this.nextDouble()-0.5)*Math.PI);
ran[i] = ran[i]*gamma/2.0D+mu;
}
return ran;
}
// Returns a Poissonian pseudorandom deviate
// follows the approach of Numerical Recipes, 2nd Edition, p 294
public double nextPoissonian(double mean){
double ran = 0.0D;
double oldm = -1.0D;
double expt = 0.0D;
double em = 0.0D;
double term = 0.0D;
double sq = 0.0D;
double lnMean = 0.0D;
double yDev = 0.0D;
if(mean < 12.0D){
if(mean != oldm){
oldm = mean;
expt = Math.exp(-mean);
}
em = -1.0D;
term = 1.0D;
do{
++em;
term *= this.nextDouble();
}while(term>expt);
ran = em;
}
else{
if(mean != oldm){
oldm = mean;
sq = Math.sqrt(2.0D*mean);
lnMean = Math.log(mean);
expt = mean*lnMean - logGamma(mean+1.0D);
}
do{
do{
yDev = Math.tan(Math.PI*this.nextDouble());
em = sq*yDev+mean;
}while(em<0.0D);
em = Math.floor(em);
term = 0.9D*(1.0D+yDev*yDev)*Math.exp(em*lnMean - logGamma(em+1.0D)-expt);
}while(this.nextDouble()>term);
ran = em;
}
return ran;
}
// Returns an array of Poisson random deviates
// follows the approach of Numerical Recipes, 2nd Edition, p 294
public double[] poissonianArray(double mean, int n){
double[] ran = new double[n];
double oldm = -1.0D;
double expt = 0.0D;
double em = 0.0D;
double term = 0.0D;
double sq = 0.0D;
double lnMean = 0.0D;
double yDev = 0.0D;
if(mean < 12.0D){
for(int i=0; i<n; i++){
if(mean != oldm){
oldm = mean;
expt = Math.exp(-mean);
}
em = -1.0D;
term = 1.0D;
do{
++em;
term *= this.nextDouble();
}while(term>expt);
ran[i] = em;
}
}
else{
for(int i=0; i<n; i++){
if(mean != oldm){
oldm = mean;
sq = Math.sqrt(2.0D*mean);
lnMean = Math.log(mean);
expt = mean*lnMean - logGamma(mean+1.0D);
}
do{
do{
yDev = Math.tan(Math.PI*this.nextDouble());
em = sq*yDev+mean;
}while(em<0.0D);
em = Math.floor(em);
term = 0.9D*(1.0D+yDev*yDev)*Math.exp(em*lnMean - logGamma(em+1.0D)-expt);
}while(this.nextDouble()>term);
ran[i] = em;
}
}
return ran;
}
// Returns a Binomial pseudorandom deviate from a binomial
// distribution of nTrial trials each of probablity, prob,
// after bndlev Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 2nd edition 1992 p295.
public double nextBinomial(double prob, int nTrials){
if(prob<0.0D || prob>1.0D)throw new IllegalArgumentException("The probablity provided, " + prob + ", must lie between 0 and 1)");
double binomialDeviate = 0.0D; // the binomial deviate to be returned
double deviateMean = 0.0D; // mean of deviate to be produced
double testDeviate = 0.0D; // test deviate
double workingProb = 0.0; // working value of the probability
double logProb = 0.0; // working value of the probability
double probOld = -1.0D; // previous value of the working probability
double probC = -1.0D; // complementary value of the working probability
double logProbC = -1.0D; // log of the complementary value of the working probability
int nOld= -1; // previous value of trials counter
double enTrials = 0.0D; // (double) trials counter
double oldGamma = 0.0D; // a previous log Gamma function value
double tanW = 0.0D; // a working tangent
double hold0 = 0.0D; // a working holding variable
int jj; // counter
workingProb=(prob <= 0.5D ? prob : 1.0-prob); // distribution invariant on swapping prob for 1 - prob
deviateMean = nTrials*workingProb;
if(nTrials < 25) {
// if number of trials greater than 25 use direct method
binomialDeviate=0.0D;
for (jj=1;jj<=nTrials;jj++)if (this.nextDouble() < workingProb) ++binomialDeviate;
}
else if(deviateMean < 1.0D) {
// if fewer than 1 out of 25 events - Poisson approximation is accurate
double expOfMean=Math.exp(-deviateMean);
testDeviate=1.0D;
for(jj=0;jj<=nTrials;jj++) {
testDeviate *= this.nextDouble();
if (testDeviate < expOfMean) break;
}
binomialDeviate=(jj <= nTrials ? jj : nTrials);
}
else{
// use rejection method
if(nTrials != nOld) {
// if nTrials has changed compute useful quantities
enTrials = (double)nTrials;
oldGamma = logGamma(enTrials + 1.0D);
nOld = nTrials;
}
if(workingProb != probOld) {
// if workingProb has changed compute useful quantities
probC = 1.0 - workingProb;
logProb = Math.log(workingProb);
logProbC = Math.log(probC);
probOld = workingProb;
}
double sq = Math.sqrt(2.0*deviateMean*probC);
do{
do{
double angle = Math.PI*this.nextDouble();
tanW = Math.tan(angle);
hold0 = sq*tanW + deviateMean;
}while(hold0 < 0.0D || hold0 >= (enTrials + 1.0D)); // rejection test
hold0 = Math.floor(hold0); // integer value distribution
testDeviate = 1.2D*sq*(1.0D + tanW*tanW)*Math.exp(oldGamma - logGamma(hold0 + 1.0D) - logGamma(enTrials - hold0 + 1.0D) + hold0*logProb + (enTrials - hold0)*logProbC);
}while(this.nextDouble() > testDeviate); // rejection test
binomialDeviate=hold0;
}
if(workingProb != prob) binomialDeviate = nTrials - binomialDeviate; // symmetry transformation
return binomialDeviate;
}
// Returns an array of n Binomial pseudorandom deviates from a binomial
// distribution of nTrial trials each of probablity, prob,
// after bndlev Numerical Recipes in C - W.H. Press et al. (Cambridge)
// 2nd edition 1992 p295.
public double[] binomialArray(double prob, int nTrials, int n){
if(nTrials<n)throw new IllegalArgumentException("Number of deviates requested, " + n + ", must be less than the number of trials, " + nTrials);
if(prob<0.0D || prob>1.0D)throw new IllegalArgumentException("The probablity provided, " + prob + ", must lie between 0 and 1)");
double[] ran = new double[n]; // array of deviates to be returned
double binomialDeviate = 0.0D; // the binomial deviate to be returned
double deviateMean = 0.0D; // mean of deviate to be produced
double testDeviate = 0.0D; // test deviate
double workingProb = 0.0; // working value of the probability
double logProb = 0.0; // working value of the probability
double probOld = -1.0D; // previous value of the working probability
double probC = -1.0D; // complementary value of the working probability
double logProbC = -1.0D; // log of the complementary value of the working probability
int nOld= -1; // previous value of trials counter
double enTrials = 0.0D; // (double) trials counter
double oldGamma = 0.0D; // a previous log Gamma function value
double tanW = 0.0D; // a working tangent
double hold0 = 0.0D; // a working holding variable
int jj; // counter
double probOriginalValue = prob;
for(int i=0; i<n; i++){
prob = probOriginalValue;
workingProb=(prob <= 0.5D ? prob : 1.0-prob); // distribution invariant on swapping prob for 1 - prob
deviateMean = nTrials*workingProb;
if(nTrials < 25) {
// if number of trials greater than 25 use direct method
binomialDeviate=0.0D;
for(jj=1;jj<=nTrials;jj++)if (this.nextDouble() < workingProb) ++binomialDeviate;
}
else if(deviateMean < 1.0D) {
// if fewer than 1 out of 25 events - Poisson approximation is accurate
double expOfMean=Math.exp(-deviateMean);
testDeviate=1.0D;
for (jj=0;jj<=nTrials;jj++) {
testDeviate *= this.nextDouble();
if (testDeviate < expOfMean) break;
}
binomialDeviate=(jj <= nTrials ? jj : nTrials);
}
else{
// use rejection method
if(nTrials != nOld) {
// if nTrials has changed compute useful quantities
enTrials = (double)nTrials;
oldGamma = logGamma(enTrials + 1.0D);
nOld = nTrials;
}
if(workingProb != probOld) {
// if workingProb has changed compute useful quantities
probC = 1.0 - workingProb;
logProb = Math.log(workingProb);
logProbC = Math.log(probC);
probOld = workingProb;
}
double sq = Math.sqrt(2.0*deviateMean*probC);
do{
do{
double angle = Math.PI*this.nextDouble();
tanW = Math.tan(angle);
hold0 = sq*tanW + deviateMean;
}while(hold0 < 0.0D || hold0 >= (enTrials + 1.0D)); // rejection test
hold0 = Math.floor(hold0); // integer value distribution
testDeviate = 1.2D*sq*(1.0D + tanW*tanW)*Math.exp(oldGamma - logGamma(hold0 + 1.0D) - logGamma(enTrials - hold0 + 1.0D) + hold0*logProb + (enTrials - hold0)*logProbC);
}while(this.nextDouble() > testDeviate); // rejection test
binomialDeviate=hold0;
}
if(workingProb != prob) binomialDeviate = nTrials - binomialDeviate; // symmetry transformation
ran[i] = binomialDeviate;
}
return ran;
}
// Returns a Pareto pseudorandom deviate
public double nextPareto(double alpha, double beta){
return Math.pow(1.0D-this.nextDouble(), -1.0D/alpha)*beta;
}
// Returns an array, of Pareto pseudorandom deviates, of length n
public double[] paretoArray (double alpha, double beta, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = Math.pow(1.0D-this.nextDouble(), -1.0D/alpha)*beta;
}
return ran;
}
// Returns an exponential pseudorandom deviate
public double nextExponential(double mu, double sigma){
return mu - Math.log(1.0D-this.nextDouble())*sigma;
}
// Returns an array, of exponential pseudorandom deviates, of length n
public double[] exponentialArray (double mu, double sigma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = mu - Math.log(1.0D-this.nextDouble())*sigma;
}
return ran;
}
// Returns a Rayleigh pseudorandom deviate
public double nextRayleigh(double sigma){
return Math.sqrt(-2.0D*Math.log(1.0D-this.nextDouble()))*sigma;
}
// Returns an array, of Rayleigh pseudorandom deviates, of length n
public double[] rayleighArray (double sigma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = Math.sqrt(-2.0D*Math.log(1.0D-this.nextDouble()))*sigma;
}
return ran;
}
// Returns a minimal Gumbel (Type I EVD) random deviate
// mu = location parameter, sigma = scale parameter
public double nextMinimalGumbel(double mu, double sigma){
return Math.log(Math.log(1.0D/(1.0D-this.nextDouble())))*sigma+mu;
}
// Returns an array of minimal Gumbel (Type I EVD) random deviates
// mu = location parameter, sigma = scale parameter, n = length of array
public double[] minimalGumbelArray(double mu, double sigma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = Math.log(Math.log(1.0D/(1.0D-this.nextDouble())))*sigma+mu;
}
return ran;
}
// Returns a maximal Gumbel (Type I EVD) random deviate
// mu = location parameter, sigma = scale parameter
public double nextMaximalGumbel(double mu, double sigma){
return mu-Math.log(Math.log(1.0D/(1.0D-this.nextDouble())))*sigma;
}
// Returns an array of maximal Gumbel (Type I EVD) random deviates
// mu = location parameter, sigma = scale parameter, n = length of array
public double[] maximalGumbelArray(double mu, double sigma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = mu-Math.log(Math.log(1.0D/(1.0D-this.nextDouble())))*sigma;
}
return ran;
}
// Returns a Frechet (Type II EVD) random deviate
// mu = location parameter, sigma = scale parameter, gamma = shape parameter
public double nextFrechet(double mu, double sigma, double gamma){
return Math.pow((1.0D/(Math.log(1.0D/this.nextDouble()))),1.0D/gamma)*sigma + mu;
}
// Returns an array of Frechet (Type II EVD) random deviates
// mu = location parameter, sigma = scale parameter, gamma = shape parameter, n = length of array
public double[] frechetArray(double mu, double sigma, double gamma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = Math.pow((1.0D/(Math.log(1.0D/this.nextDouble()))),1.0D/gamma)*sigma + mu;
}
return ran;
}
// Returns a Weibull (Type III EVD) random deviate
// mu = location parameter, sigma = scale parameter, gamma = shape parameter
public double nextWeibull(double mu, double sigma, double gamma){
return Math.pow(-Math.log(1.0D-this.nextDouble()),1.0D/gamma)*sigma + mu;
}
// Returns an array of Weibull (Type III EVD) random deviates
// mu = location parameter, sigma = scale parameter, gamma = shape parameter, n = length of array
public double[] weibullArray(double mu, double sigma, double gamma, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++){
ran[i] = Math.pow(-Math.log(1.0D-this.nextDouble()),1.0D/gamma)*sigma + mu;
}
return ran;
}
// Returns an array of Logistic distribution random deviates
// mu = location parameter, scale = scale parameter
public double nextLogistic(double mu, double scale){
return 2.0D*scale*atanh(2.0D*this.nextDouble() - 1.0D) + mu;
}
// Returns an array of Logistic distribution random deviate
// mu = location parameter, scale = scale parameter, n is the length of the returned array
public double[] logisticArray(double mu, double scale, int n){
double[] ran = new double[n];
for(int i=0; i<n; i++) ran[i] = 2.0D*scale*atanh(2.0D*this.nextDouble() - 1.0D) + mu;
return ran;
}
// PSEUDORANDOM INTEGERS
// Returns a pseudorandom int integer between 0.0 and top
public int nextInteger(int bottom, int top){
int randint = 0;
switch(this.methodOptionInteger){
case 1: // Java Random class nextInt()
randint = this.rr.nextInt(++top - bottom) + bottom;
break;
case 2: randint = (int)Math.round(this.nextDouble()*(top - bottom)) + bottom;
break;
case 3: randint = (int)Math.floor(this.nextDouble()*(++top - bottom)) + bottom;
break;
default: throw new IllegalArgumentException("methodOptionInteger, " + this.methodOptionInteger + " is not recognised");
}
return randint;
}
// Returns a pseudorandom int integer between bottom (inclusive) and top (inclusive)
public int nextInteger(int top){
return this.nextInteger(0, top);
}
// Returns an array, of length arraylength, of pseudorandom int integers between 0.0 (inclusive) and top (inclusive)
public int[] integerArray(int arrayLength, int top){
int[] array = new int[arrayLength];
for(int i=0; i<arrayLength; i++){
array[i] = this.nextInteger(top);
}
return array;
}
// Returns an array, of length arraylength, of pseudorandom int integers between bottom and top
public int[] integerArray(int arrayLength, int bottom, int top){
int[] array = new int[arrayLength];
for(int i=0; i<arrayLength; i++){
array[i] = this.nextInteger(top - bottom) + bottom;
}
return array;
}
// Returns an array, of length arraylength, of pseudorandom int integers between bottom and top with no repeats
public int[] noRepeatIntegerArray(int arrayLength, int bottom, int top){
int[] array = new int[arrayLength];
boolean test = true;
int hold = -1;
int nFound = 0;
boolean repeatTest = true;
while(test){
hold = this.nextInteger(top - bottom) + bottom;
if(nFound==0){
array[0] = hold;
nFound = 1;
}
else{
repeatTest = true;
for(int i=0; i<nFound; i++)if(array[i]==hold)repeatTest = false;
if(repeatTest){
array[nFound] = hold;
nFound++;
}
}
if(nFound==arrayLength)test = false;
}
return array;
}
// Returns an array, of length top+1, of unique pseudorandom integers between bottom and top
// i.e. no integer is repeated and all integers between bottom and top inclusive are present
public int[] uniqueIntegerArray(int bottom, int top){
int range = top - bottom;
int[] array = uniqueIntegerArray(range);
for(int i=0; i<range+1; i++)array[i] += bottom;
return array;
}
// Returns an array, of length top+1, of unique pseudorandom integers between 0 and top
// i.e. no integer is repeated and all integers between 0 and top inclusive are present
public int[] uniqueIntegerArray(int top){
int numberOfIntegers = top + 1; // number of unique pseudorandom integers returned
int[] array = new int[numberOfIntegers]; // array to contain returned unique pseudorandom integers
boolean allFound = false; // will equal true when all required integers found
int nFound = 0; // number of required pseudorandom integers found
boolean[] found = new boolean[numberOfIntegers]; // = true when integer corresponding to its index is found
for(int i=0; i<numberOfIntegers; i++)found[i] = false;
while(!allFound){
int ii = this.nextInteger(top);
if(!found[ii]){
array[nFound] = ii;
found[ii] = true;
nFound++;
if(nFound==numberOfIntegers)allFound = true;
}
}
return array;
}
// Return the serial version unique identifier
public static long getSerialVersionUID(){
return PsRandom.serialVersionUID;
}
// Inverse hyperbolic tangent of a double number
private static double atanh(double a){
double sgn = 1.0D;
if(a<0.0D){
sgn = -1.0D;
a = -a;
}
if(a>1.0D) throw new IllegalArgumentException("atanh real number argument (" + sgn*a + ") must be >= -1 and <= 1");
return 0.5D*sgn*(Math.log(1.0D + a)-Math.log(1.0D - a));
}
// log to base e of the Gamma function
// Lanczos approximation (6 terms)
// Lanczos Gamma Function approximation - N (number of coefficients -1)
private static int lgfN = 6;
private static double lgfGamma = 5.0;
// Lanczos Gamma Function approximation - Coefficients
private static double[] lgfCoeff = {1.000000000190015, 76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179E-2, -0.5395239384953E-5};
// log to base e of the Gamma function
// Lanczos approximation (6 terms)
// Retained for backward compatibility
public static double logGamma(double x){
double xcopy = x;
double fg = 0.0D;
double first = x + lgfGamma + 0.5;
double second = lgfCoeff[0];
if(x>=0.0){
first -= (x + 0.5)*Math.log(first);
for(int i=1; i<=lgfN; i++)second += lgfCoeff[i]/++xcopy;
fg = Math.log(Math.sqrt(2.0*Math.PI)*second/x) - first;
}
else{
fg = Math.PI/(gamma(1.0D-x)*Math.sin(Math.PI*x));
if(fg!=1.0/0.0 && fg!=-1.0/0.0){
if(fg<0){
throw new IllegalArgumentException("\nThe gamma function is negative");
}
else{
fg = Math.log(fg);
}
}
}
return fg;
}
// Gamma function
// Lanczos approximation (6 terms)
// retained for backward compatibity
private static double gamma(double x){
double xcopy = x;
double first = x + lgfGamma + 0.5;
double second = lgfCoeff[0];
double fg = 0.0D;
if(x>=0.0){
first = Math.pow(first, x + 0.5)*Math.exp(-first);
for(int i=1; i<=lgfN; i++)second += lgfCoeff[i]/++xcopy;
fg = first*Math.sqrt(2.0*Math.PI)*second/x;
}
else{
fg = -Math.PI/(x*gamma(-x)*Math.sin(Math.PI*x));
}
return fg;
}
}
diff --git a/DeconvolutionLab2/src/lab/tools/Tools.java b/DeconvolutionLab2/src/bilib/tools/Tools.java
similarity index 99%
rename from DeconvolutionLab2/src/lab/tools/Tools.java
rename to DeconvolutionLab2/src/bilib/tools/Tools.java
index 8bf1d76..56e8cfe 100644
--- a/DeconvolutionLab2/src/lab/tools/Tools.java
+++ b/DeconvolutionLab2/src/bilib/tools/Tools.java
@@ -1,78 +1,78 @@
-package lab.tools;
+package bilib.tools;
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import java.security.CodeSource;
public class Tools {
public static String[] explodeLower(String line, String regex) {
String[] items = line.split(regex);
String[] out = new String[items.length];
for(int i=0; i<items.length; i++)
out[i] = items[i].trim().toLowerCase();
return out;
}
public static String[] explodeCase(String line, String regex) {
String[] items = line.split(regex);
String[] out = new String[items.length];
for(int i=0; i<items.length; i++)
out[i] = items[i].trim();
return out;
}
public static String ellipsis(String text, int length) {
int l = text.length();
if (l <= length)
return text;
String result =
text.substring(0,length/2) +
"..." +
text.substring(text.length()-length/2+3, text.length());
return result;
}
public static String getWorkingPath() {
try {
CodeSource codeSource = Tools.class.getProtectionDomain().getCodeSource();
File jarFile = new File(codeSource.getLocation().toURI().getPath());
return jarFile.getParentFile().getPath() + File.separator;
}
catch(Exception ex) {
return System.getProperty("user.dir") + File.separator;
}
}
}
diff --git a/DeconvolutionLab2/src/lab/tools/WebBrowser.java b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
similarity index 98%
rename from DeconvolutionLab2/src/lab/tools/WebBrowser.java
rename to DeconvolutionLab2/src/bilib/tools/WebBrowser.java
index 95170e1..f3838c3 100644
--- a/DeconvolutionLab2/src/lab/tools/WebBrowser.java
+++ b/DeconvolutionLab2/src/bilib/tools/WebBrowser.java
@@ -1,63 +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 lab.tools;
+package bilib.tools;
import java.awt.Desktop;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class WebBrowser {
public static boolean open(String url) {
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
try {
desktop.browse(new URL(url).toURI());
return true;
}
catch (Exception e) {
e.printStackTrace();
}
}
JFrame frame = new JFrame("Help");
JLabel lbl = new JLabel(url);
frame.add(lbl);
frame.pack();
frame.setVisible(true);
return false;
}
}
diff --git a/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
index 2dd2c41..d1146a8 100644
--- a/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
+++ b/DeconvolutionLab2/src/course/DeconvolutionLab2_MemoryFootprint.java
@@ -1,103 +1,103 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package course;
+import bilib.component.CustomizedTable;
+import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import ij.plugin.PlugIn;
-import lab.component.CustomizedTable;
-import lab.tools.NumFormat;
import signal.SignalCollector;
public class DeconvolutionLab2_MemoryFootprint implements PlugIn {
public DeconvolutionLab2_MemoryFootprint() {
CustomizedTable table = new CustomizedTable(new String[] { "Name", "Algo", "Optimized", "Time", "Energy", "Peak Count", "Peak Bytes", "End Count", "End Byte", "Ratio" }, true);
table.show("Memory Footprint", 1100, 300);
run(table, "CONV");
run(table, "FISTA 10 1 1");
run(table, "ICTM 10 1 0.1");
run(table, "I");
run(table, "ISTA 10 1 1");
run(table, "LW 10 1");
run(table, "LLS 10 1");
run(table, "NLLS 10 1");
run(table, "NIF");
run(table, "DIV");
run(table, "RIF 1");
run(table, "RL 10");
run(table, "RLTV 10 1");
run(table, "SIM 1 1 1");
run(table, "BVLS 10 1");
run(table, "TM 10 1 0.1");
run(table, "TRIF 1");
run(table, "VC 10 1");
}
private void run(CustomizedTable table, String cmd) {
int nx = 64;
int ny = 32;
int nz = 12;
String size = " size " + nx + " " + ny + " " + nz;
String image = " -image synthetic Cross 110 0 1 1 80.0 " + size;
String psf = " -psf synthetic Double-Helix 100 0 3 10 10 " + size;
for (int i = 0; i <= 1; i++) {
SignalCollector.resetSignals();
SignalCollector.clear();
Deconvolution d = new Deconvolution("noise", " -algorithm " + cmd + psf + image + " -display no");
boolean optimized = i == 1;
d.getAlgo().setOptimizedMemoryFootprint(optimized);
String n = d.getAlgo().getName();
double chrono = System.nanoTime();
d.run();
String energy = "" + d.getOutput().getEnergy();
String time = NumFormat.time(System.nanoTime() - chrono);
int cp = SignalCollector.getCountPeakSignals();
int cs = SignalCollector.getCountSignals();
long bp = SignalCollector.getBytesPeakSignals();
long bs = SignalCollector.getBytesSignals();
double ratio = (bp + bs) / (nx * ny * nz * 4);
table.append(new String[] { n, cmd, "" + optimized, time, energy, "" + cp, NumFormat.bytes(bp), "" + cs, NumFormat.bytes(bs), NumFormat.nice(ratio) });
}
}
public static void main(String arg[]) {
new DeconvolutionLab2_MemoryFootprint();
}
@Override
public void run(String arg) {
new DeconvolutionLab2_MemoryFootprint();
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Command.java b/DeconvolutionLab2/src/deconvolution/Command.java
index 9ae5393..04b0d54 100644
--- a/DeconvolutionLab2/src/deconvolution/Command.java
+++ b/DeconvolutionLab2/src/deconvolution/Command.java
@@ -1,457 +1,457 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Output;
import deconvolutionlab.OutputCollection;
import deconvolutionlab.Output.View;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.monitor.Verbose;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
-import lab.tools.NumFormat;
import signal.Constraint;
import signal.Operations;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
import wavelets.Wavelets;
public class Command {
public static String keywords[] = { "-image", "-psf", "-algorithm", "-path", "-disable", "-verbose", "-monitor", "-display", "-multithreading", "-system", "-stats", "-constraint", "-time", "-residu", "-reference", "-out", "-pad", "-apo", "-norm", "-fft", "-epsilon" };
private static AbstractModule modules[];
private static CommandModule command;
public static void active(AbstractModule[] m, CommandModule c) {
modules = m;
command = c;
}
public static String command() {
if (modules == null)
return "";
String cmd = "";
for (AbstractModule m : modules)
cmd += m.getCommand() + " ";
if (command != null)
command.setCommand(cmd);
return cmd;
}
public static void decode(String command, Deconvolution deconvolution) {
AbstractAlgorithm algo = Algorithm.getDefaultAlgorithm();
boolean flagSystem = true;
boolean flagDisplay = true;
boolean flagMultithreading = true;
int monitor = 3;
int stats = 0;
Verbose verbose = Verbose.Log;
String path = System.getProperty("user.dir");
Controller controller = new Controller();
OutputCollection outs = new OutputCollection();
Padding pad = new Padding();
Apodization apo = new Apodization();
double norm = 1.0;
AbstractFFTLibrary fft = FFT.getFastestFFT();
ArrayList<Token> tokens = parse(command);
for (Token token : tokens) {
if (token.keyword.equalsIgnoreCase("-algorithm"))
algo = Command.decodeAlgorithm(token, controller);
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
path = token.parameters;
if (token.keyword.equalsIgnoreCase("-monitor"))
monitor = decodeMonitor(token);
if (token.keyword.equalsIgnoreCase("-stats"))
stats = decodeStats(token);
if (token.keyword.equalsIgnoreCase("-system"))
flagSystem = decodeSystem(token);
if (token.keyword.equalsIgnoreCase("-display"))
flagDisplay = decodeDisplay(token);
if (token.keyword.equalsIgnoreCase("-multithreading"))
flagMultithreading = decodeMultithreading(token);
if (token.keyword.equalsIgnoreCase("-verbose"))
verbose = Verbose.getByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-fft"))
fft = FFT.getLibraryByName(token.parameters);
if (token.keyword.equalsIgnoreCase("-pad"))
pad = decodePadding(token);
if (token.keyword.equalsIgnoreCase("-apo"))
apo = decodeApodization(token);
if (token.keyword.equalsIgnoreCase("-norm"))
norm = decodeNormalization(token);
if (token.keyword.equalsIgnoreCase("-constraint"))
decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-time"))
decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-residu"))
decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-reference"))
decodeController(token, controller);
if (token.keyword.equalsIgnoreCase("-epsilon"))
Operations.epsilon = NumFormat.parseNumber(token.parameters, 1e-6);
if (token.keyword.equals("-out")) {
Output out = decodeOut(token);
if (out != null)
outs.add(out);
}
}
deconvolution.setAlgorithm(algo, controller);
deconvolution.setPath(path);
deconvolution.setNormalization(norm);
deconvolution.setPadding(pad);
deconvolution.setApodization(apo);
deconvolution.setOutput(outs);
deconvolution.setVerbose(verbose);
deconvolution.setFFT(fft);
deconvolution.setMonitor(monitor);
deconvolution.setStats(stats);
deconvolution.setFlags(flagDisplay, flagMultithreading, flagSystem);
}
/**
* This methods first segments the command line, then create all the tokens
* of the command line
*
* @param command
* Command line
* @return the list of tokens extracted from the command line
*/
public static ArrayList<Token> parse(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
ArrayList<Token> tokens = new ArrayList<Token>();
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
Token token = new Token(keyword, command, begin, end);
tokens.add(token);
}
return tokens;
}
public static Token extract(String command, String keyword) {
ArrayList<Token> tokens = parse(command);
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase(keyword))
return token;
return (Token) null;
}
public static double[] parseNumeric(String line) {
ArrayList<String> num = new ArrayList<String>();
Pattern p = Pattern.compile("[-+]?[0-9]+[.]?[0-9]*([eE][-+]?[0-9]+)?");
Matcher m = p.matcher(line);
while (m.find()) {
num.add(m.group());
}
double number[] = new double[num.size()];
for (int i = 0; i < num.size(); i++)
number[i] = Double.parseDouble(num.get(i));
return number;
}
public static ArrayList<CommandSegment> findSegment(String command, String keyword) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
String regex = "(?<!\\w)" + keyword + "(?!\\w)";
if (command == null)
return segments;
Matcher matcher = Pattern.compile(regex).matcher(command);
while (matcher.find()) {
segments.add(new CommandSegment(keyword, matcher.start()));
}
return segments;
}
public static String extractOptions(String command) {
ArrayList<CommandSegment> segments = new ArrayList<CommandSegment>();
for (String keyword : keywords)
segments.addAll(findSegment(command, keyword));
Collections.sort(segments);
String options = "";
for (int i = 0; i < segments.size(); i++) {
String keyword = segments.get(i).keyword;
int begin = segments.get(i).index + keyword.length() + 1;
int end = (i < segments.size() - 1 ? segments.get(i + 1).index : command.length());
if (keyword != "-image" && keyword != "-psf" && keyword != "-algorithm")
options += keyword + " " + command.substring(begin, end);
}
return options;
}
public static AbstractAlgorithm decodeAlgorithm(Token token, Controller controller) {
String option = token.option;
AbstractAlgorithm algo = Algorithm.createAlgorithm(option);
algo.setShortname(option);
double params[] = parseNumeric(token.parameters);
if (params != null) {
algo.setParameters(params);
if (algo.isIterative() && params.length >= 1)
controller.setIterationMax((int)params[0]);
}
if (algo.isWaveletsBased()) {
for (String wavelet : Wavelets.getWaveletsAsArray()) {
int pos = token.parameters.toLowerCase().indexOf(wavelet.toLowerCase());
if (pos >= 0)
algo.setWavelets(wavelet);
}
}
return algo;
}
public static Output decodeOut(Token token) {
int freq = 0;
String line = token.parameters;
String parts[] = token.parameters.split(" ");
for (int i = 0; i < Math.min(2, parts.length); i++) {
if (parts[i].startsWith("@"))
freq = (int) NumFormat.parseNumber(parts[i], 0);
}
String p = token.parameters.toLowerCase();
Output out = null;
if (p.startsWith("stack"))
out = new Output(View.STACK, freq, line.substring("stack".length(), line.length()));
if (p.startsWith("series"))
out = new Output(View.SERIES, freq, line.substring("series".length(), line.length()));
if (p.startsWith("mip"))
out = new Output(View.MIP, freq, line.substring("mip".length(), line.length()));
if (p.startsWith("ortho"))
out = new Output(View.ORTHO, freq, line.substring("ortho".length(), line.length()));
if (p.startsWith("figure"))
out = new Output(View.FIGURE, freq, line.substring("figure".length(), line.length()));
if (p.startsWith("planar"))
out = new Output(View.PLANAR, freq, line.substring("planar".length(), line.length()));
return out;
}
public static void decodeController(Token token, Controller controller) {
String line = token.parameters;
if (token.parameters.startsWith("@")) {
String parts[] = token.parameters.split(" ");
if (parts.length >= 1) {
line = token.parameters.substring(parts[0].length(), token.parameters.length()).trim();
}
}
if (token.keyword.equals("-constraint"))
controller.setConstraint(Constraint.getByName(line.trim()));
else if (token.keyword.equals("-residu"))
controller.setResiduStop(NumFormat.parseNumber(line, -1));
else if (token.keyword.equals("-reference"))
controller.setReference(line);
else if (token.keyword.equals("-time"))
controller.setTimeStop(NumFormat.parseNumber(line, Double.MAX_VALUE));
}
public static double decodeNormalization(Token token) {
if (token.parameters.toLowerCase().endsWith("no"))
return 0;
else
return NumFormat.parseNumber(token.parameters, 1);
}
public static int decodeMonitor(Token token) {
String parts[] = token.parameters.toLowerCase().split(" ");
int m = 0;
for(String p : parts) {
if (p.startsWith("no"))
return 0;
if (p.equals("false"))
return 0;
if (p.equals("0"))
return 0;
if (p.equals("1"))
return 1;
if (p.equals("2"))
return 2;
if (p.equals("3"))
return 3;
if (p.equals("console"))
m += 1;
if (p.equals("table"))
m += 2;
}
return m;
}
public static int decodeStats(Token token) {
String parts[] = token.parameters.toLowerCase().split(" ");
int m = 0;
for(String p : parts) {
if (p.startsWith("no"))
return 0;
if (p.equals("false"))
return 0;
if (p.equals("0"))
return 0;
if (p.equals("1"))
return 1;
if (p.equals("2"))
return 2;
if (p.equals("3"))
return 3;
if (p.equals("show"))
m += 1;
if (p.equals("save"))
m += 2;
}
return m;
}
public static boolean decodeSystem(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
return true;
}
public static boolean decodeDisplay(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
return true;
}
public static boolean decodeMultithreading(Token token) {
String p = token.parameters.toLowerCase();
if (p.startsWith("no"))
return false;
if (p.equals("0"))
return false;
if (p.equals("false"))
return false;
if (p.startsWith("dis"))
return false;
return true;
}
public static Padding decodePadding(Token token) {
AbstractPadding padXY = new NoPadding();
AbstractPadding padZ = new NoPadding();
int extXY = 0;
int extZ = 0;
String param = token.parameters.trim();
String[] parts = param.split(" ");
if (parts.length > 0)
padXY = Padding.getByShortname(parts[0].trim());
if (parts.length > 1)
padZ = Padding.getByShortname(parts[1].trim());
double[] ext = NumFormat.parseNumbers(param);
if (ext.length > 0)
extXY = (int) Math.round(ext[0]);
if (ext.length > 1)
extZ = (int) Math.round(ext[1]);
return new Padding(padXY, padXY, padZ, extXY, extXY, extZ);
}
public static Apodization decodeApodization(Token token) {
AbstractApodization apoXY = new UniformApodization();
AbstractApodization apoZ = new UniformApodization();
String[] parts = token.parameters.trim().split(" ");
if (parts.length >= 1)
apoXY = Apodization.getByShortname(parts[0].trim());
if (parts.length >= 2)
apoZ = Apodization.getByShortname(parts[1].trim());
return new Apodization(apoXY, apoXY, apoZ);
}
public static String getPath() {
command();
ArrayList<Token> tokens = parse(command.getCommand());
String path = System.getProperty("user.dir");
for (Token token : tokens)
if (token.keyword.equalsIgnoreCase("-path") && !token.parameters.equalsIgnoreCase("current"))
path = token.parameters;
return path;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/Deconvolution.java b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
index 48ce8b9..20a4e98 100644
--- a/DeconvolutionLab2/src/deconvolution/Deconvolution.java
+++ b/DeconvolutionLab2/src/deconvolution/Deconvolution.java
@@ -1,550 +1,550 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution;
import java.io.File;
import java.util.ArrayList;
+import bilib.tools.NumFormat;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.OutputCollection;
import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.ConsoleMonitor;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
import deconvolutionlab.monitor.Verbose;
import deconvolutionlab.system.SystemInfo;
import fft.AbstractFFTLibrary;
-import lab.tools.NumFormat;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
public class Deconvolution implements Runnable {
public enum Finish {
DIE, ALIVE, KILL
};
public AbstractAlgorithm algo = null;
private String path;
public double norm = 1.0;
public Padding pad = new Padding();
public Apodization apo = new Apodization();
private OutputCollection outs;
private Verbose verbose = Verbose.Log;
private AbstractFFTLibrary fft;
private int flagMonitor = 3;
private int flagStats = 0;
private boolean flagDisplay = true;
private boolean flagMultithreading = true;
private boolean flagSystem = true;
public Monitors monitors = new Monitors();
private String command = "";
private boolean live = false;
private Features report = new Features();
private String name = "";
private ArrayList<DeconvolutionListener> listeners = new ArrayList<DeconvolutionListener>();
public RealSignal image;
public RealSignal psf;
private RealSignal deconvolvedImage;
private Finish finish = Finish.DIE;
private DeconvolutionDialog dialog;
private TableStats tableStats;
public Deconvolution(String name, String command) {
this.name = name;
this.finish = Finish.DIE;
setCommand(command);
tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
}
public Deconvolution(String name, String command, Finish finish) {
this.name = name;
this.finish = finish;
setCommand(command);
tableStats = new TableStats(name, Constants.widthGUI, 240, path, (flagStats & 2) == 2);
}
public void setCommand(String command) {
this.command = command;
Command.decode(command, this);
this.command = command;
if (name.equals("") && algo != null)
name = algo.getShortname();
live = false;
}
/**
* This method runs the deconvolution without graphical user interface.
*
* @param exit
* System.exit call is true
*/
public RealSignal deconvolve(RealSignal image, RealSignal psf) {
this.image = image;
this.psf = psf;
runDeconvolve();
return deconvolvedImage;
}
public RealSignal deconvolve() {
this.image = null;
this.psf = null;
runDeconvolve();
return deconvolvedImage;
}
/**
* This method runs the deconvolution without graphical user interface.
*
* @param exit
* System.exit call is true
*/
private void runDeconvolve() {
if ((flagMonitor & 2) == 2) {
TableMonitor tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
monitors.add(tableMonitor);
Lab.setVisible(tableMonitor.getPanel(), "Monitor of " + name, 10, 10);
}
if ((flagMonitor & 1) == 1)
monitors.add(new ConsoleMonitor());
if ((flagStats & 1) == 1) {
Lab.setVisible(tableStats.getPanel(), "Stats of " + name, 50, 50);
}
if (fft == null) {
run();
return;
}
if (!fft.isMultithreadable()) {
run();
return;
}
if (flagMultithreading) {
Thread thread = new Thread(this);
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
}
else {
run();
}
}
/**
* This method runs the deconvolution with a graphical user interface.
*
* @param job
* Name of the job of deconvolution
*/
public void launch() {
monitors = new Monitors();
TableMonitor tableMonitor = null;
if ((flagMonitor & 2) == 2) {
tableMonitor = new TableMonitor(name , Constants.widthGUI, 240);
monitors.add(tableMonitor);
}
if ((flagMonitor & 1) == 1)
monitors.add(new ConsoleMonitor());
if (flagStats == 0) {
tableStats = null;
}
dialog = new DeconvolutionDialog(DeconvolutionDialog.Module.ALL, this, tableMonitor, tableStats);
monitors.add(new StatusMonitor(dialog.getProgressBar()));
Lab.setVisible(dialog, false);
}
@Override
public void run() {
double chrono = System.nanoTime();
if (flagSystem)
SystemInfo.activate();
for (DeconvolutionListener listener : listeners)
listener.started();
live = true;
if (monitors != null)
monitors.setVerbose(verbose);
report.add("Path", checkPath(path));
monitors.log("Path: " + checkPath(path));
if (image == null)
image = openImage();
if (image == null) {
monitors.error("Image: Not valid " + command);
report.add("Image", "Not valid");
if (finish == Finish.KILL)
System.exit(-101);
return;
}
report.add("Image", image.dimAsString());
monitors.log("Image: " + image.dimAsString());
psf = openPSF();
if (psf == null) {
monitors.error("PSF: not valid");
report.add("PSF", "Not valid");
if (finish == Finish.KILL)
System.exit(-102);
return;
}
report.add("PSF", psf.dimAsString());
monitors.log("PSF: " + psf.dimAsString());
if (algo == null) {
monitors.error("Algorithm: not valid");
if (finish == Finish.KILL)
System.exit(-103);
return;
}
Controller controller = algo.getController();
if (controller == null) {
monitors.error("Controller: not valid");
if (finish == Finish.KILL)
System.exit(-104);
return;
}
if (flagStats > 0)
controller.setTableStats(tableStats);
report.add("FFT", fft.getLibraryName());
if (outs != null) {
outs.setPath(path);
controller.setOutputs(outs);
}
monitors.log("Algorithm: " + algo.getName());
report.add("Algorithm", algo.getName());
algo.setController(controller);
deconvolvedImage = algo.run(monitors, image, psf, fft, pad, apo, norm, true);
live = false;
for (DeconvolutionListener listener : listeners)
listener.finish();
report.add("End", NumFormat.time(System.nanoTime() - chrono));
if (flagDisplay)
Lab.show(monitors, deconvolvedImage, "Result of " + algo.getShortname());
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;
monitors = null;
System.gc();
}
public void die() {
SignalCollector.free(image);
SignalCollector.free(psf);
}
/**
* This methods make a recap of the deconvolution. Useful before starting
* the processing.
*
* @return list of messages to print
*/
public Features recap() {
Features features = new Features();
Token image = Command.extract(command, "-image");
features.add("Image", image == null ? "keyword -image not found" : image.parameters);
String normf = (norm < 0 ? " (no normalization)" : " (normalization to " + norm + ")");
Token psf = Command.extract(command, "-psf");
features.add("PSF", psf == null ? "keyword -psf not found" : psf.parameters + " norm:" + normf);
if (algo == null) {
features.add("Algorithm", "not valid>");
}
else {
Controller controller = algo.getController();
features.add("Algorithm", algo.toString());
features.add("Stopping Criteria", controller.getStoppingCriteriaAsString(algo));
features.add("Reference", controller.getReference());
features.add("Constraint", controller.getConstraintAsString());
features.add("Padding", pad.toString());
features.add("Apodization", apo.toString());
features.add("FFT", fft == null ? "null" : fft.getLibraryName());
}
features.add("Path", path);
String monitor = "";
if (flagMonitor == 0)
monitor = "no ";
if (flagMonitor == 1)
monitor = "console (" + verbose.name().toLowerCase() + ")";
if (flagMonitor == 2)
monitor = "table (" + verbose.name().toLowerCase() + ")";
if (flagMonitor == 3)
monitor = "console table (" + verbose.name().toLowerCase() + ")";
String stats = "";
if (flagStats == 0)
stats = "no ";
if (flagStats == 1)
stats = "show ";
if (flagStats == 2)
stats = "save ";
if (flagStats == 3)
stats = "show save";
String running = "";
running += "multithreading: " + (flagMultithreading ? "on " : "off ");
running += " display: " + (flagDisplay ? "on " : "off ");
running += " system: " + (flagSystem ? "shown" : "hidden ");
features.add("Monitor", monitor);
features.add("Stats", stats);
features.add("Running", running);
if (outs == null)
features.add("Output", "not valid");
else
for (Output out : outs)
features.add("Output " + out.getName(), out.toString());
return features;
}
public Features checkOutput() {
Features features = new Features();
if (deconvolvedImage == null) {
features.add("Image", "No valid output image");
return features;
}
float stati[] = deconvolvedImage.getStats();
int sizi = deconvolvedImage.nx * deconvolvedImage.ny * deconvolvedImage.nz;
float totali = stati[0] * sizi;
features.add("<html><b>Deconvolved Image</b></html>", "");
features.add("Size", deconvolvedImage.dimAsString() + " " + NumFormat.bytes(sizi*4));
features.add("Mean (stdev)", NumFormat.nice(stati[0]) + " (" + NumFormat.nice(stati[3]) + ")");
features.add("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
return features;
}
public boolean isLive() {
return live;
}
public void abort() {
live = false;
algo.getController().abort();
}
public String checkPath(String path) {
File dir = new File(path);
if (dir.exists()) {
if (dir.isDirectory()) {
if (dir.canWrite())
return path + " (writable)";
else
return path + " (non-writable)";
}
else {
return path + " (non-directory)";
}
}
else {
return path + " (not-valid)";
}
}
public RealSignal openImage() {
Token token = Command.extract(command, "-image");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
image = Lab.createRealSignal(monitors, arg, cmd, path);
return image;
}
public RealSignal openPSF() {
Token token = Command.extract(command, "-psf");
if (token == null)
return null;
if (token.parameters.startsWith(">>>"))
return null;
String arg = token.option.trim();
String cmd = token.parameters.substring(arg.length(), token.parameters.length()).trim();
psf = Lab.createRealSignal(monitors, arg, cmd, path);
return psf;
}
public void addDeconvolutionListener(DeconvolutionListener listener) {
listeners.add(listener);
}
public OutputCollection getOuts() {
return outs;
}
public void setAlgorithm(AbstractAlgorithm algo, Controller controller) {
this.algo = algo;
if (algo != null && controller != null) {
algo.setController(controller);
}
}
public AbstractAlgorithm getAlgo() {
return algo;
}
public void setPath(String path) {
this.path = path;
}
public String getPath() {
return path;
}
public void setNormalization(double norm) {
this.norm = norm;
}
public void setPadding(Padding pad) {
this.pad = pad;
}
public Padding getPadding() {
return pad;
}
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 void setApodization(Apodization apo) {
this.apo = apo;
}
public Apodization getApodization() {
return apo;
}
public void setOutput(OutputCollection outs) {
this.outs = outs;
}
public void setVerbose(Verbose verbose) {
this.verbose = verbose;
}
public void setFFT(AbstractFFTLibrary fft) {
this.fft = fft;
}
public void setMonitor(int flagMonitor) {
this.flagMonitor = flagMonitor;
}
public void setStats(int flagStats) {
this.flagStats = flagStats;
}
public void setFlags(boolean flagDisplay, boolean flagMultithreading, boolean flagSystem) {
this.flagDisplay = flagDisplay;
this.flagMultithreading = flagMultithreading;
this.flagSystem = flagSystem;
}
public String getCommand() {
return command;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
index 718fdd7..119225a 100644
--- a/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
+++ b/DeconvolutionLab2/src/deconvolution/DeconvolutionDialog.java
@@ -1,379 +1,379 @@
/*
* 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.JPanelImage;
import deconvolution.modules.AlgorithmDModule;
import deconvolution.modules.ImageDModule;
import deconvolution.modules.PSFDModule;
import deconvolution.modules.RecapDModule;
import deconvolution.modules.ReportDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.StatusMonitor;
import deconvolutionlab.monitor.TableMonitor;
-import lab.component.BorderToggledButton;
-import lab.component.JPanelImage;
public class DeconvolutionDialog extends JDialog implements WindowListener, ActionListener, Runnable {
public enum State {
NOTDEFINED, READY, RUN, FINISH
};
public enum Module {
ALL, RECAP, IMAGE, PSF, ALGO
};
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 BorderToggledButton bnReport = new BorderToggledButton("Report");
private BorderToggledButton bnMonitor = new BorderToggledButton("Monitor");
private BorderToggledButton bnStats = new BorderToggledButton("Stats");
private Thread thread = null;
private Deconvolution deconvolution;
private JProgressBar progress = new JProgressBar();
public static Point location = new Point(0, 0);
private JPanel cards = new JPanel(new CardLayout());
private boolean flagMonitor = false;
private boolean flagStats = false;
private ImageDModule image;
private PSFDModule psf;
private RecapDModule recap;
private AlgorithmDModule algorithm;
private ReportDModule report;
private TableStats tableStats;
private TableMonitor tableMonitor;
public DeconvolutionDialog(Module module, Deconvolution deconvolution, TableMonitor tableMonitor, TableStats tableStats) {
super(new JFrame(), deconvolution.getName());
this.deconvolution = deconvolution;
this.tableMonitor = tableMonitor;
this.tableStats = tableStats;
image = new ImageDModule(deconvolution);
psf = new PSFDModule(deconvolution);
recap = new RecapDModule(deconvolution);
algorithm = new AlgorithmDModule(deconvolution);
report = new ReportDModule(deconvolution);
// 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(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) {
JPanelImage buttons = new JPanelImage("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());
if (tableMonitor != null)
cards.add("Monitor", tableMonitor.getPanel());
if (tableStats != null)
cards.add("Stats", tableStats.getPanel());
// 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) {
JToolBar tool = new JToolBar();
tool.setFloatable(false);
tool.setLayout(new GridLayout(1, 6));
tool.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
tool.add(bnRecap);
tool.add(bnImage);
tool.add(bnPSF);
tool.add(bnAlgo);
if (tableMonitor != null)
tool.add(bnMonitor);
if (tableStats != null)
tool.add(bnStats);
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);
bnPSF.addActionListener(this);
bnAlgo.addActionListener(this);
bnRecap.addActionListener(this);
if (tableMonitor != null)
bnMonitor.addActionListener(this);
if (tableStats != null)
bnStats.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);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
image.update();
}
if (module == Module.PSF) {
toggle(bnPSF);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
psf.update();
}
if (module == Module.ALGO) {
toggle(bnAlgo);
deconvolution.monitors.add(new StatusMonitor(getProgressBar()));
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() == 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);
if (tableMonitor != null)
tableMonitor.clear();
if (tableStats != null)
tableStats.clear();
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);
}
@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());
deconvolution.run();
toggle(bnReport);
bnStop.setEnabled(false);
report.update();
bnRecap.setEnabled(true);
bnAlgo.setEnabled(true);
bnPSF.setEnabled(true);
bnImage.setEnabled(true);
thread = null;
}
public static void setLocationLaunch(Point l) {
location = l;
}
private void toggle(BorderToggledButton bn) {
((CardLayout) (cards.getLayout())).show(cards, bn.getText());
bnRecap.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) {
}
public JProgressBar getProgressBar() {
return progress;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
index 33fe094..becc3da 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/AbstractAlgorithm.java
@@ -1,240 +1,240 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import bilib.tools.NumFormat;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
-import lab.tools.NumFormat;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
import signal.apodization.Apodization;
import signal.padding.Padding;
/**
* This class is the common part of every algorithm of deconvolution.
*
* @author Daniel Sage
*
*/
public abstract class AbstractAlgorithm implements Callable<RealSignal> {
/** y is the input signal of the deconvolution. */
protected RealSignal y = null;
/** h is the PSF signal for the deconvolution. */
protected RealSignal h = null;
/** The controller takes the control of the algorithm, in
* particular to do some operations at the starting,
* at every iteration and at the end. */
protected Controller controller = null;
/** This is the FFT used. */
protected AbstractFFT fft = null;
/** Shortname of the algorithm given by the user, useful in particular to deal with the synonym. */
protected String shortname = "I";
/** Optimized implementation in term of memory footprint */
protected boolean optimizedMemoryFootprint = true;
public AbstractAlgorithm() {
this.controller = new Controller();
}
public void setShortname(String shortname) {
this.shortname = shortname;
}
public String getShortname() {
return shortname;
}
public void setOptimizedMemoryFootprint(boolean optimizedMemoryFootprint) {
this.optimizedMemoryFootprint = optimizedMemoryFootprint;
}
public abstract String getName();
public abstract double getMemoryFootprintRatio();
public abstract int getComplexityNumberofFFT();
public abstract boolean isRegularized();
public abstract boolean isStepControllable();
public abstract boolean isIterative();
public abstract boolean isWaveletsBased();
public abstract void setParameters(double[] params);
public abstract double getRegularizationFactor();
public abstract double getStepFactor();
public abstract double[] getParameters();
public abstract double[] getDefaultParameters();
public RealSignal run(Monitors monitors,
RealSignal image, RealSignal psf,
AbstractFFTLibrary fftlib, Padding pad, Apodization apo, double norm, boolean threaded) {
if (image == null)
return null;
if (psf == null)
return null;
if (fftlib != null)
fft = FFT.createFFT(monitors, fftlib, image.nx, image.ny, image.nz);
else
fft = FFT.createDefaultFFT(monitors, image.nx, image.ny, image.nz);
controller.setFFT(fft);
y = pad.pad(monitors, image);
y.setName("y");
apo.apodize(monitors, y);
monitors.log("Input: " + y.dimAsString());
h = psf.changeSizeAs(y);
h.setName("h");
h.normalize(norm);
monitors.log("PSF: " + h.dimAsString() + " normalized " + (norm <= 0 ? "no" : norm));
String iterations = (isIterative() ? controller.getIterationMax() + " iterations" : "direct");
monitors.log(getShortname() + " is starting (" + iterations + ")");
controller.setMonitors(monitors);
controller.start(y);
h.circular();
if (fft == null)
fft = FFT.createDefaultFFT(monitors, y.nx, y.ny, y.nz);
else
fft.init(monitors, y.nx, y.ny, y.nz);
monitors.log(getShortname() + " data ready");
double params[] = getParameters();
if (params != null) {
if (params.length > 0) {
String s = " ";
for (double param : params)
s += "" + param + " ";
monitors.log(getShortname() + s);
}
}
RealSignal x = null;
try {
if (threaded == true) {
ExecutorService pool = Executors.newSingleThreadExecutor();
Future<RealSignal> future = pool.submit(this);
x = future.get();
}
else {
x = call();
}
}
catch (InterruptedException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (ExecutionException ex) {
ex.printStackTrace();
x = y.duplicate();
}
catch (Exception e) {
e.printStackTrace();
x = y.duplicate();
}
x.setName("x");
controller.finish(x);
monitors.log(getName() + " is finished");
SignalCollector.free(y);
SignalCollector.free(h);
RealSignal result = pad.crop(monitors, x);
SignalCollector.free(x);
return result;
}
public AbstractFFT getFFT() {
return fft;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
}
public int getIterations() {
return controller.getIterations();
}
public double getTime() {
return controller.getTimeNano();
}
public double getMemory() {
return controller.getMemory();
}
public void setWavelets(String waveletsName) {
}
@Override
public String toString() {
String s = "";
s += getName();
s += (isIterative() ? ", " + controller.getIterationMax() + " iterations" : " (direct)");
s += (isRegularized() ? ", &lambda=" + NumFormat.nice(getRegularizationFactor()) : "");
s += (isStepControllable() ? ", &gamma=" + NumFormat.nice(getStepFactor()) : "");
return s;
}
public String getParametersAsString() {
double p[] = getParameters();
String param = "";
for(int i=0; i<p.length; i++)
if (i==p.length-1)
param += p[i];
else
param += p[i] + ", ";
return param;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
index 67ee002..e1bc26b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Controller.java
@@ -1,353 +1,353 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.Timer;
import java.util.TimerTask;
+import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolutionlab.OutputCollection;
import deconvolutionlab.TableStats;
import deconvolutionlab.monitor.Monitors;
import deconvolutionlab.system.SystemUsage;
import fft.AbstractFFT;
import fft.FFT;
-import lab.tools.NumFormat;
import signal.Assessment;
import signal.ComplexSignal;
import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
/**
* 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.
*
* @author sage
*
*/
public class Controller {
private int iterationsMax = 100;
private double timeMax = 1000;
private double residuMin = -1;
private boolean doResidu = false;
private boolean doTime = false;
private boolean doReference = false;
private boolean doConstraint = false;
private boolean 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 Constraint.Mode constraint = Constraint.Mode.NO;
private OutputCollection outs = null;
private String referenceName = "";
private RealSignal refImage;
private RealSignal prevImage;
private RealSignal x;
private Timer timer;
private AbstractFFT fft;
private TableStats tableStats;
private float[] statsInput;
private Monitors monitors = new Monitors();
public Controller() {
constraint = Constraint.Mode.NO;
doResidu = false;
doTime = false;
doReference = false;
doConstraint = false;
}
public void setTableStats(TableStats tableStats) {
this.tableStats = tableStats;
}
public void setMonitors(Monitors monitors) {
this.monitors = monitors;
}
public void setFFT(AbstractFFT fft) {
this.fft = fft;
}
public void abort() {
this.abort = true;
}
public int getIterationMax() {
return iterationsMax;
}
public void setIterationMax(int iterationsMax) {
this.iterationsMax = iterationsMax;
}
public void setTimeStop(double timeMax) {
this.doTime = true;
this.timeMax = timeMax * 1e9;
}
public void setResiduStop(double residuMin) {
this.doResidu = true;
this.residuMin = residuMin;
}
public void setReference(String referenceName) {
this.doReference = true;
this.referenceName = referenceName;
}
public void setConstraint(Constraint.Mode constraint) {
this.doConstraint = true;
this.constraint = constraint;
}
public void setOutputs(OutputCollection outs) {
this.outs = outs;
}
public boolean needSpatialComputation() {
return doConstraint || doResidu || doReference;
}
public void start(RealSignal x) {
this.x = x;
statsInput = x.getStats();
if (tableStats != null)
tableStats.nextStats(monitors, stats());
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 = 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");
}
if (outs != null)
outs.executeStarting(monitors, x, this);
this.prevImage = x;
}
public boolean ends(ComplexSignal X) {
boolean out = outs == null ? false : outs.hasShow(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);
if (outs != null)
outs.executeIterative(monitors, x, this, iterations);
iterations++;
double p = iterations * 100.0 / iterationsMax;
monitors.progress("Iterative " + iterations + "/" + iterationsMax, p);
double timeElapsed = getTimeNano();
boolean stopIter = (iterations >= iterationsMax);
boolean stopTime = doTime && (timeElapsed >= timeMax);
boolean stopResd = doResidu && (residu <= residuMin);
monitors.log("@" + iterations + " Time: " + NumFormat.seconds(timeElapsed));
if (tableStats != null)
tableStats.nextStats(monitors, stats());
String prefix = "Stopped>> by ";
if (abort)
monitors.log(prefix + "abort");
if (stopIter)
monitors.log(prefix + "iteration " + iterations + " > " + iterationsMax);
if (stopTime)
monitors.log(prefix + "time " + timeElapsed + " > " + timeMax);
if (stopResd)
monitors.log(prefix + "residu " + NumFormat.nice(residu) + " < " + NumFormat.nice(residuMin));
return abort | stopIter | stopTime | stopResd;
}
public void finish(RealSignal x) {
this.x = x;
boolean ref = doReference;
boolean con = doConstraint;
boolean res = doResidu;
if (con || res || ref)
compute(iterations, x, con, res, ref);
if (tableStats != null)
tableStats.lastStats(monitors, stats());
if (outs != null)
outs.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 && constraint != null)
new Constraint(monitors).apply(x, constraint);
if (ref && refImage != null) {
String s = "";
psnr = Assessment.psnr(x, refImage);
snr = Assessment.snr(x, refImage);
s += " PSNR: " + NumFormat.nice(psnr);
s += " SNR: " + NumFormat.nice(snr);
monitors.log("@" + iterations + " " + s);
}
residu = Double.MAX_VALUE;
if (res && prevImage != null) {
residu = Assessment.relativeResidu(x, prevImage);
prevImage = x.duplicate();
monitors.log("@" + iterations + " Residu: " + NumFormat.nice(residu));
}
}
public String[] stats() {
if (tableStats == null)
return null;
float params[] = null;
if (x != null)
params = x.getStats();
String[] row = new String[12];
row[0] = "" + iterations;
row[1] = (params == null ? "-" : "" + params[0]);
row[2] = (params == null ? "-" : "" + params[1]);
row[3] = (params == null ? "-" : "" + params[2]);
row[4] = (params == null ? "-" : "" + params[3]);
row[5] = (params == null ? "-" : "" + params[5]);
row[6] = NumFormat.seconds(getTimeNano());
row[7] = NumFormat.bytes(SystemUsage.getHeapUsed());
row[8] = SignalCollector.sumarize();
row[9] = doReference ? NumFormat.nice(psnr) : "n/a";
row[10] = doReference ? NumFormat.nice(snr) : "n/a";
row[11] = doResidu ? NumFormat.nice(residu) : "n/a";
return row;
}
public double getTimeNano() {
return (System.nanoTime() - timeStarting);
}
public Constraint.Mode getConstraint() {
return constraint;
}
public String getReference() {
return doReference ? referenceName : "no ground-truth";
}
public String getConstraintAsString() {
if (!doConstraint)
return "no";
if (constraint == null)
return "null";
return constraint.name().toLowerCase();
}
public String getStoppingCriteriaAsString(AbstractAlgorithm algo) {
String stop = algo.isIterative() ? "iterations limit=" + getIterationMax() + ", " : "direct, ";
stop += doTime ? ", time limit=" + NumFormat.nice(timeMax * 1e-9) : " no time limit" + ", ";
stop += doResidu ? ", residu limit=" + NumFormat.nice(residuMin) : " no residu limit";
return stop;
}
public float[] getStatsInput() {
return statsInput;
}
public double getMemory() {
return memoryPeak - memoryStarting;
}
public String getMemoryAsString() {
return NumFormat.bytes(getMemory());
}
public int getIterations() {
return iterations;
}
private void update() {
memoryPeak = Math.max(memoryPeak, SystemUsage.getHeapUsed());
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
index 5213e96..4a93291 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ConvolutionPanel.java
@@ -1,72 +1,72 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
-import lab.component.GridPanel;
+import bilib.component.GridPanel;
public class ConvolutionPanel extends AbstractAlgorithmPanel {
private Convolution algo = new Convolution();
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
@Override
public String getCommand() {
return "";
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"CONV"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm is only used for simulation. It make a pure convolution of the input image with the PSF in the Fourier domain.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
index 349e54a..66bcaac 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/FISTAPanel.java
@@ -1,167 +1,167 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class FISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
private FISTA algo = new FISTA(10, 1, 0.1, "Haar", 3);
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
double lambda = reg.getValue();
String waveletsName = (String) cmbWav.getSelectedItem();
int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"FISTA"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname: FISTA</h2>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p></p>";
s += "<h3>Reference: Beck and Teboulle, SIAM <b>2</b> 2009</h3>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
index 3243e7c..24e82df 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ICTMPanel.java
@@ -1,144 +1,144 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class ICTMPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private ICTM algo = new ICTM(10, 0.1, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"ICTM"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
index 526516c..16ff813 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/ISTAPanel.java
@@ -1,165 +1,165 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
import wavelets.AbstractWavelets;
import wavelets.Wavelets;
public class ISTAPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private RegularizationPanel reg;
private JComboBox<String> cmbWav = new JComboBox<String>(Wavelets.getWaveletsAsArray());
private JComboBox<String> cmbScale = new JComboBox<String>(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" });
private ISTA algo = new ISTA(0, 1, 0.1, "Haar", 3);
@Override
public JPanel getPanelParameters() {
AbstractWavelets wavdef = Wavelets.getDefaultWavelets();
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[2]);
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
cmbWav.setPreferredSize(Constants.dimParameters);
cmbScale.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
pn.place(5, 0, "<html><span \"nowrap\"><b>Wavelets</b></span></html>");
pn.place(5, 2, cmbWav);
pn.place(5, 3, "<html>Scale</html>");
pn.place(5, 4, cmbScale);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "wavelets", cmbWav, wavdef.getName());
Config.register("Algorithm." + algo.getShortname(), "scale", cmbScale, wavdef.getScales());
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
cmbWav.addActionListener(this);
cmbScale.addActionListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
double lambda = reg.getValue();
String waveletsName = (String) cmbWav.getSelectedItem();
int scale = Integer.parseInt((String) cmbScale.getSelectedItem());
return iter + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda) + " " + waveletsName + " " + scale;
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"ISTA"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
index 9689aec..e6836c8 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/IdentityPanel.java
@@ -1,72 +1,72 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
-import lab.component.GridPanel;
+import bilib.component.GridPanel;
public class IdentityPanel extends AbstractAlgorithmPanel {
private Identity algo = new Identity();
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
@Override
public String getCommand() {
return "";
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"I", "ID"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm does nothing. It returns the input image.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
index 4197e3b..865687a 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPanel.java
@@ -1,109 +1,109 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class LandweberPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private Landweber algo = new Landweber(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, "<html><span \"nowrap\"><b>Regularization</b></span></html>");
pn.place(2, 1, 4, 1, "<html><span \"nowrap\">No regularization</i></span></html>");
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"LW", "LLS"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
index 403d09e..8ca1655 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/LandweberPositivityPanel.java
@@ -1,109 +1,109 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class LandweberPositivityPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private LandweberPositivity algo = new LandweberPositivity(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, "<html><span \"nowrap\"><b>Regularization</b></span></html>");
pn.place(2, 1, 4, 1, "<html><span \"nowrap\">No regularization</i></span></html>");
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"NLLS", "LW+"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
index bcabb4c..7fa81fc 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NaiveInverseFilterPanel.java
@@ -1,75 +1,75 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
-import lab.component.GridPanel;
+import bilib.component.GridPanel;
public class NaiveInverseFilterPanel extends AbstractAlgorithmPanel {
private NaiveInverseFilter algo = new NaiveInverseFilter();
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
@Override
public String getCommand() {
return "";
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"NIF", "IF"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h3>Shortname: NIF or IF</p>";
s += "<p>This is the classical inverse filter.</p>";
s += "<p>This algorithm only performs a stabilized division in the Fourier domain.</p>";
s += "<p>The stabilization is controlled by the machine epsilon parameter &Epsilon; set by default at 1E-6.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
index d77ba67..39ed17a 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/NonStabilizedDivisionPanel.java
@@ -1,76 +1,76 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
-import lab.component.GridPanel;
+import bilib.component.GridPanel;
public class NonStabilizedDivisionPanel extends AbstractAlgorithmPanel {
private NonStabilizedDivision algo = new NonStabilizedDivision();
@Override
public JPanel getPanelParameters() {
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\">No parameters</span></html>");
return pn;
}
@Override
public String getCommand() {
return "";
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"DIV"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
index dd505b8..a36961c 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RegularizedInverseFilterPanel.java
@@ -1,115 +1,115 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.tools.NumFormat;
public class RegularizedInverseFilterPanel extends AbstractAlgorithmPanel implements KeyListener, ChangeListener {
private RegularizationPanel reg;
private RegularizedInverseFilter algo = new RegularizedInverseFilter(0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"RIF", "LRIF"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname RIF or LRIF</h2>";
s += "<p>Laplacian Regularized Inverse Filter</p>";
s += "<p>This is a inverse filter with a Laplacian regularization that tends to have an effect on high frequency</p>";
s += "<p>It is very fast, non-iterative algorithm</p>";
s += "<p>The regularization blurs the noise and the image. It is controlled by &lambda;</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
index 489e331..47d0a6c 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyPanel.java
@@ -1,94 +1,94 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeInteger;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeInteger;
public class RichardsonLucyPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private RichardsonLucy algo = new RichardsonLucy(10);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
spnIter.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return "" + spnIter.get();
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"RL"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2> Shortname: RL</h2>";
s += "<p>This is the well-known Richardson-Lucy algorithm.</p>";
s += "<p>It is an iterative with a slow convergence, it has only one parameter to tune: the maximum number of iterations</p>";
s += "<p>RL is well appropiate for dominant Poison noise.</p>";
s += "<p>It is a maximum likelihood estimator (MLE).</p>";
s += "<p>Warning: the input image should have only positive values</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
index f0d531c..1e7a41b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/RichardsonLucyTVPanel.java
@@ -1,130 +1,130 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class RichardsonLucyTVPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private RegularizationPanel reg;
private RichardsonLucyTV algo = new RichardsonLucyTV(10, 0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[1]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(2, 0, 3, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(lambda);
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"RLTV"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2> Shortname: RLTV</h2>";
s += "<p>This algorithm is a combinaison of the Richardson–Lucy algorithm with a regularization constraint based on Total Variation, which tends to reduce unstable oscillations while preserving object edges.</p>";
s += "<p>It is a iterative algorithm, relative slow to compute the Total Variation at every iteration.s</p>";
s += "<p>It has a weighted parameter &lamdba; to control the effect of the total variation.</p>";
s += "<p></p>";
s += "<h3>Reference: Dey et al., Microscopy Research and Technics, 2006 " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java b/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
index e390b7b..4faaaf2 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/Simulation.java
@@ -1,159 +1,159 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.util.concurrent.Callable;
-import lab.tools.PsRandom;
+import bilib.tools.PsRandom;
import signal.ComplexSignal;
import signal.Operations;
import signal.RealSignal;
import signal.SignalCollector;
public class Simulation extends AbstractAlgorithm implements Callable<RealSignal> {
private static PsRandom rand = new PsRandom(1234);
private double mean = 0.0;
private double stdev = 10.0;
private double poisson = 0.0;
public Simulation(double mean, double stdev, double poisson) {
super();
this.mean = mean;
this.stdev = stdev;
this.poisson = poisson;
}
@Override
public RealSignal call() {
ComplexSignal Y = fft.transform(y);
ComplexSignal H = fft.transform(h);
ComplexSignal X = Operations.multiply(H, Y);
SignalCollector.free(Y);
SignalCollector.free(H);
RealSignal x = fft.inverse(X);
SignalCollector.free(X);
gaussian(x, mean, stdev);
poisson(x, poisson);
return x;
}
public void gaussian(RealSignal x, double mean, double sd) {
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
slice[j] += (float) rand.nextGaussian(mean, sd);
}
}
public void poisson(RealSignal x, double factor) {
if (factor < Operations.epsilon)
return;
double f = 1.0/(factor);
for (int k = 0; k < x.nz; k++) {
float[] slice = x.getXY(k);
for (int j = 0; j < x.ny * x.nx; j++)
if (slice[j] > Operations.epsilon) {
slice[j] = (float)(rand.nextPoissonian(f*(slice[j])) * factor);
}
}
}
@Override
public String getName() {
return "Simulation with noise [SIM]";
}
@Override
public int getComplexityNumberofFFT() {
return 3;
}
@Override
public double getMemoryFootprintRatio() {
return 8.0;
}
@Override
public boolean isRegularized() {
return false;
}
@Override
public boolean isStepControllable() {
return false;
}
@Override
public boolean isIterative() {
return false;
}
@Override
public boolean isWaveletsBased() {
return false;
}
@Override
public void setParameters(double[] params) {
if (params == null)
return;
if (params.length > 0)
mean = params[0];
if (params.length > 1)
stdev = params[1];
if (params.length > 2)
poisson = params[2];
}
@Override
public double[] getDefaultParameters() {
return new double[] {0, 1, 0};
}
@Override
public double[] getParameters() {
return new double[] {mean, stdev, poisson};
}
@Override
public double getRegularizationFactor() {
return 0.0;
}
@Override
public double getStepFactor() {
return 0;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
index 11d9f2f..d0bf53b 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/SimulationPanel.java
@@ -1,114 +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 deconvolution.algorithm;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.GridPanel;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
public class SimulationPanel extends AbstractAlgorithmPanel implements KeyListener {
private JTextField txtMean;
private JTextField txtStdev;
private JTextField txtPoisson;
private Simulation algo = new Simulation(0, 0, 0);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
txtMean = new JTextField("" + params[0], 5);
txtStdev = new JTextField("" + params[1], 5);
txtPoisson = new JTextField("" + params[2], 5);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html>Gaussian (Mean)</html>");
pn.place(1, 2, txtMean);
pn.place(2, 0, "<html>Gaussian (Stdev)</html>");
pn.place(2, 2, txtStdev);
pn.place(3, 0, "<html>Poisson</html>");
pn.place(3, 2, txtPoisson);
txtMean.addKeyListener(this);
txtStdev.addKeyListener(this);
txtPoisson.addKeyListener(this);
Config.register("Algorithm." + algo.getShortname(), "gaussian.mean", txtMean, params[0]);
Config.register("Algorithm." + algo.getShortname(), "gaussian.stdev", txtStdev, params[1]);
Config.register("Algorithm." + algo.getShortname(), "poisson", txtPoisson, params[2]);
return pn;
}
@Override
public String getCommand() {
return txtMean.getText() + " " + txtStdev.getText() + " " + txtPoisson.getText();
}
@Override
public void keyTyped(KeyEvent e) {
Command.command();
}
@Override
public void keyPressed(KeyEvent e) {
Command.command();
}
@Override
public void keyReleased(KeyEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"SIM", "SIMU"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>This algorithm is only used for simulation. It convolves the input image with the PSF and adds some noise.</p>";
s += "<p>The noise has a Gaussian distribution (mean, stdev) and a Poisson distribution (poisson).</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/StarkParkerPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/StarkParkerPanel.java
index 5206a7a..d36bd80 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/StarkParkerPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/StarkParkerPanel.java
@@ -1,110 +1,110 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class StarkParkerPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private StarkParker algo = new StarkParker(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, "<html><span \"nowrap\"><b>Regularization</b></span></html>");
pn.place(2, 1, 4, 1, "<html><span \"nowrap\">No regularization</i></span></html>");
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] { "BVLS", "SP" };
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h1>Stark-Parker Algorithm</p>";
s += "<h2>Shortname: BVLS or SP</p>";
s += "<p>This algorithm also known as Stark-Parker algorithm is a least squares variant with a bounded-variable constraint.</p>";
s += "<p>In this implementation, the bounds are the bounds of the input image.</p>";
s += "<p></p>";
s += "<p>Reference: Stark and Parker, Computational Statistics <b>10</b>, 1995.</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
index b748877..e131cd2 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovMillerPanel.java
@@ -1,142 +1,142 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class TikhonovMillerPanel extends AbstractAlgorithmPanel implements KeyListener, ActionListener, ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1, "###");
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1, "#.#");
private RegularizationPanel reg;
private TikhonovMiller algo = new TikhonovMiller(10, 1, 0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
reg = new RegularizationPanel(params[2]);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
pn.place(2, 0, 5, 1, reg);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
double gamma = spnStep.get();
double lambda = reg.getValue();
return spnIter.get() + " " + NumFormat.nice(gamma) + " " + NumFormat.nice(lambda);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"TM"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
index de79415..9c09017 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/TikhonovRegularizationInverseFilterPanel.java
@@ -1,123 +1,123 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.RegularizationPanel;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.component.RegularizationPanel;
-import lab.tools.NumFormat;
public class TikhonovRegularizationInverseFilterPanel extends AbstractAlgorithmPanel implements ActionListener, ChangeListener, KeyListener {
private RegularizationPanel reg;
private TikhonovRegularizationInverseFilter algo = new TikhonovRegularizationInverseFilter(0.1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
reg = new RegularizationPanel(params[0]);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, reg);
Config.register("Algorithm." + algo.getShortname(), "reg", reg.getText(), "0.1");
reg.getText().addKeyListener(this);
reg.getSlider().addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
return NumFormat.nice(reg.getValue());
}
@Override
public void stateChanged(ChangeEvent e) {
reg.getText().removeKeyListener(this);
reg.updateFromSlider();
Command.command();
reg.getText().addKeyListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
Command.command();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
reg.getSlider().removeChangeListener(this);
reg.updateFromText();
Command.command();
reg.getSlider().addChangeListener(this);
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"TRIF"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<h2>Shortname TRIF</h2>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
index b383959..499ebb5 100644
--- a/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
+++ b/DeconvolutionLab2/src/deconvolution/algorithm/VanCittertPanel.java
@@ -1,106 +1,106 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolution.algorithm;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class VanCittertPanel extends AbstractAlgorithmPanel implements ChangeListener {
private SpinnerRangeInteger spnIter = new SpinnerRangeInteger(10, 1, 99999, 1);
private SpinnerRangeDouble spnStep = new SpinnerRangeDouble(1, 0, 2, 0.1);
private VanCittert algo = new VanCittert(10, 1);
@Override
public JPanel getPanelParameters() {
double[] params = algo.getDefaultParameters();
spnIter.setPreferredSize(Constants.dimParameters);
spnStep.setPreferredSize(Constants.dimParameters);
GridPanel pn = new GridPanel(false);
pn.place(1, 0, "<html><span \"nowrap\"><b>Iterations</b></span></html>");
pn.place(1, 1, "<html><span \"nowrap\"><i>N</i></span></html>");
pn.place(1, 2, spnIter);
pn.place(1, 3, "<html><span \"nowrap\">Step <i>&gamma;</i></span></html>");
pn.place(1, 4, spnStep);
Config.register("Algorithm." + algo.getShortname(), "iterations", spnIter, params[0]);
Config.register("Algorithm." + algo.getShortname(), "step", spnStep, params[1]);
spnIter.addChangeListener(this);
spnStep.addChangeListener(this);
return pn;
}
@Override
public String getCommand() {
int iter = spnIter.get();
double gamma = spnStep.get();
return iter + " " + NumFormat.nice(gamma);
}
@Override
public void stateChanged(ChangeEvent e) {
Command.command();
}
@Override
public String getName() {
return algo.getName();
}
@Override
public String[] getShortname() {
return new String[] {"VC"};
}
@Override
public String getDocumentation() {
String s = "";
s += "<h1>" + getName() + "</h1>";
s += "<p>Iterative: " + algo.isIterative() + "</p>";
s += "<p>Step controllable: " + algo.isStepControllable() + "</p>";
s += "<p>Regularization: " + algo.isRegularized() + "</p>";
s += "<p>Wavelet-base: " + algo.isWaveletsBased() + "</p>";
s += "<p>Shortname: " + getShortname() + "</p>";
return s;
}
}
diff --git a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
index a1bb3d0..3854b6e 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/AlgorithmDModule.java
@@ -1,153 +1,153 @@
package deconvolution.modules;
import javax.swing.JSplitPane;
+import bilib.component.CustomizedTable;
+import bilib.component.HTMLPane;
+import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolution.algorithm.Controller;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.FFT;
-import lab.component.CustomizedTable;
-import lab.component.HTMLPane;
-import lab.tools.NumFormat;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.SignalCollector;
public class AlgorithmDModule extends AbstractDModule implements Runnable {
private CustomizedTable table;
private HTMLPane doc;
public AlgorithmDModule(Deconvolution deconvolution) {
super(deconvolution);
doc = new HTMLPane(100, 1000);
table = new CustomizedTable(new String[] { "Features", "Values" }, false);
split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table.getPane(200, 200), doc.getPane());
}
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() {
return "Algorithm";
}
@Override
public void run() {
Features features = new Features();
if (deconvolution.algo == null) {
features.add("Algorithm", "No valid algorithm");
return;
}
AbstractAlgorithm algo = deconvolution.algo;
doc.clear();
String name = algo.getShortname();
AbstractAlgorithmPanel algoPanel = Algorithm.getPanel(name);
if (algoPanel != null)
doc.append(algoPanel.getDocumentation());
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.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == 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;
}
Controller controller = deconvolution.algo.getController();
if (controller == null) {
features.add("Controller", "No valid controller");
return;
}
startAsynchronousTimer("Run FFT", 200);
deconvolution.algo.setController(controller);
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("Tested on", mx + "x" + my + "x" + mz);
features.add("Estimated Time on small", NumFormat.time(chrono) );
chrono = chrono * ratio * algo.getComplexityNumberofFFT();
int n = algo.isIterative() ? controller.getIterationMax() : 1;
features.add("Estimated Time", NumFormat.time(chrono) );
features.add("Estimated Number of FFT / Transform", ""+algo.getComplexityNumberofFFT());
}
else
features.add("Estimated Time", "Error" );
double mem = (algo.getMemoryFootprintRatio() * deconvolution.image.nx * deconvolution.image.ny * deconvolution.image.nz * 4);
features.add("Estimated Memory", NumFormat.bytes(mem));
features.add("Iterative", algo.isIterative() ? "" + controller.getIterationMax() : "Direct");
table.removeRows();
for (String[] feature : features)
table.append(feature);
stopAsynchronousTimer();
}
}
\ No newline at end of file
diff --git a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
index 1849b17..c28a3da 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/ImageDModule.java
@@ -1,109 +1,109 @@
package deconvolution.modules;
import java.awt.Dimension;
import javax.swing.JSplitPane;
+import bilib.component.CustomizedTable;
+import bilib.component.JPanelImage;
+import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
-import lab.component.CustomizedTable;
-import lab.component.JPanelImage;
-import lab.tools.NumFormat;
import signal.RealSignal;
import signal.SignalCollector;
public class ImageDModule extends AbstractDModule implements Runnable {
private JPanelImage pnImage;
private CustomizedTable table;
public ImageDModule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new JPanelImage();
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);
}
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() {
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.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == null) {
features.add("Apodization", "No valid apodization");
return;
}
startAsynchronousTimer("Preprocessing 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("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
RealSignal signal = deconvolution.pad.pad(deconvolution.monitors, deconvolution.image);
deconvolution.apo.apodize(deconvolution.monitors, signal);
float stats[] = signal.getStats();
int sizs = signal.nx * signal.ny * signal.nz;
float totals = stats[0] * sizs;
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("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size Increase ", NumFormat.nice((double)(sizs-sizi)/sizi*100.0));
features.add("Energy Lost", 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/modules/PSFDModule.java b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
index 437b23f..1fc32d5 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/PSFDModule.java
@@ -1,122 +1,122 @@
package deconvolution.modules;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.swing.JSplitPane;
+import bilib.component.CustomizedTable;
+import bilib.component.JPanelImage;
+import bilib.tools.NumFormat;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
-import lab.component.CustomizedTable;
-import lab.component.JPanelImage;
-import lab.tools.NumFormat;
import signal.Constraint;
import signal.RealSignal;
import signal.SignalCollector;
public class PSFDModule extends AbstractDModule implements Runnable {
private JPanelImage pnImage;
private CustomizedTable table;
public PSFDModule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new JPanelImage();
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);
}
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() {
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.image == null) {
features.add("Image", "No valid input image");
return;
}
if (deconvolution.pad == null) {
features.add("Padding", "No valid padding");
return;
}
if (deconvolution.apo == 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("Preprocessing 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("Min ... Max", NumFormat.nice(stati[1]) + " ... " + NumFormat.nice(stati[2]));
features.add("Energy (int)", NumFormat.nice(stati[5]) + " (" + NumFormat.nice(totali) + ")");
table.removeRows();
for (String[] feature : features)
table.append(feature);
RealSignal h = deconvolution.psf.changeSizeAs(deconvolution.image);
h.normalize(deconvolution.norm);
float stats[] = h.getStats();
int sizs = h.nx * h.ny * h.nz;
float totals = stats[0] * sizs;
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("Min Max", NumFormat.nice(stats[1]) + " " + NumFormat.nice(stats[2]));
features.add("Energy (int)", NumFormat.nice(stats[5]) + " (" + NumFormat.nice(totals) + ")");
features.add("<html><b>Information</b></html>", "");
features.add("Size Increase ", NumFormat.nice((double) (sizs - sizi) / sizi * 100.0));
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/modules/RecapDModule.java b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
index 4ae3f77..9c04b02 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/RecapDModule.java
@@ -1,74 +1,74 @@
package deconvolution.modules;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JSplitPane;
import javax.swing.text.BadLocationException;
+import bilib.component.CustomizedTable;
+import bilib.component.HTMLPane;
import deconvolution.Deconvolution;
-import lab.component.CustomizedTable;
-import lab.component.HTMLPane;
public class RecapDModule extends AbstractDModule implements KeyListener {
private HTMLPane pnCommand;
private CustomizedTable table;
public RecapDModule(Deconvolution deconvolution) {
super(deconvolution);
// Panel command
pnCommand = new HTMLPane("Monaco", "#10FF10", "100020", 100, 100);
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());
}
public void update() {
if (table == null)
return;
table.removeRows();
for (String[] feature : deconvolution.recap())
table.append(feature);
split.setDividerLocation(0.5);
split.repaint();
}
public String getCommand() {
return pnCommand.getText();
}
@Override
public String getName() {
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/modules/ReportDModule.java b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
index 59d9a73..ed8dcfc 100644
--- a/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
+++ b/DeconvolutionLab2/src/deconvolution/modules/ReportDModule.java
@@ -1,51 +1,51 @@
package deconvolution.modules;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import javax.swing.JSplitPane;
+import bilib.component.CustomizedTable;
+import bilib.component.JPanelImage;
import deconvolution.Deconvolution;
-import lab.component.CustomizedTable;
-import lab.component.JPanelImage;
import signal.RealSignal;
public class ReportDModule extends AbstractDModule {
private JPanelImage pnImage;
private CustomizedTable table;
public ReportDModule(Deconvolution deconvolution) {
super(deconvolution);
pnImage = new JPanelImage();
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);
}
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"});
return;
}
pnImage.setImage(image.preview());
for (String[] feature : deconvolution.checkOutput())
table.append(feature);
split.setDividerLocation(300);
}
@Override
public String getName() {
return "Report";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Config.java b/DeconvolutionLab2/src/deconvolutionlab/Config.java
index 9c2934c..fca3d35 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Config.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Config.java
@@ -1,385 +1,385 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Properties;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
+import bilib.component.CustomizedTable;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolutionlab.monitor.Monitors;
-import lab.component.CustomizedTable;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
public class Config {
private static String project = Constants.name;
private static String filename;
private static HashMap<String, Object> inits;
private static HashMap<String, JComponent> components = new HashMap<String, JComponent>();
private static HashMap<String, CustomizedTable> tables = new HashMap<String, CustomizedTable>();;
private static HashMap<String, JDialog> dialogs = new HashMap<String, JDialog>();
private static Monitors monitors = Monitors.createDefaultMonitor();
public static Config init(String filename) {
Config.filename = filename;
Config.inits = new HashMap<String, Object>();
Config.components = new HashMap<String, JComponent>();
Config.tables = new HashMap<String, CustomizedTable>();
Config.dialogs = new HashMap<String, JDialog>();
return new Config();
}
public static void setFilename(String filename) {
Config.filename = filename;
}
public static String getFilename() {
return filename;
}
public static boolean check() {
File file = new File(Config.filename);
if (!file.exists())
return false;
if (file.isDirectory())
return false;
return true;
}
public static void register(String module, String key, JComponent component, Object init) {
if (component == null)
return;
components.put(module + "." + key, component);
inits.put(module + "." + key, init);
setValue(key, init);
}
public static void registerTable(String module, String key, CustomizedTable table) {
if (table == null)
return;
tables.put(module + "." + key, table);
}
public static void registerFrame(String module, String key, JDialog dialog) {
if (dialog == null)
return;
dialogs.put(module + "." + key, dialog);
}
public static String getAsString(String key) {
Object object = getValue(key);
if (object instanceof String)
return ((String) object);
else if (object instanceof Double)
return ((Double) object).toString();
else if (object instanceof Integer)
return ((Integer) object).toString();
else if (object instanceof Boolean)
return ((Boolean) object).toString();
return null;
}
public static double getAsDouble(String key) {
Object object = getValue(key);
if (object instanceof Double)
return ((Double) object).doubleValue();
else if (object instanceof Integer)
return ((Integer) object).intValue();
return 0;
}
private static void setValue(String key, Object value) {
JComponent component = components.get(key);
if (component == null)
return;
if (value == null)
value = inits.get(key);
if (component instanceof JTextField) {
JTextField txt = (JTextField) component;
txt.setText(value.toString());
}
else if (component instanceof JComboBox) {
JComboBox<String> cmb = (JComboBox<String>) component;
cmb.setSelectedItem(value.toString());
}
else if (component instanceof JLabel) {
JLabel lbl = (JLabel) component;
lbl.setText(value.toString());
}
else if (component instanceof JCheckBox) {
JCheckBox chk = (JCheckBox) component;
chk.setSelected(value.toString().equals("true"));
}
else if (component instanceof SpinnerRangeDouble) {
SpinnerRangeDouble spn = (SpinnerRangeDouble) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.doubleValue());
}
else if (value instanceof String) {
try {
spn.set(Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof SpinnerRangeInteger) {
SpinnerRangeInteger spn = (SpinnerRangeInteger) component;
if (value instanceof Number) {
Number number = (Number) value;
spn.set(number.intValue());
}
else if (value instanceof String) {
try {
spn.set((int) Double.parseDouble((String) value));
}
catch (NumberFormatException ex) {
}
}
}
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
String source = value.toString();
for (int i = 0; i < tab.getTabCount(); i++)
if (source.equals(tab.getTitleAt(i)))
tab.setSelectedIndex(i);
}
}
private static Object getValue(String key) {
JComponent component = components.get(key);
if (component == null)
return inits.get(key);
if (component instanceof JTextField)
return ((JTextField) component).getText();
else if (component instanceof JComboBox)
return (String) ((JComboBox) component).getSelectedItem();
else if (component instanceof JCheckBox)
return ((JCheckBox) component).isSelected() ? "true" : "false";
else if (component instanceof JLabel)
return ((JLabel) component).getText();
else if (component instanceof SpinnerRangeDouble)
return new Double(((SpinnerRangeDouble) component).get());
else if (component instanceof SpinnerRangeInteger)
return new Integer(((SpinnerRangeInteger) component).get());
else if (component instanceof JTabbedPane) {
JTabbedPane tab = (JTabbedPane) component;
return tab.getTitleAt(tab.getSelectedIndex());
}
return inits.get(key);
}
public static void load() {
Properties props = new Properties();
try {
FileInputStream in = new FileInputStream(filename);
props.load(in);
}
catch (Exception e) {
props = new Properties();
}
for (String key : components.keySet()) {
Object init = inits.get(key);
String value = props.getProperty(key, init.toString());
setValue(key, value);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
for (int i = 0; i < 100; i++) {
String keyrow = key + ".row" + i;
String value = props.getProperty(keyrow, "???");
if (!value.equals("???"))
table.append(value.split(";"));
}
String selected[] = props.getProperty(key + ".selected", "???").split(";");
int ncol = Math.min(table.getColumnCount(), selected.length) - 1;
for (int i = 0; i < table.getRowCount(); i++) {
int n = 0;
for (int j = 0; j < ncol; j++) {
n += table.getCell(i, j).trim().equals(selected[j].trim()) ? 1 : 0;
}
if (n == ncol)
table.setRowSelectionInterval(i, i);
}
}
for (String key : dialogs.keySet()) {
int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "" + 0), 0);
int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "" + 0), 0);
int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "" + 400), 400);
int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "" + 400), 400);
dialogs.get(key).setSize(w, h);
dialogs.get(key).setLocation(x, y);
}
monitors.log("Load Config from " + filename + " (" + components.size() + " items)");
}
public static boolean store() {
Properties props = new Properties();
for (String key : components.keySet()) {
String s = getAsString(key);
if (s != null)
props.setProperty(key, s);
}
for (String key : tables.keySet()) {
CustomizedTable table = tables.get(key);
int nrows = table.getRowCount();
for (int row = 0; row < nrows; row++)
props.setProperty(key + ".row" + row, table.getRowCSV(row, ";"));
int row = table.getSelectedRow();
if (row >= 0)
props.setProperty(key + ".selected", table.getRowCSV(row, ";"));
}
for (String key : dialogs.keySet()) {
JDialog dialog = dialogs.get(key);
props.setProperty(key + ".location.x", "" + dialog.getLocation().x);
props.setProperty(key + ".location.y", "" + dialog.getLocation().y);
props.setProperty(key + ".location.w", "" + dialog.getSize().width);
props.setProperty(key + ".location.h", "" + dialog.getSize().height);
}
try {
FileOutputStream out = new FileOutputStream(filename);
props.store(out, project);
}
catch (Exception e) {
monitors.error("Store Config to " + filename + " (" + components.size() + " items)");
return false;
}
monitors.log("Store Config to " + filename + " (" + components.size() + " items)");
File file = new File(filename);
if (file.exists()) {
String line = "";
try {
BufferedReader br = new BufferedReader(new FileReader(filename));
ArrayList<String> keys = new ArrayList<String>();
ArrayList<String> headers = new ArrayList<String>();
line = br.readLine();
if (line != null)
if (!line.startsWith("#"))
keys.add(line);
else
headers.add(line);
while (line != null) {
if (!line.startsWith("#"))
keys.add(line);
else
headers.add(line);
line = br.readLine();
}
br.close();
Collections.sort(keys);
BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
for (String ln : headers)
bw.write(ln + "\n");
for (String ln : keys)
bw.write(ln + "\n");
bw.close();
}
catch (Exception ex) {
monitors.error("ERROR " + filename + " line: " + line);
return false;
}
}
return true;
}
public static ArrayList<String> list() {
ArrayList<String> list = new ArrayList<String>();
for (String key : components.keySet()) {
list.add(key + " = " + getValue(key));
}
return list;
}
public static void print() {
ArrayList<String> list = list();
System.out.println("--");
for (String line : list)
System.out.println(line);
System.out.println("--");
}
public static void printInit() {
for (String key : inits.keySet()) {
Object object = inits.get(key);
if (object != null)
System.out.println("Default " + key + " = " + (object.toString()));
}
}
public static Rectangle getDialog(String key) {
Properties props = new Properties();
try {
FileInputStream in = new FileInputStream(filename);
props.load(in);
}
catch (Exception e) {
props = new Properties();
}
int x = (int) NumFormat.parseNumber(props.getProperty(key + ".location.x", "-1"), -1);
int y = (int) NumFormat.parseNumber(props.getProperty(key + ".location.y", "-1"), -1);
int w = (int) NumFormat.parseNumber(props.getProperty(key + ".location.w", "-1"), -1);
int h = (int) NumFormat.parseNumber(props.getProperty(key + ".location.h", "-1"), -1);
return new Rectangle(x, y, w, h);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Lab.java b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
index 9f9f0cd..e1ce296 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Lab.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Lab.java
@@ -1,381 +1,379 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
-import java.util.Timer;
-import java.util.TimerTask;
import java.util.regex.Pattern;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
+import bilib.tools.NumFormat;
+import bilib.tools.WebBrowser;
import deconvolutionlab.Imaging.ContainerImage;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFT;
import fft.AbstractFFTLibrary;
import fft.FFT;
import imagej.IJImager;
-import lab.tools.NumFormat;
-import lab.tools.WebBrowser;
import plugins.sage.deconvolutionlab.IcyImager;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
import signal.factory.SignalFactory;
import signal.factory.Sphere;
public class Lab {
private static Imaging imaging;
private static ArrayList<JFrame> frames;
private static ArrayList<JDialog> dialogs;
static {
frames = new ArrayList<JFrame>();
dialogs = new ArrayList<JDialog>();
imaging = new IJImager();
Config.init(System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
public static Imaging.Platform getPlatform() {
return imaging.getPlatform();
}
public static void init(Imaging.Platform p) {
init(p, System.getProperty("user.dir") + File.separator + "DeconvolutionLab2.config");
}
public static void init(Imaging.Platform platform, String config) {
switch (platform) {
case IMAGEJ:
imaging = new IJImager();
break;
case ICY:
imaging = new IcyImager();
break;
default:
imaging = new IJImager();
break;
}
Config.init(System.getProperty("user.dir")+File.separator+"DeconvolutionLab2.config");
}
public static void help() {
WebBrowser.open(Constants.url);
}
public static void checkFFT(Monitors monitors) {
ArrayList<AbstractFFTLibrary> libraries = FFT.getInstalledLibraries();
for (int k = 1; k <= 3; k++)
for (AbstractFFTLibrary library : libraries) {
RealSignal y = new Sphere(3, 1).generate(40, 30, 20);
double chrono = System.nanoTime();
AbstractFFT fft = library.getDefaultFFT();
fft.init(monitors, y.nx, y.ny, y.nz);
RealSignal x = fft.inverse(fft.transform(y));
chrono = System.nanoTime() - chrono;
double residu = y.getEnergy() - x.getEnergy();
monitors.log(fft.getName() + " Test " + k);
monitors.log("\t residu of reconstruction: " + residu);
monitors.log("\t computation time (" + x.nx + "x" + x.ny + "x" + x.nz + ") " + NumFormat.time(chrono));
}
}
public static ContainerImage createContainer(Monitors monitors, String title) {
monitors.log("Create Live Real Signal " + title);
return imaging.createContainer(title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title) {
imaging.append(container, signal, title, Imaging.Type.FLOAT);
monitors.log("Add Live Real Signal " + title);
}
public static void append(Monitors monitors, ContainerImage container, RealSignal signal, String title, Imaging.Type type) {
imaging.append(container, signal, title, type);
monitors.log("Add Live Real Signal " + title);
}
public static void show(Monitors monitors, ComplexSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, ComplexComponent.MODULE);
}
public static void show(Monitors monitors, ComplexSignal signal, String title, ComplexComponent complex) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, complex);
}
public static void show(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, Imaging.Type.FLOAT, signal.nz / 2);
}
public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, signal.nz / 2);
}
public static void show(Monitors monitors, RealSignal signal, String title, Imaging.Type type, int z) {
if (signal == null) {
monitors.error("Show " + title + " this image does not exist.");
return;
}
monitors.log("Show Real Signal " + title);
imaging.show(signal, title, type, z);
}
public static void save(Monitors monitors, RealSignal signal, String filename) {
imaging.save(signal, filename, Imaging.Type.FLOAT);
monitors.log("Save Real Signal " + filename);
}
public static void save(Monitors monitors, RealSignal signal, String filename, Imaging.Type type) {
imaging.save(signal, filename, type);
monitors.log("Save Real Signal " + filename);
}
public static RealSignal createRealSignal(Monitors monitors, String arg, String cmd, String path) {
RealSignal signal = null;
if (arg.equalsIgnoreCase("synthetic")) {
signal = SignalFactory.createFromCommand(cmd);
}
if (arg.equalsIgnoreCase("platform")) {
signal = getImager().create(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 static RealSignal openFile(Monitors monitors, String filename) {
RealSignal signal = imaging.open(filename);
if (signal == null)
monitors.error("Unable to open " + filename);
else
monitors.log("Load " + filename);
return signal;
}
public static RealSignal openDir(Monitors monitors, String path) {
String parts[] = path.split(" pattern ");
String dirname = path;
String regex = "";
if (parts.length == 2) {
dirname = parts[0].trim();
regex = parts[1].trim();
}
File file = new File(dirname + File.separator);
if (!file.isDirectory()) {
monitors.error("Dir " + dirname + " is not a directory.");
return null;
}
String[] list = file.list();
ArrayList<RealSignal> slices = new ArrayList<RealSignal>();
int nx = 0;
int ny = 0;
Pattern pattern = Pattern.compile(regex);
for (String filename : list) {
if (pattern.matcher(filename).find()) {
RealSignal slice = imaging.open(dirname + File.separator + filename);
if (slice != null) {
slices.add(slice);
nx = Math.max(nx, slice.nx);
ny = Math.max(ny, slice.ny);
monitors.log("Image " + path + File.separator + filename + " is loaded.");
}
}
else {
monitors.error("Error in loading image " + path + File.separator + filename);
}
}
int nz = slices.size();
if (nz <= 0) {
monitors.error("Dir " + path + " do no contain valid images.");
return null;
}
RealSignal signal = new RealSignal(file.getName(), nx, ny, nz);
for (int z = 0; z < slices.size(); z++)
signal.setSlice(z, slices.get(z));
return signal;
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title, int hx, int hy, int hz) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.Type.FLOAT, 0);
}
public static void showOrthoview(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Orthoview " + title + " this image does not exist.");
return;
}
int hx = signal.nx / 2;
int hy = signal.ny / 2;
int hz = signal.nz / 2;
imaging.show(signal.createOrthoview(hx, hy, hz), title, Imaging.Type.FLOAT, 0);
}
public static void showMIP(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show MIP " + title + " this image does not exist.");
return;
}
imaging.show(signal.createMIP(), title, Imaging.Type.FLOAT, 0);
}
public static void showMontage(Monitors monitors, RealSignal signal, String title) {
if (signal == null) {
monitors.error("Show Montage " + title + " this image does not exist.");
return;
}
imaging.show(signal.createMontage(), title, Imaging.Type.FLOAT, 0);
}
public static RealSignal create(Monitors monitors, String name) {
RealSignal signal = imaging.create(name);
if (signal != null)
monitors.log("Created the real signal " + name + " " + signal.toString());
else
monitors.error("Impossible to create the real signal " + name);
return signal;
}
public static RealSignal create(Monitors monitors) {
RealSignal signal = imaging.create();
if (signal != null)
monitors.log("Created the real signal from the active window " + signal.toString());
else
monitors.error("Impossible to create the real signal from the active window");
return signal;
}
public static Imaging getImager() {
return imaging;
}
public static String getActiveImage() {
if (imaging.isSelectable())
return imaging.getSelectedImage();
return "";
}
public static void setVisible(JDialog dialog, boolean modal) {
if (dialog == null)
return;
dialogs.add(dialog);
imaging.setVisible(dialog, modal);
}
public static void setVisible(JPanel panel, String name, int x, int y) {
JFrame frame = new JFrame(name);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocation(x, y);
frame.setVisible(true);
frames.add(frame);
}
public static void setVisible(JFrame frame) {
frames.add(frame);
frame.setVisible(true);
}
public static void close() {
for(JFrame frame : frames)
if (frame != null)
frame.dispose();
for(JDialog dialog : dialogs)
if (dialog != null)
dialog.dispose();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
index 3668410..27a854c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/LabPanel.java
@@ -1,294 +1,294 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.JPanelImage;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.dialog.BatchDialog;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
import deconvolutionlab.modules.RunningModule;
import deconvolutionlab.system.SystemInfo;
-import lab.component.JPanelImage;
public class LabPanel extends JPanel implements ActionListener, ChangeListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnQuit = new JButton("Quit");
private JButton bnSystem = new JButton("System");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnClose;
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
private RunningModule running;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
public LabPanel(JButton bnClose) {
this.bnClose = bnClose;
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
running = new RunningModule(false);
modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, batch, running };
Command.active(modules, command);
Command.command();
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
Border border = BorderFactory.createEmptyBorder(5, 5, 5, 5);
JPanelImage bottom = new JPanelImage("celegans.jpg");
bottom.setBorder(border);
bottom.setLayout(new GridLayout(1, 6));
bottom.setBorder(border);
bottom.add(bnHelp);
bottom.add(bnSystem);
bottom.add(bnClose);
bottom.add(bnBatch);
bottom.add(bnRun);
bottom.add(bnLaunch);
tab.add("Deconvolution", panelDeconv);
tab.add("Advanced", panelAdvanc);
tab.add("Scripting", panelScript);
tab.add("About", panelAbout);
tab.addChangeListener(this);
setLayout(new BorderLayout());
add(tab, BorderLayout.CENTER);
add(bottom, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
bnSystem.addActionListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.load();
running.init();
//sizeModule();
Command.command();
running.update();
image.update();
psf.update();
output.update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp)
Lab.help();
else if (e.getSource() == bnClose)
Config.store();
else if (e.getSource() == bnSystem)
SystemInfo.activate();
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
BatchDialog dlg = new BatchDialog(batch);
Lab.setVisible(dlg, true);
}
else if (e.getSource() == bnLaunch) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command(), Deconvolution.Finish.ALIVE);
d.launch();
}
else if (e.getSource() == bnRun) {
String job = language.getJobName() + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
Deconvolution d = new Deconvolution(job, Command.command());
d.deconvolve();
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
list.add(running);
return list;
}
private ArrayList<AbstractModule> buildAdvancedPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(output);
list.add(controller);
list.add(border);
list.add(fourier);
return list;
}
private ArrayList<AbstractModule> buildProgrammingPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(batch);
list.add(command);
list.add(language);
return list;
}
private ArrayList<AbstractModule> buildAboutPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(about);
list.add(licence);
list.add(config);
return list;
}
public void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
Lab.close();
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0)
sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1)
sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2)
sizePanel(panelScript);
if (tab.getSelectedIndex() == 3)
sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 70;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
setMinimumSize(new Dimension(Constants.widthGUI, 4*hpc));
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/Output.java b/DeconvolutionLab2/src/deconvolutionlab/Output.java
index 13392de..d7106f7 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/Output.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/Output.java
@@ -1,370 +1,370 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab;
import java.io.File;
+import bilib.tools.NumFormat;
import deconvolution.algorithm.Controller;
import deconvolutionlab.Imaging.ContainerImage;
import deconvolutionlab.monitor.Monitors;
-import lab.tools.NumFormat;
import signal.Constraint;
import signal.RealSignal;
public class Output {
public enum View {
STACK, SERIES, ORTHO, MIP, PLANAR, FIGURE
};
public enum Dynamic {
INTACT, RESCALED, NORMALIZED, CLIPPED
};
private ContainerImage container = null;
private int px = 0;
private int py = 0;
private int pz = 0;
private boolean center = true;
private String name = "";
private boolean save = true;
private boolean show = true;
private View view = View.STACK;
private Imaging.Type type = Imaging.Type.FLOAT;
private Dynamic dynamic = Dynamic.INTACT;
private int frequency = 0;
private String path = "";
public Output(View view, int frequency, String param) {
String[] tokens = param.trim().split(" ");
this.view = view;
this.frequency = frequency;
this.name = "";
this.center = true;
this.save = true;
this.show = true;
this.container = Lab.createContainer(Monitors.createDefaultMonitor(), "");
for (int i = 0; i < tokens.length; i++) {
boolean found = false;
String p = tokens[i].trim().toLowerCase();
if (p.startsWith("@")) {
found = true;
}
if (p.startsWith("noshow")) {
show = false;
found = true;
}
if (p.startsWith("nosave")) {
save = false;
found = true;
}
for (Dynamic d : Dynamic.values()) {
if (p.toLowerCase().equals(d.name().toLowerCase())) {
dynamic = d;
found = true;
}
}
for (View v : View.values()) {
if (p.toLowerCase().equals(v.name().toLowerCase())) {
view = v;
found = true;
}
}
for (Imaging.Type t : Imaging.Type.values()) {
if (p.toLowerCase().equals(t.name().toLowerCase())) {
type = t;
found = true;
}
}
if (p.startsWith("(") && p.endsWith(")")) {
double pos[] = NumFormat.parseNumbers(p);
if (pos.length > 0)
px = (int) Math.round(pos[0]);
if (pos.length > 1)
py = (int) Math.round(pos[1]);
if (pos.length > 2)
pz = (int) Math.round(pos[2]);
found = true;
center = false;
}
if (!found)
name += tokens[i] + " ";
name = name.trim();
}
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.Type type, boolean center) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = center;
this.frequency = frequency;
}
public Output(View view, boolean show, boolean save, int frequency, String name, Dynamic dynamic, Imaging.Type type, int px, int py, int pz) {
this.name = name;
this.show = show;
this.save = save;
this.view = view;
this.type = type;
this.dynamic = dynamic;
this.center = false;
this.px = px;
this.py = py;
this.pz = pz;
this.frequency = frequency;
}
public boolean is(int iterations) {
if (frequency == 0)
return false;
return iterations % frequency == 0;
}
public View getView() {
return view;
}
public String getName() {
return name;
}
public void setPath(String path) {
this.path = path;
}
public int extractFrequency(String param) {
String line = param.trim();
if (!line.startsWith("@"))
line = "@0 " + line;
String parts[] = line.split(" ");
if (parts.length >= 1) {
return (int) Math.round(NumFormat.parseNumber(parts[0], 0));
}
return 0;
}
public void setKeypoint(int px, int py, int pz) {
this.px = px;
this.py = py;
this.pz = pz;
this.center = false;
}
public String[] getAsString() {
String t = (type == Imaging.Type.FLOAT ? "" : type.name().toLowerCase());
String d = (dynamic == Dynamic.INTACT ? "" : dynamic.name().toLowerCase());
String k = "";
if (!center)
k = " (" + px + "," + py + "," + pz + ")";
else
k = "";
String sa = save ? "\u2713" : "";
String sh = show ? "\u2713" : "";
String fr = frequency > 0 ? " @" + frequency : "";
return new String[] { view.name().toLowerCase() + fr, name, d, t, k, sh, sa, "\u232B" };
}
public void executeStarting(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, true, false, false, 0);
}
public void executeFinal(Monitors monitors, RealSignal signal, Controller controller) {
execute(monitors, signal, controller, false, false, true, 0);
}
public void executeIterative(Monitors monitors, RealSignal signal, Controller controller, int iter) {
execute(monitors, signal, controller, false, true, false, iter);
}
public void execute(Monitors monitors, RealSignal signal, Controller controller, boolean start, boolean live, boolean finish, int iter) {
if (signal == null)
return;
String title = name;
if (live)
if (!is(iter))
return;
if (controller != null && live) {
if (controller.getIterations() > 0) {
title += "@" + controller.getIterations();
}
}
RealSignal x = null;
Constraint constraint = new Constraint(monitors);
switch (dynamic) {
case RESCALED:
x = signal.duplicate();
constraint.rescaled(x, 0, 255);
break;
case CLIPPED:
x = signal.duplicate();
float[] stats = controller.getStatsInput();
if (stats != null)
constraint.clipped(x, stats[1], stats[2]);
break;
case NORMALIZED:
x = signal.duplicate();
float[] stats1 = controller.getStatsInput();
if (stats1 != null)
constraint.normalized(x, stats1[0], stats1[3]);
break;
default:
x = signal;
}
String filename = path + File.separator + title + ".tif";
switch (view) {
case STACK:
if (show && !live)
Lab.show(monitors, x, title, type, (center ? x.nz / 2 : pz));
if (save && !live)
Lab.save(monitors, x, filename, type);
break;
case SERIES:
for (int k = 0; k < x.nz; k++) {
RealSignal slice = x.getSlice(k);
if (show && !live)
Lab.show(monitors, slice, title, type);
if (save && !live)
Lab.save(monitors, slice, filename, type);
}
break;
case ORTHO:
if (!start)
orthoview(monitors, x, title, filename, live);
break;
case FIGURE:
if (!start)
figure(monitors, x, title, filename, live);
break;
case MIP:
if (!start)
mip(monitors, x, title, filename, live);
break;
case PLANAR:
if (!start)
planar(monitors, x, title, filename, live);
break;
default:
break;
}
}
private void mip(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMIP();
if (show && live) {
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void orthoview(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createOrthoview(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void figure(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
int cx = px;
int cy = py;
int cz = pz;
if (center) {
cx = signal.nx / 2;
cy = signal.ny / 2;
cz = signal.nz / 2;
}
RealSignal plane = signal.createFigure(cx, cy, cz);
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
private void planar(Monitors monitors, RealSignal signal, String title, String filename, boolean live) {
RealSignal plane = signal.createMontage();
if (show && live) {
if (container == null)
container = Lab.createContainer(monitors, title);
Lab.append(monitors, container, plane, title, type);
}
if (show && !live)
Lab.show(monitors, plane, title, type);
if (save)
Lab.save(monitors, plane, filename, type);
}
@Override
public String toString() {
String t = type.name().toLowerCase();
String v = view.name().toLowerCase();
String d = dynamic.name().toLowerCase();
String f = frequency > 0 ? " every " + frequency + " iterations" : "";
String k = (center ? "" : " keypoint = (" + px + "," + py + "," + pz + ")");
return v + " " + name + " format = (" + d + ", " + t + ") " + k + f;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
index 368efff..d511d45 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/TableStats.java
@@ -1,89 +1,89 @@
package deconvolutionlab;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.table.DefaultTableModel;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
import deconvolutionlab.monitor.Monitors;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
public class TableStats {
private JPanel panel;
private CustomizedTable table;
private String name;
private boolean save;
private String path;
public TableStats(String name, int width, int height, String path, boolean save) {
this.name = name;
this.save = save;
this.path = path;
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Iterations", String.class, 100, false));
columns.add(new CustomizedColumn("Mean", String.class, 100, false));
columns.add(new CustomizedColumn("Minimum", String.class, 100, false));
columns.add(new CustomizedColumn("Maximum", String.class, 100, false));
columns.add(new CustomizedColumn("Stdev", String.class, 100, false));
columns.add(new CustomizedColumn("Energy", String.class, 100, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Signal", String.class, 100, false));
columns.add(new CustomizedColumn("PSNR", String.class, 100, false));
columns.add(new CustomizedColumn("SNR", String.class, 100, false));
columns.add(new CustomizedColumn("Residu", String.class, 100, false));
table = new CustomizedTable(columns, true);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JPanel main = new JPanel(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public String getName() {
return name;
}
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
public void nextStats(Monitors monitors, String[] stats) {
if (table == null)
return;
if (stats == null)
return;
table.append(stats);
monitors.log("Stats ");
}
public void lastStats(Monitors monitors, String[] stats) {
if (stats == null)
return;
if (table == null)
return;
if (save) {
String filename = path + File.separator + name + ".csv";
monitors.log("Stats save " + filename);
table.saveCSV(filename);
}
}
public JPanel getPanel() {
return panel;
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
index cd7e6e5..4abe394 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/BatchDialog.java
@@ -1,154 +1,154 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.GridPanel;
+import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.modules.BatchModule;
import ij.gui.GUI;
-import lab.component.GridPanel;
-import lab.component.HTMLPane;
public class BatchDialog extends JDialog implements ActionListener, WindowListener {
private JTextField txt = new JTextField("job", 10);
private HTMLPane pnCommand;
private JButton bnAdd = new JButton("Add Job");
private JButton bnCancel = new JButton("Cancel");
private BatchModule module;
public BatchDialog(BatchModule module) {
super(new JFrame(), "Batch");
this.module = module;
txt.setText("job" + module.getCountJob());
Deconvolution deconvolution = new Deconvolution(txt.getText(), Command.command());
pnCommand = new HTMLPane("Monaco", Constants.widthGUI, 100);
pnCommand.append("p", deconvolution.getCommand());
pnCommand.setEditable(true);
GridPanel pn = new GridPanel(true, 5);
pn.place(1, 0, "Job Name");
pn.place(1, 1, txt);
GridPanel bn = new GridPanel(false);
bn.place(11, 0, bnCancel);
bn.place(11, 1, bnAdd);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(pnCommand.getPane(), BorderLayout.CENTER);
panel.add(bn, BorderLayout.SOUTH);
bnAdd.addActionListener(this);
bnCancel.addActionListener(this);
add(panel);
pack();
addWindowListener(this);
setMinimumSize(new Dimension(400, 300));
}
private void addJob() {
module.addJob(txt.getText(), pnCommand.getText());
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnAdd) {
addJob();
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
return;
}
else if (e.getSource() == bnCancel) {
bnAdd.removeActionListener(this);
bnCancel.removeActionListener(this);
dispose();
}
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
addJob();
dispose();
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
index 73475d5..118070d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputDialog.java
@@ -1,275 +1,275 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.HTMLPane;
+import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Imaging;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
import ij.gui.GUI;
-import lab.component.GridPanel;
-import lab.component.HTMLPane;
-import lab.component.SpinnerRangeInteger;
public class OutputDialog extends JDialog implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputDialog(View view) {
super(new JFrame(), "Create a new output");
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
pack();
GUI.center(this);
setModal(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
dispose();
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
dispose();
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
index 8954d79..0a3ab84 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/OutputPanel.java
@@ -1,269 +1,269 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.HTMLPane;
+import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Imaging;
import deconvolutionlab.Output;
import deconvolutionlab.Output.Dynamic;
import deconvolutionlab.Output.View;
import ij.gui.GUI;
-import lab.component.GridPanel;
-import lab.component.HTMLPane;
-import lab.component.SpinnerRangeInteger;
public class OutputPanel extends JPanel implements ActionListener, ChangeListener {
private JComboBox<String> cmbDynamic = new JComboBox<String>(new String[] { "intact", "rescaled", "normalized", "clipped" });
private JComboBox<String> cmbType = new JComboBox<String>(new String[] { "float", "short", "byte" });
private JCheckBox chkSave = new JCheckBox("Save output", true);
private JCheckBox chkShow = new JCheckBox("Show output", true);
private SpinnerRangeInteger snpSnapshot = new SpinnerRangeInteger(0, 0, 99999, 1);
private JComboBox<String> cmbSnapshot = new JComboBox<String>(new String[] { "Final Output", "Specify Iterations..." });
private SpinnerRangeInteger spnX = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnY = new SpinnerRangeInteger(128, 0, 99999, 1);
private SpinnerRangeInteger spnZ = new SpinnerRangeInteger(32, 0, 99999, 1);
private JTextField txtName = new JTextField("Noname", 18);
private JCheckBox chkCenter = new JCheckBox("Center of the volume", true);
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private JLabel lblBit = new JLabel("32-bit");
private JLabel lblIter = new JLabel("iterations");
private JLabel lblSnapshot = new JLabel("Iterations");
private Output out;
private View view;
private GridPanel pnOrtho;
private HTMLPane info = new HTMLPane(200, 200);
private static int count = 1;
public OutputPanel(View view) {
this.view = view;
lblBit.setBorder(BorderFactory.createEtchedBorder());
lblIter.setBorder(BorderFactory.createEtchedBorder());
txtName.setText(view.name().substring(0, 2) + (count++));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, "Name");
pn.place(0, 1, txtName);
pn.place(1, 0, "Dynamic");
pn.place(1, 1, cmbDynamic);
pn.place(2, 0, "Type");
pn.place(2, 1, cmbType);
pn.place(3, 1, lblBit);
if (view != View.SERIES && view != View.STACK) {
pn.place(4, 0, "Snapshot");
pn.place(4, 1, cmbSnapshot);
pn.place(5, 0, lblSnapshot);
pn.place(5, 1, snpSnapshot);
pn.place(6, 1, lblIter);
}
pn.place(7, 1, 3, 1, chkShow);
pn.place(8, 1, 3, 1, chkSave);
GridPanel main = new GridPanel(false);
main.place(1, 0, 2, 1, pn);
if (view == View.ORTHO || view == View.FIGURE) {
pn.place(9, 1, 3, 1, chkCenter);
pnOrtho = new GridPanel("Keypoint");
pnOrtho.place(4, 0, "Position in X");
pnOrtho.place(4, 1, spnX);
pnOrtho.place(4, 2, "[pixel]");
pnOrtho.place(5, 0, "Position in Y");
pnOrtho.place(5, 1, spnY);
pnOrtho.place(5, 2, "[pixel]");
pnOrtho.place(6, 0, "Position in Z");
pnOrtho.place(6, 1, spnZ);
pnOrtho.place(5, 2, "[pixel]");
main.place(2, 0, 2, 1, pnOrtho);
}
pn.place(10, 0, 2, 1, info.getPane());
main.place(3, 0, bnCancel);
main.place(3, 1, bnOK);
info();
cmbSnapshot.addActionListener(this);
snpSnapshot.addChangeListener(this);
chkCenter.addActionListener(this);
cmbType.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
add(main);
update();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == chkCenter) {
update();
}
else if (e.getSource() == cmbSnapshot) {
update();
}
else if (e.getSource() == cmbType) {
if (cmbType.getSelectedIndex() == 0)
lblBit.setText("32-bits");
if (cmbType.getSelectedIndex() == 1)
lblBit.setText("16-bits");
if (cmbType.getSelectedIndex() == 2)
lblBit.setText("8-bits");
}
else if (e.getSource() == bnCancel) {
cancel = true;
return;
}
else if (e.getSource() == bnOK) {
int freq = snpSnapshot.get();
Dynamic dynamic = Output.Dynamic.values()[cmbDynamic.getSelectedIndex()];
Imaging.Type type = Imaging.Type.values()[cmbType.getSelectedIndex()];
boolean show = chkShow.isSelected();
boolean save = chkSave.isSelected();
String name = txtName.getText();
if (chkCenter.isSelected()) {
out = new Output(view, show, save, freq, name, dynamic, type, true);
}
else {
int px = spnX.get();
int py = spnY.get();
int pz = spnZ.get();
out = new Output(view, show, save, freq, name, dynamic, type, px, py, pz);
}
cancel = false;
}
}
private void update() {
if (cmbSnapshot.getSelectedIndex() == 0) {
snpSnapshot.set(0);
lblSnapshot.setEnabled(false);
lblIter.setEnabled(false);
lblSnapshot.setEnabled(false);
}
else {
lblSnapshot.setEnabled(true);
lblIter.setEnabled(true);
lblSnapshot.setEnabled(true);
}
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
if (snpSnapshot.get() == 0)
lblIter.setText("at the end (default)");
else
lblIter.setText("every " + snpSnapshot.get() + " iterations");
boolean b = !chkCenter.isSelected();
if (pnOrtho != null) {
pnOrtho.setEnabled(b);
for (Component c : pnOrtho.getComponents())
c.setEnabled(b);
}
//pack();
}
@Override
public void stateChanged(ChangeEvent e) {
if (e.getSource() == snpSnapshot)
update();
}
public Output getOut() {
return out;
}
public boolean wasCancel() {
return cancel;
}
private void info() {
if (view == View.FIGURE) {
info.append("h1", "figure");
info.append("h2", "Create a view with 2 panels (XY) and (YZ) with a border.");
}
if (view == View.MIP) {
info.append("h1", "mip");
info.append("h2", "Create a view 3 orthogonal projections.");
}
if (view == View.ORTHO) {
info.append("h1", "ortho");
info.append("h2", "Create a view 3 orthogonal section centered on the keypoint.");
}
if (view == View.PLANAR) {
info.append("h1", "ortho");
info.append("h2", "Create a montage of all Z-slice in one large flatten plane.");
}
if (view == View.STACK) {
info.append("h1", "stack");
info.append("h2", "Create a z-stack of image.");
}
if (view == View.SERIES) {
info.append("h1", "series");
info.append("h2", "Create a series of z-slices.");
}
info.append("p", "<b>Name:</b> This string will be used as title of the window in <i>show</i> mode or a filename in <i>save</i> mode.");
info.append("p", "<b>Dynamic:</b> Select the dynamic range used for the display. The default value is <i>intact</i> which preserves the true values.");
info.append("p", "<b>Type:</b> Select the data type. The default value is <i>float</i> which preserves the true values without loosing precision.");
info.append("p", "<b>Snapshot:</b> The output is usually shown (or saved) at the end of the processing, optionally it is possible to specify to show (or save) every N iterations.");
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
index a936e05..b371173 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/PatternDialog.java
@@ -1,226 +1,226 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.GridPanel;
import ij.gui.GUI;
-import lab.component.GridPanel;
public class PatternDialog extends JDialog implements ActionListener, WindowListener, KeyListener {
private JTextField txt = new JTextField("");
private JLabel lblDir = new JLabel("");
private JLabel lbl1 = new JLabel(".tif (only tif files)");
private JLabel lbl2 = new JLabel("Empty to take all files");
private JLabel lblCount = new JLabel("count files");
private JButton bnCount = new JButton("Count");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private File file;
private String command = "";
private String name = "";
public PatternDialog(File file) {
super(new JFrame(), "Pattern");
lblDir.setText(file.getAbsolutePath());
lblDir.setBorder(BorderFactory.createEtchedBorder());
lbl1.setBorder(BorderFactory.createEtchedBorder());
lbl2.setBorder(BorderFactory.createEtchedBorder());
lblCount.setBorder(BorderFactory.createEtchedBorder());
this.file = file;
GridPanel pn = new GridPanel(true, 5);
pn.place(0, 0, "Directory");
pn.place(0, 1, lblDir);
pn.place(1, 0, "Pattern");
pn.place(1, 1, txt);
pn.place(2, 0, "Example 1");
pn.place(2, 1, lbl1);
pn.place(3, 0, "Example 2");
pn.place(3, 1, lbl2);
pn.place(4, 0, "Count");
pn.place(4, 1, lblCount);
GridPanel bn = new GridPanel(false);
bn.place(11, 0, bnCancel);
bn.place(11, 1, bnCount);
bn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnCount.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
txt.addKeyListener(this);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.CENTER);
panel.add(bn, BorderLayout.SOUTH);
add(panel);
pack();
update();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void update() {
command = "";
name = "";
if (file == null)
return;
if (!file.exists())
return;
if (!file.isDirectory())
return;
String list[] = file.list();
int count = 0;
int n = list.length;
String regex = txt.getText().trim();
Pattern pattern = Pattern.compile(regex);
for (int i = 0; i < n; i++)
if (pattern.matcher(list[i]).find())
count++;
if (!regex.trim().equals(""))
command = file.getAbsolutePath() + " pattern " + regex;
else
command = file.getAbsolutePath();
name = file.getName();
lblCount.setText("" + n + " files in dir, " + count + " matched files");
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnCount) {
update();
}
else if (e.getSource() == bnCancel) {
bnCount.removeActionListener(this);
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
txt.removeKeyListener(this);
dispose();
cancel = true;
command = "";
name = "";
return;
}
else if (e.getSource() == bnOK) {
update();
bnCount.removeActionListener(this);
bnOK.removeActionListener(this);
bnCancel.removeActionListener(this);
txt.removeKeyListener(this);
dispose();
cancel = false;
}
}
public String getCommand() {
return command;
}
public String getDirName() {
return name;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
index 4c2a8ac..78011ef 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/SyntheticDialog.java
@@ -1,311 +1,311 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeDouble;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolutionlab.Lab;
import deconvolutionlab.monitor.Monitors;
import ij.gui.GUI;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeDouble;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class SyntheticDialog extends JDialog implements ActionListener, WindowListener {
private SpinnerRangeDouble spnSignal = new SpinnerRangeDouble(100, -999999, 999999, 1);
private SpinnerRangeDouble spnBackground = new SpinnerRangeDouble(0, -999999, 999999, 1);
private SpinnerRangeInteger spnWidth = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnHeight = new SpinnerRangeInteger(128, 1, 9999, 1);
private SpinnerRangeInteger spnSlices = new SpinnerRangeInteger(32, 1, 9999, 1);
private SpinnerRangeDouble spnCenterX = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterY = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnCenterZ = new SpinnerRangeDouble(0.5, -10, 10, 0.05);
private SpinnerRangeDouble spnParameter1 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter2 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private SpinnerRangeDouble spnParameter3 = new SpinnerRangeDouble(10, -9999, 9999, 1);
private JLabel lbl1 = new JLabel("Parameters 1 of the shape");
private JLabel lbl2 = new JLabel("Parameters 2 of the shape");
private JLabel lbl3 = new JLabel("Parameters 3 of the shape");
private JComboBox<String> cmbShapes;
private JButton bnShow = new JButton("Show");
private JButton bnOK = new JButton("OK");
private JButton bnCancel = new JButton("Cancel");
private boolean cancel = false;
private String shape;
private String command;
public SyntheticDialog(ArrayList<SignalFactory> list) {
super(new JFrame(), "Synthetic");
String[] cmb = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
cmb[i] = list.get(i).getName();
}
cmbShapes = new JComboBox<String>(cmb);
GridPanel pnIntensity = new GridPanel("Intensity", 3);
pnIntensity.place(1, 0, "Signal Intensity");
pnIntensity.place(1, 1, spnSignal);
pnIntensity.place(2, 0, "Background Intensity");
pnIntensity.place(2, 1, spnBackground);
GridPanel pnSize = new GridPanel("Dimension", 3);
pnSize.place(1, 0, "Width [pixels] (nx)");
pnSize.place(1, 1, spnWidth);
pnSize.place(2, 0, "Height [pixels] (ny)");
pnSize.place(2, 1, spnHeight);
pnSize.place(3, 0, "Number of Slices (nz)");
pnSize.place(3, 1, spnSlices);
GridPanel pnCenter = new GridPanel("Center", 3);
pnCenter.place(4, 0, "Center [% of nx] (cx)");
pnCenter.place(4, 1, spnCenterX);
pnCenter.place(5, 0, "Center [% of ny] (cy)");
pnCenter.place(5, 1, spnCenterY);
pnCenter.place(7, 0, "Center [% of nz] (cz)");
pnCenter.place(7, 1, spnCenterZ);
GridPanel pnParams = new GridPanel("Specific Parameters", 3);
pnParams.place(8, 0, lbl1);
pnParams.place(8, 1, spnParameter1);
pnParams.place(9, 0, lbl2);
pnParams.place(9, 1, spnParameter2);
pnParams.place(10, 0, lbl3);
pnParams.place(10, 1, spnParameter3);
GridPanel pn = new GridPanel(false);
pn.place(0, 0, 3, 1, cmbShapes);
pn.place(1, 0, 3, 1, pnIntensity);
pn.place(2, 0, 3, 1, pnParams);
pn.place(3, 0, 3, 1, pnSize);
pn.place(4, 0, 3, 1, pnCenter);
pn.place(11, 0, bnCancel);
pn.place(11, 1, bnShow);
pn.place(11, 2, bnOK);
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bnShow.addActionListener(this);
bnOK.addActionListener(this);
bnCancel.addActionListener(this);
cmbShapes.addActionListener(this);
add(pn);
pack();
updateInterface();
addWindowListener(this);
GUI.center(this);
setModal(true);
}
private void updateInterface() {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
String labels[] = factory.getParametersName();
lbl1.setVisible(false);
lbl2.setVisible(false);
lbl3.setVisible(false);
if (labels.length >= 1) {
lbl1.setVisible(true);
lbl1.setText(labels[0]);
}
if (labels.length >= 2) {
lbl2.setVisible(true);
lbl2.setText(labels[1]);
}
if (labels.length >= 3) {
lbl3.setVisible(true);
lbl3.setText(labels[2]);
}
double params[] = factory.getParameters();
spnParameter1.setVisible(false);
spnParameter2.setVisible(false);
spnParameter3.setVisible(false);
if (params.length >= 1) {
spnParameter1.setVisible(true);
spnParameter1.set(params[0]);
}
if (params.length >= 2) {
spnParameter2.setVisible(true);
spnParameter2.set(params[1]);
}
if (params.length >= 3) {
spnParameter3.setVisible(true);
spnParameter3.set(params[2]);
}
pack();
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnShow) {
SignalFactory factory = SignalFactory.get((String) cmbShapes.getSelectedItem());
double params[] = factory.getParameters();
factory.setParameters(params);
factory.center(spnCenterX.get(), spnCenterX.get(), spnCenterX.get());
RealSignal signal = factory.generate(spnWidth.get(), spnWidth.get(), spnWidth.get());
Lab.show(Monitors.createDefaultMonitor(), signal, factory.getName());
}
if (e.getSource() == cmbShapes) {
updateInterface();
}
if (e.getSource() == bnCancel) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
if (e.getSource() == bnOK) {
int nx = spnWidth.get();
int ny = spnHeight.get();
int nz = spnSlices.get();
shape = (String) cmbShapes.getSelectedItem();
command = shape + " " + spnSignal.get() + " " + spnBackground.get() + " ";
SignalFactory factory = SignalFactory.get(shape);
int n = factory.getParameters().length;
if (n >= 1) {
command += "" + spnParameter1.get();
if (n >= 2)
command += " " + spnParameter2.get();
if (n >= 3)
command += " " + spnParameter3.get();
command += " ";
}
command += " size " + nx + " " + ny + " " + nz + " ";
if (spnCenterX.get() != 0.5 || spnCenterY.get() != 0.5 || spnCenterZ.get() != 0.5) {
double cx = Math.round(spnCenterX.get() * 1000000) / 1000000.0;
double cy = Math.round(spnCenterY.get() * 1000000) / 1000000.0;
double cz = Math.round(spnCenterZ.get() * 1000000) / 1000000.0;
command += " center " + cx + " " + cy + " " + cz + " ";
}
dispose();
cancel = false;
}
}
public void setParameters(String name, String parameters) {
double params[] = NumFormat.parseNumbers(parameters);
cmbShapes.setSelectedItem(name);
SignalFactory factory = SignalFactory.getFactoryByName(name);
if (factory == null)
return;
int np = factory.getParameters().length;
if (params.length > 0)
spnSignal.set(params[0]);
if (params.length > 1)
spnBackground.set(params[1]);
if (params.length > 2 + np)
spnWidth.set((int) params[2 + np]);
if (params.length > 3 + np)
spnHeight.set((int) params[3 + np]);
if (params.length > 4 + np)
spnSlices.set((int) params[4 + np]);
if (params.length > 5 + np)
spnCenterX.set(params[5 + np]);
if (params.length > 6 + np)
spnCenterY.set(params[6 + np]);
if (params.length > 7 + np)
spnCenterZ.set(params[7 + np]);
if (np >= 1 && params.length > 2 + np)
spnParameter1.set(params[2]);
if (np >= 2 && params.length > 3 + np)
spnParameter2.set(params[3]);
if (np >= 3 && params.length > 4 + np)
spnParameter3.set(params[4]);
}
public String getShapeName() {
return shape;
}
public String getCommand() {
return command;
}
public boolean wasCancel() {
return cancel;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
dispose();
cancel = true;
shape = "";
command = "";
return;
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
index 6412960..8ce410b 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AboutModule.java
@@ -1,78 +1,78 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
+import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
-import lab.component.HTMLPane;
public class AboutModule extends AbstractModule {
public AboutModule(boolean expanded) {
super("About", "", "Help", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p", Constants.copyright);
html.append("p", "<b>Reference:</b> " + Constants.reference);
html.append("h3", "<b>Authors:</b> " + Constants.authors);
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (getAction1Button() == e.getSource())
Lab.help();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
index 5269524..c61d1ba 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AlgorithmModule.java
@@ -1,153 +1,153 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.algorithm.AbstractAlgorithmPanel;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import deconvolutionlab.Lab;
-import lab.component.HTMLPane;
public class AlgorithmModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmb;
private HTMLPane doc;
private JPanel cards;
public AlgorithmModule(boolean expanded) {
super("Algorithm", "-algorithm", "", "Check", expanded);
ArrayList<AbstractAlgorithmPanel> deconv = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : deconv)
cmb.addItem(panel.getName());
cmb.addActionListener(this);
}
@Override
public String getCommand() {
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
String cmd = "-algorithm " + algo.getShortname()[0] + " " + algo.getCommand();
String synopsis = name;
setSynopsis(synopsis);
setCommand(cmd);
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmb = new JComboBox<String>();
JPanel pnc = new JPanel();
pnc.add(cmb);
doc = new HTMLPane(100, 1000);
cards = new JPanel(new CardLayout());
ArrayList<AbstractAlgorithmPanel> panels = Algorithm.getAvailableAlgorithms();
for (AbstractAlgorithmPanel panel : panels) {
JScrollPane scroll = new JScrollPane(panel.getPanelParameters());
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
cards.add(panel.getName(), scroll);
}
cmb.setMaximumRowCount(panels.size());
JPanel control = new JPanel();
control.setLayout(new BoxLayout(control, BoxLayout.PAGE_AXIS));
Border b1 = BorderFactory.createEtchedBorder();
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
control.setBorder(BorderFactory.createCompoundBorder(b1, b2));
control.add(cmb);
control.add(cards);
doc.append("h1", "Documentation");
JPanel panel = new JPanel(new BorderLayout());
panel.add(control, BorderLayout.NORTH);
panel.add(doc.getPane(), BorderLayout.CENTER);
// cmb.addActionListener(this);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
Config.register(getName(), "algorithm", cmb, Algorithm.getDefaultAlgorithm());
panel.setBorder(BorderFactory.createEtchedBorder());
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb) {
doc.clear();
String name = (String) cmb.getSelectedItem();
AbstractAlgorithmPanel algo = Algorithm.getPanel(name);
doc.append(algo.getDocumentation());
CardLayout cl = (CardLayout) (cards.getLayout());
cl.show(cards, name);
}
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Algorithm", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.ALGO, deconvolution, null, null);
Lab.setVisible(d, false);
}
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
setSynopsis((String) cmb.getSelectedItem());
setCommand(getCommand());
Command.command();
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
index 4bf64ae..69a5878 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BatchModule.java
@@ -1,169 +1,169 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.ListSelectionModel;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
import deconvolution.Deconvolution;
import deconvolutionlab.Constants;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
public class BatchModule extends AbstractModule implements MouseListener, ActionListener {
private CustomizedTable table;
private JButton bnRun;
private JButton bnLaunch;
public BatchModule(boolean expanded) {
super("Batch", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
bnRun = new JButton("Run Jobs");
bnLaunch = new JButton("Launch Jobs");
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Job", String.class, 120, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(2).setMaxWidth(30);
table.getColumnModel().getColumn(2).setMinWidth(30);
table.addMouseListener(this);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
JToolBar pn = new JToolBar("Controls Batch");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 2));
pn.setFloatable(false);
pn.add(bnRun);
pn.add(bnLaunch);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
panel.add(pn, BorderLayout.SOUTH);
getAction1Button().addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnRun) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch" + table.getCell(row, 0), table.getCell(row, 1)).deconvolve();
}
else if (e.getSource() == bnLaunch) {
if (table.getSelectedRows().length == 0)
table.setColumnSelectionInterval(0, table.getRowCount());
int rows[] = table.getSelectedRows();
for (int row : rows)
new Deconvolution("Batch " + table.getCell(row, 0), table.getCell(row, 1)).launch();
}
}
private void update() {
setSynopsis("" + table.getRowCount() + " jobs");
}
public int getCountJob() {
return table.getRowCount();
}
public void addJob(String name, String command) {
table.append(new String[] { name, command, "" });
update();
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 2) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
}
update();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
index f069217..03f1e66 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/BorderModule.java
@@ -1,247 +1,247 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeInteger;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.Features;
import deconvolutionlab.Config;
import deconvolutionlab.monitor.Monitors;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeInteger;
-import lab.tools.NumFormat;
import signal.RealSignal;
import signal.apodization.AbstractApodization;
import signal.apodization.Apodization;
import signal.apodization.UniformApodization;
import signal.padding.AbstractPadding;
import signal.padding.NoPadding;
import signal.padding.Padding;
public class BorderModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbPadXY;
private JComboBox<String> cmbPadZ;
private JComboBox<String> cmbApoXY;
private JComboBox<String> cmbApoZ;
private SpinnerRangeInteger spnExtensionXY;
private SpinnerRangeInteger spnExtensionZ;
private JLabel lblPad;
private JLabel lblApo;
private boolean build = false;
public BorderModule(boolean expanded) {
super("Border", "", "Test", "Default", expanded);
}
@Override
public String getCommand() {
AbstractPadding pxy = Padding.getByName((String) cmbPadXY.getSelectedItem());
AbstractPadding paz = Padding.getByName((String) cmbPadZ.getSelectedItem());
AbstractApodization axy = Apodization.getByName((String) cmbApoXY.getSelectedItem());
AbstractApodization apz = Apodization.getByName((String) cmbApoZ.getSelectedItem());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
String extXY = (ext ? "" + spnExtensionXY.get() : "") + " ";
String extZ = ext ? "" + spnExtensionZ.get() : "";
String cmd = "";
if (!(pxy instanceof NoPadding) || !(paz instanceof NoPadding) || spnExtensionXY.get() > 0 || spnExtensionZ.get() > 0)
cmd += " -pad " + pxy.getShortname() + " " + paz.getShortname() + " " + extXY + extZ;
if (!(axy instanceof UniformApodization) || !(apz instanceof UniformApodization))
cmd += " -apo " + axy.getShortname() + " " + apz.getShortname() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
lblPad = new JLabel("Information on padding size");
lblPad.setBorder(BorderFactory.createEtchedBorder());
lblApo = new JLabel("Information on apodization energy");
lblApo.setBorder(BorderFactory.createEtchedBorder());
cmbPadXY = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbPadZ = new JComboBox<String>(Padding.getPaddingsAsArray());
cmbApoXY = new JComboBox<String>(Apodization.getApodizationsAsArray());
cmbApoZ = new JComboBox<String>(Apodization.getApodizationsAsArray());
spnExtensionXY = new SpinnerRangeInteger(0, 0, 99999, 1);
spnExtensionZ = new SpinnerRangeInteger(0, 0, 99999, 1);
GridPanel pnBorder = new GridPanel(false, 3);
pnBorder.place(0, 1, "Lateral (XY)");
pnBorder.place(0, 2, "Axial (Z)");
pnBorder.place(2, 0, "Apodization");
pnBorder.place(2, 1, cmbApoXY);
pnBorder.place(2, 2, cmbApoZ);
pnBorder.place(3, 0, "Padding Extension");
pnBorder.place(3, 1, spnExtensionXY);
pnBorder.place(3, 2, spnExtensionZ);
pnBorder.place(4, 0, "Padding Constraint");
pnBorder.place(4, 1, cmbPadXY);
pnBorder.place(4, 2, cmbPadZ);
pnBorder.place(5, 0, 3, 1, lblPad);
pnBorder.place(6, 0, 3, 1, lblApo);
JScrollPane scroll = new JScrollPane(pnBorder);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "padxy", cmbPadXY, Padding.getDefault().getName());
Config.register(getName(), "padz", cmbPadZ, Padding.getDefault().getName());
Config.register(getName(), "apoxy", cmbApoXY, Apodization.getDefault().getName());
Config.register(getName(), "apoz", cmbApoZ, Apodization.getDefault().getName());
Config.register(getName(), "extxy", spnExtensionXY, "0");
Config.register(getName(), "extz", spnExtensionZ, "0");
spnExtensionXY.addChangeListener(this);
spnExtensionZ.addChangeListener(this);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
build = true;
return panel;
}
private void update() {
setCommand(getCommand());
boolean ext = spnExtensionXY.get() + spnExtensionZ.get() > 0;
boolean pad = cmbPadXY.getSelectedIndex() + cmbPadZ.getSelectedIndex() > 0;
boolean apo = cmbApoXY.getSelectedIndex() + cmbApoZ.getSelectedIndex() > 0;
if (pad || apo || ext) {
setSynopsis("" + " " + (pad ? "Padding" : "") + " " + (ext ? "Extension" : "") + " " + (apo ? "Apodization" : ""));
}
else {
setSynopsis("Default options");
}
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
cmbPadXY.setSelectedIndex(0);
cmbPadZ.setSelectedIndex(0);
cmbApoXY.setSelectedIndex(0);
cmbApoZ.setSelectedIndex(0);
spnExtensionXY.set(0);
spnExtensionZ.set(0);
cmbPadXY.addActionListener(this);
cmbPadZ.addActionListener(this);
cmbApoXY.addActionListener(this);
cmbApoZ.addActionListener(this);
update();
return;
}
if (e.getSource() == getAction1Button()) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getAction1Button().setEnabled(false);
getAction2Button().setEnabled(false);
Deconvolution d = new Deconvolution("CheckImage", Command.command());
Apodization apo = d.getApodization();
if (apo == null) {
lblApo.setText("Error in Apodization");
return;
}
Padding pad = d.getPadding();
if (pad == null) {
lblPad.setText("Error in Padding");
return;
}
RealSignal x = d.openImage();
if (x == null) {
lblPad.setText("Error in input image");
lblApo.setText("Error in input image");
return;
}
Monitors m = Monitors.createDefaultMonitor();
RealSignal y = pad.pad(m, x);
apo.apodize(m, y);
lblPad.setText(x.dimAsString() + " > " + y.dimAsString());
lblApo.setText(NumFormat.nice(x.getStats()[5]) + " > " + NumFormat.nice(y.getStats()[5]));
getAction1Button().setEnabled(true);
getAction2Button().setEnabled(true);
}
});
thread.setPriority(Thread.MIN_PRIORITY);
thread.start();
return;
}
update();
}
@Override
public void close() {
cmbPadXY.removeActionListener(this);
cmbPadZ.removeActionListener(this);
cmbApoXY.removeActionListener(this);
cmbApoZ.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
spnExtensionXY.removeChangeListener(this);
spnExtensionZ.removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
index d242449..99b0c40 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/CommandModule.java
@@ -1,100 +1,100 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JPanel;
+import bilib.component.HTMLPane;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
-import lab.component.HTMLPane;
-import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class CommandModule extends AbstractModule {
private HTMLPane window;
public CommandModule() {
super("Command", "", "", "Check", true);
}
public HTMLPane getPane() {
return window;
}
@Override
public JPanel buildExpandedPanel() {
window = new HTMLPane("Monaco", 100, 100);
JPanel panel = new JPanel(new BorderLayout());
panel.add(window.getPane(), BorderLayout.CENTER);
getAction2Button().setToolTipText("Human readable of the command line");
getAction2Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction2Button()) {
Deconvolution deconvolution = new Deconvolution("Check Command", Command.command());
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.RECAP, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
window.clear();
window.append("p", command);
}
@Override
public String getCommand() {
return "";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
index f1d9ee4..dbe63bc 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ConfigModule.java
@@ -1,124 +1,124 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
public class ConfigModule extends AbstractModule implements ActionListener {
private JButton bnLoad;
private JButton bnSave;
private CustomizedTable table;
private JLabel lblDefault;
public ConfigModule(boolean expanded) {
super("Config", "", "", "", expanded);
}
@Override
public String getCommand() {
return "";
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Key", String.class, 180, false));
columns.add(new CustomizedColumn("Value", String.class, Constants.widthGUI - 80, true));
table = new CustomizedTable(columns, true);
read();
lblDefault = new JLabel(Config.getFilename());
bnLoad = new JButton("Load");
bnSave = new JButton("Save");
lblDefault.setBorder(BorderFactory.createEtchedBorder());
JPanel button = new JPanel();
button.setLayout(new FlowLayout());
button.add(bnLoad);
button.add(bnSave);
JPanel panel = new JPanel(new BorderLayout());
panel.add(lblDefault, BorderLayout.NORTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnLoad.addActionListener(this);
bnSave.addActionListener(this);
return panel;
}
private void read() {
String filename = Config.getFilename();
File file = new File(filename);
if (file.exists()) {
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String entry = line.trim();
if (!entry.startsWith("#")) {
String[] parts = entry.split("=");
if (parts.length == 2)
table.append(parts);
}
}
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void close() {
bnLoad.removeActionListener(this);
bnSave.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
index f582a51..6f48f37 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ControllerModule.java
@@ -1,245 +1,245 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.tools.Files;
import signal.Constraint;
public class ControllerModule extends AbstractModule implements ActionListener, ChangeListener, KeyListener {
private JButton bnBrowse;
private JTextField txtReference;
private JTextField txtResidu;
private JTextField txtTime;
private JTextField txtIterations;
private JComboBox<String> cmbConstraint;
private JCheckBox chkResidu;
private JCheckBox chkReference;
private JCheckBox chkConstraint;
private JCheckBox chkTime;
private JCheckBox chkItermax;
public ControllerModule(boolean expanded) {
super("Controller", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (chkConstraint.isSelected())
cmd += "-constraint " + cmbConstraint.getSelectedItem() + " ";
if (chkReference.isSelected())
cmd += "-reference " + txtReference.getText() + " ";
if (chkResidu.isSelected())
cmd += "-residu " + txtResidu.getText() + " ";
if (chkTime.isSelected())
cmd += "-time " + txtTime.getText() + " ";
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
chkTime = new JCheckBox("Time Limitation (s)");
chkItermax = new JCheckBox("Early Stopping");
chkConstraint = new JCheckBox("Constraint");
chkResidu = new JCheckBox("Residu Minimun");
chkReference = new JCheckBox("Reference");
bnBrowse = new JButton("Browse");
txtReference = new JTextField("");
txtResidu = new JTextField("0.01");
txtTime = new JTextField("3600");
txtIterations = new JTextField("Iteration max (mandatory)");
txtIterations.setEditable(false);
cmbConstraint = new JComboBox<String>(Constraint.getContraintsAsArray());
txtReference.setPreferredSize(new Dimension(200, 20));
GridPanel pn = new GridPanel(true);
pn.place(0, 0, chkItermax);
pn.place(0, 1, txtIterations);
pn.place(1, 0, chkResidu);
pn.place(1, 1, txtResidu);
pn.place(4, 0, chkConstraint);
pn.place(4, 1, cmbConstraint);
pn.place(5, 0, chkTime);
pn.place(5, 1, txtTime);
pn.place(7, 0, chkReference);
pn.place(7, 1, txtReference);
pn.place(8, 0, "Ground-truth file");
pn.place(8, 1, bnBrowse);
JScrollPane scroll = new JScrollPane(pn);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "residu.enable", chkResidu, false);
Config.register(getName(), "reference.enable", chkReference, false);
Config.register(getName(), "constraint.enable", chkConstraint, false);
Config.register(getName(), "time.enable", chkTime, false);
Config.register(getName(), "itmax.enable", chkItermax, true);
Config.register(getName(), "reference.value", txtReference, "");
Config.register(getName(), "residu.value", txtResidu, "0.01");
Config.register(getName(), "time.value", txtTime, "3600");
Config.register(getName(), "constraint.value", cmbConstraint, "No");
chkItermax.setSelected(true);
bnBrowse.addActionListener(this);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.addChangeListener(this);
txtResidu.addKeyListener(this);
txtReference.addKeyListener(this);
txtTime.addKeyListener(this);
cmbConstraint.addActionListener(this);
getAction1Button().addActionListener(this);
return panel;
}
private void update() {
chkItermax.setSelected(true);
setCommand(getCommand());
int count = 0;
count += (chkResidu.isSelected() ? 1 : 0);
count += (chkConstraint.isSelected() ? 1 : 0);
count += (chkTime.isSelected() ? 1 : 0);
count += (chkItermax.isSelected() ? 1 : 0);
setSynopsis("" + count + " stopping criteria");
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File file = Files.browseFile(Command.getPath());
if (file != null)
txtReference.setText(file.getAbsolutePath());
}
if (e.getSource() == getAction1Button()) {
chkResidu.removeChangeListener(this);
chkReference.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkTime.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkResidu.setSelected(false);
chkReference.setSelected(false);
chkConstraint.setSelected(false);
chkTime.setSelected(false);
chkItermax.setSelected(true);
txtReference.setText("");
txtResidu.setText("0.01");
txtTime.setText("3600");
cmbConstraint.setSelectedIndex(0);
chkResidu.addChangeListener(this);
chkReference.addChangeListener(this);
chkConstraint.addChangeListener(this);
chkTime.addChangeListener(this);
chkItermax.addChangeListener(this);
}
update();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
@Override
public void close() {
bnBrowse.removeActionListener(this);
chkReference.removeChangeListener(this);
chkResidu.removeChangeListener(this);
chkConstraint.removeChangeListener(this);
chkItermax.removeChangeListener(this);
chkTime.removeChangeListener(this);
getAction1Button().removeChangeListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
index 7712ef0..fb27b6b 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/FFTModule.java
@@ -1,170 +1,170 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import bilib.component.GridPanel;
+import bilib.tools.NumFormat;
import deconvolution.Command;
import deconvolution.algorithm.Algorithm;
import deconvolutionlab.Config;
import fft.FFT;
-import lab.component.GridPanel;
-import lab.tools.NumFormat;
public class FFTModule extends AbstractModule implements ActionListener, ChangeListener {
private JComboBox<String> cmbFFT;
private JComboBox<String> cmbType;
private JComboBox<String> cmbSep;
private JComboBox<String> cmbEpsilon;
private JComboBox<String> cmbNormalization;
boolean init = false;
public FFTModule(boolean expanded) {
super("Computation", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbNormalization.getSelectedIndex() != 0)
cmd += " -norm " + NumFormat.parseNumber((String)cmbNormalization.getSelectedItem(), 1);
if (cmbFFT.getSelectedIndex() != 0) {
cmd += " -fft " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName();
}
if (cmbEpsilon.getSelectedIndex() != 6)
cmd += " -epsilon " + (String) cmbEpsilon.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbFFT = new JComboBox<String>(FFT.getLibrariesAsArray());
cmbType = new JComboBox<String>(new String[] { "float" });
cmbSep = new JComboBox<String>(new String[] { "XYZ" });
cmbEpsilon = new JComboBox<String>(new String[] { "1E-0", "1E-1", "1E-2", "1E-3", "1E-4", "1E-5", "1E-6", "1E-7", "1E-8", "1E-9", "1E-10", "1E-11", "1E-12" });
cmbEpsilon.setSelectedItem("1E-6");
cmbNormalization = new JComboBox<String>(new String[] { "1", "10", "1000", "1E+6", "1E+9", "no" });
cmbNormalization.addActionListener(this);
cmbNormalization.setSelectedIndex(0);
cmbNormalization.removeActionListener(this);
GridPanel pnNumeric = new GridPanel(false, 3);
pnNumeric.place(1, 0, "PSF Normalization");
pnNumeric.place(1, 1, cmbNormalization);
pnNumeric.place(1, 2, "1, recommended");
pnNumeric.place(3, 0, new JLabel("FFT Library"));
pnNumeric.place(3, 1, cmbFFT);
pnNumeric.place(3, 2, new JLabel("Fourier"));
pnNumeric.place(6, 0, new JLabel("FFT Processing"));
pnNumeric.place(6, 1, cmbSep);
pnNumeric.place(6, 2, new JLabel("Dimension Ordering"));
pnNumeric.place(7, 0, new JLabel("Machine Epsilon"));
pnNumeric.place(7, 1, cmbEpsilon);
pnNumeric.place(7, 2, new JLabel("<html>&epsilon;</html>"));
pnNumeric.place(8, 0, new JLabel("Data Type"));
pnNumeric.place(8, 1, cmbType);
pnNumeric.place(8, 2, new JLabel("(Only float)"));
JScrollPane scroll = new JScrollPane(pnNumeric);
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEtchedBorder());
panel.add(scroll, BorderLayout.CENTER);
Config.register(getName(), "normalization", cmbNormalization, cmbNormalization.getItemAt(0));
Config.register(getName(), "fft", cmbFFT, Algorithm.getDefaultAlgorithm());
Config.register(getName(), "dim", cmbSep, "XYZ");
Config.register(getName(), "epsilon", cmbEpsilon, "1E-6");
cmbFFT.addActionListener(this);
cmbType.addActionListener(this);
cmbSep.addActionListener(this);
cmbEpsilon.addActionListener(this);
cmbNormalization.addActionListener(this);
getAction1Button().addActionListener(this);
init = true;
return panel;
}
private void update() {
setCommand(getCommand());
if (init)
setSynopsis("Norm " + cmbNormalization.getSelectedItem() + " " + FFT.getLibraryByName((String) cmbFFT.getSelectedItem()).getLibraryName());
Command.command();
}
@Override
public void stateChanged(ChangeEvent e) {
update();
}
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("" + e);
super.actionPerformed(e);
if (e.getSource() == getAction1Button()) {
cmbFFT.setSelectedIndex(0);
cmbSep.setSelectedIndex(0);
cmbType.setSelectedIndex(0);
cmbEpsilon.setSelectedIndex(0);
cmbNormalization.setSelectedIndex(0);
}
update();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
cmbFFT.removeActionListener(this);
cmbSep.removeActionListener(this);
cmbType.removeActionListener(this);
cmbEpsilon.removeActionListener(this);
cmbNormalization.removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
index ca7542d..09b5d25 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/ImageModule.java
@@ -1,354 +1,354 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.modules.ImageDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class ImageModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public ImageModule(boolean expanded) {
super("Image", "-image", (Lab.getPlatform() == Imaging.Platform.IMAGEJ ? "Active" : ""), "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-image " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 4));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "image", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button()) {
int row = -1;
for(int i=0; i<table.getRowCount(); i++) {
if (table.getCell(i, 0).equalsIgnoreCase("active"))
if (table.getCell(i, 1).equalsIgnoreCase("platform"))
if (table.getCell(i, 2).equalsIgnoreCase("active"))
row = i;
}
if (row < 0)
table.insert(new String[] { "active", "platform", "active", "\u232B" });
else
table.setRowSelectionInterval(row, row);
}
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] { name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getImages();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "\u232B" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for (SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check Image", Command.command());
deconvolution.openImage();
if (stack) {
RealSignal x = deconvolution.getImage();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.IMAGE, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
index 7951826..21ebb6f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/LanguageModule.java
@@ -1,251 +1,251 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.HTMLPane;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.Token;
import deconvolution.algorithm.AbstractAlgorithm;
import deconvolutionlab.Config;
-import lab.component.HTMLPane;
public class LanguageModule extends AbstractModule implements ActionListener {
private HTMLPane language;
private JComboBox<String> cmb;
private JComboBox<String> gui;
private JTextField txt;
public LanguageModule(boolean expanded) {
super("Language", "", "", "", expanded);
}
public String getJobName() {
if (txt != null)
return txt.getText();
return "";
}
@Override
public JPanel buildExpandedPanel() {
language = new HTMLPane("Monaco", 100, 100);
cmb = new JComboBox<String>(new String[] { "Command line", "ImageJ Macro", "Java", "Matlab" });
gui = new JComboBox<String>(new String[] { "Run (Headless)", "Launch (with control panel)" });
txt = new JTextField("Job", 8);
JPanel pn = new JPanel(new BorderLayout());
pn.add(cmb, BorderLayout.WEST);
pn.add(txt, BorderLayout.CENTER);
pn.add(gui, BorderLayout.EAST);
JPanel panel = new JPanel(new BorderLayout());
panel.add(pn, BorderLayout.NORTH);
panel.add(language.getPane(), BorderLayout.CENTER);
cmb.addActionListener(this);
gui.addActionListener(this);
Config.register(getName(), "language", cmb, cmb.getItemAt(0));
Config.register(getName(), "headless", gui, gui.getItemAt(0));
Config.register(getName(), "job", txt, "Job");
language.clear();
return panel;
}
@Override
public void expand() {
super.expand();
update();
}
public void update() {
if (cmb.getSelectedIndex() == 0) {
language.clear();
String run = gui.getSelectedIndex() == 0 ? " Run " : " Launch ";
language.append("p", "java -jar DeconvolutionLab_2.jar " + run + Command.command());
language.append("p", "");
language.append("p", "java -cp JTransforms.jar:DeconvolutionLab_2.jar DeconvolutionLab2 "+ run + Command.command());
}
else if (cmb.getSelectedIndex() == 1) {
language.clear();
language.append("p", imagej(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 2) {
language.clear();
language.append("p", java(gui.getSelectedIndex() == 0));
}
else if (cmb.getSelectedIndex() == 3) {
language.clear();
language.append("p", matlab());
}
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == cmb)
update();
if (e.getSource() == gui)
update();
}
@Override
public void close() {
}
@Override
public void setCommand(String command) {
update();
}
@Override
public String getCommand() {
return "";
}
private String matlab() {
String job = txt.getText();
String script = "";
String cmd = Command.command();
Deconvolution d = new Deconvolution("Matlab", cmd);
String options = Command.extractOptions(cmd);
AbstractAlgorithm algo = d.getAlgo();
if (algo == null)
return "ERROR";
String s = algo.getShortname();
String param = algo.getParametersAsString();
script += p("% this function returns the deconvolved image as an 3D matrix");
script += p("% image is a 3D matrix containing the image");
script += p("% psf is a 3D matrix containing the PSF");
script += p("function result = " + job + "(image, psf)");
script += p1("% Install first DeconvolutionLab_2.jar into the java directory of Matlab");
script += p1("javaaddpath([matlabroot filesep 'java' filesep 'DeconvolutionLab_2.jar'])");
script += p1("% Run the deconvolution\n");
script += p1("result = DL2." + s + "(image, psf, " + param +" , '" + options +"');");
script += p("end");
return script;
}
private String imagej(boolean headless) {
String job = txt.getText();
String macro = p("// Job: " + job + " ");
macro += p("// Macro generated by DeconvolutionLab2 ");
macro += p("// " + new SimpleDateFormat("dd/MM/yy HH:m:s").format(new Date()) + " ");
String param = p("parameters = \"\" ");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = "image = \" NOT DEFINED \" ";
String psf = "psf = \" NOT DEFINED \" ";
String algo = "algo = \" NOT DEFINED \" ";
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p("image = \" -image " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-psf"))
psf = p("psf = \" -psf " + token.parameters.trim() + "\" ");
else if (token.keyword.equals("-algorithm"))
algo = p("algorithm = \" -algorithm " + token.parameters.trim() + "\" ");
else
param += p("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\"");
}
String option = macro + image + psf + algo + param;
String cmd = "";
if (headless)
cmd = p("run(\"DeconvolutionLab2 Run\", image + psf + algorithm + parameters)");
else
cmd = p("run(\"DeconvolutionLab2 Launch\", image + psf + algorithm + parameters)");
return option + cmd;
}
private String java(boolean headless) {
String job = txt.getText();
String code = "";
code += p("import deconvolution.Deconvolution;");
code += p("import ij.plugin.PlugIn;");
code += p("");
code += p("public class DeconvolutionLab2_" + job + " implements PlugIn {");
code += p1("public DeconvolutionLab2_" + job + "() {");
String param = p2("String parameters = \"\";");
ArrayList<Token> tokens = Command.parse(Command.command());
String image = p2("String image = \" NOT DEFINED \";");
String psf = p2("String psf = \" NOT DEFINED \";");
String algo = p2("String algo = \" NOT DEFINED \";");
for (Token token : tokens) {
if (token.keyword.equals("-image"))
image = p2("String image = \" -image " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-psf"))
psf = p2("String psf = \" -psf " + token.parameters.trim() + "\";");
else if (token.keyword.equals("-algorithm"))
algo = p2("String algorithm = \" -algorithm " + token.parameters.trim() + "\";");
else
param += p2("parameters += \" " + token.keyword + " " + token.parameters.trim() + "\";");
}
code += image + psf + algo + param;
code += p2("new Deconvolution(image + psf + algorithm + parameters)");
code += p1("}");
code += p1("");
code += p1("@Override");
code += p1("public void run(String arg0) {");
code += p2(" new DeconvolutionLab2_" + job + "();");
code += p1("}");
code += p("}");
return code;
}
private String p(String content) {
return "<p>" + content + "</p>";
}
private String p1(String content) {
return "<p style=\"padding-left:10px\">" + content + "</p>";
}
private String p2(String content) {
return "<p style=\"padding-left:20px\">" + content + "</p>";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
index 7176066..1052d7f 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/LicenceModule.java
@@ -1,88 +1,88 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import javax.swing.JPanel;
+import bilib.component.HTMLPane;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
-import lab.component.HTMLPane;
public class LicenceModule extends AbstractModule {
public LicenceModule(boolean expanded) {
super("Licence", "", "", "", expanded);
}
@Override
public String getCommand() {
return "DeconvolutionLab2 " + Constants.version;
}
@Override
public JPanel buildExpandedPanel() {
JPanel panel = new JPanel(new BorderLayout());
HTMLPane html = new HTMLPane("verdana", 200, 200);
html.append("h1", "DeconvolutionLab2 " + Constants.version);
html.append("p",
"DeconvolutionLab2 is free software: you can redistribute it "+
"and/or modify it under the terms of the GNU General " +
"Public License as published by the Free Software Foundation, " +
"either version 3 of the License, or (at your option) any later version.");
html.append("p",
"DeconvolutionLab2 is distributed in the hope that it will be useful, " +
"but WITHOUT ANY WARRANTY; without even the implied warranty " +
"of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " +
"See the GNU General Public License for more details.");
html.append("p",
"You should have received a copy of the GNU General Public License along with " +
"DeconvolutionLab2. If not, see http://www.gnu.org/licenses/.");
panel.add(html.getPane(), BorderLayout.CENTER);
getAction1Button().addActionListener(this);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (getAction1Button() == e.getSource())
Lab.help();
}
@Override
public void close() {
getAction1Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
index fcb13b3..a877d5e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/OutputModule.java
@@ -1,236 +1,236 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Output;
import deconvolutionlab.Output.View;
import deconvolutionlab.dialog.OutputDialog;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
public class OutputModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnStack;
private JButton bnSeries;
private JButton bnMIP;
private JButton bnOrtho;
private JButton bnPlanar;
private JButton bnFigure;
public OutputModule(boolean expanded) {
super("Output", "", "", "Default", expanded);
}
@Override
public String getCommand() {
String cmd = " ";
if (table == null)
return cmd;
for (int i = 0; i < table.getRowCount(); i++) {
String[] values = new String[table.getColumnCount()];
for(int c=0; c<table.getColumnCount(); c++)
values[c] = table.getCell(i, c) == null ? "" : table.getCell(i, c).trim();
cmd += " -out " + values[0] + " " + values[1] + " " + values[2] + " " + values[3] + " " + values[4];
if (values[5].equals(""))
cmd += " noshow";
if (values[6].equals(""))
cmd += " nosave";
}
return cmd;
}
public void update() {
setCommand(getCommand());
setSynopsis(table.getRowCount() + " output" + (table.getRowCount() > 1 ? "s" : ""));
Command.command();
getAction1Button().setEnabled(table.getRowCount() > 0);
}
@Override
public JPanel buildExpandedPanel() {
String[] dynamics = { "intact", "rescaled", "normalized", "clipped" };
String[] types = { "float", "short", "byte" };
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Mode", String.class, 80, false));
columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
columns.add(new CustomizedColumn("Keypoint", String.class, 120, false));
columns.add(new CustomizedColumn("Show", String.class, 50, false));
columns.add(new CustomizedColumn("Save", String.class, 50, false));
columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(5).setMaxWidth(50);
table.getColumnModel().getColumn(6).setMaxWidth(50);
table.getColumnModel().getColumn(7).setMaxWidth(30);
table.getColumnModel().getColumn(0).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(3).setMaxWidth(100);
table.addMouseListener(this);
bnStack = new JButton("\u2295 stack");
bnSeries = new JButton("\u2295 series");
bnMIP = new JButton("\u2295 mip");
bnOrtho = new JButton("\u2295 ortho");
bnPlanar = new JButton("\u2295 planar");
bnFigure = new JButton("\u2295 figure");
JToolBar pn = new JToolBar("Controls Image");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 6));
pn.setFloatable(false);
pn.add(bnStack);
pn.add(bnSeries);
pn.add(bnMIP);
pn.add(bnOrtho);
pn.add(bnPlanar);
pn.add(bnFigure);
JToolBar tool = new JToolBar("Path");
tool.setBorder(BorderFactory.createEmptyBorder());
tool.setLayout(new BorderLayout());
tool.setFloatable(false);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(tool, BorderLayout.NORTH);
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
bnStack.addActionListener(this);
bnSeries.addActionListener(this);
bnMIP.addActionListener(this);
bnOrtho.addActionListener(this);
bnPlanar.addActionListener(this);
bnFigure.addActionListener(this);
getAction1Button().addActionListener(this);
Config.registerTable(getName(), "output", table);
return panel;
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
View view = null;
if (e.getSource() == bnStack)
view = View.STACK;
else if (e.getSource() == bnSeries)
view = View.SERIES;
else if (e.getSource() == bnMIP)
view = View.MIP;
else if (e.getSource() == bnOrtho)
view = View.ORTHO;
else if (e.getSource() == bnPlanar)
view = View.PLANAR;
else if (e.getSource() == bnFigure)
view = View.FIGURE;
if (view != null) {
OutputDialog dlg = new OutputDialog(view);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
Output out = dlg.getOut();
if (out != null)
table.insert(out.getAsString());
//Lab.setVisible(new OutputPanel(view), "panel", 30, 30);
update();
}
if (e.getSource() == getAction1Button()) {
table.removeRows();
}
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 7) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnStack.removeActionListener(this);
bnSeries.removeActionListener(this);
bnMIP.removeActionListener(this);
bnOrtho.removeActionListener(this);
bnPlanar.removeActionListener(this);
bnFigure.removeActionListener(this);
getAction1Button().removeActionListener(this);
getAction2Button().removeActionListener(this);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
index df38533..8ef6d7d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PSFModule.java
@@ -1,342 +1,342 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolution.modules.PSFDModule;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import deconvolutionlab.dialog.PatternDialog;
import deconvolutionlab.dialog.SyntheticDialog;
import deconvolutionlab.monitor.Monitors;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.Files;
import signal.RealSignal;
import signal.factory.SignalFactory;
public class PSFModule extends AbstractModule implements ActionListener, MouseListener {
private CustomizedTable table;
private JButton bnFile;
private JButton bnDirectory;
private JButton bnSynthetic;
private JButton bnPlatform;
public PSFModule(boolean expanded) {
super("PSF", "-psf", "", "Check", expanded);
}
@Override
public String getCommand() {
int row = table.getSelectedRow();
if (row < 0)
return "";
return "-psf " + table.getCell(row, 1) + " " + table.getCell(row, 2);
}
@Override
public JPanel buildExpandedPanel() {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 100, false));
columns.add(new CustomizedColumn("Source", String.class, 100, false));
columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI - 200, true));
columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this PSF source"));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(3).setMaxWidth(30);
table.getColumnModel().getColumn(3).setMinWidth(30);
table.addMouseListener(this);
bnFile = new JButton("\u2295 file");
bnDirectory = new JButton("\u2295 directory");
bnSynthetic = new JButton("\u2295 synthetic");
bnPlatform = new JButton("\u2295 platform");
JToolBar pn = new JToolBar("Controls PSF");
pn.setBorder(BorderFactory.createEmptyBorder());
pn.setLayout(new GridLayout(1, 5));
pn.setFloatable(false);
pn.add(bnFile);
pn.add(bnDirectory);
pn.add(bnSynthetic);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
pn.add(bnPlatform);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEtchedBorder());
panel.setLayout(new BorderLayout());
panel.add(pn, BorderLayout.SOUTH);
panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);
table.setDropTarget(new LocalDropTarget());
getCollapsedPanel().setDropTarget(new LocalDropTarget());
bnFile.addActionListener(this);
bnDirectory.addActionListener(this);
bnSynthetic.addActionListener(this);
if (Lab.getPlatform() == Imaging.Platform.IMAGEJ)
bnPlatform.addActionListener(this);
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
getAction2Button().setToolTipText("Click to have a preview, Shift-click or Ctrl-click to show the complete stack");
getAction1Button().setToolTipText("Select the active window");
Config.registerTable(getName(), "psf", table);
return panel;
}
public void update() {
int row = table.getSelectedRow();
if (row >= 0) {
setCommand(getCommand());
setSynopsis(table.getCell(row, 0));
Command.command();
}
else {
setSynopsis("");
setCommand("Drag your image file, here");
}
getAction2Button().setEnabled(table.getRowCount() > 0);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnFile)
file(Command.getPath());
else if (e.getSource() == bnDirectory)
dir(Command.getPath());
else if (e.getSource() == bnSynthetic)
synthetic(false);
else if (e.getSource() == bnPlatform)
platform();
else if (e.getSource() == getAction1Button())
platform();
else if (e.getSource() == getAction2Button()) {
boolean s = (e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK;
boolean c = (e.getModifiers() & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK;
display(s | c);
}
update();
}
public void platform() {
String name = Lab.getActiveImage();
if (name != "")
table.insert(new String[] {name, "platform", name, "\u232B" });
}
private void file(String path) {
File file = Files.browseFile(path);
if (file == null)
return;
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "\u232B" });
}
private void dir(String path) {
File file = Files.browseDirectory(path);
if (file == null)
return;
PatternDialog dlg = new PatternDialog(file);
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
table.insert(new String[] { dlg.getDirName(), "directory", dlg.getCommand(), "\u232B" });
}
private void synthetic(boolean edit) {
ArrayList<SignalFactory> list = SignalFactory.getPSF();
SyntheticDialog dlg = new SyntheticDialog(list);
if (edit) {
int row = table.getSelectedRow();
if (row >= 0) {
dlg.setParameters(table.getCell(row, 0), table.getCell(row, 1));
}
}
Lab.setVisible(dlg, true);
if (dlg.wasCancel())
return;
if (edit) {
int row = table.getSelectedRow();
if (row <= 0)
table.removeRow(row);
}
table.insert(new String[] { dlg.getShapeName(), "synthetic", dlg.getCommand(), "" });
}
private void edit() {
int row = table.getSelectedRow();
if (row < 0)
return;
String name = table.getCell(row, 0).trim();
for(SignalFactory factory : SignalFactory.getAll()) {
if (name.equals(factory.getName().trim()))
synthetic(true);
return;
}
String filename = table.getCell(row, 1).trim();
File file = new File(filename);
if (!file.exists())
return;
if (file.isFile())
file(table.getCell(row, 21));
else
dir(table.getCell(row, 1));
}
private void display(boolean stack) {
int row = table.getSelectedRow();
if (row < 0)
return;
Deconvolution deconvolution = new Deconvolution("Check PSF", Command.command());
deconvolution.openPSF();
if (stack) {
RealSignal x = deconvolution.getPSF();
if (x != null)
Lab.show(Monitors.createDefaultMonitor(), x, table.getCell(row, 0));
}
else {
DeconvolutionDialog d = new DeconvolutionDialog(DeconvolutionDialog.Module.PSF, deconvolution, null, null);
Lab.setVisible(d, false);
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() == table) {
int row = table.getSelectedRow();
if (row < 0)
return;
if (table.getSelectedColumn() == 3) {
table.removeRow(row);
if (table.getRowCount() > 0)
table.setRowSelectionInterval(0, 0);
}
update();
if (e.getClickCount() == 2) {
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void close() {
bnFile.removeActionListener(this);
bnDirectory.removeActionListener(this);
bnSynthetic.removeActionListener(this);
bnPlatform.removeActionListener(this);
}
public class LocalDropTarget extends DropTarget {
@Override
public void drop(DropTargetDropEvent e) {
e.acceptDrop(DnDConstants.ACTION_COPY);
e.getTransferable().getTransferDataFlavors();
Transferable transferable = e.getTransferable();
DataFlavor[] flavors = transferable.getTransferDataFlavors();
for (DataFlavor flavor : flavors) {
if (flavor.isFlavorJavaFileListType()) {
try {
List<File> files = (List<File>) transferable.getTransferData(flavor);
for (File file : files) {
if (file.isDirectory()) {
table.insert(new String[] { file.getName(), "directory", file.getAbsolutePath(), "" });
table.setRowSelectionInterval(0, 0);
update();
}
if (file.isFile()) {
table.insert(new String[] { file.getName(), "file", file.getAbsolutePath(), "" });
update();
}
}
}
catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
e.dropComplete(true);
super.drop(e);
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
index fe4faa3..7537dd6 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/PreferencesModule.java
@@ -1,73 +1,73 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import javax.swing.JPanel;
+import bilib.component.GridPanel;
+import bilib.component.SpinnerRangeInteger;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.component.SpinnerRangeInteger;
public class PreferencesModule extends AbstractModule {
private SpinnerRangeInteger spnMaxItems;
public PreferencesModule(boolean expanded) {
super("Preferences", "", "", "", expanded);
}
@Override
public String getCommand() {
return "NO";
}
@Override
public JPanel buildExpandedPanel() {
spnMaxItems = new SpinnerRangeInteger(50, 1, 1000, 1);
JPanel panel = new JPanel(new BorderLayout());
GridPanel pn = new GridPanel(true);
pn.place(3, 0, "Maximum number of items in table");
pn.place(3, 1, spnMaxItems);
panel.add(pn, BorderLayout.NORTH);
Config.register(getName(), "maximum-items", spnMaxItems, 50);
return panel;
}
@Override
public void close() {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
index ead41ca..a4c285c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/RunningModule.java
@@ -1,264 +1,264 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.Files;
public class RunningModule extends AbstractModule implements MouseListener {
private CustomizedTable table;
private String[] valuesMonitor;
private String[] valuesVerbose;
private String[] valuesSystem;
private String[] valuesMultithreading;
private String[] valuesDisplay;
private String[] valuesStats;
private String[] valuesPath;
private JTextField txtMonitor;
private JTextField txtVerbose;
private JTextField txtSystem;
private JTextField txtMultithreading;
private JTextField txtDisplay;
private JTextField txtStats;
private JTextField txtPath;
private JTextField txtDirectory;
public RunningModule(boolean expanded) {
super("Running", "", "Default", "Browse", expanded);
}
@Override
public String getCommand() {
String cmd = "";
String p = txtPath.getText();
if (!p.equalsIgnoreCase(valuesPath[0]))
cmd += " -path " + txtDirectory.getText().toLowerCase();
if (!txtMonitor.getText().equalsIgnoreCase(valuesMonitor[0]))
cmd += " -monitor " + txtMonitor.getText().toLowerCase();
if (!txtVerbose.getText().equalsIgnoreCase(valuesVerbose[0]))
cmd += " -verbose " + txtVerbose.getText().toLowerCase();
if (!txtSystem.getText().equalsIgnoreCase(valuesSystem[0]))
cmd += " -system " + txtSystem.getText().toLowerCase();
if (!txtDisplay.getText().equalsIgnoreCase(valuesDisplay[0]))
cmd += " -display " + txtDisplay.getText().toLowerCase();
if (!txtStats.getText().equalsIgnoreCase(valuesStats[0]))
cmd += " -stats " + txtStats.getText().toLowerCase();
if (!txtMultithreading.getText().equalsIgnoreCase(valuesMultithreading[0]))
cmd += " -multithreading " + txtMultithreading.getText().toLowerCase();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
valuesPath = new String[] { "current", "specify" };
valuesMonitor = new String[] { "console table", "console", "table", "no" };
valuesStats = new String[] { "no", "show", "save", "show save" };
valuesVerbose = new String[] { "log", "quiet", "mute", "prolix" };
valuesSystem = new String[] { "yes", "no" };
valuesMultithreading = new String[] { "yes", "no" };
valuesDisplay = new String[] { "yes", "no" };
txtDirectory = new JTextField(System.getProperty("user.dir"));
txtPath = new JTextField(valuesPath[0]);
txtMonitor = new JTextField(valuesMonitor[0]);
txtStats = new JTextField(valuesStats[0]);
txtVerbose = new JTextField(valuesVerbose[0]);
txtSystem = new JTextField(valuesSystem[0]);
txtMultithreading = new JTextField(valuesMultithreading[0]);
txtDisplay = new JTextField(valuesDisplay[0]);
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Settings", String.class, 150, false));
columns.add(new CustomizedColumn("State", String.class, 100, false));
columns.add(new CustomizedColumn("Information", String.class, Constants.widthGUI - 250, true));
columns.add(new CustomizedColumn("", String.class, 100, "Change", "Change this setting"));
table = new CustomizedTable(columns, false);
table.getColumnModel().getColumn(3).setMaxWidth(140);
table.getColumnModel().getColumn(3).setMaxWidth(140);
JPanel panel = new JPanel(new BorderLayout());
panel.add(table.getPane(100, 100), BorderLayout.CENTER);
Config.register(getName(), "Path", txtPath, valuesPath[0]);
Config.register(getName(), "Monitor", txtMonitor, valuesMonitor[0]);
Config.register(getName(), "Stats", txtStats, valuesStats[0]);
Config.register(getName(), "Verbose", txtVerbose, valuesVerbose[0]);
Config.register(getName(), "System", txtSystem, valuesSystem[0]);
Config.register(getName(), "Multithreading", txtMultithreading, valuesMultithreading[0]);
Config.register(getName(), "Display", txtDisplay, valuesDisplay[0]);
Config.register(getName(), "Directory", txtDirectory, System.getProperty("user.dir"));
getAction1Button().addActionListener(this);
getAction2Button().addActionListener(this);
table.addMouseListener(this);
return panel;
}
public void init() {
table.append(new String[] { "Path", txtPath.getText(), txtDirectory.getText(), "Change" });
table.append(new String[] { "Monitor", txtMonitor.getText(), "Monitor in table and in console", "Change" });
table.append(new String[] { "Stats", txtStats.getText(), "Compute stats (slow down)", "Change" });
table.append(new String[] { "Verbose", txtVerbose.getText(), "Level of messages in monitor", "Change" });
table.append(new String[] { "System", txtSystem.getText(), "Open the system window", "Change" });
table.append(new String[] { "Multithreading", txtMultithreading.getText(), "Activation of the multithreading", "Change" });
table.append(new String[] { "Display", txtDisplay.getText(), "Display result at the end", "Change" });
update();
}
public void update() {
setCommand(getCommand());
setSynopsis(txtDirectory.getText());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == getAction1Button()) {
for (int row = 0; row < table.getRowCount(); row++) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
setDefault(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
setDefault(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("stats"))
setDefault(row, valuesStats, txtStats);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
setDefault(row, valuesVerbose, txtVerbose);
if (table.getCell(row, 0).equalsIgnoreCase("system"))
setDefault(row, valuesSystem, txtSystem);
if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
setDefault(row, valuesMultithreading, txtMultithreading);
if (table.getCell(row, 0).equalsIgnoreCase("display"))
setDefault(row, valuesDisplay, txtDisplay);
}
}
if (e.getSource() == getAction2Button()) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtDirectory.setText(f.getAbsolutePath());
txtPath.setText(valuesPath[1]);
table.setCell(0, 1, txtPath.getText());
table.setCell(0, 2, txtDirectory.getText());
}
}
update();
}
@Override
public void close() {
}
@Override
public void mouseClicked(MouseEvent e) {
int row = table.getSelectedRow();
if (table.getSelectedColumn() == 3) {
if (table.getCell(row, 0).equalsIgnoreCase("path")) {
toggle(row, valuesPath, txtPath);
txtDirectory.setText(System.getProperty("user.dir"));
table.setCell(0, 2, System.getProperty("user.dir"));
}
if (table.getCell(row, 0).equalsIgnoreCase("monitor"))
toggle(row, valuesMonitor, txtMonitor);
if (table.getCell(row, 0).equalsIgnoreCase("stats"))
toggle(row, valuesStats, txtStats);
if (table.getCell(row, 0).equalsIgnoreCase("verbose"))
toggle(row, valuesVerbose, txtVerbose);
if (table.getCell(row, 0).equalsIgnoreCase("system"))
toggle(row, valuesSystem, txtSystem);
if (table.getCell(row, 0).equalsIgnoreCase("multithreading"))
toggle(row, valuesMultithreading, txtMultithreading);
if (table.getCell(row, 0).equalsIgnoreCase("display"))
toggle(row, valuesDisplay, txtDisplay);
}
update();
Command.command();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
private void toggle(int row, String values[], JTextField txt) {
for (int i = 0; i < values.length; i++) {
if (table.getCell(row, 1).equalsIgnoreCase(values[i])) {
int k = i == values.length - 1 ? 0 : i + 1;
table.setCell(row, 1, values[k]);
txt.setText(values[k]);
return;
}
}
setDefault(row, values, txt);
}
private void setDefault(int row, String values[], JTextField txt) {
table.setCell(row, 1, values[0]);
txt.setText(values[0]);
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
index 878a4de..0f5168e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/WatcherModule.java
@@ -1,186 +1,186 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
+import bilib.component.GridPanel;
+import bilib.tools.Files;
import deconvolution.Command;
import deconvolutionlab.Config;
-import lab.component.GridPanel;
-import lab.tools.Files;
public class WatcherModule extends AbstractModule implements ActionListener, KeyListener {
private JComboBox<String> cmbVerbose;
private JComboBox<String> cmbMonitor;
private JComboBox<String> cmbDisplay;
private JComboBox<String> cmbMultithreading;
private JComboBox<String> cmbPath;
private JTextField txtPath;
private JButton bnBrowse;
public WatcherModule(boolean expanded) {
super("Path & Watcher", "", "Default", "", expanded);
}
@Override
public String getCommand() {
String cmd = "";
if (cmbPath.getSelectedIndex() != 0)
cmd += " -path " + txtPath.getText();
if (cmbMultithreading.getSelectedIndex() != 0)
cmd += " -" + (String)cmbMultithreading.getSelectedItem();
if (cmbDisplay.getSelectedIndex() != 0)
cmd += " -" + (String)cmbDisplay.getSelectedItem();
if (cmbMonitor.getSelectedIndex() != 0)
cmd += " -" + (String)cmbMonitor.getSelectedItem();
if (cmbVerbose.getSelectedIndex() != 0)
cmd += " -" + (String)cmbVerbose.getSelectedItem();
return cmd;
}
@Override
public JPanel buildExpandedPanel() {
cmbVerbose = new JComboBox<String>(new String[] { "verbose log ", "verbose quiet ", "verbose prolix", "verbose mute" });
cmbDisplay = new JComboBox<String>(new String[] { "display final", "display no"});
cmbMonitor = new JComboBox<String>(new String[] { "monitor full", "monitor console", "monitor none"});
cmbMultithreading = new JComboBox<String>(new String[] { "multithreading enabled", "multithreading disabled"});
cmbPath = new JComboBox<String>(new String[] { "Current", "Specify"});
txtPath = new JTextField("", 30);
bnBrowse = new JButton("Browse");
GridPanel pn1 = new GridPanel(true, 3);
pn1.place(0, 0, 2, 1, "Working directory");
pn1.place(1, 0, cmbPath);
pn1.place(1, 1, bnBrowse);
pn1.place(2, 0, 2, 1, txtPath);
GridPanel pn2 = new GridPanel(true, 3);
pn2.place(2, 0, cmbVerbose);
pn2.place(2, 1, cmbMonitor);
pn2.place(3, 0, cmbDisplay);
pn2.place(3, 1, cmbMultithreading);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.add(pn1);
panel.add(pn2);
String dir = System.getProperty("user.dir");
Config.register(getName(), "verbose", cmbVerbose, cmbVerbose.getItemAt(0));
Config.register(getName(), "monitor", cmbMonitor, cmbMonitor.getItemAt(0));
Config.register(getName(), "display", cmbDisplay, cmbDisplay.getItemAt(0));
Config.register(getName(), "multithreading", cmbMultithreading, cmbMultithreading.getItemAt(0));
Config.register(getName(), "current", cmbPath, cmbPath.getItemAt(0));
Config.register(getName(), "path", txtPath, dir);
cmbPath.addActionListener(this);
txtPath.addKeyListener(this);
cmbVerbose.addActionListener(this);
cmbDisplay.addActionListener(this);
cmbMultithreading.addActionListener(this);
cmbMonitor.addActionListener(this);
bnBrowse.addActionListener(this);
return panel;
}
private void update() {
setCommand(getCommand());
if (cmbPath.getSelectedIndex() == 0) {
txtPath.setText(System.getProperty("user.dir"));
txtPath.setEnabled(false);
bnBrowse.setEnabled(false);
}
else {
txtPath.setEnabled(true);
bnBrowse.setEnabled(true);
}
setSynopsis(txtPath.getText());
Command.command();
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
if (e.getSource() == bnBrowse) {
File f = Files.browseDirectory(txtPath.getText());
if (f != null) {
txtPath.setText(f.getAbsolutePath());
}
}
else if (e.getSource() == cmbPath) {
if (cmbPath.getSelectedIndex() == 0) {
File f = new File(System.getProperty("user.dir"));
txtPath.setText(f.getAbsolutePath());
}
}
update();
}
@Override
public void close() {
cmbVerbose.removeActionListener(this);
cmbDisplay.removeActionListener(this);
cmbMultithreading.removeActionListener(this);
cmbMonitor.removeActionListener(this);
cmbPath.removeActionListener(this);
txtPath.removeKeyListener(this);
bnBrowse.removeActionListener(this);
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
update();
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
index 382d599..8d3ced9 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/Message.java
@@ -1,82 +1,82 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
+import bilib.tools.NumFormat;
import deconvolutionlab.system.SystemUsage;
-import lab.tools.NumFormat;
public class Message {
private static long id = 0;
private double chrono;
private String mem;
private Verbose level;
private String message;
private double progress;
public Message(Verbose level, String message, double chrono, double progress) {
id = id+1;
this.chrono = chrono;
this.mem = SystemUsage.getMemoryMB();
this.message = message;
this.level = level;
this.progress = progress;
}
public long getID() {
return id;
}
public String getMessage() {
return message;
}
public Verbose getLevel() {
return level;
}
public double getProgress() {
return progress;
}
public String formatProgress() {
return NumFormat.time(chrono) + " \t " + message + " (" + progress + "%)";
}
public String formatTab() {
return level.name() + " \t " + NumFormat.time(chrono) + " \t " + mem + " \t " + message;
}
public String[] formatArray() {
return new String[] {NumFormat.time(chrono), mem, message};
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
index 0e38608..69b6b5c 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/RunningMonitor.java
@@ -1,133 +1,133 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.table.DefaultTableModel;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.tools.NumFormat;
import deconvolutionlab.system.SystemUsage;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.NumFormat;
public class RunningMonitor implements AbstractMonitor {
private CustomizedTable table;
private JPanel panel;
private double chrono = System.nanoTime();
private double peak = 0;
public RunningMonitor(int width, int height) {
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Iteration", String.class, 60, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 4*100), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(40);
table.getColumnModel().getColumn(0).setMaxWidth(80);
table.getColumnModel().getColumn(1).setMinWidth(40);
table.getColumnModel().getColumn(1).setMaxWidth(80);
table.getColumnModel().getColumn(2).setMinWidth(40);
table.getColumnModel().getColumn(2).setMaxWidth(80);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JToolBar main = new JToolBar();
main.setFloatable(true);
main.setLayout(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public void reset() {
chrono = System.nanoTime();
peak = 0;
}
public JPanel getPanel() {
return panel;
}
public void show(String title) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
@Override
public void add(Message message) {
String msg = message.getMessage();
String iteration = "";
if (msg.startsWith("@")) {
String parts[] = msg.split(" ");
if (parts.length >= 1)
iteration = parts[0];
msg = msg.substring(parts[0].length(), msg.length()).trim();
}
String time = NumFormat.seconds(System.nanoTime()-chrono);
peak = Math.max(peak, SystemUsage.getHeapUsed());
String mem = NumFormat.bytes(peak);
String[] row = new String[] {time, mem, iteration, msg};
table.append(row);
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public String getName() {
return "running";
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
index a3f3fdd..750716e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/monitor/TableMonitor.java
@@ -1,150 +1,150 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.monitor;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
public class TableMonitor implements AbstractMonitor, ActionListener {
private CustomizedTable table;
private JButton bnClear = new JButton("Clear");
private HashMap<Long, Color> colors = new HashMap<Long, Color>();
private JPanel panel;
private String name;
public TableMonitor(String name, int width, int height) {
this.name = name;
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("#", Long.class, 60, false));
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 3 * 60), false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(0).setMinWidth(60);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.getColumnModel().getColumn(1).setMaxWidth(100);
table.getColumnModel().getColumn(1).setMinWidth(100);
table.getColumnModel().getColumn(2).setMaxWidth(100);
table.getColumnModel().getColumn(2).setMinWidth(100);
RowRenderer renderer = new RowRenderer();
for (int i = 0; i < 4; i++)
table.getColumnModel().getColumn(i).setCellRenderer(renderer);
JScrollPane scroll = new JScrollPane(table);
scroll.setPreferredSize(new Dimension(width, height));
JPanel main = new JPanel(new BorderLayout());
main.add(scroll, BorderLayout.CENTER);
bnClear.addActionListener(this);
panel = new JPanel(new BorderLayout());
panel.add(main);
panel.setBorder(BorderFactory.createEtchedBorder());
}
public JPanel getPanel() {
return panel;
}
@Override
public void clear() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
@Override
public void add(Message message) {
String msg[] = message.formatArray();
int n = msg.length;
Object[] row = new Object[n + 1];
row[0] = message.getID();
for (int i = 0; i < n; i++)
row[i + 1] = msg[i];
table.append(row);
Verbose level = message.getLevel();
Color c = new Color(0, 0, 0);
if (level == Verbose.Prolix)
c = new Color(255, 0, 0);
else if (level == Verbose.Quiet)
c = new Color(200, 200, 0);
colors.put(new Long(message.getID()), c);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnClear) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
}
}
@Override
public String getName() {
return name;
}
class RowRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (row >= 0) {
Long id = (Long) model.getValueAt(row, 0);
Color color = colors.get(id);
c.setForeground(color);
}
return c;
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
index 2aeeb79..57abb74 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/AbstractMeter.java
@@ -1,119 +1,119 @@
/*
* 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.component.CustomizedTable;
import deconvolutionlab.Constants;
-import lab.component.CustomizedTable;
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;
setBorder(BorderFactory.createEtchedBorder());
setPreferredSize(new Dimension(w, h));
setMinimumSize(new Dimension(w, 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 getName();
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 525acf3..0f00ac9 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FFTMeter.java
@@ -1,64 +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 java.io.File;
import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory;
+import bilib.tools.NumFormat;
import fft.FFT;
-import lab.tools.NumFormat;
public class FFTMeter extends AbstractMeter {
@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 getName() {
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 d636961..c0c099d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/FileMeter.java
@@ -1,91 +1,91 @@
/*
* 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 lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class FileMeter extends AbstractMeter {
@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 getName() {
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 183c775..3b3f3be 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/JavaMeter.java
@@ -1,79 +1,79 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.Graphics;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
-import lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class JavaMeter extends AbstractMeter {
@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 getName() {
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 6c42d7a..287943e 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/MemoryMeter.java
@@ -1,101 +1,101 @@
/*
* 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 lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class MemoryMeter extends AbstractMeter {
private double peak;
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 getName() {
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 9ea7da4..d50f35d 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/ProcessorMeter.java
@@ -1,104 +1,104 @@
/*
* 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 lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class ProcessorMeter extends AbstractMeter {
@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 getName() {
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/SystemInfo.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
index abfeb6f..32658e1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemInfo.java
@@ -1,287 +1,287 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
+import bilib.component.PanelImage;
+import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import fft.FFTPanel;
-import lab.component.PanelImage;
-import lab.tools.NumFormat;
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();
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);
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.getName());
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
index bc1fbe4..87c1f19 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemPanel.java
@@ -1,246 +1,246 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
+import bilib.component.PanelImage;
+import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import fft.FFTPanel;
-import lab.component.PanelImage;
-import lab.tools.NumFormat;
import signal.SignalCollector;
public class SystemPanel extends JPanel implements ActionListener, MouseListener {
private JPanel cards;
private String[] rates = new String[] { "1 s.", "0.5 s.", "0.2 s.", "0.1 s.", "10 s.", "5 s.", "2 s." };
private JButton bnRate = new JButton("1 s.");
private JButton bnClear = new JButton("Clear");
private Timer timer = new Timer();
private TimerTask updater = new Updater();
private MemoryMeter memory;
private ProcessorMeter processor;
private SignalMeter signal;
private FFTMeter fft;
private JavaMeter java;
private FileMeter file;
private int width = Constants.widthGUI;
private static SystemPanel instance;
private int rate = 0;
private static JFrame frame;
private ArrayList<AbstractMeter> meters = new ArrayList<AbstractMeter>();
public static SystemPanel getInstance(JFrame parent) {
if (instance == null) {
instance = new SystemPanel();
}
frame = parent;
return instance;
}
private SystemPanel() {
memory = new MemoryMeter();
processor = new ProcessorMeter();
signal = new SignalMeter();
fft = new FFTMeter();
java = new JavaMeter();
file = new FileMeter();
meters.add(memory);
meters.add(processor);
meters.add(signal);
meters.add(fft);
meters.add(java);
meters.add(file);
// Panel meters on top
JPanel meters = new JPanel(new GridLayout(2, 3));
meters.add(file);
meters.add(memory);
meters.add(processor);
meters.add(java);
meters.add(signal);
meters.add(fft);
bnClear.setToolTipText("Clear all the entries");
bnRate.setToolTipText("Choose the rate of refreshing the information");
JPanel pan = new JPanel(new GridLayout(2, 1));
pan.add(bnRate);
pan.add(bnClear);
restart();
// Panel Compact
PanelImage pnCompact = new PanelImage("celegans.jpg");
pnCompact.setPreferredSize(new Dimension(width, 20));
// Panel cards, compact is visible
cards = new JPanel(new CardLayout());
cards.add("collapse", pnCompact);
cards.add(signal.getName(), SignalCollector.getPanel(width, 200));
cards.add(memory.getName(), memory.getPanel(width, 200));
cards.add(processor.getName(), processor.getPanel(width, 200));
cards.add(fft.getName(), new FFTPanel(width, 200));
cards.add(java.getName(), java.getPanel(width, 200));
cards.add(file.getName(), file.getPanel(width, 200));
cards.setVisible(false);
JPanel top = new JPanel(new BorderLayout());
top.add(meters, BorderLayout.CENTER);
top.add(pan, BorderLayout.EAST);
setLayout(new BorderLayout());
add(top, BorderLayout.NORTH);
add(cards, BorderLayout.CENTER);
bnClear.addActionListener(this);
signal.addMouseListener(this);
memory.addMouseListener(this);
processor.addMouseListener(this);
java.addMouseListener(this);
file.addMouseListener(this);
fft.addMouseListener(this);
bnRate.addActionListener(this);
setMinimumSize(new Dimension(width, 70));
bnClear.setEnabled(signal.isExpanded());
Rectangle rect = Config.getDialog("System.Frame");
if (rect.x > 0 && rect.y > 0)
setLocation(rect.x, rect.y);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnRate) {
rate++;
if (rate >= rates.length)
rate = 0;
bnRate.setText(rates[rate]);
restart();
}
if (e.getSource() == bnClear) {
SignalCollector.clear();
}
}
public void update() {
for(AbstractMeter meter : meters)
meter.update();
}
public void restart() {
long refreshTime = (long) (NumFormat.parseNumber(bnRate.getText(), 1) * 1000);
if (updater != null) {
updater.cancel();
updater = null;
}
updater = new Updater();
timer.schedule(updater, 0, refreshTime);
}
private class Updater extends TimerTask {
@Override
public void run() {
update();
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getSource() instanceof AbstractMeter) {
AbstractMeter meter = (AbstractMeter) e.getSource();
if (meter.isExpanded()) {
meter.collapse();
cards.setVisible(false);
}
else for(AbstractMeter m : meters) {
if (m.isExpanded())
m.collapse();
meter.expand();
cards.setVisible(true);
}
((CardLayout) (cards.getLayout())).show(cards, meter.getName());
}
bnClear.setEnabled(signal.isExpanded());
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java b/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
index 89e5b6b..062c770 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/system/SystemUsage.java
@@ -1,121 +1,121 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.system;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
-import lab.tools.NumFormat;
+import bilib.tools.NumFormat;
public class SystemUsage {
public static String getMemoryMB() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
double c = 1.0 / (1024.0 * 1024.0);
double heap = mem.getHeapMemoryUsage().getUsed() * c;
return String.format("%6.1fMb ", heap);
}
public String getMemoryUsage() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
double c = 1.0 / (1024.0 * 1024.0);
double heap = mem.getHeapMemoryUsage().getUsed() * c;
double nonheap = mem.getNonHeapMemoryUsage().getUsed() * c;
return String.format("Heap:%6.1fMb NonHeap:%6.1fMb ", heap, nonheap);
}
public static String getMemory() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
String heap = NumFormat.bytes(mem.getHeapMemoryUsage().getUsed());
String max = NumFormat.bytes(mem.getHeapMemoryUsage().getMax());
return heap + "/" + max;
}
public static String getCores() {
String load = "" + Runtime.getRuntime().availableProcessors() + " cores";
return load;
}
public static double getHeapUsed() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
return mem.getHeapMemoryUsage().getUsed();
}
public static double getNonHeapUsed() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
return mem.getNonHeapMemoryUsage().getUsed();
}
public static double[] getHeap() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
double u = mem.getHeapMemoryUsage().getUsed();
double m = mem.getHeapMemoryUsage().getMax();
double i = mem.getHeapMemoryUsage().getInit();
return new double[] { i, u, m };
}
public static String getNonHeap() {
MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
double c = 1.0 / (1024.0 * 1024.0);
double u = mem.getNonHeapMemoryUsage().getUsed() * c;
double m = mem.getNonHeapMemoryUsage().getMax() * c;
double i = mem.getNonHeapMemoryUsage().getMax() * c;
return String.format("u=%3.2f m=%3.2f i=%3.2f Mb", u, m, i);
}
public static double getLoad() {
try {
OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
return os.getSystemLoadAverage();
}
catch (Exception ex) {
}
return 0;
}
public static double getAvailableSpace() {
File[] roots = File.listRoots();
for(File root : roots)
return root.getUsableSpace();
return 0;
}
public static double getTotalSpace() {
File[] roots = File.listRoots();
for(File root : roots)
return root.getTotalSpace();
return 0;
}
}
diff --git a/DeconvolutionLab2/src/fft/FFTPanel.java b/DeconvolutionLab2/src/fft/FFTPanel.java
index 1c50c45..9694991 100644
--- a/DeconvolutionLab2/src/fft/FFTPanel.java
+++ b/DeconvolutionLab2/src/fft/FFTPanel.java
@@ -1,86 +1,86 @@
package fft;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.component.HTMLPane;
+import bilib.tools.NumFormat;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.component.HTMLPane;
-import lab.tools.NumFormat;
import signal.Operations;
public class FFTPanel extends JPanel implements MouseListener {
private HTMLPane info;
private CustomizedTable table;
private ArrayList<AbstractFFTLibrary> libs;
public FFTPanel(int w, int h) {
super(new BorderLayout());
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Name", String.class, 120, false));
columns.add(new CustomizedColumn("Installed", String.class, 120, false));
columns.add(new CustomizedColumn("Multithreadable", String.class, 120, false));
columns.add(new CustomizedColumn("Location", String.class, Constants.widthGUI, false));
table = new CustomizedTable(columns, true);
table.setRowSelectionAllowed(true);
table.addMouseListener(this);
libs = FFT.getRegisteredLibraries();
for (AbstractFFTLibrary lib : libs) {
String name = lib.getLibraryName();
String installed = lib.isInstalled() ? "Yes" : "No";
String multit = lib.isMultithreadable() ? "Yes" : "No";
String location = lib.getLocation();
table.append(new String[] { name, installed, multit, location });
}
info = new HTMLPane(w, h-100);
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, table.getPane(w, 100), info.getPane());
split.setDividerLocation(0.5);
add(split, BorderLayout.CENTER);
table.setRowSelectionInterval(0, 0);
info.clear();
info.append("p", libs.get(0).getLicence());
}
@Override
public void mouseClicked(MouseEvent e) {
int i = table.getSelectedRow();
if (i<0)
return;
if (i>=libs.size())
return;
info.clear();
info.append("p", libs.get(i).getLicence());
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}
diff --git a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
index 5b90d23..7a865c7 100644
--- a/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
+++ b/DeconvolutionLab2/src/plugins/sage/deconvolutionlab/IcyImager.java
@@ -1,273 +1,227 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package plugins.sage.deconvolutionlab;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JDialog;
import javax.swing.JFrame;
import deconvolutionlab.Imaging;
import deconvolutionlab.Lab;
import icy.file.Saver;
import icy.gui.frame.IcyFrameEvent;
import icy.gui.frame.IcyFrameListener;
import icy.image.IcyBufferedImage;
import icy.imagej.ImageJUtil;
import icy.main.Icy;
import icy.sequence.Sequence;
import icy.type.DataType;
import icy.type.collection.array.Array1DUtil;
import ij.ImagePlus;
import ij.io.Opener;
import signal.ComplexComponent;
import signal.ComplexSignal;
import signal.RealSignal;
-public class IcyImager extends Imaging implements IcyFrameListener {
+public class IcyImager extends Imaging {
@Override
public Platform getPlatform() {
return Imaging.Platform.ICY;
}
@Override
public void setVisible(JDialog dialog, boolean modal) {
/*
IcyFrame icf = new IcyFrame();
icf.addFrameListener(this);
icf.setTitle(dialog.getTitle());
//dialog.setModal(modal);
icf.add(dialog.getContentPane());
//icf.add(panel);
icf.toFront();
icf.addToDesktopPane();
icf.setVisible(true);
*/
//Lab.setVisible(dialog, true);
dialog.pack();
dialog.setLocation(30, 30);
dialog.setVisible(true);
}
public static RealSignal create(Sequence seq) {
int nx = seq.getSizeX();
int ny = seq.getSizeY();
int nz = seq.getSizeZ();
RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
@Override
public RealSignal create() {
return build(Icy.getMainInterface().getActiveSequence());
}
@Override
public RealSignal create(String name) {
ArrayList<Sequence> sequences = Icy.getMainInterface().getSequences(name);
for(Sequence sequence : sequences)
if (sequence.getName().equals(name))
return build(sequence);
return null;
}
@Override
public RealSignal open(String filename) {
Opener opener = new Opener();
ImagePlus imp = opener.openImage(filename);
Sequence seq = ImageJUtil.convertToIcySequence(imp, null);
return build(seq);
}
@Override
public void show(ComplexSignal signal, String title, ComplexComponent complex) {
Sequence sequence = new Sequence();
for (int k = 0; k < signal.nz; k++) {
float[] plane = null;
switch(complex) {
case REAL: plane = signal.getRealXY(k); break;
case IMAGINARY: plane = signal.getImagXY(k); break;
case MODULE: plane = signal.getModuleXY(k); break;
default: plane = signal.getModuleXY_dB(k);
}
IcyBufferedImage image = new IcyBufferedImage(signal.nx, signal.ny, 1, DataType.FLOAT);
Array1DUtil.floatArrayToSafeArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, k, image);
}
sequence.setName(title);
Icy.getMainInterface().addSequence(sequence);
}
@Override
public void save(RealSignal signal, String filename, Imaging.Type type) {
Sequence sequence = build(signal, type);
File file = new File(filename);
Saver.save(sequence, file, false, true);
}
private RealSignal build(Sequence seq) {
int nx = seq.getSizeX();
int ny = seq.getSizeY();
int nz = seq.getSizeZ();
RealSignal signal = new RealSignal("icy-" + seq.getName(), nx, ny, nz);
for (int k = 0; k < nz; k++) {
float pixels[] = new float[nx * ny];
Array1DUtil.arrayToFloatArray(seq.getDataXY(0, k, 0), pixels, seq.isSignedDataType());
signal.setXY(k, pixels);
}
return signal;
}
private Sequence build(RealSignal signal, Imaging.Type type) {
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
Sequence sequence = new Sequence();
for (int z = 0; z < nz; z++) {
if (type == Imaging.Type.SHORT) {
short[] plane = Array1DUtil.arrayToShortArray(signal.data[z], false);
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.USHORT);
Array1DUtil.shortArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
else if (type == Imaging.Type.BYTE) {
byte[] plane = Array1DUtil.arrayToByteArray(signal.data[z]);
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.UBYTE);
Array1DUtil.byteArrayToArray(plane, image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
else {
IcyBufferedImage image = new IcyBufferedImage(nx, ny, 1, DataType.FLOAT);
Array1DUtil.floatArrayToSafeArray(signal.data[z], image.getDataXY(0), image.isSignedDataType());
image.dataChanged();
sequence.setImage(0, z, image);
}
}
return sequence;
}
@Override
public String getName() {
return "Icy";
}
@Override
public ContainerImage createContainer(String title) {
// TODO Auto-generated method stub
return null;
}
@Override
public void append(ContainerImage container, RealSignal signal, String title, Type type) {
// TODO Auto-generated method stub
}
@Override
public void show(RealSignal signal, String title, Type type, int z) {
Sequence sequence = build(signal, type);
sequence.setName(title);
Icy.getMainInterface().addSequence(sequence);
}
@Override
public String getSelectedImage() {
return null;
}
@Override
public boolean isSelectable() {
return false;
}
-
- @Override
- public void icyFrameOpened(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameClosing(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameClosed(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameIconified(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameDeiconified(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameActivated(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameDeactivated(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameInternalized(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
- @Override
- public void icyFrameExternalized(IcyFrameEvent e) {
- System.out.println("" + e);
- }
-
}
diff --git a/DeconvolutionLab2/src/signal/SignalCollector.java b/DeconvolutionLab2/src/signal/SignalCollector.java
index 89393c4..e370fe5 100644
--- a/DeconvolutionLab2/src/signal/SignalCollector.java
+++ b/DeconvolutionLab2/src/signal/SignalCollector.java
@@ -1,157 +1,157 @@
package signal;
import java.util.ArrayList;
import javax.swing.JScrollPane;
+import bilib.component.CustomizedColumn;
+import bilib.component.CustomizedTable;
+import bilib.tools.NumFormat;
import deconvolutionlab.system.SystemUsage;
-import lab.component.CustomizedColumn;
-import lab.component.CustomizedTable;
-import lab.tools.NumFormat;
public class SignalCollector {
private static long bytesReal = 0;
private static int countReal = 0;
private static long bytesComplex = 0;
private static int countComplex = 0;
private static double chrono = 0;
private static CustomizedTable table;
private static double progress = 0;
private static int countPeakComplex = 0;
private static int countPeakReal = 0;
private static long bytesPeakComplex = 0;
private static long bytesPeakReal = 0;
private static ArrayList<Signal> signals;
protected final static int NOTIFICATION_RATE = 25;
static {
bytesReal = 0;
countReal = 0;
bytesComplex = 0;
countComplex = 0;
signals = new ArrayList<Signal>();
chrono = System.nanoTime();
ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
columns.add(new CustomizedColumn("Time", String.class, 100, false));
columns.add(new CustomizedColumn("Name", String.class, 600, false));
columns.add(new CustomizedColumn("Dimension", String.class, 60, false));
columns.add(new CustomizedColumn("Count", String.class, 100, false));
columns.add(new CustomizedColumn("Total", String.class, 100, false));
columns.add(new CustomizedColumn("Memory", String.class, 100, false));
table = new CustomizedTable(columns, true);
table.getColumnModel().getColumn(4).setMaxWidth(100);
table.getColumnModel().getColumn(4).setMinWidth(100);
}
public static JScrollPane getPanel(int w, int h) {
return table.getPane(w, h);
}
public static String sumarize() {
String r = "Signals: " + NumFormat.bytes(bytesReal + bytesComplex);
return r;
}
public static void clear() {
for(Signal signal : signals) {
for (int z = 0; z < signal.nz; z++)
signal.data[z] = new float[1];
}
signals.clear();
table.removeRows();
}
public static double getProgress() {
return progress;
}
public static void setProgress(double p) {
progress = p;
}
public static void marker(String msg) {
String row[] = { "", msg, "", "", "", "" };
table.append(row);
}
public static void alloc(Signal signal) {
if (signal == null) {
marker("error in allocating");
return;
}
signals.add(signal);
addTable(signal, 1);
}
public static void free(Signal signal) {
if (signal == null) {
marker("error in freeing");
return;
}
for (int z = 0; z < signal.nz; z++)
signal.data[z] = new float[1];
signals.remove(signal);
addTable(signal, -1);
signal = null;
}
public static void addTable(Signal signal, int sign) {
boolean complex = signal instanceof ComplexSignal;
int nx = signal.nx;
int ny = signal.ny;
int nz = signal.nz;
long b = sign * (nx * ny * nz * 4 * (complex ? 2 : 1));
if (complex) {
bytesComplex += b;
countComplex += sign;
}
else {
bytesReal += b;
countReal += sign;
}
bytesPeakComplex = Math.max(bytesPeakComplex, bytesComplex);
bytesPeakReal = Math.max(bytesPeakReal, bytesReal);
countPeakComplex = Math.max(countPeakComplex, countComplex);
countPeakReal = Math.max(countPeakReal, countReal);
String m = NumFormat.bytes(SystemUsage.getHeapUsed());
String t = NumFormat.time(System.nanoTime() - chrono);
String dim = "" + nx + "x" + ny + "x" + nz;
String c = "" + (countReal + countComplex);
String a = NumFormat.bytes(bytesReal + bytesComplex);
String row[] = { t, (sign > 0 ? "+" : "-") + signal.name, dim, c, a, m };
table.append(row);
}
public static int getCountSignals() {
return countComplex + countReal;
}
public static long getBytesSignals() {
return bytesComplex + bytesReal;
}
public static long getBytesPeakSignals() {
return bytesPeakComplex + bytesPeakReal;
}
public static int getCountPeakSignals() {
return countPeakComplex + countPeakReal;
}
public static void resetSignals() {
countPeakComplex = 0;
countPeakReal = 0;
bytesPeakComplex = 0;
bytesPeakReal = 0;
countComplex = 0;
countReal = 0;
bytesComplex = 0;
bytesReal = 0;
}
}

Event Timeline