atlalign.label package¶
Submodules¶
atlalign.label.cli module¶
atlalign.label.io module¶
Input and output utilities for the command line interface.
- load_image(file_path, allowed_suffix=('jpg', 'png'), output_dtype=None, output_channels=None, output_shape=None, input_shape=None, keep_last=False)[source]¶
Load image.
- Parameters
file_path (str or pathlib.Path) – Path to where the image stored.
allowed_suffix (tuple) – List of allowed suffixes.
output_dtype (str or None) – Determines the dtype of the output image. If None, then the same as input.
output_channels (int, {1, 3} or None) – If 1 then grayscale, if 3 then RGB. If None then the sampe as the input image.
output_shape (tuple) – Two element tuple representing (h_output, w_output).
input_shape (tuple or None) – If None no assertion on the input shape. If not None then a tuple representing (h_input_expected, w_input_expected).
keep_last (bool) – Only active if output_channels=1. If True, then the output has shape (h, w, 1). Else (h, w).
- Returns
img – Array of shape (h, w)
- Return type
np.array
atlalign.label.new_GUI module¶
Graphical User Interface for manual registration.
- class HelperGlobal(img_ref, img_mov, mode, title)[source]¶
Bases:
object
Just a way how to avoid using global variables.
- Parameters
img_ref (np.ndaray) – Reference image. Needs to be dtype == np.uint8.
img_mov (np.ndarray) – Input image. Needs to be dtype == np.uint8 and the same shape as img_ref.
mode (str, {'ref2mov', 'mov2ref'}) – If ‘ref2mov’ then the first point should be in the reference image and the other point in the moving one. For ‘mov2ref’ its vice versa.
title (str,) – Additional title of the figure.
- img_ref_¶
Copy of the reference image.
- Type
np.ndarray
- img_mov_¶
Copy of the moving image.
- Type
np.ndarray
- img_reg¶
Continuously updated registered image.
- Type
np.ndarray
- ax, ax_reg
- Axes objects:
ax — overlay of the img_ref_ and img_mov_ together with scatter of current keypoints. ax_reg - overlay of the img_ref_ and img_reg.
- Type
matplotlib.Axes
- keypoints¶
The keys are (x_ref, y_ref) pairs in the reference image whereas the values are (x_mov, y_mov) tuples. Note that we make heavy use of the None sentinel whenever a new pair is being inputted. If mode = ‘ref2mov’ then it holds that n_ref = n_mov or n_ref = n_mov + 1. In the second case, the sentinel is used in dictionary values. If mode = ‘mov2ref’ then it holds that n_ref = n_mov or n_ref = n_mov - 1. In the second case, the sentinel is used in dictionary keys.
- Type
dict
- all_colors¶
All possible colors for the scatter plot. Note that we infinitely iteratre through this for new input points.
- Type
deque
- epsilon¶
A parameter that determines the rectangle around a clicked point during deletions (spacebar) The higher this parameter the less precise you need to be when trying to delete a reference keypoint.
- Type
int
- on_click(event)[source]¶
Take action on a click.
- Parameters
event (matplotlib.backend_bases.LocationEvent) – The location event.
Notes
We can use this to extract x and y coordinate of the click.
- run_gui(img_ref, img_mov, mode='ref2mov', title='')[source]¶
Graphical user interface for manual labeling.
Notes
If mode == ‘ref2mov’ then one first specifies the point in the reference image (circle marker) and then the corresponding pixel in the moving image (star marker). Note that these pairs have the same color. To delete a specific pair hover above on the undesirable reference point and press space bar and this will automatically delete it. Note that deletion delete both the reference point and the moving point but you can only point at the reference one for deletions.
- Parameters
img_ref (np.ndaray) – Reference image. Needs to be dtype == np.uint8.
img_mov (np.ndarray) – Input image. Needs to be dtype == np.uint8 and the same shape as img_ref.
mode (str, {'ref2mov', 'mov2ref'}) – If ‘ref2mov’ then the first point should be in the reference image and the other point in the moving one. For ‘mov2ref’ its vice versa.
title (str,) – Additional title of the figure.
- Returns
df (DisplacementField) – Displacement field corresponding to the last change before closing the window of the GUI.
keypoints (dict) – Dictionary of keypoints.
symmetric_registration (bool) – Whether or not the registration was symmetrized. If true then all the returned keypoints should be mirrored across a vertical line through the image. This can be done by setting x => (width - x) for all keypoints.
img_reg (np.ndarray) – Registered image.
interpolation_method (str) – Interpolation method
kernel (str) – Kernel.
Module contents¶
Module containing the interactive labeling tool.