Skip to main content

Statistical single-exposure retrieval of transmission, isotropic and directional dark-field signals for X-ray imaging

Project description

🌀 SerPy — Statistical single-exposure Retrieval of directional dark-field in PYthon

SerPy implements a statistical single-exposure framework for retrieving transmission, isotropic dark-field, and directional dark-field (DF) signals from a single pair of images (reference and sample).
It is compatible with both modulation-based, speckle-based, single grid, edge illumination, and grating-based X-ray imaging techniques.


🚀 Overview

Conventional dark-field imaging requires multiple phase steps or modulator positions to separate phase, absorption, and scattering information.
SerPy eliminates this need by relying on local contrast statistics computed within small sliding windows.
From these statistics, the method reconstructs the directional scattering ellipse at each pixel, yielding quantitative maps of:

  • Transmission $ T(\mathbf{r})$
  • Isotropic dark-field $ D_f(\mathbf{r}) $
  • Directional dark-field: orientation, anisotropy, and magnitude

✳️ Key Features

  • 🔹 Single-exposure retrieval — no phase stepping or mask motion required
  • 🔹 Local statistical analysis of contrast anisotropy
  • 🔹 Directional dark-field extraction via ellipse fitting in polar space
  • 🔹 Orientation smoothing using circular Gaussian filtering
  • 🔹 Vectorized & Numba-accelerated kernels for high performance
  • 🔹 Compatible with modulation-based, speckle-based, single grid, edge illumination, grating-based setups

⚙️ Installation

▶️ From PyPI (recommended)

pip install serpy_x

▶️ From source

git clone https://github.com/MuguiwaraSamy/SerPy.git
cd SerPy
pip install -U pip
pip install -e .

🧠 Quickstart Example

import numpy as np
from Serpy.statdf import retrieval_Algorithm

# img, ref : 2D numpy arrays (sample and reference)
out = retrieval_Algorithm(img, ref, n_angles=19, window_size=5)

Key Description
angles Array of sampled orientation angles (in radians) used for the directional analysis
T Transmission map ( T(\mathbf{r}) )
Non-oriented Df Isotropic dark-field (scalar visibility loss)
Oriented Df Directional dark-field profiles sampled along each orientation ((H, W, N_\theta))
major axis Semi-major axis of the fitted ellipse (maximum scattering direction)
minor axis Semi-minor axis of the fitted ellipse (minimum scattering direction)
Orientation Raw ellipse orientation (principal scattering direction, before smoothing)
Corrected Orientation Smoothed and π-periodic orientation map
saturation Local angular coherence or stability of the orientation field
(optionally) mean_s, std_s, mean_r, std_r Intermediate directional statistics (sample/reference means and standard deviations), included if return_intermediates=True

⚠️ Patent Notice

A patent application covering the underlying method and algorithm has been filed by the author(s): "Procédé d’imagerie et produit programme d’ordinateur correspondant", filed on September 26, 2025.

The publication of this code under the MIT license does not grant any license or rights to practice the patented invention.
Use of this software for research and non-commercial purposes is permitted under the terms of the MIT License.
Any commercial use of the patented method requires a separate license from the patent holder.

📜 License

Distributed under the MIT License. © 2025 Samy Kefs. All rights reserved.

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

serpy_x-0.1.3.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

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

serpy_x-0.1.3-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file serpy_x-0.1.3.tar.gz.

File metadata

  • Download URL: serpy_x-0.1.3.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for serpy_x-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f404f44b87de169046745f52e3579171a923ac439dc3093fa72a30b6e36bba28
MD5 61c29c9a909a6e3788145b395c80cb26
BLAKE2b-256 b24e6ec18ea6697c29e2a8b427382328b5be14aea896b336f512f1ead80d3599

See more details on using hashes here.

File details

Details for the file serpy_x-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: serpy_x-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for serpy_x-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7081a3020b6a90f026e9a51417018019727feabd1cdf919d101e6cf7636cbfec
MD5 477b7e165d51b394ceb4351361ae146d
BLAKE2b-256 2839ba498040e7b2dfe6bc1b91588e8976ba0396002aaa8d67e651c5d91b0cf9

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