This repository contains some code about Propagation-Based Phase-Contrast imaging of homogeneous samples using X-rays.
-
Clone the repository using git, or copy-paste source code into your own files.
-
Download and install the latest version of Julia;
-
In Julia, type
cd("path\\to\\your\\directory"). Beware to write double\signs, since they are used as special characters in Julia strings -
If these packages are not already installed, type
] add LinearAlgebra
] add Images
] add FFTW
] add FileIO
] add ImageMagick
] add ImageTransformations
] add Interpolations
] add https://github.com/JuliaPhysics/PhysicalOptics.jl-
Copy the three
.jlfiles from thesrcfolder to your directory -
You can now use the functions of this project your Julia script by adding the lines
include("simulation.jl")
include("retrieval.jl")In the simulation.jl file, there are four main functions of interest:
AbsoprtionRadiography(thickness, β, k, I_0)which simulates a traditional absorption radiography image through the Beer-Lambert law:
Arguments description
thicknessis expected to be a matrix of thickness values representing the sample;βis the imaginary part of the refractive index;kis the wave number;I_0the initial intensity of radiation. Note:thicknessandkmust be expressed in the same unit system.
LaplacianRadiography(thickness, δ, β, k, I_0, R, pixelsize)which simulates a Propagation-Based Phase-Contrast image through the analytical expression derived from the Transport of Intensity Equation. Namely:
Arguments description
thicknessis expected to be a matrix of thickness values representing the sample;δis the real decrement of the refractive index;βis the imaginary part of the refractive index;kis the wave number;I_0the initial intensity of radiation;Ris the propagation distance;pixelsizeis the size of the pixel in the imaging system. Note:thickness,k,R, andpixelsizemust be expressed in the same unit system.
FresnelRadiography(thickness, δ, β, k, I_0, R, pixelsize)which simulates a Propagation-Based Phase-Contrast image by propagating the absorption image through the Fresnel Propagation Integral:
Arguments description
thicknessis expected to be a matrix of thickness values representing the sample;δis the real decrement of the refractive index;βis the imaginary part of the refractive index;kis the wave number;I_0the initial intensity of radiation;Ris the propagation distance;pixelsizeis the size of the pixel in the imaging system. Note:thickness,k,R, andpixelsizemust be expressed in the same unit system.
montecarlo_radiography(size_x, size_y, photons_per_pixel, t, grad_t, δ, β, k, R, pixelsize; multithreading = true)which simulates a Propagation-Based Phase-Contrast image through a MC simulation.
Arguments description
size_xandsize_yare the dimensions of the desired output image;photons_per_pixelis the average number of photons per pixel to be simulated;tis a function representing the thickness distribution of the sample, e.g.:thickness::Float64 = t(x::Tuple{Float64,Float64});grad_tis a function representing the gradient oft, e.g.:grad_thickness::Tuple{Float64,Float64} = grad_t(x::Tuple{Float64,Float64});δis the real decrement of the refractive index;βis the imaginary part of the refractive index;kis the wave number;I_0the initial intensity of radiation;Ris the propagation distance;pixelsizeis the size of the pixel in the imaging system.multithreadingis an optional argument which defaults to true and controls whether the code should be executed on all available threads. You can check the number of available threads by:
julia> Threads.nthreads()Note: thickness, k, R, and pixelsize must be expressed in the same unit system.
In the retrieval.jl file, there are two main functions of interest:
PhaseRetrieve(input_image, δ, β, k, R, pixelsize)which executes the numerical phase retrieval on a Propagation-Based Phase-Contrast image through the Paganin Method:
Arguments description
input_imageis the measured image;δis the real decrement of the refractive index;βis the imaginary part of the refractive index;kis the wave number;Ris the propagation distance;pixelsizeis the size of the pixel in the imaging system.
Note: k, R, and pixelsize must be expressed in the same unit system. The output will be in that unit system.
DarkFieldRetrieve(input_image, δ, β, R, λ, pixelsize, ε; scale = 1, save_images = true)which executes the numerical retrieval of dark-field signal on a Propagation-Based Phase-Contrast image through the Gureyev Method:
Arguments description
input_imageis the measured image;δis the real decrement of the refractive index;βis the imaginary part of the refractive index;Ris the propagation distance;λis the wavelength;pixelsizeis the size of the pixel in the imaging system;εis the dimensionless parameter for Tykhonoff regularization;scaleis the optional upscaling factor (default value 1) to use in forward propagations to avoid artifacts due to sampling;save_imagesis the optional parameter to save all intermediate images and defaults tofalse.
Note: λ, R, and pixelsize must be expressed in the same unit system.
The output is a Tuple containing A_Born, I_TIE_PR (TIE Phase-Retrieval), and, optionally (if save_images is set to true), images_paths, an array containing the paths to the saved images.