nabu.preproc.ctf module

class nabu.preproc.ctf.GeoPars(z1_vh=None, z2=None, pix_size_det=None, wavelength=None, magnification=True, length_scale=1e-05, logger=None)[source]

Bases: object

A class to describe the geometry of a phase contrast radiography with a source obtained by a focussing system, possibly astigmatic, which is at distance z1_vh from the sample. The detector is at z2 from the sample

Parameters:
  • z1_vh (None, a float, or a sequence of two floats) – the source sample distance (meters), if None the parallel beam is assumed. If two floats are given then they are taken as the distance of the vertically focused source (horizontal line) and the horizontaly focused source (vertical line) for KB mirrors.

  • z2 (float) – the sample detector distance (meters).

  • pix_size_det (float) – pixel size (meters)

  • wavelength (float) – beam wave length (meters).

  • magnification (boolean defaults to True) – if false no magnification is considered

  • length_scale (float) – rescaling length scale, meant to avoid having too big or too small numbers. defaults to 10.0e-6

  • logger (Logger, optional) – A logging object

class nabu.preproc.ctf.CTFPhaseRetrieval(shape, geo_pars, delta_beta, padded_shape='auto', padding_mode='reflect', translation_vh=None, normalize_by_mean=False, lim1=1e-05, lim2=0.2, use_rfft=False, fftw_num_threads=None, fft_num_threads=None, logger=None)[source]

Bases: object

This class implements the CTF formula of [1] in its regularised form which avoids the zeros of unregularised_filter_denominator (unreg_filter_denom is the so here named denominator/delta_beta of equation 8).

References

[1] B. Yu, L. Weber, A. Pacureanu, M. Langer, C. Olivier, P. Cloetens, and F. Peyrin, “Evaluation of phase retrieval approaches in magnified X-ray phase nano computerized tomography applied to bone tissue”, Optics Express, Vol 26, No 9, 11110-11124 (2018)

Initialize a Contrast Transfer Function phase retrieval.

Parameters:
  • geo_pars (GeoPars) – the geometry description

  • delta_beta (float) – the delta/beta ratio

  • padded_shape (str or tuple, optional) – Padded image shape, in the form (num_rows, num_columns) i.e (vertical, horizontal). By default, it is twice the image shape.

  • padding_mode (str) – Padding mode. It must be valid for the numpy.pad function

  • translation_vh (array, optional) – Shift in the form (y, x). It is used to perform a translation of the image before applying the CTF filter.

  • normalize_by_mean (bool) – Whether to divide the (padded) image with its mean before applying the CTF filter.

  • lim1 (float >0) – the regulariser strenght at low frequencies

  • lim2 (float >0) – the regulariser strenght at high frequencies

  • use_rfft (bool, optional) – Whether to use real-to-complex (R2C) FFT instead of usual complex-to-complex (C2C).

  • fftw_num_threads (bool or None or int, optional) – DEPRECATED - please use fft_num_threads instead.

  • fft_num_threads (bool or None or int, optional) – Number of threads to use for FFT. If a number is provided: number of threads to use for FFT. You can pass a negative number to use N - fft_num_threads cores.

  • logger (optional) – a logger object

retrieve_phase(img, output=None)[source]

Apply the CTF filter to retrieve the phase.

Parameters:

img (np.ndarray) – Projection image. It must have been already flat-fielded.

Returns:

ph – Phase image

Return type:

numpy.ndarray

nabu.preproc.ctf.CtfFilter

alias of CTFPhaseRetrieval