manual_registration#

Attributes#

Classes#

ManualImageCorrection

Manual image correction using a graphical user interface. Corrections

Functions#

apply_transform(ty, tx, theta, coordinates)

Apply transformation to coordinates. Coordinates are expected to be

apply_scaling(data, vmin, vmax)

Rescale image intensities from (vmin, vmax) to (0.0, 1.0). Values

transform_and_rescale_slice(slice, ty, tx, theta, ...)

Transform and rescale 2D slice. Transform consists of a translation

Module Contents#

manual_registration.PREV_REF_LABEL = 'Previous slice as reference'[source]#
manual_registration.NEXT_REF_LABEL = 'Next slice as reference'[source]#
manual_registration.NO_REF_LABEL = 'No reference slice'[source]#
class manual_registration.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.

downsample[source]#
max_z[source]#
image_interpolator[source]#
grid_coordinates[source]#
transforms = None[source]#
custom_ranges = None[source]#
ref_z_mode = 'No reference slice'[source]#
current_x[source]#
current_y[source]#
current_z = 0[source]#
axim_a[source]#
axim_b[source]#
axim_c[source]#
scalebar[source]#
s_offset_a[source]#
s_offset_b[source]#
s_current_z[source]#
s_current_y[source]#
s_current_x[source]#
s_theta[source]#
radio_buttons[source]#
start()[source]#

Start GUI.

Returns:

return – True when the window closes.

Return type:

bool

on_change_scaling(scaling_range)[source]#
Return type:

None

on_change_z(val)[source]#
Return type:

None

on_change_y(val)[source]#
Return type:

None

on_change_x(val)[source]#
Return type:

None

on_change_offset_a(val)[source]#
Return type:

None

on_change_offset_b(val)[source]#
Return type:

None

on_change_theta(val)[source]#
Return type:

None

on_change_ref_z(label)[source]#
Return type:

None

transform_coordinates(coordinates, z=None)[source]#
apply_scaling(data, z=None)[source]#
draw_cursor(data)[source]#
get_view_a()[source]#
get_view_b()[source]#
get_view_c()[source]#
save_results(filename)[source]#

Save resulting corrections to npz file.

Parameters:

filename (string or Path) – Output filename.

Return type:

None

manual_registration.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.

Returns:

coordinates – Transformed coordinates.

Return type:

ndarray (nz, ny, nx, 3)

manual_registration.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:
  • data (ndarray) – The intensities to rescale.

  • vmin (float or ndarray of shape (data.shape[0],)) – Minimum value. Will be worth 0 after rescaling.

  • vmax (float or ndarray of shape (data.shape[0],)) – Maximum value. Will be worth 1 after rescaling.

Returns:

data – Recaled intensities.

Return type:

ndarray

manual_registration.transform_and_rescale_slice(slice, ty, tx, theta, vmin, vmax)[source]#

Transform and rescale 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:
  • slice (ndarray of shape (ny, nx)) – Slice to process.

  • ty (float) – Translation along y axis (first axis).

  • tx (float) – Translation along x axis (second axis).

  • theta (float) – Rotation in radians.

  • vmin (float) – Minimum value for rescaling.

  • vmax (float) – Maximum value for rescaling.

Returns:

slice – Processed slice.

Return type:

ndarray of shape (ny, nx)