This repository contains an improved, faster implementation of the "Unified Modulated Pattern Analysis" (UMPA) model, which is achieved through the use of C++ and Cython. A publication describing and explaining this work can be found at
Please cite this work when using this version of UMPA!
-
This package is also used by an extension to directional dark-field. That work is described in the publication R. Smith, F. De Marco, L. Broche, M.-C. Zdora, N. W. Phillips, R. Boardman, and P. Thibault, "X-ray directional dark-field imaging using Unified Modulated Pattern Analysis," PLoS ONE 17(8), e0273315 (2022).
-
The original (Python-based) implementation of the method is available at https://github.com/pierrethibault/UMPA, and is also included in this repository, in the file speckle_matching.py. The publication associated with that work is M.-C. Zdora, P. Thibault, T. Zhou, F. J. Koch, J. Romell, S. Sala, A. Last, C. Rau, and I. Zanette, “X-ray Phase-Contrast Imaging and Metrology through Unified Modulated Pattern Analysis,” Phys. Rev. Lett., 118 203903 (2017).
In the current state, this repository is only compatible with Linux, and has only been tested with the gcc
/ g++
compiler.
The latest release of Cython seems to be causing some issues with the install process which we are investigating. In the meantime, reverting to an older version seems to help:
pip install Cython==0.29.37 --force-reinstall
Installation via
python setup.py install
or
pip install UMPA/
should be possible.
Compilation with Microsoft Visual Studio under Windows is possible, but requires the modification of setup.py.
- Download "Visual Studio 2022, community version", select "Desktop development with C++" under "Workloads" when starting Visual Studio.
- In setup.py, modify
ext_1 = Extension(SRC_DIR + ".model",
[SRC_DIR + "/model.pyx"],
language="c++",
libraries=["m"],
extra_compile_args=["-std=c++17", "-O3", "-ffast-math", "-march=native", "-fopenmp" ],
extra_link_args=['-fopenmp'],
include_dirs=[np.get_include()])
to
ext_1 = Extension(SRC_DIR + ".model",
[SRC_DIR + "/model.pyx"],
language="c++",
extra_compile_args=["/std:c++17", "/O2", "/fp:fast", "/favor:INTEL64", "/openmp" ],
include_dirs=[np.get_include()])
This should work, it was tested on a Windows 11 laptop, multithreading works too. I'll modify setup.py to do this change automatically depending on architecture...
Installation on Mac currently fails due to unknown reasons.