corrct.alignment.shifts
Detector shifts finding classes.
@author: Nicola VIGANÒ, Computational Imaging group, CWI, The Netherlands, and ESRF - The European Synchrotron, Grenoble, France
Module Contents
Classes
Compute the detector shifts for a given dataset. |
|
Compute the pre-alignment detector shifts for a given dataset. |
|
Compute the center-of-rotation for a given dataset, by cross correlation. |
Functions
Data
API
- corrct.alignment.shifts.eps
None
- corrct.alignment.shifts.NDArrayFloat
None
- corrct.alignment.shifts._filter_shifts(shifts_vu: corrct.alignment.shifts.NDArrayFloat, max_shifts: corrct.alignment.shifts.NDArrayFloat) corrct.alignment.shifts.NDArrayFloat [source]
- class corrct.alignment.shifts.DetectorShiftsBase(data_dvwu: corrct.alignment.shifts.NDArrayFloat, rot_angle_rad: Union[numpy.typing.ArrayLike, corrct.alignment.shifts.NDArrayFloat], *, data_format: str = 'dvwu', data_mask_dvwu: Optional[numpy.typing.NDArray] = None, borders_dvwu: dict = {'d': None, 'v': None, 'w': None, 'u': None}, max_shifts: Union[float, corrct.alignment.shifts.NDArrayFloat, None] = None, precision_decimals: int = 2, verbose: bool = True)[source]
Compute the detector shifts for a given dataset.
Initialization
Initialize the base class for detector shifts.
Parameters
data_dvwu : NDArrayFloat The tomographic data. rot_angle_rad : ArrayLike | NDArrayFloat The rotation angles in radians. data_format : str, optional The data organization, by default “dvwu” data_mask_dvwu : NDArray | None, optional The mask of the tomographic data, by default None borders_dvwu : dict, optional The borders of the tomographic data, by default {“d”: None, “v”: None, “w”: None, “u”: None} max_shifts : float | NDArrayFloat | None, optional Maximum shifts allowed, by default None precision_decimals : int, optional The precision of the results, by default 2 verbose : bool, optional Whether to be verbose, by default True
Raises
ValueError Raised when passing incoherent data and angles.
- data_vwu: corrct.alignment.shifts.NDArrayFloat
None
- angles_rad: corrct.alignment.shifts.NDArrayFloat
None
- class corrct.alignment.shifts.DetectorShiftsPRE(data_dvwu: corrct.alignment.shifts.NDArrayFloat, rot_angle_rad: Union[numpy.typing.ArrayLike, corrct.alignment.shifts.NDArrayFloat], *, data_format: str = 'dvwu', data_mask_dvwu: Optional[numpy.typing.NDArray] = None, borders_dvwu: dict = {'d': None, 'v': None, 'w': None, 'u': None}, max_shifts: Union[float, corrct.alignment.shifts.NDArrayFloat, None] = None, precision_decimals: int = 2, verbose: bool = True)[source]
Bases:
corrct.alignment.shifts.DetectorShiftsBase
Compute the pre-alignment detector shifts for a given dataset.
Initialization
Initialize the base class for detector shifts.
Parameters
data_dvwu : NDArrayFloat The tomographic data. rot_angle_rad : ArrayLike | NDArrayFloat The rotation angles in radians. data_format : str, optional The data organization, by default “dvwu” data_mask_dvwu : NDArray | None, optional The mask of the tomographic data, by default None borders_dvwu : dict, optional The borders of the tomographic data, by default {“d”: None, “v”: None, “w”: None, “u”: None} max_shifts : float | NDArrayFloat | None, optional Maximum shifts allowed, by default None precision_decimals : int, optional The precision of the results, by default 2 verbose : bool, optional Whether to be verbose, by default True
Raises
ValueError Raised when passing incoherent data and angles.
- fit_v(use_derivative: bool = True, use_rfft: bool = True, normalize_fourier: bool = True) corrct.alignment.shifts.NDArrayFloat [source]
Compute the pre-alignment vertical shifts of a 3D dataset.
The pre-alignment shifts are computed by cross-correlation of one projection against the others. The projections are integrated in the horizontal direction.
In the vertical direction, it is suggested to use some high pass filter. The default option is to use the derivates of the intensity profiles.
Parameters
use_derivative : bool, optional Whether to use the derivate of the vertical profile, by default True use_rfft : bool, optional Whether to use the
rfft
transform for the cross-correlation, by default True normalize_fourier : bool, optional Whether to normalize the cross-correlation in Fourier space, by default TrueReturns
NDArrayFloat The vertical shifts.
Raises
ValueError If the dataset is 2D.
- fit_u(fit_l1: bool = False, background: Union[float, numpy.typing.NDArray, None] = None, method: str = 'com') tuple[corrct.alignment.shifts.NDArrayFloat, float] [source]
Compute the pre-alignment shifts for the horizontal dimension.
The pre-alignment shifts, and center-of-rotation (CoR) are computed by fitting a sinusoid to the centers of mass of each angle in the sinogram. The bias of the sinusoid corresponds to the CoR, while the deviations from the fitted curve correspond to the shifts.
Parameters
fit_l1 : bool, optional Computes the l1-min fit of the sinusoid, by default False. background : float | NDArray | None, optional Removes the given background, by default None. method : str, optional The method used for the identification of the fiducial marker position. Options are “com” (center-of-mass) | “max” (maximum value), by default “com”.
Returns
Tuple[NDArrayFloat, float] The shifts and the CoR.
- class corrct.alignment.shifts.DetectorShiftsXC(data_dvwu: corrct.alignment.shifts.NDArrayFloat, rot_angle_rad: Union[numpy.typing.ArrayLike, corrct.alignment.shifts.NDArrayFloat], *, data_format: str = 'dvwu', data_mask_dvwu: Optional[numpy.typing.NDArray] = None, borders_dvwu: dict = {'d': None, 'v': None, 'w': None, 'u': None}, max_shifts: Union[float, corrct.alignment.shifts.NDArrayFloat, None] = None, precision_decimals: int = 2, verbose: bool = True)[source]
Bases:
corrct.alignment.shifts.DetectorShiftsBase
Compute the center-of-rotation for a given dataset, by cross correlation.
Initialization
Initialize the base class for detector shifts.
Parameters
data_dvwu : NDArrayFloat The tomographic data. rot_angle_rad : ArrayLike | NDArrayFloat The rotation angles in radians. data_format : str, optional The data organization, by default “dvwu” data_mask_dvwu : NDArray | None, optional The mask of the tomographic data, by default None borders_dvwu : dict, optional The borders of the tomographic data, by default {“d”: None, “v”: None, “w”: None, “u”: None} max_shifts : float | NDArrayFloat | None, optional Maximum shifts allowed, by default None precision_decimals : int, optional The precision of the results, by default 2 verbose : bool, optional Whether to be verbose, by default True
Raises
ValueError Raised when passing incoherent data and angles.
- fit_vu_accum_drifts(ref_data_dvwu: Optional[corrct.alignment.shifts.NDArrayFloat] = None) numpy.typing.NDArray [source]
Fit static image drifts.
Parameters
ref_data_dvwu : Optional[NDArrayFloat], optional Reference image, by default None. If None, the first image in the data stack will be used.
Returns
NDArray The shifts of the image stack.
Raises
ValueError When the number of reference images is either too many or not enough.
- fit_vu(fit_l1: bool = False) numpy.typing.NDArray [source]
Compute the pre-alignment vertical and horizontal shifts, using cross-correlation.
Parameters
fit_l1 : bool, optional Computes the l1-min fit of the sinusoid, by default False.
Returns
NDArray Pre-alignment shifts in VU coordinates.
- fit_u_180() float [source]
Find the center-of-rotation, using the 0 and 180 degrees projections.
Returns
float The center-of-rotation.
- fit_u_360() float [source]
Find the center of rotation over a 360 degrees scan, by taking the average of the 0-180 over all pairs of angles.
Returns
float The center-of-rotation.
- find_shifts_vu(data_dvwu: corrct.alignment.shifts.NDArrayFloat, proj_dvwu: corrct.alignment.shifts.NDArrayFloat, use_derivative: bool = False, xc_opts: collections.abc.Mapping = dict(normalize_fourier=False)) corrct.alignment.shifts.NDArrayFloat [source]
Find shifts between two images or sets of lines.
Parameters
data_dvwu : NDArrayFloat The reference data. proj_dvwu : NDArrayFloat The other data. use_derivative : bool, optional Whether to use derivatives over the horizontal (U) coordinate, by default False.
Returns
NDArrayFloat The shifts in vertical (optional) and horizontal coordinates ([V]U).