nabu.pipeline.estimators module

nabu.pipeline.estimators: helper classes/functions to estimate parameters of a dataset (center of rotation, detector tilt, etc).

nabu.pipeline.estimators.estimate_cor(method, dataset_info, do_flatfield=True, cor_options=None, logger=None)[source]

High level function to compute the center of rotation (COR)

Parameters:
  • method (name of the method to be used for computing the center of rotation) –

  • dataset_info (nabu.resources.dataset_analyzer.DatasetAnalyzer) – Dataset information structure

  • do_flatfield (If True apply flat field to compute the center of rotation) –

  • cor_options (optional dictionary that can contain the following keys:) –

    • slice_idx: index of the slice to use for computing the sinogram (for sinogram based algorithms)

    • subsampling subsampling

    • radio_angles: angles of the radios to use (for radio based algorithms)

  • logger (logging object) –

class nabu.pipeline.estimators.CORFinderBase(method, dataset_info, do_flatfield=True, cor_options=None, logger=None)[source]

Bases: object

A base class for CoR estimators. It does common tasks like data reading, flatfield, etc.

Initialize a CORFinder object.

Parameters:

dataset_info (nabu.resources.dataset_analyzer.DatasetAnalyzer) – Dataset information structure

search_methods = {}
class nabu.pipeline.estimators.CORFinder(method, dataset_info, do_flatfield=True, cor_options=None, logger=None, radio_angles=(0.0, 3.141592653589793))[source]

Bases: CORFinderBase

Find the Center of Rotation with methods based on two (180-degrees opposed) radios.

Initialize a CORFinder object.

Parameters:
  • dataset_info (nabu.resources.dataset_analyzer.DatasetAnalyzer) – Dataset information structure

  • radio_angles (angles to use to find the cor) –

search_methods = {'centered': {'class': <class 'nabu.estimation.cor.CenterOfRotation'>}, 'global': {'class': <class 'nabu.estimation.cor.CenterOfRotationAdaptiveSearch'>, 'default_kwargs': {'high_pass': 20, 'low_pass': 1}}, 'growing-window': {'class': <class 'nabu.estimation.cor.CenterOfRotationGrowingWindow'>}, 'octave-accurate': {'class': <class 'nabu.estimation.cor.CenterOfRotationOctaveAccurate'>}, 'sliding-window': {'class': <class 'nabu.estimation.cor.CenterOfRotationSlidingWindow'>}}
find_cor()[source]

Find the center of rotation.

Returns:

cor – The estimated center of rotation for the current dataset.

Return type:

float

nabu.pipeline.estimators.COREstimator

alias of CORFinder

class nabu.pipeline.estimators.SinoCORFinder(method, dataset_info, do_flatfield=True, take_log=True, cor_options=None, logger=None, slice_idx='middle', subsampling=10)[source]

Bases: CORFinderBase

A class for finding Center of Rotation based on 360 degrees sinograms. This class handles the steps of building the sinogram from raw radios.

Initialize a SinoCORFinder object.

Parameters:
  • cor_options. (The following keys can be set in) –

  • slice_idx (int or str) – Which slice index to take for building the sinogram. For example slice_idx=0 means that we extract the first line of each projection. Value can also be “first”, “top”, “middle”, “last”, “bottom”.

  • subsampling (int, float) – subsampling strategy when building sinograms. As building the complete sinogram from raw projections might be tedious, the reading is done with subsampling. A positive integer value means the subsampling step (i.e projections[::subsampling]).

search_methods = {'fourier-angles': {'class': <class 'nabu.estimation.cor_sino.CenterOfRotationFourierAngles'>}, 'sino-coarse-to-fine': {'class': <class 'nabu.estimation.cor_sino.SinoCorInterface'>}, 'sino-growing-window': {'class': <class 'nabu.estimation.cor.CenterOfRotationGrowingWindow'>}, 'sino-sliding-window': {'class': <class 'nabu.estimation.cor.CenterOfRotationSlidingWindow'>}, 'vo': {'class': <class 'nabu.estimation.cor_sino.CenterOfRotationVo'>}}
find_cor()[source]
nabu.pipeline.estimators.SinoCOREstimator

alias of SinoCORFinder

class nabu.pipeline.estimators.CompositeCORFinder(dataset_info, oversampling=4, theta_interval=5, n_subsampling_y=40, take_log=True, cor_options=None, spike_threshold=0.04, logger=None, norm_order=1)[source]

Bases: CORFinderBase

Class and method to prepare sinogram and calculate COR The pseudo sinogram is built with shrinked radios taken every theta_interval degres

Compared to first writing by Christian Nemoz:
  • gives the same result of the original octave script on the dataset sofar tested

  • The meaning of parameter n_subsampling_y (alias subsampling_y)is now the number of lines which are taken from every radio. This is more meaningful in terms of amout of collected information because it does not depend on the radio size. Moreover this is what was done in the octave script

  • The spike_threshold has been added with default to 0.04

  • The angular sampling is every 5 degree by default, as it is now the case also in the octave script

  • The finding of the optimal overlap is doing by looping over the possible overlap, according to the overlap.

    After a first testing phase, this part, which is the time consuming part, can be accelerated by several order of magnitude without modifing the final result

Initialize a CORFinder object.

Parameters:

dataset_info (nabu.resources.dataset_analyzer.DatasetAnalyzer) – Dataset information structure

search_methods = {'composite-coarse-to-fine': {'class': <class 'nabu.estimation.cor.CenterOfRotation'>}}
get_radio(image_num)[source]
get_sino(reload=False)[source]

Build sinogram (composite image) from the radio files

find_cor(reload=False)[source]
error_metric(common_right, common_left, common_blurred_right, common_blurred_left)[source]
error_metric_l2(common_right, common_left)[source]
error_metric_l1(common_right, common_left, common_blurred_right, common_blurred_left)[source]
nabu.pipeline.estimators.oversample(radio, ovs_s)[source]

oversampling an image in arbitrary directions. The first and last point of each axis will still remain as extremal points of the new axis.

nabu.pipeline.estimators.CompositeCOREstimator

alias of CompositeCORFinder

nabu.pipeline.estimators.get_default_kwargs(func)[source]
nabu.pipeline.estimators.update_func_kwargs(func, options)[source]
nabu.pipeline.estimators.get_class_name(class_object)[source]
class nabu.pipeline.estimators.DetectorTiltEstimator(dataset_info, do_flatfield=True, logger=None, autotilt_options=None)[source]

Bases: object

Helper class for detector tilt estimation. It automatically chooses the right radios and performs flat-field.

Initialize a detector tilt estimator helper.

Parameters:
  • dataset_info (dataset_info object) – Data structure with the dataset information.

  • do_flatfield (bool, optional) – Whether to perform flat field on radios.

  • logger (Logger object, optional) – Logger object

  • autotilt_options (dict, optional) – named arguments to pass to the detector tilt estimator class.

default_tilt_method = '1d-correlation'
tilt_threshold = 0.25
find_tilt(tilt_method=None)[source]

Find the detector tilt.

Parameters:

tilt_method (str, optional) – Which tilt estimation method to use.

nabu.pipeline.estimators.TiltFinder

alias of DetectorTiltEstimator