Skip to content

Commit

Permalink
Instructions to run the example app
Browse files Browse the repository at this point in the history
Given the screenshot on the original author's lab website
(https://www.ee.cuhk.edu.hk/~tblu/monsite/phps/fastPSF.php), reproduce
the same outputs with the C++ example app. Replicate the identical
inputs in the C++ file at `examples/generate-psf.cpp`. Write the
instructions in Raadme.
  • Loading branch information
antonysigma committed Nov 26, 2024
1 parent d2eefc0 commit 38f95ea
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ ninja all
sudo ninja install
```

## Running the examples

First, follow the *Quick start* instructions to build the example app. Then, given the following microscope configurations in the screenshot...
<img src="https://www.ee.cuhk.edu.hk/~tblu/monsite/demos/fastPSF/gui.png"/>

... program the example C++ file at (https://github.com/MicroscPSF/MicroscPSF-Cpp/blob/main/examples/generate-psf.cpp)[examples/generate-psf.cpp]

```c++
microscope_params_t params{};
params.NA = 1.4;
params.ti0 = 150.0_um;
params.ni = 1.5;
params.ni0 = 1.5;
params.pz = 2.0_um;

precision_li2017_t precision{};
precision.num_basis = 153;
precision.rho_samples = 1000;

const auto psf =
makePSF(params, {0.1_um, 0.25_um}, {256, 128}, 0.610_um, precision);
```
Next, repeat the *Quick start* steps to re-compile the C++ app. Run `ninja test`
to invoke the compiled example. Locate the outputs `psf_xy.pgm`, `psf_xz.pgm`,
and `psf.h5`. The XZ cross-section of the C++-simulated PSF should match the
screenshot above.
<img src="examples/psf_xz.png"/>
## Appendix: Bessel function support
- The original ISO C++ proposal: https://wg21.link/p0226r1
Expand Down
15 changes: 13 additions & 2 deletions examples/generate-psf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ int main() {
namespace hdf5_opts = arma::hdf5_opts;
using namespace ::units::literals;

microscope_params_t params{};
params.NA = 1.4;
params.ti0 = 150.0_um;
params.ni = 1.5;
params.ni0 = 1.5;
params.pz = 2.0_um;

precision_li2017_t precision{};
precision.num_basis = 153;
precision.rho_samples = 1000;

const auto psf =
makePSF(microscope_params_t{}, {0.1_um, 0.25_um}, {120, 63}, 0.530_um, precision_li2017_t{});
#ifdef ARMA_USE_HDF5
makePSF(params, {0.1_um, 0.25_um}, {256, 128}, 0.610_um, precision);
#ifdef ARMA_USE_HDF5
std::cout << "Saving volume to HDF5...\n";
psf.save(hdf5_name("psf.h5", "psf", hdf5_opts::trans));
std::cout << R"(Done.
Expand Down
Binary file added examples/psf_xz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38f95ea

Please sign in to comment.