48 program->
addParamsLine(
" [--lambda <v=2.43>] : X-ray wavelength (nm).");
49 program->
addParamsLine(
" [--out_width <deltaR=40>] : Outermost zone width of the X-ray Fresnel lens (nm).");
50 program->
addParamsLine(
" [--zones <N=560>] : Number of zones of the X-ray Fresnel lens.");
51 program->
addParamsLine(
" [--mag <Ms=2304>] : Magnification of the X-ray microscope.");
52 program->
addParamsLine(
" [--sampling <dxy=10> <dz=dxy>] : Sampling rate in X-Y plane and Z axis (nm).");
53 program->
addParamsLine(
" [--zshift <deltaZ=0>] : Longitudinal displacement along Z axis in microns.");
54 program->
addParamsLine(
" [--size <x> <y=x> <z=x>] : Size of the X-ray PSF volume.");
55 program->
addParamsLine(
" [--type <lens_type=ideal>] : Lens type to generate the PSF.");
109 psfGen().setXmippOrigin();
115 std::vector<double> dimV;
153 if ((fh_param = fopen(fn.c_str(),
"r")) ==
nullptr)
155 (std::string)
"XmippXROTF::read: There is a problem " 156 "opening the file " + fn);
176 std::cout << XE << std::endl;
202 std::vector<double> dimV(3);
218 <<
"--------------------------------------" << std::endl
219 <<
"XrayPSF:: X-Ray Microscope parameters:" << std::endl
220 <<
"--------------------------------------" << std::endl
222 <<
"lambda = " << psf.
lambda * 1e9 <<
" nm" << std::endl
223 <<
"zones_number = " << psf.
Nzp << std::endl
224 <<
"outer_zone_width = " << psf.
deltaR * 1e9 <<
" nm" << std::endl
225 <<
"magnification = " << psf.
Ms << std::endl
226 <<
"sampling_rate = " << psf.
dxo * 1e9 <<
" nm" << std::endl
227 <<
"z_sampling_rate = " << psf.
dzo * 1e9 <<
" nm" << std::endl
228 <<
"z_axis_shift = " << psf.
DeltaZo * 1e6 <<
" um" << std::endl
230 <<
"focal_length = " << psf.
Flens * 1e3 <<
" mm" << std::endl
231 <<
"Lens Radius = " << psf.
Rlens * 1e6 <<
" um" << std::endl
232 <<
"Zo = " << psf.
Zo * 1e3 <<
" mm" << std::endl
233 <<
"Zi = " << psf.
Zi * 1e3 <<
" mm" << std::endl
234 <<
"Depth_of_Focus = " << psf.
DoF * 1e6 <<
" um" << std::endl
236 <<
"dxi = " << psf.
dxi * 1e6 <<
" um" << std::endl
237 <<
"dxiMax = " << psf.
dxiMax * 1e6 <<
" um" << std::endl
246 std::cout << *
this << std::endl;
283 dzo = (_dzo > 0)? _dzo :
dxo;
307 double scaleFactorZ = 1;
309 dMij(
T, 0, 0) = scaleFactor;
310 dMij(
T, 1, 1) = scaleFactor;
311 dMij(
T, 2, 2) = scaleFactorZ;
317 mdaPsfVol.
resize(1, (
size_t)(
Noz/scaleFactorZ),
318 (
size_t)(
Noy/scaleFactor),
319 (
size_t)(
Nox/scaleFactor),
false);
324 xmipp_transformation::IS_INV, xmipp_transformation::DONT_WRAP);
329 mdaPsfVol *= scaleFactor*scaleFactor;
353 double maxValue =
A3D_ELEM(mdaPsfVol,maxPos.
z,maxPos.
y,maxPos.
x);
354 threshold *= maxValue;
357 double maxTemp = maxValue;
360 double tempV =
A3D_ELEM(mdaPsfVol,
k,maxPos.
y,maxPos.
x);
361 if ( maxTemp - tempV > threshold)
372 double tempV =
A3D_ELEM(mdaPsfVol,
k,maxPos.
y,maxPos.
x);
373 if ( maxTemp - tempV > threshold)
406 _Im.
write((
"psfxr-ImIn.spi"));
416 _Im.
write((
"psfxr-ImIn_after.spi"));
420 _Im().resizeNoCopy(OTF);
423 _Im.
write(
"psfxr-otf.spi");
425 _Im().resizeNoCopy(ImFT);
428 _Im.
write((
"psfxr-imft1.spi"));
441 _Im.
write((
"psfxr-imft2.spi"));
453 _Im.
write((
"psfxr-imout.spi"));
478 double zIndexPSF = (
Zo - Zpos)/
dzoPSF;
486 dMij(
T, 2, 3) = zIndexPSF;
488 xmipp_transformation::IS_INV, xmipp_transformation::DONT_WRAP,
dAkij(mPsfVol,0,0,0));
504 _Im.
write(
"psfxr-psfi.spi");
518 _Im.
write(
"psfxr-otf2.spi");
583 double focalEquiv = 1/(1/Zpos - 1/
Zo);
601 _Im().resize(OTFTemp);
604 _Im.
write(
"phase_lens.spi");
607 _Im.
write(
"abs_lens.spi");
623 _Im.
write(
"psfitemp.spi");
644 _Im.
write(
"generate-psfi.spi");
658 _Im.
write(
"otftemp.spi");
699 std::cout << std::endl;
700 std::cout <<
"----------------------" << std::endl;
701 std::cout <<
"XrayPSF::Param adjust:" << std::endl;
702 std::cout <<
"----------------------" << std::endl;
703 std::cout <<
"(Nox,Noy,Nz) = (" <<
Nox <<
"," <<
Noy <<
"," <<
Noz <<
")" << std::endl;
704 std::cout <<
"Larger volume Z plane to be calculated = " << (
ABS(
DeltaZo)+(
Noz-1)/2*
dzo)*1e6 <<
" um" << std::endl;
705 std::cout <<
"Larger allowed discrete Z plane (x,y) = (" <<
deltaZMaxX*1e6 <<
", " << deltaZMaxY*1e6 <<
") um" << std::endl;
718 std::cout <<
"XrayPSF: Image plane sampling too small: increasing resolution" << std::endl;
763 std::cout <<
"XrayPSF: Image plane size too small: increasing size" << std::endl;
764 std::cout <<
"New slice dimensions: " <<
"(Nix, Niy) = (" <<
Nix <<
", " <<
Niy <<
")" << std::endl;
766 std::cout <<
"(dxl, dyl) = (" <<
dxl*1e6 <<
", " <<
dyl*1e6 <<
") um" << std::endl;
767 std::cout <<
"Pupile Diameter in pixels (NpX, NpY) = (" << ceil(2*
Rlens /
dxl)
768 <<
", " << ceil(2*
Rlens /
dyl) <<
")" << std::endl;
769 std::cout << std::endl;
789 if (x*x + y2 <= Rlens2)
823 double K = (-
PI / (lambda *
Flens));
833 phase = K * (x * x + y2);
834 A2D_ELEM(Im,i,j) = std::complex<double>(cos(phase),sin(phase));
bool checkParameter(int argc, const char **argv, const char *param)
void init_progress_bar(long total)
double pupileSizeMin
Minimum diameter size of the microscope pupile in the lens plane, measured in pixels.
#define A2D_ELEM(v, i, j)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
Case or algorithm not implemented yet.
double getDoubleParam(const char *param, int arg=0)
double lambda
Lambda of illumination.
double DeltaZo
Z axis global shift.
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...
#define REPORT_ERROR(nerr, ErrormMsg)
PsfType type
Define the selected PSF generation algorithm.
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
void resizeNoCopy(const MultidimArray< T1 > &v)
void applyOTF(MultidimArray< double > &Im, const double sliceOffset) const
Apply the OTF to the image, by means of the convolution.
void generatePSF()
Generate the 3D Point Spread Function (PSF) according to Microscope parameters.
FileName addExtension(const String &ext) const
double deltaR
Outermost zone width.
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void maxIndex(int &jmax) const
#define MULTIDIM_ARRAY(v)
void abs(Image< double > &op)
double dxoPSF
object space XY-plane sampling rate of the PSF Volume
Image< double > psfVol
3D PSF read from file
void setFocalShift(double zShift)
Add focal shift to previously read psf zshift.
double dyl
Pixel size in Y-dim in lens plane.
T norm(const std::vector< T > &v)
double dxo
object space XY-plane sampling rate
double Nzp
Number of zones in zone plate.
static void defineParams(XmippProgram *program)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
void CenterFFT(MultidimArray< T > &v, bool forward)
void threshold(double *phi, unsigned long nvox, double limit)
#define A3D_ELEM(V, k, i, j)
Standard mode, image size does not changes.
void reducePSF2Slabs(double threshold)
Calculate the width of the slabs to reduce computing time and the mean PSF for each.
double Zo
Object plane on Focus (Reference)
const char * getParameter(int argc, const char **argv, const char *param, const char *option)
const char * getParam(const char *param, int arg=0)
std::vector< int > slabIndex
Z positions in the original PSF Volume to determine de slabs.
void read(const FileName &fn, bool readVolume=true)
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const
size_t Noz
Z size of the input image (object plane size)
float textToFloat(const char *str)
double DoF
Depth of focus. Only for information purposes.
void readParams(XmippProgram *program)
size_t Nix
Size of the image in image plane, to be rescaled if needed.
void setSlice(int k, const MultidimArray< T1 > &v, size_t n=0)
void progress_bar(long rlen)
void max(Image< double > &op1, const Image< double > &op2)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define dAkij(V, k, i, j)
double Rlens
Lens Aperture Radius.
#define DIRECT_MULTIDIM_ELEM(v, n)
double deltaZMaxX
Z limits around Zo in the psf generation due to Nyquist Limit.
int verbose
Switch to control verbose mode.
Couldn't read from file.
#define STR_EQUAL(str1, str2)
void calculateParams(double _dxo, double _dzo=-1, double threshold=0.)
Produce Side information.
double Flens
Focal length.
void show()
Show the microscope parameters.
void adjustParam()
Calculate if a resize of the X-Y plane is needed to avoid the Nyquist Limit.
bool isMetaData(bool failIfNotExists=true) const
size_t Nox
X size of the input image (object plane size)
Increasing the image size by Interpolating.
FileName withoutExtension() const
void write(const FileName &fn)
void lensPD(MultidimArray< std::complex< double > > &Im, double Flens, double lambda, double dx, double dy)
Generate the quadratic phase distribution of a ideal lens.
double dzo
object space Z sampling rate
int textToInteger(const char *str)
double dxl
Pixel size in X-dim in lens plane.
double dzoPSF
object space Z sampling rate of the PSF Volume
static String label2Str(const MDLabel &label)
PsfxrAdjust AdjustType
Parameters to change image size to avoid Nyquist limit.
void generatePSFIdealLens(MultidimArray< double > &PSFi, double Zpos) const
Generate the PSF for a single plane according to a ideal lens.
void initZeros(const MultidimArray< T1 > &op)
friend std::ostream & operator<<(std::ostream &out, const XRayPSF &psf)
Show.
double dxi
Image space XY-plane sampling rate.
int getIntParam(const char *param, int arg=0)
int readMapped(const FileName &name, size_t select_img=ALL_IMAGES, int mode=WRITE_READONLY)
size_t Noy
Y size of the input image (object plane size)
void addParamsLine(const String &line)
MultidimArray< double > * mask
Lens shape Mask.
void CenterOriginFFT(MultidimArray< std::complex< double > > &v, bool forward)