diff --git a/microsc-psf/inc/make_psf.h b/microsc-psf/inc/make_psf.h index e61ef6f..20a606e 100644 --- a/microsc-psf/inc/make_psf.h +++ b/microsc-psf/inc/make_psf.h @@ -43,11 +43,11 @@ struct precision_li2017_t { }; template -struct pair_t { - T x{}; +struct scale_t { + T xy{}; T z{}; }; -arma::Cube makePSF(microscope_params_t, pair_t voxel, pair_t volume, +arma::Cube makePSF(microscope_params_t, scale_t voxel, scale_t volume, Micron wavelength = 0.530_um, precision_li2017_t = {}); } // namespace microsc_psf \ No newline at end of file diff --git a/microsc-psf/src/main.cpp b/microsc-psf/src/main.cpp index 88f2e44..9387cbf 100644 --- a/microsc-psf/src/main.cpp +++ b/microsc-psf/src/main.cpp @@ -23,27 +23,27 @@ iota(uint32_t N) { /** Piecewise linear interpolation. */ arma::Cube cylToRectTransform(const arma::mat& PSF0, const arma::vec& R, - microsc_psf::pair_t volume) { + microsc_psf::scale_t volume) { using namespace arma; assert(PSF0.n_cols == uint32_t(volume.z)); vec rPixel; { - const double x0 = (volume.x - 1) / 2.0; + const double x0 = (volume.xy - 1) / 2.0; // meshgrid(0:nx - x0, 0:ny - y0) - mat X(volume.x, volume.x); - X.each_row() = (iota(volume.x) - x0).t(); + mat X(volume.xy, volume.xy); + X.each_row() = (iota(volume.xy) - x0).t(); #define Y X.t() rPixel = sqrt(X % X + Y % Y).as_col(); } - Cube PSF(volume.x, volume.x, volume.z); + Cube PSF(volume.xy, volume.xy, volume.z); #pragma omp parallel for for (uint32_t zi = 0; zi < volume.z; zi++) { // Memory map the PSF slice to an 1D vector without memory copy. - vec interpolated{&(PSF(0, 0, zi)), static_cast(volume.x) * volume.x, false, true}; + vec interpolated{&(PSF(0, 0, zi)), static_cast(volume.xy) * volume.xy, false, true}; interp1(R, PSF0.col(zi), rPixel, interpolated, "linear", 0.0); } @@ -55,18 +55,18 @@ cylToRectTransform(const arma::mat& PSF0, const arma::vec& R, namespace microsc_psf { arma::Cube -makePSF(microscope_params_t params, pair_t voxel, pair_t volume, +makePSF(microscope_params_t params, scale_t voxel, scale_t volume, Micron wavelength, precision_li2017_t precision) { using ::units::literals::operator""_m; - const double x0 = (volume.x - 1) / 2.0; + const double x0 = (volume.xy - 1) / 2.0; const double y0 = x0; const double z0 = (volume.z - 1) / 2.0; using namespace arma; // Max radius is the length of the diagonal of the volume xy plane. - const double max_radius = round(abs(cx_double{volume.x - x0, volume.x - y0})) + 1; + const double max_radius = round(abs(cx_double{volume.xy - x0, volume.xy - y0})) + 1; const float max_rho = std::min({ params.NA, // @@ -115,7 +115,7 @@ makePSF(microscope_params_t params, pair_t voxel, pair_t volum // See equation 5 in Li, Xue, and Blu 2017. mat Ele; { - const vec A = k0 * params.NA * Meter(voxel.x) * R; + const vec A = k0 * params.NA * Meter(voxel.xy) * R; // bsxfun(@minus, an2', A2); mat domin(A.n_elem, scaling_factor.n_elem);