LEB-EPFL / imajin

Tools to simulate optics and microscopy experiments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Imajin

build

Tools to simulate optics and microscopy experiments.

Getting started

See the integration tests for examples.

Performance Tuning

The simulation's performance may be tuned by setting various environment variables:

  • IMAJIN_CACHE_SIZE_SM_RATES -- The size of the cache storing the state machine rate computations. The recommended value is equal to the number of fluorophores in the simulation.
  • IMAJIN_CACHE_SIZE_SM_STOPPED_STATES - The size of the cache holding the state machines' stopped states. The recommended value is equal to the number of distinct fluorophore types in the simulation. Usually this is just 1.

Installation

Choose one of the following methods. It is recommended to install into a virtual environment.

# With SSH:
pip install git+ssh://git@github.com/LEB-EPFL/imajin.git

# With a GitHub access token:
pip install git+https://"$GITHUB_TOKEN"@github.com/LEB-EPFL/imajin.git

See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token for how to generate an access token. The token requires repo privileges.

Development

Setup the development environment

  1. Install pyenv: curl https://pyenv.run | bash
  2. Install Python interpreter(s): pyenv install 3.10.6
  3. Install poetry: curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
  4. Set the virtual environment Python version to 3.10: poetry env use 3.10
  5. Activate the virtual environment: poetry shell
  6. Install the dependencies: poetry install

Testing

Run all tests and linters (except for benchmarks)

poetry run tox

Run specific tests and linters

# Black, isort, mypy, pylint
poetry run tox -e black
# etc. ...

# Python 3.X tests
poetry run tox -e py310

Run the benchmarks

poetry run tox -e benchmark

Format the code

poetry run tox -e format

Lock dependencies

poetry lock

Profiling

Profiling will tell you how long the code spends in each function call. A few benchmarks are already setup for profiling.

poetry run tox -e profile

To view the results of, for example, test_benchmark_simulator_0_result.json:

poetry run vizviewer test_benchmark_simulator_0_result.json

Troubleshooting

Poetry is using the wrong Python version

Check the version of Python used by Poetry to create the virtual environment:

poetry env info

Set the Python version to 3.10 (for example):

poetry env use 3.10

About

Tools to simulate optics and microscopy experiments.


Languages

Language:Python 100.0%