psfs = CollectionPSF.getStandardCollection();
88 | buildButtons();
89 | panel = new MainPanel(settings, buttons, psfs, luts, types, this);
90 | frame = new JFrame(About.title());
91 | frame.getContentPane().add(panel);
92 | frame.setResizable(false);
93 | frame.pack();
94 | GUI.center(frame);
95 | frame.setVisible(true);
96 | }
97 |
98 | private void buildButtons() {
99 | buttons.clear();
100 | buttons.put("run", ButtonFactory.run(false));
101 | buttons.put("stop", ButtonFactory.stop(false));
102 | buttons.put("settings", ButtonFactory.prefs(false));
103 | buttons.put("help", ButtonFactory.help(false));
104 | buttons.put("about", ButtonFactory.about(false));
105 | buttons.put("close", ButtonFactory.close(false));
106 |
107 | buttons.get("close").addActionListener(this);
108 | }
109 |
110 | public void close() {
111 | if (panel != null) {
112 | settings.storeValue("PSF-shortname", panel.getSelectedPSFShortname());
113 | panel.onClosed();
114 | }
115 | if (frame != null)
116 | frame.dispose();
117 | settings.storeRecordedItems();
118 | }
119 |
120 | @Override
121 | public void actionPerformed(ActionEvent event) {
122 | JButton bn = (JButton) event.getSource();
123 | if (bn == buttons.get("close"))
124 | close();
125 | }
126 |
127 | @Override
128 | public void onFailure(Pool pool, JobEvent event) {
129 | panel.setEnabledRun(true);
130 | Exception ex = event.getException();
131 | if (ex != null) {
132 | IJ.log(" POOL " + pool.getName() + " " + pool.size());
133 | // event.getJob().getPool().die();
134 | StackTraceElement elements[] = ex.getStackTrace();
135 | IJ.log("" + event);
136 | for (StackTraceElement element : elements)
137 | IJ.log(element.toString());
138 | }
139 | }
140 |
141 | @Override
142 | public void onEvent(Pool pool, JobEvent event) {
143 | }
144 |
145 | @Override
146 | public void onSuccess(Pool pool, JobEvent event) {
147 | if (event.getJob() instanceof PSF) {
148 | int type = panel.getSelectedType();
149 | int lut = panel.getSelectedLUT();
150 | PSF psf = (PSF) event.getSource();
151 | panel.finish();
152 |
153 | ImagePlus imp = createImagePlus(psf, type);
154 | display(psf, imp, lut);
155 | JFrame frame = new JFrame("Characterization of PSF");
156 | JTabbedPane tab = new JTabbedPane();
157 | tab.add("Summary", new SummaryPanel(psf));
158 | tab.add("Plane by plane", new ResultPlanesTable(psf));
159 | frame.getContentPane().add(tab);
160 | frame.pack();
161 | frame.setVisible(true);
162 | }
163 | panel.setEnabledRun(true);
164 | }
165 |
166 | public ImagePlus createImagePlus(PSF psf, int type) {
167 | String name = psf.getShortname();
168 | Data3D data = psf.getData();
169 | int nx = data.nx;
170 | int ny = data.ny;
171 | int nz = data.nz;
172 |
173 | ImageStack stack = new ImageStack(nx, ny);
174 | for (int z = 0; z < nz; z++) {
175 | if (type == 0)
176 | stack.addSlice(new FloatProcessor(nx, ny, data.createAsFloat(z)));
177 | else if (type == 2)
178 | stack.addSlice(new ShortProcessor(nx, ny, data.createAsShort(z), null));
179 | else if (type == 1)
180 | stack.addSlice(new ByteProcessor(nx, ny, data.createAsByte(z)));
181 | }
182 | return new ImagePlus("PSF " + name, stack);
183 | }
184 |
185 | private void display(PSF psf, ImagePlus imp, int lut) {
186 | imp.show();
187 | imp.setSlice(imp.getStackSize() / 2);
188 | imp.getCalibration().pixelHeight = psf.resLateral;
189 | imp.getCalibration().pixelWidth = psf.resLateral;
190 | imp.getCalibration().pixelDepth = psf.resAxial;
191 | imp.getCalibration().setUnit("nm");
192 | try {
193 | IJ.run((String) luts[lut]);
194 | }
195 | catch (Exception e) {
196 | IJ.error("Unknown LUT " + (String) luts[lut]);
197 | }
198 | }
199 |
200 | }
201 |
--------------------------------------------------------------------------------
/src/matlab/Converter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * PSFGenerator
3 | *
4 | * Authors: Daniel Sage and Hagai Kirshner
5 | * Organization: Biomedical Imaging Group (BIG), Ecole Polytechnique Federale de Lausanne
6 | * Address: EPFL-STI-IMT-LIB, 1015 Lausanne, Switzerland
7 | * Information: http://bigwww.epfl.ch/algorithms/psfgenerator/
8 | *
9 | * References:
10 | * [1] H. Kirshner, F. Aguet, D. Sage, M. Unser
11 | * 3-D PSF Fitting for Fluorescence Microscopy: Implementation and Localization Application
12 | * Journal of Microscopy, vol. 249, no. 1, pp. 13-25, January 2013.
13 | * Available at: http://bigwww.epfl.ch/publications/kirshner1301.html
14 | *
15 | * [2] A. Griffa, N. Garin, D. Sage
16 | * Comparison of Deconvolution Software in 3D Microscopy: A User Point of View
17 | * G.I.T. Imaging & Microscopy, vol. 12, no. 1, pp. 43-45, March 2010.
18 | * Available at: http://bigwww.epfl.ch/publications/griffa1001.html
19 | *
20 | * Conditions of use:
21 | * Conditions of use: You are free to use this software for research or
22 | * educational purposes. In addition, we expect you to include adequate
23 | * citations and acknowledgments whenever you present or publish results that
24 | * are based on it.
25 | */
26 |
27 | /**
28 | * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
29 | *
30 | * This file is part of PSFGenerator.
31 | *
32 | * PSFGenerator is free software: you can redistribute it and/or modify it under the
33 | * terms of the GNU General Public License as published by the Free Software
34 | * Foundation, either version 3 of the License, or (at your option) any later
35 | * version.
36 | *
37 | * PSFGenerator is distributed in the hope that it will be useful, but WITHOUT ANY
38 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
39 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
40 | *
41 | * You should have received a copy of the GNU General Public License along with
42 | * PSFGenerator. If not, see .
43 | */
44 |
45 | package matlab;
46 |
47 | import ij.ImagePlus;
48 | import ij.ImageStack;
49 | import ij.process.ByteProcessor;
50 | import ij.process.ColorProcessor;
51 | import ij.process.FloatProcessor;
52 | import ij.process.ShortProcessor;
53 |
54 | public class Converter {
55 |
56 | /**
57 | * Get an image.
58 | *
59 | * @param imageplus
60 | * image
61 | * @return an N x M array representing the input image
62 | */
63 | public static Object get(ImagePlus imageplus) {
64 | if (imageplus == null)
65 | return null;
66 | int width = imageplus.getWidth();
67 | int height = imageplus.getHeight();
68 | int stackSize = imageplus.getStackSize();
69 | int counter = 0;
70 | ImageStack imagestack = imageplus.getStack();
71 | switch (imageplus.getType()) {
72 |
73 | case ImagePlus.COLOR_256: {
74 | ;
75 | }
76 | case ImagePlus.GRAY8: {
77 | short[][][] is = new short[height][width][stackSize];
78 | for (int sz = 0; sz < stackSize; sz++) {
79 | ByteProcessor byteprocessor = (ByteProcessor) imagestack.getProcessor(sz + 1);
80 | byte[] pixels = (byte[]) byteprocessor.getPixels();
81 | counter = 0;
82 | int h = 0;
83 | while (h < height) {
84 | int w = 0;
85 | while (w < width) {
86 | is[h][w][sz] = (short) (pixels[counter] & 0xff);
87 | w++;
88 | counter++;
89 | }
90 | counter = ++h * width;
91 | }
92 | }
93 | return is;
94 | }
95 | case ImagePlus.GRAY16: {
96 | int[][][] is = new int[height][width][stackSize];
97 | for (int sz = 0; sz < stackSize; sz++) {
98 | counter = 0;
99 | ShortProcessor shortprocessor = (ShortProcessor) imagestack.getProcessor(sz + 1);
100 | short[] spixels = (short[]) shortprocessor.getPixels();
101 | int h = 0;
102 | while (h < height) {
103 | int w = 0;
104 | while (w < width) {
105 | is[h][w][sz] = (int) (spixels[counter] & 0xffff);
106 | w++;
107 | counter++;
108 | }
109 | counter = ++h * width;
110 | }
111 | }
112 | return is;
113 | }
114 | case ImagePlus.GRAY32: {
115 | double[][][] fs = new double[height][width][stackSize];
116 | for (int sz = 0; sz < stackSize; sz++) {
117 | FloatProcessor floatprocessor = (FloatProcessor) imagestack.getProcessor(sz + 1);
118 | float[] fpixels = (float[]) floatprocessor.getPixels();
119 | counter = 0;
120 | int i = 0;
121 | while (i < height) {
122 | int j = 0;
123 | while (j < width) {
124 | fs[i][j][sz] = (double) fpixels[counter];
125 | j++;
126 | counter++;
127 | }
128 | counter = ++i * width;
129 | }
130 | }
131 | return fs;
132 | }
133 | case ImagePlus.COLOR_RGB: {
134 | if (stackSize == 1) {
135 | short[][][] is = new short[height][width][3];
136 | ColorProcessor colorprocessor = (ColorProcessor) imagestack.getProcessor(1);
137 | byte[] red = new byte[width * height];
138 | byte[] green = new byte[width * height];
139 | byte[] blue = new byte[width * height];
140 | colorprocessor.getRGB(red, green, blue);
141 | counter = 0;
142 | int h = 0;
143 | while (h < height) {
144 | int w = 0;
145 | while (w < width) {
146 | is[h][w][0] = (short) (red[counter] & 0xff);
147 | is[h][w][1] = (short) (green[counter] & 0xff);
148 | is[h][w][2] = (short) (blue[counter] & 0xff);
149 | w++;
150 | counter++;
151 | }
152 | counter = ++h * width;
153 | }
154 | return is;
155 | }
156 | short[][][][] is = new short[height][width][stackSize][3];
157 | for (int sz = 0; sz < stackSize; sz++) {
158 | ColorProcessor colorprocessor = (ColorProcessor) imagestack.getProcessor(sz + 1);
159 | byte[] red = new byte[width * height];
160 | byte[] green = new byte[width * height];
161 | byte[] blue = new byte[width * height];
162 | colorprocessor.getRGB(red, green, blue);
163 | counter = 0;
164 | int h = 0;
165 | while (h < height) {
166 | int w = 0;
167 | while (w < width) {
168 | is[h][w][sz][0] = (short) red[counter];
169 | is[h][w][sz][1] = (short) green[counter];
170 | is[h][w][sz][2] = (short) blue[counter];
171 | w++;
172 | counter++;
173 | }
174 | counter = ++h * width;
175 | }
176 | }
177 | return is;
178 | }
179 | default:
180 | System.out.println("MIJ Error message: Unknow type of volumes.");
181 | return null;
182 | }
183 | }
184 | }
185 |
--------------------------------------------------------------------------------
/src/plugins/sage/psfgenerator/PSFGenerator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * PSFGenerator
3 | *
4 | * Authors: Daniel Sage and Hagai Kirshner
5 | * Organization: Biomedical Imaging Group (BIG), Ecole Polytechnique Federale de Lausanne
6 | * Address: EPFL-STI-IMT-LIB, 1015 Lausanne, Switzerland
7 | * Information: http://bigwww.epfl.ch/algorithms/psfgenerator/
8 | *
9 | * References:
10 | * [1] H. Kirshner, F. Aguet, D. Sage, M. Unser
11 | * 3-D PSF Fitting for Fluorescence Microscopy: Implementation and Localization Application
12 | * Journal of Microscopy, vol. 249, no. 1, pp. 13-25, January 2013.
13 | * Available at: http://bigwww.epfl.ch/publications/kirshner1301.html
14 | *
15 | * [2] A. Griffa, N. Garin, D. Sage
16 | * Comparison of Deconvolution Software in 3D Microscopy: A User Point of View
17 | * G.I.T. Imaging & Microscopy, vol. 12, no. 1, pp. 43-45, March 2010.
18 | * Available at: http://bigwww.epfl.ch/publications/griffa1001.html
19 | *
20 | * Conditions of use:
21 | * Conditions of use: You are free to use this software for research or
22 | * educational purposes. In addition, we expect you to include adequate
23 | * citations and acknowledgments whenever you present or publish results that
24 | * are based on it.
25 | */
26 |
27 | /**
28 | * Copyright 2010-2017 Biomedical Imaging Group at the EPFL.
29 | *
30 | * This file is part of PSFGenerator.
31 | *
32 | * PSFGenerator is free software: you can redistribute it and/or modify it under the
33 | * terms of the GNU General Public License as published by the Free Software
34 | * Foundation, either version 3 of the License, or (at your option) any later
35 | * version.
36 | *
37 | * PSFGenerator is distributed in the hope that it will be useful, but WITHOUT ANY
38 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
39 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
40 | *
41 | * You should have received a copy of the GNU General Public License along with
42 | * PSFGenerator. If not, see .
43 | */
44 |
45 | package plugins.sage.psfgenerator;
46 |
47 | import icy.plugin.abstract_.PluginActionable;
48 |
49 | public class PSFGenerator extends PluginActionable {
50 |
51 | @Override
52 | public void run() {
53 | new PSFGeneratorIcyFrame();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/psf/.svn/all-wcprops:
--------------------------------------------------------------------------------
1 | K 25
2 | svn:wc:ra_dav:version-url
3 | V 50
4 | /svn/psfgenerator/!svn/ver/32/PSFGenerator/src/psf
5 | END
6 | DefocussingPSF.java
7 | K 25
8 | svn:wc:ra_dav:version-url
9 | V 70
10 | /svn/psfgenerator/!svn/ver/29/PSFGenerator/src/psf/DefocussingPSF.java
11 | END
12 | GaussianPSF.java
13 | K 25
14 | svn:wc:ra_dav:version-url
15 | V 67
16 | /svn/psfgenerator/!svn/ver/29/PSFGenerator/src/psf/GaussianPSF.java
17 | END
18 | KoehlerPSF.java
19 | K 25
20 | svn:wc:ra_dav:version-url
21 | V 66
22 | /svn/psfgenerator/!svn/ver/29/PSFGenerator/src/psf/KoehlerPSF.java
23 | END
24 | MainDialog.java
25 | K 25
26 | svn:wc:ra_dav:version-url
27 | V 66
28 | /svn/psfgenerator/!svn/ver/32/PSFGenerator/src/psf/MainDialog.java
29 | END
30 |
--------------------------------------------------------------------------------
/src/psf/.svn/entries:
--------------------------------------------------------------------------------
1 | 10
2 |
3 | dir
4 | 32
5 | https://svn.epfl.ch/svn/psfgenerator/PSFGenerator/src/psf
6 | https://svn.epfl.ch/svn/psfgenerator
7 |
8 |
9 |
10 | 2012-11-27T10:25:13.249218Z
11 | 32
12 | kirshner
13 |
14 |
15 | svn:special svn:externals svn:needs-lock
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 28c35a94-be80-47a4-8420-aa990001146c
28 |
29 | DefocussingPSF.java
30 | file
31 |
32 |
33 |
34 |
35 | 2012-11-27T10:45:32.000000Z
36 | 32071db1c4f9bbfd0325900246ee85fc
37 | 2012-07-05T06:31:32.932295Z
38 | 29
39 | dsage
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | 6925
62 |
63 | GaussianPSF.java
64 | file
65 |
66 |
67 |
68 |
69 | 2012-11-27T10:45:32.000000Z
70 | 24e90f391d6fb75f48590f1ca3c4ff86
71 | 2012-07-05T06:31:32.932295Z
72 | 29
73 | dsage
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | 4549
96 |
97 | KoehlerPSF.java
98 | file
99 |
100 |
101 |
102 |
103 | 2012-11-27T10:45:32.000000Z
104 | 0ea1027cd34dd632991d8a10a80455ee
105 | 2012-07-05T06:31:32.932295Z
106 | 29
107 | dsage
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | 6311
130 |
131 | MainDialog.java
132 | file
133 |
134 |
135 |
136 |
137 | 2012-11-27T10:45:32.000000Z
138 | e56dd70950055a9272b295c9ac0e119d
139 | 2012-11-27T10:25:13.249218Z
140 | 32
141 | kirshner
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 | 13477
164 |
165 | bw
166 | dir
167 |
168 | gl
169 | dir
170 |
171 | mgl
172 | dir
173 |
174 | rw
175 | dir
176 |
177 | tv
178 | dir
179 |
180 | utils
181 | dir
182 |
183 |
--------------------------------------------------------------------------------
/src/psf/.svn/text-base/GaussianPSF.java.svn-base:
--------------------------------------------------------------------------------
1 | //=====================================================================================
2 | // Project: PSF Generator
3 | //
4 | // Organization: Biomedical Imaging Group (BIG)
5 | // Ecole Polytechnique Federale de Lausanne (EPFL)
6 | // Lausanne, Switzerland
7 | //
8 | // Information: http://bigwww.epfl.ch/deconvolution/
9 | //
10 | // Reference:
11 | // Alessandra Griffa, Nathalie Garin, Daniel Sage,
12 | // Comparison of Deconvolution Software in 3D Microscopy: A User Point of View
13 | // G.I.T. Imaging & Microscopy, vol. 12, no. 1, pp. 43-45, March 2010.
14 | // Available: http://bigwww.epfl.ch/publications/griffa1001.html
15 | //
16 | // Conditions of use:
17 | // You'll be free to use this software for research purposes, but you
18 | // should not redistribute it without our consent. In addition, we
19 | // expect you to include a citation or acknowledgment whenever
20 | // you present or publish results that are based on it.
21 | //=====================================================================================
22 |
23 | package psf;
24 |
25 | import imageware.Builder;
26 | import imageware.ImageWare;
27 |
28 | import javax.swing.JLabel;
29 | import javax.swing.JPanel;
30 |
31 | import psf.utils.PSF;
32 | import additionaluserinterface.GridToolbar;
33 | import additionaluserinterface.Settings;
34 | import additionaluserinterface.SpinnerDouble;
35 |
36 | /**
37 | * This class generates Gaussian PSF.
38 | *
39 | * @author Daniel Sage, Biomedical Imaging Group, Ecole Polytechnique Federale de Lausanne (EPFL).
40 | */
41 | public class GaussianPSF extends PSF {
42 |
43 | static private double sigmaFocus_Default = 2;
44 | static private double sigmaDefocus_Default = 10;
45 | private double sigmaFocus = sigmaFocus_Default;;
46 | private double sigmaDefocus = sigmaDefocus_Default;
47 | static private SpinnerDouble spnFocus = new SpinnerDouble(sigmaFocus_Default, 0, 10000, 1);
48 | static private SpinnerDouble spnDefocus = new SpinnerDouble(sigmaDefocus_Default, 0, 10000, 1);
49 |
50 | /**
51 | * Constructor.
52 | */
53 | public GaussianPSF() {
54 | super();
55 | name = "Gaussian function";
56 | shortName = "Gauss";
57 | }
58 |
59 | /**
60 | * Check the size.
61 | */
62 | public String checkSize(int nx, int ny, int nz) {
63 | if (nz < 3) return ("nz should be greater than 3.");
64 | if (nx < 4) return ("nx should be greater than 4.");
65 | if (ny < 4) return ("ny should be greater than 4.");
66 | return "";
67 | }
68 |
69 | /**
70 | * Reset the parameters as default.
71 | */
72 | public void resetParameters() {
73 | spnFocus.set(sigmaFocus_Default);
74 | spnDefocus.set(sigmaDefocus_Default);
75 | }
76 |
77 | /**
78 | * Returns the number of blank lines in the description.
79 | */
80 | public int getNumberBlankLines() {
81 | return 2;
82 | }
83 |
84 | /**
85 | * Read the parameters for the user interface
86 | */
87 | public void readParameters() {
88 | this.sigmaFocus = spnFocus.get();
89 | this.sigmaDefocus = spnDefocus.get();
90 | }
91 |
92 | /**
93 | * Build the panel for the user parameters.
94 | */
95 |
96 | public JPanel getParametersPanel() {
97 | GridToolbar pn = new GridToolbar(false);
98 | pn.place(01, 0, new JLabel("σfocus"));
99 | pn.place(02, 0, new JLabel("σdefocus"));
100 | pn.place(01, 1, spnFocus);
101 | pn.place(02, 1, spnDefocus);
102 | JPanel panel = new JPanel();
103 | panel.add(pn);
104 | return panel;
105 | }
106 |
107 | /**
108 | *
109 | */
110 | public String getDescription() {
111 | String desc = "";
112 | desc = "Simulates a blurring effect using a 2D Gaussian function:
";
113 | desc += "
G(x,y) = exp(-(x2+y2)/2σ2))/σ2
";
114 | desc += "
The value of &sigma changes linearly with z, starting with σfocus.
";
115 | desc += "The final value of &sigma is σdefocus.
";
116 | return desc;
117 | }
118 |
119 | /**
120 | * getLink.
121 | */
122 | public String getLink() {
123 | return "http://bigwww.epfl.ch/algorithms/psfgenerator/#g";
124 | }
125 |
126 |
127 | /**
128 | * Record the parameters in the settings file
129 | */
130 | public void recordSettings(Settings settings) {
131 | settings.record(name + "spnFocus", spnFocus, "" + sigmaFocus_Default);
132 | settings.record(name + "spnDefocus", spnDefocus, "" + sigmaDefocus_Default);
133 | }
134 |
135 | /**
136 | * Create the 3D PSF.
137 | */
138 | public void generate() {
139 |
140 | // Center of the stack
141 | double x0 = (nx-1)/2.0;
142 | double y0 = (ny-1)/2.0;
143 | double z0 = (nz-1)/2.0;
144 |
145 | double sigma, value;
146 | ImageWare slice;
147 | double delSigma = (sigmaDefocus-sigmaFocus)/z0;
148 |
149 | for(int z=0; zRefractive index ν0