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.2.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.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: serpy_x-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d1fae04c68e7fd96b49c3f5bfa2da0a9ae105907f30234047a1b1e79b427c20f
MD5 8188cb0c3c9bc828c3e6043666f5f237
BLAKE2b-256 fa968c00149c8f8d3e5b05a228b1a5d52a79832f74653a610e415994bfc4e689

See more details on using hashes here.

File details

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

File metadata

  • Download URL: serpy_x-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d657ccc446a617e59bf26d7122f46a9f7b57ebf867d6faa6d3068ccb4d61f264
MD5 c86b506a9271f2d17fd1f7fb8bb103cb
BLAKE2b-256 2358326a2d4714b4e0441b7309c8f3325e1a99290f5c3ef0b30f515943a8cb88

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