linumpy.registration.manual#
Manual image registration and correction GUI for z-slice stacks.
Attributes#
Classes#
Manual image correction using a graphical user interface. |
Functions#
|
Apply transformation to coordinates. |
|
Rescale image intensities from (vmin, vmax) to (0.0, 1.0). |
|
Transform and rescale a 2D slice. |
Module Contents#
- class linumpy.registration.manual.ManualImageCorrection(data, resolution, downsample_factor, transforms=None, custom_ranges=None)[source]#
Manual image correction using a graphical user interface.
Corrections include independent translation and rotation of each z-slice as well as image intensities rescaling per z-slice.
- Parameters:
data (ndarray of shape (nz, ny, nx)) – Stack of images, where images are stacked along the first axis (z).
resolution (3-tuple) – Resolution of the dataset (rz, ry, rx).
downsample_factor (int) – Factor by which the full resolution images are downscaled prior to rendering. Tradeoff between image quality and interactivity of the GUI. Does not influence the resolution of the corrected image.
transforms (ndarray (nz, 3), optional) – Transform for each slice where each array (3,) contains a translation (ty, tx) and a rotation (theta).
custom_ranges (ndarray (nz, 2), optional) – Intensities for rescaling each slice. One (vmin, vmax) per slice.
- on_change_scaling(scaling_range)[source]#
Update intensity rescaling for the current z-slice.
- Parameters:
scaling_range (tuple)
- Return type:
None
- on_change_offset_a(val)[source]#
Update y-translation for the current z-slice.
- Parameters:
val (float)
- Return type:
None
- on_change_offset_b(val)[source]#
Update x-translation for the current z-slice.
- Parameters:
val (float)
- Return type:
None
- on_change_theta(val)[source]#
Update rotation angle for the current z-slice.
- Parameters:
val (float)
- Return type:
None
- on_change_ref_z(label)[source]#
Update reference z-slice mode.
- Parameters:
label (str | None)
- Return type:
None
- transform_coordinates(coordinates, z=None)[source]#
Apply the stored transform to a set of grid coordinates.
- Parameters:
coordinates (numpy.ndarray)
z (int | None)
- Return type:
- apply_scaling(data, z=None)[source]#
Rescale slice intensities using the stored per-slice ranges.
- Parameters:
data (numpy.ndarray)
z (int | None)
- Return type:
- draw_cursor(data)[source]#
Draw a cursor line at the current z position on a view.
- Parameters:
data (numpy.ndarray)
- Return type:
- linumpy.registration.manual.apply_transform(ty, tx, theta, coordinates)[source]#
Apply transformation to coordinates.
Coordinates are expected to be of shape (nz, ny, nx, 3), with each coordinate given in the order (z, y, x).
- Parameters:
ty (float or ndarray of shape (nz,)) – Translation along y axis.
tx (float or ndarray of shape (nz,)) – Translation along x axis.
theta (float or ndarray of shape (nz,)) – Rotation around z axis in radians. The center of rotation is the center of the image.
coordinates (ndarray of shape (nz, ny, nx, 3)) – Input grid coordinates in (z, y, x) order.
- Returns:
coordinates – Transformed coordinates.
- Return type:
ndarray (nz, ny, nx, 3)
- linumpy.registration.manual.apply_scaling(data, vmin, vmax)[source]#
Rescale image intensities from (vmin, vmax) to (0.0, 1.0).
Values outside the range (vmin, vmax) are clipped.
Rescaling can be performed with a single range for the whole image or with a different range for each ROW. In the case, the first dimension of data should correspond to the number of elements in vmin, vmax.
- Parameters:
- Returns:
data – Recaled intensities.
- Return type:
ndarray
- linumpy.registration.manual.transform_and_rescale_slice(slice, ty, tx, theta, vmin, vmax)[source]#
Transform and rescale a 2D slice.
Transform consists of a translation (ty, tx) and a rotation theta. Rescaling clips intensities to (vmin, vmax) and rescales the resulting values to the range (0, 1).
- Parameters:
- Returns:
slice – Processed slice.
- Return type:
ndarray of shape (ny, nx)