#fft #psf #optics #imaging #microscopy

rusty-psf

A comprehensive Point Spread Function (PSF) library for microscopy and optical systems

1 unstable release

0.1.0 Jan 4, 2025

#578 in Math

Download history 145/week @ 2025-01-02

145 downloads per month

BSD-3-Clause

39KB
527 lines

Rusty-PSF: Point Spread Function Library

Crates.io docs.rs License

[!NOTE] This is a comprehensive Rust library for calculating Point Spread Functions (PSF) in microscopy and optical systems. It provides efficient implementations for various PSF models including Gaussian, defocus, and optical aberrations using Zernike polynomials.

Table of Contents

Installation

[!TIP] Make sure you have Rust and Cargo installed on your system before proceeding. Visit rust-lang.org for installation instructions.

To use this library, add the following dependencies to your Cargo.toml file:

[dependencies]
rusty-psf = "0.1.0"
ndarray = { version = "0.16.1", features = ["rayon"] }
num-complex = "0.4.6"

Getting Started

To get started with the Rusty-PSF library, follow these examples:

Basic PSF Generation

[!NOTE] Generate a theoretical Gaussian PSF with specified optical parameters:

use rusty_psf::{
    types::OpticalParameters,
    core::gaussian::create_theoretical_psf,
};

fn main() {
    // Define optical parameters
    let params = OpticalParameters {
        na: 1.4,                // Numerical aperture
        wavelength: 0.532,      // Wavelength in micrometers (green light)
        refractive_index: 1.518, // Oil immersion
    };

    // Create a theoretical PSF
    let size = 64;             // Grid size
    let pixel_size = 0.1;      // Pixel size in micrometers
    let psf = create_theoretical_psf(&params, size, pixel_size);
}

Optical Aberrations

[!NOTE] Create a PSF with specific optical aberrations using Zernike polynomials:

use rusty_psf::{
    types::OpticalParameters,
    optics::{ZernikeMode, AberrationCoefficients, aberrated_psf},
};

fn main() {
    let params = OpticalParameters::default();
    
    // Define aberrations
    let mut coeffs = AberrationCoefficients::new();
    coeffs.set(ZernikeMode::Defocus, 0.5);         // Defocus
    coeffs.set(ZernikeMode::AstigmatismX, 0.25);   // Astigmatism
    
    // Generate aberrated PSF
    let size = 64;
    let pixel_size = 0.1;
    let psf = aberrated_psf(size, &coeffs, &params, pixel_size);
}

Features

[!TIP] The library provides comprehensive PSF modeling capabilities:

  • 🔬 Gaussian PSF with theoretical parameters
  • 🎯 Defocus and through-focus series
  • 🌊 Zernike polynomial-based aberrations
  • 📊 Efficient FFT implementations
  • 📐 Strehl ratio calculations
  • 🔄 Normalized coordinate systems
  • ⚡ Parallel processing support
  • 🧮 High-performance numerical computations

Documentation

[!NOTE] For detailed API documentation and examples, please refer to the Documentation.

License

[!IMPORTANT] This library is licensed under the BSD 3-Clause License. See the LICENSE file for details.

Dependencies

~11MB
~207K SLoC