Page MenuHomec4science

No OneTemporary

File Metadata

Created
Sat, May 18, 14:56
diff --git a/DeconvolutionLab2/DeconvolutionLab2.config b/DeconvolutionLab2/DeconvolutionLab2.config
index fa32aa7..faf4e07 100644
--- a/DeconvolutionLab2/DeconvolutionLab2.config
+++ b/DeconvolutionLab2/DeconvolutionLab2.config
@@ -1,84 +1,84 @@
#DeconvolutionLab2 [Beta 1]
#DeconvolutionLab2 [Beta 1]
-#Tue Feb 07 19:01:05 CET 2017
+#Wed Feb 08 13:46:16 CET 2017
Algorithm.FISTA.iterations=10
Algorithm.FISTA.reg=0.1
Algorithm.FISTA.scale=3
Algorithm.FISTA.step=1.0
Algorithm.FISTA.wavelets=Haar
Algorithm.ICTM.iterations=10
Algorithm.ICTM.reg=0.1
Algorithm.ICTM.step=1.0
Algorithm.ISTA.iterations=10
Algorithm.ISTA.reg=0.1
Algorithm.ISTA.scale=3
Algorithm.ISTA.step=1.0
Algorithm.ISTA.wavelets=Haar
Algorithm.LW+.iterations=10
Algorithm.LW+.step=1.0
Algorithm.LW.iterations=10
Algorithm.LW.step=1.0
Algorithm.RIF.reg=0.1
Algorithm.RL.iterations=10
Algorithm.RLTV.reg=0.1
Algorithm.SIM.gaussian.mean=0.0
Algorithm.SIM.gaussian.stdev=1.0
Algorithm.SIM.poisson=0.0
Algorithm.TM.iterations=10
Algorithm.TM.reg=0.1
Algorithm.TM.step=1.0
Algorithm.TRIF.reg=0.1
Algorithm.VC.iterations=10
Algorithm.VC.step=1.0
Algorithm.algorithm=Richardson-Lucy
Border.apoxy=Uniform
Border.apoz=Uniform
Border.extxy=0
Border.extz=0
Border.normalization=1
Border.padxy=None
Border.padz=None
Controller.constraint.enable=false
Controller.constraint.snapshot=1
Controller.constraint.value=No
Controller.reference.enable=false
Controller.reference.snapshot=1
Controller.reference.value=
Controller.residu.enable=false
Controller.residu.snapshot=1
Controller.residu.value=0.01
Controller.savestats.enable=false
Controller.savestats.snapshot=1
Controller.savestats.value=Stats
Controller.showstats.enable=false
Controller.showstats.snapshot=1
Controller.showstats.value=Stats
DeconvolutionLab.MainDialog.location.h=608
DeconvolutionLab.MainDialog.location.w=502
DeconvolutionLab.MainDialog.location.x=337
DeconvolutionLab.MainDialog.location.y=53
Fourier.dim=XYZ
Fourier.epsilon=1E-6
Fourier.fft=Academic
Image.image.row0=RandomLines;synthetic;RandomLines 100.0 0.0 300.0 size 300 300 32 ;null
Image.image.row1=logo-h360.png;file;/Users/dsage/Desktop/logo-h360.png;null
Image.image.row2=logo-psf.png;file;/Users/dsage/Desktop/logo-psf.png;null
Image.image.selected=RandomLines;synthetic;RandomLines 100.0 0.0 300.0 size 300 300 32 ;null
Language.headless=Run (Headless)
Language.job=Job
Language.language=Command line
-PSF.psf.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+PSF.psf.row0=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
PSF.psf.row1=AirySimulated;synthetic;AirySimulated 100.0 0.0 10.0 size 128 128 32 ;null
PSF.psf.row2=AirySimulated;synthetic;AirySimulated 100.0 0.0 1.0 size 128 128 32 ;null
PSF.psf.row3=AirySimulated;synthetic;AirySimulated 100.0 0.0 10.0 10.0 size 128 128 32 ;null
PSF.psf.row4=Airy;synthetic;Airy 100.0 0.0 10.0 10.0 size 128 128 32 ;null
PSF.psf.row5=Airy;synthetic;Airy 100.0 0.0 1.0 size 128 128 32 ;null
-PSF.psf.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;
+PSF.psf.selected=Cube;synthetic;Cube 100.0 0.0 10.0 1.0 size 128 128 32 ;null
Watcher.disable.console=false
Watcher.disable.display=false
Watcher.disable.multithreading=false
Watcher.disable.table=false
Watcher.path=/Users/dsage/git/deconvolution/DeconvolutionLab2
Watcher.time.value=3600
Watcher.time=No time limitation
Watcher.verbose=Verbose\: log
diff --git a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
index 5b8d8e8..07f97e1 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/dialog/LabDialog.java
@@ -1,369 +1,369 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.dialog;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import deconvolution.Command;
import deconvolution.Deconvolution;
import deconvolution.DeconvolutionDialog;
import deconvolutionlab.Config;
import deconvolutionlab.Constants;
import deconvolutionlab.Lab;
import deconvolutionlab.Platform;
import deconvolutionlab.modules.AboutModule;
import deconvolutionlab.modules.AbstractModule;
import deconvolutionlab.modules.AlgorithmModule;
import deconvolutionlab.modules.BatchModule;
import deconvolutionlab.modules.BorderModule;
import deconvolutionlab.modules.CommandModule;
import deconvolutionlab.modules.ConfigModule;
import deconvolutionlab.modules.ControllerModule;
import deconvolutionlab.modules.FFTModule;
import deconvolutionlab.modules.GroupedModulePanel;
import deconvolutionlab.modules.ImageModule;
import deconvolutionlab.modules.LanguageModule;
import deconvolutionlab.modules.LicenceModule;
import deconvolutionlab.modules.OutputModule;
import deconvolutionlab.modules.PSFModule;
import deconvolutionlab.modules.WatcherModule;
import lab.component.JPanelImage;
import lab.system.SystemPanel;
public class LabDialog extends JDialog implements ComponentListener, ActionListener, ChangeListener, WindowListener {
private JTabbedPane tab = new JTabbedPane();
private JButton bnHelp = new JButton("Help");
private JButton bnClose = new JButton("Close");
private JButton bnQuit = new JButton("Quit");
private JButton bnBatch = new JButton("Batch");
private JButton bnRun = new JButton("Run");
private JButton bnLaunch = new JButton("Launch");
private JButton bnSystem = new JButton("System");
private ImageModule image;
private PSFModule psf;
private AlgorithmModule algo;
private AboutModule about;
private LicenceModule licence;
private OutputModule output;
private FFTModule fourier;
private BorderModule border;
private ConfigModule config;
private BatchModule batch;
private LanguageModule language;
private CommandModule command;
private WatcherModule watcher;
private ControllerModule controller;
private GroupedModulePanel panelDeconv;
private GroupedModulePanel panelAdvanc;
private GroupedModulePanel panelScript;
private GroupedModulePanel panelAbout;
private AbstractModule modules[];
public LabDialog() {
super(new JFrame(), Constants.name);
image = new ImageModule(false);
psf = new PSFModule(false);
algo = new AlgorithmModule(true);
output = new OutputModule(true);
fourier = new FFTModule(false);
border = new BorderModule(false);
controller = new ControllerModule(false);
batch = new BatchModule(false);
language = new LanguageModule(false);
about = new AboutModule(true);
licence = new LicenceModule(false);
config = new ConfigModule(false);
command = new CommandModule();
watcher = new WatcherModule(false);
doDialog();
modules = new AbstractModule[] { image, psf, algo, output, controller, border, fourier, watcher, batch };
Command.active(modules, command);
Command.command();
addWindowListener(this);
addComponentListener(this);
((GroupedModulePanel) tab.getSelectedComponent()).organize();
setMinimumSize(new Dimension(500, 500));
Config.registerFrame("DeconvolutionLab", "MainDialog", this);
pack();
setVisible(true);
Config.load();
sizeModule();
Command.command();
image.update();
psf.update();
output.update();
}
private void doDialog() {
panelDeconv = new GroupedModulePanel(buildDeconvolutionPanel(), this);
panelAdvanc = new GroupedModulePanel(buildAdvancedPanel(), this);
panelScript = new GroupedModulePanel(buildProgrammingPanel(), this);
panelAbout = new GroupedModulePanel(buildAboutPanel(), this);
JPanelImage bottom = new JPanelImage("celegans.jpg");
bottom.setLayout(new GridLayout(1, 7));
Border b2 = BorderFactory.createEmptyBorder(10, 10, 10, 10);
bottom.setBorder(b2);
bottom.add(bnHelp);
bottom.add(bnSystem);
- bottom.add(bnQuit);
+ //bottom.add(bnQuit);
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);
JPanel base = new JPanel(new BorderLayout());
base.add(bottom, BorderLayout.CENTER);
//base.add(statusBar, BorderLayout.SOUTH);
//PanelImage pi = new PanelImage("logo.png", 380, 75);
//pi.setPreferredSize(new Dimension(400, 75));
//add(pi, BorderLayout.NORTH);
add(tab, BorderLayout.CENTER);
add(base, BorderLayout.SOUTH);
bnBatch.addActionListener(this);
bnRun.addActionListener(this);
bnLaunch.addActionListener(this);
bnClose.addActionListener(this);
bnQuit.addActionListener(this);
bnHelp.addActionListener(this);
bnSystem.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnHelp) {
Lab.help();
}
else if (e.getSource() == bnSystem) {
SystemPanel.show(400, 400);
}
else if (e.getSource() == bnClose) {
Config.store();
dispose();
}
else if (e.getSource() == bnQuit) {
dispose();
}
else if (e.getSource() == bnBatch) {
tab.setSelectedIndex(2);
batch.expand();
sizeModule();
new BatchDialog(batch);
}
else if (e.getSource() == bnLaunch) {
new Deconvolution(Command.command()).launch("", false);
}
else if (e.getSource() == bnRun) {
new Deconvolution(Command.command()).deconvolve(false);
}
}
@Override
public void stateChanged(ChangeEvent e) {
((GroupedModulePanel) tab.getSelectedComponent()).organize();
Command.command();
}
private ArrayList<AbstractModule> buildDeconvolutionPanel() {
ArrayList<AbstractModule> list = new ArrayList<AbstractModule>();
list.add(image);
list.add(psf);
list.add(algo);
list.add(watcher);
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;
}
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
Config.store();
dispose();
}
@Override
public void windowClosed(WindowEvent e) {
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
private void close() {
for (AbstractModule module : modules)
module.close();
bnLaunch.removeActionListener(this);
bnRun.removeActionListener(this);
bnBatch.removeActionListener(this);
bnClose.removeActionListener(this);
bnHelp.removeActionListener(this);
removeWindowListener(this);
}
@Override
public void dispose() {
super.dispose();
if (Lab.getPlatform() == Platform.STANDALONE) System.exit(0);
}
@Override
public void componentResized(ComponentEvent e) {
sizeModule();
}
@Override
public void componentMoved(ComponentEvent e) {
Point p = this.getLocation();
p.x += this.getWidth();
DeconvolutionDialog.setLocationLaunch(p);
}
@Override
public void componentShown(ComponentEvent e) {
sizeModule();
}
@Override
public void componentHidden(ComponentEvent e) {
}
public void sizeModule() {
if (tab.getSelectedIndex() == 0) sizePanel(panelDeconv);
if (tab.getSelectedIndex() == 1) sizePanel(panelAdvanc);
if (tab.getSelectedIndex() == 2) sizePanel(panelScript);
if (tab.getSelectedIndex() == 3) sizePanel(panelAbout);
}
private void sizePanel(GroupedModulePanel panel) {
Dimension dim = getSize();
int hpc = 60;
int npc = hpc * panel.getModules().size();
Dimension small = new Dimension(dim.width, hpc);
Dimension large = new Dimension(dim.width, dim.height - npc);
for (AbstractModule module : panel.getModules()) {
if (module.isExpanded()) {
module.setPreferredSize(large);
module.setMaximumSize(large);
module.setMinimumSize(small);
module.getExpandedPanel().setPreferredSize(large);
module.getExpandedPanel().setMaximumSize(large);
module.getExpandedPanel().setMinimumSize(small);
}
else {
module.setPreferredSize(small);
module.setMaximumSize(small);
module.setMinimumSize(small);
module.getCollapsedPanel().setPreferredSize(small);
module.getCollapsedPanel().setMaximumSize(small);
module.getCollapsedPanel().setMinimumSize(small);
}
}
}
}
diff --git a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
index 1f54884..baf3073 100644
--- a/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
+++ b/DeconvolutionLab2/src/deconvolutionlab/modules/AbstractModule.java
@@ -1,227 +1,233 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package deconvolutionlab.modules;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.Font;
+import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public abstract class AbstractModule extends JPanel implements ActionListener {
private JButton bnTitle;
private JButton bnSynopsis;
private JButton bnAction1 = new JButton();
private JButton bnAction2 = new JButton();
private JLabel lblCommand;
private JButton bnExpand;
private CardLayout card = new CardLayout();
private JPanel space = new JPanel(card);
private boolean expanded = false;
private GroupedModulePanel mpns;
private JPanel pnExpanded;
private JPanel pnCollapsed;
private String name;
private String key;
private int heightButton = 22;
public AbstractModule(String name, String key, String action1, String action2, boolean expanded) {
this.name = name;
this.key = key;
pnCollapsed = buildCollapsedPanel();
pnExpanded = buildExpandedPanel();
setLayout(new BorderLayout());
this.expanded = expanded;
bnTitle = new JButton("<html><b>" + name + "</b></html>");
bnTitle.setHorizontalAlignment(SwingConstants.LEFT);
bnTitle.setPreferredSize(new Dimension(150, heightButton));
bnTitle.setMaximumSize(new Dimension(250, heightButton));
bnTitle.setMinimumSize(new Dimension(120, heightButton));
+ bnTitle.setMargin(new Insets(1, 1, 1, 1));
bnTitle.addActionListener(this);
bnSynopsis = new JButton("");
bnSynopsis.setHorizontalAlignment(SwingConstants.LEFT);
bnSynopsis.setPreferredSize(new Dimension(200, heightButton));
+ bnSynopsis.setMargin(new Insets(1, 1, 1, 1));
bnSynopsis.addActionListener(this);
bnExpand = new JButton("\u25BA");
Font font = bnExpand.getFont();
bnExpand.setFont(new Font(font.getFamily(), font.getStyle(), font.getSize()-3));
bnExpand.setPreferredSize(new Dimension(40, heightButton));
bnExpand.setMaximumSize(new Dimension(40, heightButton));
bnExpand.setMinimumSize(new Dimension(40, heightButton));
+ bnExpand.setMargin(new Insets(1, 1, 1, 1));
bnExpand.addActionListener(this);
JPanel tool0 = new JPanel(new BorderLayout());
JPanel tool1 = new JPanel(new BorderLayout());
tool1.add(bnExpand, BorderLayout.WEST);
tool1.add(bnTitle, BorderLayout.EAST);
tool0.add(tool1, BorderLayout.WEST);
tool0.add(bnSynopsis, BorderLayout.CENTER);
JPanel toola = null;
if (!action1.equals("")) {
bnAction1.setText(action1);
bnAction1.setPreferredSize(new Dimension(70, heightButton));
+ bnAction1.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction1, BorderLayout.WEST);
}
if (!action2.equals("")) {
bnAction2.setText(action2);
bnAction2.setPreferredSize(new Dimension(70, heightButton));
+ bnAction2.setMargin(new Insets(1, 1, 1, 1));
if (toola == null)
toola = new JPanel(new BorderLayout());
toola.add(bnAction2, BorderLayout.EAST);
}
if (toola != null)
tool0.add(toola, BorderLayout.EAST);
space.add(pnExpanded, "expand");
space.add(pnCollapsed, "collapse");
add(tool0, BorderLayout.NORTH);
add(space, BorderLayout.CENTER);
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
if (expanded)
expand();
else
collapse();
setPreferredSize(pnCollapsed.getPreferredSize());
}
public JPanel buildCollapsedPanel() {
JPanel panel = new JPanel(new BorderLayout());
lblCommand = new JLabel("");
lblCommand.setBorder(BorderFactory.createEtchedBorder());
lblCommand.setHorizontalAlignment(SwingConstants.LEFT);
lblCommand.setPreferredSize(new Dimension(500, 32));
panel.add(lblCommand, BorderLayout.NORTH);
lblCommand.setMinimumSize(new Dimension(500, 36));
return panel;
}
public abstract JPanel buildExpandedPanel();
public abstract String getCommand();
public abstract void close();
public JButton getAction1Button() {
return bnAction1;
}
public JButton getAction2Button() {
return bnAction2;
}
@Override
public String getName() {
return name;
}
public String getKey() {
return key;
}
public String getTitle() {
return bnTitle.getText();
}
public void setCommand(String command) {
lblCommand.setText("<html><p style=\"font-family: monospace\"><small>" + command + "</small></p></html>");
}
public void setSynopsis(String synopsis) {
bnSynopsis.setText(synopsis);
}
public JPanel getCollapsedPanel() {
return pnCollapsed;
}
public JPanel getExpandedPanel() {
return pnExpanded;
}
public void setMultipleModulePanel(GroupedModulePanel mpns) {
this.mpns = mpns;
}
@Override
public Dimension getPreferredSize() {
if (expanded)
return pnExpanded.getPreferredSize();
else
return pnCollapsed.getPreferredSize();
}
public boolean isExpanded() {
return expanded;
}
public void collapse() {
expanded = false;
card.show(space, "collapse");
bnExpand.setText("\u25BA");
}
public void expand() {
expanded = true;
card.show(space, "expand");
bnExpand.setText("\u25BC");
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == bnTitle || e.getSource() == bnExpand || e.getSource() == bnSynopsis) {
if (expanded) {
collapse();
}
else {
for (AbstractModule module : mpns.getModules())
module.collapse();
expand();
}
mpns.organize();
}
}
}
diff --git a/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java b/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
index 726b107..2691b8d 100644
--- a/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
+++ b/DeconvolutionLab2/src/fft/fftw/FFTWLibrary.java
@@ -1,190 +1,201 @@
/*
* DeconvolutionLab2
*
* Conditions of use: You are free to use this software for research or
* educational purposes. In addition, we expect you to include adequate
* citations and acknowledgments whenever you present or publish results that
* are based on it.
*
* Reference: DeconvolutionLab2: An Open-Source Software for Deconvolution
* Microscopy D. Sage, L. Donati, F. Soulez, D. Fortun, G. Schmit, A. Seitz,
* R. Guiet, C. Vonesch, M Unser, Methods of Elsevier, 2017.
*/
/*
* Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
*
* This file is part of DeconvolutionLab2 (DL2).
*
* DL2 is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DL2 is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DL2. If not, see <http://www.gnu.org/licenses/>.
*/
package fft.fftw;
import java.io.File;
import java.security.CodeSource;
import deconvolutionlab.monitor.Monitors;
import fft.AbstractFFTLibrary;
import jfftw.complex.nd.Plan;
public class FFTWLibrary extends AbstractFFTLibrary {
private String location;
public FFTWLibrary(Monitors monitors) {
String path = "";
boolean found = false;
if (!found) {
try {
CodeSource code = FFTWLibrary.class.getProtectionDomain().getCodeSource();
File file = new File(code.getLocation().toURI().getPath());
path = file.getParentFile().getPath() + File.separator + "FFTW" + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
CodeSource code = FFTWLibrary.class.getProtectionDomain().getCodeSource();
File file = new File(code.getLocation().toURI().getPath());
path = file.getParentFile().getPath() + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
path = System.getProperty("user.home") + File.separator + "FFTW" + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found) {
try {
path = System.getProperty("user.home") + File.separator;
found = existsWidsom(monitors, path);
location = path;
}
catch (Exception ex) {
monitors.log("FFTW Widsom not found in : " + path);
location = "Not found in " + path;
found = false;
}
}
if (!found)
return;
loadLibraries(monitors, path);
try {
new Plan(new int[] { 20, 20, 20 }, Plan.FORWARD, Plan.ESTIMATE | Plan.IN_PLACE | Plan.USE_WISDOM);
ffts.add(new FFTW3D());
installed = true;
}
catch (UnsatisfiedLinkError ex) {
ex.printStackTrace();
installed = false;
}
}
@Override
public String getLocation() {
return location;
}
@Override
public boolean isMultithreadable() {
return true;
}
@Override
public String getCredit() {
return "http://www.fftw.org (FFTW Version 2)";
}
@Override
public String getLibraryName() {
return "FFTW2";
}
@Override
public String getLicence() {
return "<h1>FFTW Version 2, " + "<p>http://www.fftw.org" + "<p>FFTW 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 2 of the License, or " + "(at your option) any later version.";
}
private static void loadLibraries(Monitors monitors, String path) {
try {
String osname = System.getProperty("os.name");
-
- if (osname.startsWith("Windows")) {
+
+ if (osname.startsWith("Linux")) {
+ String osarch = System.getProperty("os.arch");
+ if (osarch.contains("64")) {
+ System.load(path + "libFFTWJNI64.so");
+ monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "libFFTWJNI64.so");
+ }
+ else {
+ System.load(path + "libFFTWJNI32.so");
+ monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "libFFTWJNI32.so");
+ }
+ }
+ else if (osname.startsWith("Windows")) {
String osarch = System.getProperty("os.arch");
if (osarch.contains("64")) {
System.load(path + "FFTWJNIWin64.dll");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "FFTWJNIWin64.dll");
}
else {
System.load(path + "FFTWJNIWin32.dll");
monitors.log("Loading library FFTW for " + osarch + " " + osname + " " + path + "FFTWJNIWin32.dll");
}
}
else if (osname.startsWith("Mac")) {
System.load(path + "libFFTWJNIMac.jnilib");
monitors.log("Loading library FFTW for " + osname + " " + path + "libFFTWJNIMac.jnilib");
}
else {
monitors.log("FFTW is not provided for the architecture : " + osname);
}
}
catch (Exception ex) {
monitors.log("FFTW not found in : " + path);
System.out.println(">>" + ex.toString());
}
}
private static boolean existsWidsom(Monitors monitors, String path) {
boolean found = false;
if (new File(path + "Wisdom").exists()) {
monitors.log("FFTW found in : " + path);
found = true;
}
else {
monitors.log("FFTW Widsom not found in : " + path);
found = false;
}
return found;
}
}

Event Timeline