Skip to content

PolarizedLightFieldMicroscopy/BirTomo

Repository files navigation

python versions Run Pytest

BirTomo: Birefringence Tomography

Polarized light field microscopy forward model and inverse model using geometrical optics and Jones Calculus.

Installation

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]

Requirements

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)

Birefringence tomography

To be updated soon...

For the forward model, the main script is run_simulations.py. The workflow within that script is the following:

  1. Create a birefringent raytracer.
  2. Compute the ray geometry.
  3. Create a volume to image.
  4. Raytrace through the volume.

For the iterative reconstruction, the main script is run_recon.py. The workflow within that script is the following:

  1. Generate birefringence and retardance images with forward model that will serve as the ground truth (measurement) images.
    1. Create a birefringent raytracer.
    2. Compute the ray geometry.
    3. Create a volume to image.
    4. Raytrace through the volume.
  2. Make an initial guess of the volume.
  3. Create an optimizer.
    1. Choose to optimize for the birefringence $\Delta n$ and optic axis $\hat{a}$
    2. Choose an optimization method, such as gradient descent.
  4. Define a loss function to be minimized.
  5. 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/

Testing

  • 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.

About

Geometrical Birefringence Tomography

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages