Skip to main content

A Python package to determine the best pair of lenses to use as a tube lens for remote refocusing or classical microscopy.

Project description

PyRFTL PyPI Version

PyRFTL

Welcome to PyRFTL repository !

This is the official repository of PyRFTL : an open source python tool for custom tube lens generation from off-the-shelf optics, Becar Quentin, Montgomery Paul, Nahas Amir, and Maioli Vincent. Optics Letters (2025) doi: 10.1364/OL.571058

This Python tool is used to determine the best pair of lenses to use as a tube lens for remote refocusing or classical microscopy.

The objective for which the tube lens must be designed should be infinity conjugated and correct aberrations on its own. Typically, one can use Olympus or Nikon objectives, but not Leica or Zeiss ones (which often rely on the tube lens to correct some aberrations).

Licensing

This software is under GNU GPLv3 license, except following files :

Installation

PyRFTL necessitates the installation of Python (>3.12). It is recommended to install conda (Anaconda, Miniconda, ...) to create a specific environment for PyRFTL.

With Anaconda Prompt, one can use the following procedure :

  • create a new environment

    conda create --name pyrftl_env python=3.12.4
    
  • install pyrftl

    conda activate pyrftl_env
    pip install pyrftl
    
  • (optional) To access more Schott materials (ancient materials like BK7, F3, ...), it is possible to modify the opticalglass package (not necessary if you compare new lenses) :

    1. download the Schott AGF file, which contains Schott materials information. This file is denoted below as schott-optical-glasses-preferred-and-inquiry-en.AGF. It can be downloaded on the Schott website, at datasheet Optical Glass – Overview Glass Types (ZEMAX format). The AGF file is contained in the downloaded archive schott-optical-glass-overview-zemax-format.zip. (Wayback Machine link)

    2. obtain conda environnement location (exemple with Anaconda Prompt) :

      conda info
      

      and look for active env location : (environment can be activated with conda activate pyrftl_env)

    3. in the environment directory : \Lib\site-packages\opticalglass, replace schott.py by src/pyrftl/rayopt/schott.py and add schott-optical-glasses-preferred-and-inquiry-en.AGF in \Lib\site-packages\opticalglass\data

  • It is needed to have on your computer the sequential model of lenses you want to use to create pairs. Lens files should be in Zemax .zmx, CodeV .seq or RayOptics .roa format. Some can be downloaded directly from the lenses repository, and others can be obtained on manufacturers' websites. For some manufacturers, like Ross Optical, only zmf file can be downloaded. One can use zmf2zmx to split a zmf archive into zmx files. (Please note that an older Python version is needed).

  • Check the system : see the test section below

  • Start to use the software, see indications below

Installation check

To check the correct installation of the software, read the instructions in the pdf in test directory.

How to use

After installing the software, one can use it following these steps :

  • Group all commercial lens files to use in the same directory. It can contain subfolders.
  • [GUI] In Python console, type:
    from pyrftl.gui_main import pyrftl_gui
    pyrftl_gui()
    
    Then, on the displayed graphical interface, select pair selector and fill all necessary parameters. If needed, use ? buttons to get explanations.
  • [No GUI] To not use the graphical interface, one can set parameters in user_select_pair_successive.py, and run this file.
  • Processing can take some time, advancement is shown in your IDE Python console. Do not close the GUI interface until computation is done, or results will not be exported.
  • Results are exported in a csv file. When using the GUI, it is possible to see extra data of pairs. To observe a pair, use change pair and put the pair short name (obtained in the csv file).

No pair is selected

In some cases, no pair is found by the system. When it is because no pair fits the geometrical constraints, one can:

  • Remove distance constraints
  • Add more lenses to import
  • Modify the required focal length (for remote focusing, this also implies modifying the other tube lens)
  • Disable the thin lens filtering (if it was enabled)

In the case no pair has a good performance, one can:

  • Remove distance constraints
  • Add more lenses to import
  • Reduce the spectral range
  • Increase the required focal length (for remote focusing, this also implies modifying the other tube lens)
  • Disable the thin lens filtering (if it was enabled)

Issues

If you encounter some issues (which are not listed below) or want to discuss this tool, please address them on the Codeberg repository.

Others

This version of PyRFTL was tested with rayoptics 0.9.8 and PyCharm Community Edition 2024.1.1.

See Unistra and Codeberg repositories.

Article : Optics Letters

Author Manuscript (available as of 18/03/2026 after the embargo period due to copyright transfer and french law) : HAL

Supplementary dataset : Zenodo

Code archive : Zenodo

Corresponding author : maioli [at] unistra.fr

Images

Some screenshots of the software in use are shown below.

Here is the GUI when selecting desire parameters, with an helpbox. Image of the GUI

Then while computing, the advancement is displayed in the IDE Python console. Image of the GUI

When the analysis is ended, pairs can be observed in the GUI. Ray trace diagram and wavefront aberration maps can be displayed, with the wavefront aberration data returned in the Python console. Image of the GUI

Analysis and pairs main parameters are also available in a csv text file. Image of the csv file

Known bugs

Here are listed some known bugs which are not yet fixed.

  • The text scaling does not fully work on every pages.
  • When the main windows is changed of screen, it became transparent. A temporary solution is implemented : clicking on the cancel transparency button resolve it.
  • An optical model file .roa which is created with original opticalglass Schott class (see above) cannot be opened with modified opticalglass, and vice versa.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrftl-1.1.3.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrftl-1.1.3-py3-none-any.whl (476.3 kB view details)

Uploaded Python 3

File details

Details for the file pyrftl-1.1.3.tar.gz.

File metadata

  • Download URL: pyrftl-1.1.3.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for pyrftl-1.1.3.tar.gz
Algorithm Hash digest
SHA256 92b2055306d386b0e4dbfadc7027fd8ac9f8be5682db0c3f17b5837268b63a73
MD5 73c4d51c4b3e937ebcec63266b338d37
BLAKE2b-256 c17464b02e7c5b01256e914e09dd17030f2f612717c66f9dca4e466ba36e696b

See more details on using hashes here.

File details

Details for the file pyrftl-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: pyrftl-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 476.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for pyrftl-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3a947a5560d934315b7509cd6dd9365e61ec41a0162b58271f86806d4c1ae7a2
MD5 5782c60e1b764783b48aa0a2ec24eb19
BLAKE2b-256 ebcdee34afb203b043b9b6cf3e4706587d48044b53b259ba9d1f9ad127578ec0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page