Skip to content

Hardware control and image analysis code for Fourier ptychography.

License

Notifications You must be signed in to change notification settings

LEB-EPFL/ptycho

Repository files navigation

LEB Ptychography

build DOI

Hardware control and image analysis code for Fourier Ptychography.

leb-ptycho - A Python package for Fourier Ptychography

This is a port of the Fourier Ptychography MATLAB code presented in this paper: Jiang, et al., Spatial and Fourier-domain ptychography for high-throughput bio-imaging, Nature Protocols 18, 2051 (2023)

Getting Started

from leb.ptycho import fp_simulation, fp_recover

# Simulate a Fourier Ptychography dataset
dataset, unaberrated_pupil, ground_truth_object, ground_truth_pupil = fp_simulation()

# Recover the complex object function and pupil
obj, pupil = fp_recover(dataset=dataset, pupil=unaberrated_pupil)

Scripts

This library provides the following scripts for automating certain tasks:

  1. calibrate_ptycho - Acquire a Fourier Ptychography calibration dataset.

See the script docstrings for documentation on their use.

Development

Cloning and updating test data

After you clone this repo, you will need to also synchronize the submodules that hold the test data for this project.

git submodule init
git submodule update

To pull any upstream changes to the test data:

git submodule update --remote led-array-datasets

Setup the development environment

  1. Install Python >= 3.11 OR install pyenv: curl https://pyenv.run | bash, then install Python interpreter(s): pyenv install 3.11.4
  2. Install poetry:
# Linux, macOS, WSL
curl -sSL https://install.python-poetry.org | python3 -

# Windows
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
  1. Verify that Poetry is installed by running the command poetry --version. If the command is not found, you might need to add the directory containing the Poetry executable to your PATH environment variable. On Windows, the directory to add is %APPDATA%\Python\Scripts. On Linux/macOS, it's $HOME/.local/bin.

  2. Tell Poetry to use virtual environments in the project root directory: poetry config virtualenvs.in-project true

  3. Set the virtual environment Python version to 3.11: poetry env use 3.11

  4. Activate the virtual environment: poetry shell

  5. Install the dependencies: poetry install

Testing

From inside the poetry shell:

pytest

Linters

From inside the poetry shell:

ruff check .

To reformat the code automatically:

black .

Adding/removing dependencies

  1. Add or remove your dependency to pyproject.toml
  2. Regenerate the lock file: poetry lock
  3. Synchronize your virtual environment with the new lock file: poetry install

LED Matrix Controller - Arduino code to control an LED matrix

See arduino_src/led_matrix_controller/README.md.

uManager - Micro-Manager scripts for acquisition control

See umanager/README.md.

About

Hardware control and image analysis code for Fourier ptychography.

Resources

License

Stars

Watchers

Forks

Packages

No packages published