pystack3d.registration_calculation module
Functions related to the registration calculation processing
- pystack3d.registration_calculation.init_args(params, shape)
Initialize arguments related to the current processing (‘registration_calculation’) and return a specific array to share (tmats)
- Parameters:
params (dict) – Dictionary related to the current process. See the related documentation for more details.
shape (tuple of 3 int) – Shape of the stack to process
- Returns:
tmats – Transformation matrices to be shared during the (multi)processing
- Return type:
numpy.ndarray((shape[0], nblocks[0]*nblocks[1], 3, 3))
- pystack3d.registration_calculation.registration_calculation(fnames=None, inds_partition=None, queue_incr=None, area=None, threshold=None, nb_blocks=None, transformation='TRANSLATION', output_dirname=None)
Function dedicated to the transformation matrices calculation used in the image registration
- Parameters:
fnames (list of pathlib.Path, optional) – List of ‘.tif’ filenames to process
inds_partition (list of ints, optional) – List of indexes to be considered by the global var SHARED_ARRAY when working in multiprocessing
queue_incr (multiprocessing.Queue, optional) – Queue passed to the function to interact with the progress bar
area (iterable of 4 ints, optional) – Area defined from coordinates (xmin, xmax, ymin, ymax) to calculate the transformation matrices. If None, consider the whole images.
threshold (float, optional) – Threshold value used to perform registration on binarized images
nb_blocks (tuple of 2 ints (p, q), optional) – Number of patches (sub-images) to consider in each axis to perform the registrations. If None, consider the whole image
transformation (str, optional) – Transformation matrix type to consider for the registration. To choose among : [‘TRANSLATION’, ‘RIGID_BODY’, ‘SCALED_ROTATION’, ‘AFFINE’] (See pystackreg documentation for more details). If None, the default Transformation matrix type is ‘TRANSLATION’
output_dirname (str, optional) – Directory pathname for process results saving
- pystack3d.registration_calculation.tmat_calculation(ref, img, nb_blocks=None, transformation='TRANSLATION')
Transformation matrix calculation with StackReg from pystackreg package applied on patches (sub-images)
- Parameters:
ref (numpy.ndarray((m,n))) – Image used as reference
img (numpy.ndarray((m,n))) – Image considered as ‘moving’ image
nb_blocks (tuple of 2 ints (p, q), optional) – Number of patches (sub-images) to consider in each axis to perform the registrations. If None, consider the whole image
transformation (str, optional) – Transformation matrix type to consider for the registration. To choose among : [‘TRANSLATION’, ‘RIGID_BODY’, ‘SCALED_ROTATION’, ‘AFFINE’] (See pystackreg documentation for more details). If None, the default Transformation matrix type is ‘TRANSLATION’
- Returns:
tmats – Transformation matrix calculated in all patches
- Return type:
numpy.ndarray((p*q, 3*3))
- pystack3d.registration_calculation.plot(output_dirname)
Plot the specific data related to the current process
- pystack3d.registration_calculation.registration_plot(tmats, nb_blocks=None, transformation='RIGID_BODY', cumul=False, title='Registration')
Plot the evolution of the transformation matrix components issued from the registration processing
- Parameters:
tmats (sequence of nslices * nb_blocks * numpy.ndarray((3, 3))) – Transformations matrices calculated during the registration processing
nb_blocks (tuple of 2 ints (p, q)) – Number of patches (sub-images) used during the registration processing
transformation (str, optional) – Transformation matrix type considered for the plotting. If None, consider a ‘RIGID_BODY’ transformation type.
cumul (bool, optional) – Activation key to plot the cumulative transformations matrices evolution
title (str, optional) – Title of the figure
- Returns:
fig
- Return type:
matplotlib.figure
- pystack3d.registration_calculation.decomposition(tmat)
Return ‘transl_x’, ‘transl_y’, ‘rotation’, ‘scale_x’, ‘scale_y’ and ‘shear’ related to a 2D-Affine transformation matrix
Notes
Translation values are given according to “natural” (x, y) coordinates. Rotation angle are given according to the counter-clockwise convention.