Xmipp  v3.23.11-Nereus
psf_xr.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Joaquin Oton (joton@cnb.csic.es)
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef _PSF_XR_HH
27 #define _PSF_XR_HH
28 
29 #include "core/matrix2d.h"
30 #include "core/xmipp_image.h"
32 
33 class XmippProgram;
34 
38 
42 {
46 } ;
47 
48 // PSF Generation algorithm
49 /* ANALITIC_ZP is based on O. Mendoza-Yero et als."PSF analysis of nanometric Fresnel
50  * zone plates," EOS Topical Meeting on Diffractive Optics 2010,
51  * ISBN 978-3-00-024193-2, 14th-18th February
52  * 2010, Koli, Finland. (contact email:omendoza@uji.es)
53  */
54 enum PsfType
55 {
58 };
59 
74 
103 class XRayPSF
104 {
105 public:
106 
107  // Operation modes
108  typedef enum
109  {
112  } operMode;
113 
114  operMode mode;
115 
118 
119 // /// Current OTF
120 // MultidimArray< std::complex<double> > OTF;
126 // /// Axial intensity
127 // MultidimArray<float> axialInt;
129  double slabThr;
131  std::vector<int> slabIndex;
132  // Transformation Matrix when reading PSF from file
134 
136  MultidimArray<double> *mask; // This class should use applyOTF simultaneously from several threads
137 
138  /* RX Microscope configuration */
140  double Rlens;
142  double Zo;
144 // double Z;
146  double Zi;
148  double DoF;
149 
150  /* Digital Parameters */
152  size_t Nox;
154  size_t Noy;
156  size_t Noz;
157  /* Maximum pixel size in image plane (Minimum resolution condition).
158  The same for both axis x-y, due to the symmetry of the lens aperture */
159  double dxiMax;
161  double dxl;
163  double dyl;
165  double deltaZMaxX;
166  double deltaZMaxY;
167  double deltaZMinX;
168  double deltaZMinY;
169 
174 
175 // // Fourier Transformer to generate OTF, declared in class to avoid copy output
176 // FourierTransformer ftGenOTF;
177 
178 public:
180  double lambda;
181 
182  /* RX Microscope configuration */
184  double Flens;
186  double Nzp;
188  double deltaR;
190  double Ms;
192  double DeltaZo;
193 
194 
195  /* Digital Parameters */
197  double dxo;
199  double dxi;
201  double dzo;
203  size_t Nix;
204  size_t Niy;
205 
207  double dxoPSF;
209  double dzoPSF;
210 
212  int verbose;
213 
214  // Number of threads
215  int nThr;
216 
217 public:
219  XRayPSF();
220 
221  XRayPSF(const XRayPSF&)=delete; // Removal of copy constructor
222  XRayPSF(const XRayPSF&&)=delete; // Removal of move constructor
223  XRayPSF& operator = (const XRayPSF&)=delete; // Removal of copy assignment
224  XRayPSF& operator = (const XRayPSF&&)=delete; // Removal of move assignment
225 
226  /* Destructor
227  */
228  ~XRayPSF();
229 
230  /* Initialization of parameters
231  */
232  void init();
233 
235  void clear();
236 
237  /* Definition of params to be read from command line
238  */
239  static void defineParams(XmippProgram * program);
240 
241  /* Read of params from command line
242  */
243  void readParams(XmippProgram * program);
244 
247  void read(const FileName &fn, bool readVolume = true);
248 
251  void write(const FileName &fn);
252 
254  void show();
255 
257  friend std::ostream & operator <<(std::ostream &out, const XRayPSF &psf);
258 
260  void setFocalShift(double zShift);
261 
263  void calculateParams(double _dxo, double _dzo = -1, double threshold = 0.);
264 
266  void reducePSF2Slabs(double threshold);
267 
269  void applyOTF(MultidimArray<double> &Im, const double sliceOffset) const;
270 
272  void generateOTF(MultidimArray<std::complex<double> > &OTF, double Zpos) const;
273 
275  void generatePSF();
276 
278  void adjustParam();
280 
281 protected:
283  void generatePSFIdealLens(MultidimArray<double> &PSFi, double Zpos) const;
284 };
285 
287 void lensPD(MultidimArray<std::complex<double> > &Im, double Flens, double lambda, double dx, double dy);
288 
290 #endif
double pupileSizeMin
Minimum diameter size of the microscope pupile in the lens plane, measured in pixels.
Definition: psf_xr.h:173
double lambda
Lambda of illumination.
Definition: psf_xr.h:180
~XRayPSF()
Definition: psf_xr.cpp:38
double DeltaZo
Z axis global shift.
Definition: psf_xr.h:192
void generateOTF(MultidimArray< std::complex< double > > &OTF, double Zpos) const
Generate the Optical Transfer Function (OTF) for a slice according to Microscope and Im parameters...
Definition: psf_xr.cpp:458
double Zi
Object plane.
Definition: psf_xr.h:146
PsfType type
Define the selected PSF generation algorithm.
Definition: psf_xr.h:117
double dxiMax
Definition: psf_xr.h:159
MultidimArray< double > PSF
Working PSF with nonlinear zdim whose slices are the mean PSF for slabs.
Definition: psf_xr.h:125
void applyOTF(MultidimArray< double > &Im, const double sliceOffset) const
Apply the OTF to the image, by means of the convolution.
Definition: psf_xr.cpp:384
void generatePSF()
Generate the 3D Point Spread Function (PSF) according to Microscope parameters.
Definition: psf_xr.cpp:525
double deltaR
Outermost zone width.
Definition: psf_xr.h:188
XRayPSF & operator=(const XRayPSF &)=delete
double dxoPSF
object space XY-plane sampling rate of the PSF Volume
Definition: psf_xr.h:207
Image< double > psfVol
3D PSF read from file
Definition: psf_xr.h:123
void init()
Definition: psf_xr.cpp:250
void setFocalShift(double zShift)
Add focal shift to previously read psf zshift.
Definition: psf_xr.cpp:273
double dyl
Pixel size in Y-dim in lens plane.
Definition: psf_xr.h:163
int nThr
Definition: psf_xr.h:215
double deltaZMaxY
Definition: psf_xr.h:166
double dxo
object space XY-plane sampling rate
Definition: psf_xr.h:197
double Nzp
Number of zones in zone plate.
Definition: psf_xr.h:186
static void defineParams(XmippProgram *program)
Definition: psf_xr.cpp:45
PsfxrAdjust
Definition: psf_xr.h:41
void threshold(double *phi, unsigned long nvox, double limit)
Definition: lib_vwk.cpp:524
Standard mode, image size does not changes.
Definition: psf_xr.h:44
double psf
void reducePSF2Slabs(double threshold)
Calculate the width of the slabs to reduce computing time and the mean PSF for each.
Definition: psf_xr.cpp:345
double Zo
Object plane on Focus (Reference)
Definition: psf_xr.h:142
std::vector< int > slabIndex
Z positions in the original PSF Volume to determine de slabs.
Definition: psf_xr.h:131
void read(const FileName &fn, bool readVolume=true)
Definition: psf_xr.cpp:82
size_t Noz
Z size of the input image (object plane size)
Definition: psf_xr.h:156
double DoF
Depth of focus. Only for information purposes.
Definition: psf_xr.h:148
void readParams(XmippProgram *program)
Definition: psf_xr.cpp:64
size_t Nix
Size of the image in image plane, to be rescaled if needed.
Definition: psf_xr.h:203
double dx
double Rlens
Lens Aperture Radius.
Definition: psf_xr.h:140
double deltaZMaxX
Z limits around Zo in the psf generation due to Nyquist Limit.
Definition: psf_xr.h:165
int verbose
Switch to control verbose mode.
Definition: psf_xr.h:212
double slabThr
Threshold to separate The volume into slabs to use the same PSF.
Definition: psf_xr.h:129
operMode mode
Definition: psf_xr.h:114
double deltaZMinY
Definition: psf_xr.h:168
void calculateParams(double _dxo, double _dzo=-1, double threshold=0.)
Produce Side information.
Definition: psf_xr.cpp:279
double Flens
Focal length.
Definition: psf_xr.h:184
void show()
Show the microscope parameters.
Definition: psf_xr.cpp:244
double deltaZMinX
Definition: psf_xr.h:167
Matrix2D< double > T
Definition: psf_xr.h:133
void adjustParam()
Calculate if a resize of the X-Y plane is needed to avoid the Nyquist Limit.
Definition: psf_xr.cpp:673
size_t Niy
Definition: psf_xr.h:204
void clear()
Clear.
Definition: psf_xr.cpp:267
ImageGeneric psfGen
Definition: psf_xr.h:121
size_t Nox
X size of the input image (object plane size)
Definition: psf_xr.h:152
operMode
Definition: psf_xr.h:108
Increasing the image size by Interpolating.
Definition: psf_xr.h:45
void write(const FileName &fn)
Definition: psf_xr.cpp:184
void lensPD(MultidimArray< std::complex< double > > &Im, double Flens, double lambda, double dx, double dy)
Generate the quadratic phase distribution of a ideal lens.
Definition: psf_xr.cpp:814
PsfType
Definition: psf_xr.h:54
double dzo
object space Z sampling rate
Definition: psf_xr.h:201
double dxl
Pixel size in X-dim in lens plane.
Definition: psf_xr.h:161
double dzoPSF
object space Z sampling rate of the PSF Volume
Definition: psf_xr.h:209
XRayPSF()
Definition: psf_xr.cpp:33
PsfxrAdjust AdjustType
Parameters to change image size to avoid Nyquist limit.
Definition: psf_xr.h:171
void generatePSFIdealLens(MultidimArray< double > &PSFi, double Zpos) const
Generate the PSF for a single plane according to a ideal lens.
Definition: psf_xr.cpp:581
friend std::ostream & operator<<(std::ostream &out, const XRayPSF &psf)
Show.
Definition: psf_xr.cpp:214
double dxi
Image space XY-plane sampling rate.
Definition: psf_xr.h:199
size_t Noy
Y size of the input image (object plane size)
Definition: psf_xr.h:154
double Ms
Magnification.
Definition: psf_xr.h:190
MultidimArray< double > * mask
Lens shape Mask.
Definition: psf_xr.h:136