Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions to run the example app #13

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.