Polarized light field microscopy forward model and inverse model using geometrical optics and Jones Calculus.
Run the following code to create a virtual environment will all the necessary and relevant packages:
conda create --name bir-tomo python=3.11 --yes
conda activate bir-tomo
pip install -e .
If you have a CUDA on your computer, or having issues with pytorch, try following the instructions here for installing pytorch.
To download an editable installation in developer mode:
pip install -e .[dev]
See pyproject.toml
for the dependencies.
Necessary packages:
- matplotlib (numpy is included)
- tqdm
- torch
- h5py (for reading and saving volumes)
- tifffile (for reading and saving images)
- plotly (for visualizing volumes)
- ipykernel (for using jupyter notebooks)
- streamlit (for running the streamlit page locally)
- pytest (for testing code during development)
- scikit-image (for analyzing images)
To be updated soon...
For the forward model, the main script is run_simulations.py
. The workflow within that script is the following:
- Create a birefringent raytracer.
- Compute the ray geometry.
- Create a volume to image.
- Raytrace through the volume.
For the iterative reconstruction, the main script is run_recon.py
.
The workflow within that script is the following:
- Generate birefringence and retardance images with forward model that will serve as the ground truth (measurement) images.
- Create a birefringent raytracer.
- Compute the ray geometry.
- Create a volume to image.
- Raytrace through the volume.
- Make an initial guess of the volume.
- Create an optimizer.
- Choose to optimize for the birefringence
$\Delta n$ and optic axis$\hat{a}$ - Choose an optimization method, such as gradient descent.
- Choose to optimize for the birefringence
- Define a loss function to be minimized.
- Perform many iterations of the estimated volume being updated from the gradients of the loss function with respect to the estimated volume.
Open the streamlit page locally with
streamlit run User_Interface.py
You can also use our streamlit app that runs on the streamlit cloud and uses the code in the stream branch: https://polarizedlightfieldmicroscopy-forward-mo-user-interface-dc1r85.streamlit.app/
- Run
pytest
in the terminal to check that all the tests pass. - An example of running a particular test is
pytest -v tests/test_jones.py::test_polscope
.