fishdist.coordinate_utils

compute_registration_matrix(anterior_src, posterior_src, proximal_src, distal_src, anterior_target, posterior_target, proximal_target, distal_target, return_transformer=False)

Compute the registration matrix for alignment.

Parameters:
  • anterior_src (ndarray) –

    Source image of the anterior landmarks.

  • posterior_src (ndarray) –

    Source image of the posterior landmarks.

  • proximal_src (ndarray) –

    Source image of the proximal landmarks.

  • distal_src (ndarray) –

    Source image of the distal landmarks.

  • anterior_target (ndarray) –

    Target image of the anterior landmarks.

  • posterior_target (ndarray) –

    Target image of the posterior landmarks.

  • proximal_target (ndarray) –

    Target image of the proximal landmarks.

  • distal_target (ndarray) –

    Target image of the distal landmarks.

  • return_transformer (bool, default: False ) –

    Flag indicating whether to return the affine transformation object.

Returns:
  • ndarray

    Registration matrix as a numpy array or affine transformation object.

convert_slices_to_set_of_coordinates(slices_list)

Converts a list of slices to a set of coordinates.

Parameters:
  • slices_list (list) –

    List of slices.

Returns:
  • numpy.ndarray: Array of coordinates.

Examples:

Convert a list of slices to a set of coordinates:

>>> coordinates = convert_slices_to_set_of_coordinates(slices_list)

get_cuboid(image, centroid, cube_radius, return_cuboid_coords_instead=False, force_centroid_int=True)

Extracts a cuboid region from an image based on the centroid and cube radius.

Parameters:
  • image (ndarray) –

    The input image.

  • centroid (ndarray or list) –

    The centroid coordinates.

  • cube_radius (ndarray or list) –

    The radius of the cuboid in each dimension.

  • return_cuboid_coords_instead (bool, default: False ) –

    If True, returns the coordinates of the cuboid instead of the cuboid itself. Defaults to False.

  • force_centroid_int (bool, default: True ) –

    If True, forces the centroid coordinates to be integers. Defaults to True.

Returns:
  • numpy.ndarray or list: The cuboid region or its coordinates.

Examples:

Extract a cuboid region from an image:

>>> cuboid = get_cuboid(image, centroid, cube_radius)

Extract the coordinates of a cuboid region:

>>> cuboid_coords = get_cuboid(image, centroid, cube_radius, return_cuboid_coords_instead=True)

make_point_in_bounds(point, bounds_array_as_n_and_2_dimensions_giving_min_and_max_of_each_dim)

Adjusts a point to be within the given bounds.

Parameters:
  • point (ndarray) –

    The point coordinates.

  • bounds_array_as_n_and_2_dimensions_giving_min_and_max_of_each_dim (ndarray) –

    Bounds array with min and max values for each dimension.

Returns:
  • numpy.ndarray: The adjusted point within the bounds.

Examples:

Adjust a point to be within the bounds:

>>> new_point = make_point_in_bounds(point, bounds_array)

nd_slice_to_indexes(nd_slice)

Converts an n-dimensional slice to indices.

Parameters:
  • nd_slice (slice or tuple) –

    The n-dimensional slice.

Returns:
  • tuple

    Indexes for each dimension.

Examples:

Convert an n-dimensional slice to indices:

>>> indexes = nd_slice_to_indexes(nd_slice)

remove_out_of_bonds_coords(region_coords, bounds)

Removes coordinates that are outside of the given bounds.

Parameters:
  • region_coords (ndarray) –

    The region coordinates.

  • bounds (tuple) –

    The bounds of the region.

Returns:
  • numpy.ndarray: The region coordinates within the bounds.

Examples:

Remove coordinates outside of the bounds:

>>> new_coords = remove_out_of_bonds_coords(region_coords, bounds)

remove_out_of_bonds_coords_nd(region_coords, bounds_array_as_n_and_2_dimensions_giving_min_and_max_of_each_dim)

Removes coordinates that are outside of the given bounds.

Parameters:
  • region_coords (ndarray) –

    The region coordinates.

  • bounds_array_as_n_and_2_dimensions_giving_min_and_max_of_each_dim (ndarray) –

    Bounds array with min and max values for each dimension.

Returns:
  • numpy.ndarray: The region coordinates within the bounds.

Examples:

Remove coordinates outside of the bounds:

>>> new_coords = remove_out_of_bonds_coords_nd(region_coords, bounds_array)

remove_out_of_image_coords(region_coords, img)

Removes coordinates that are outside of the image bounds.

Parameters:
  • region_coords (ndarray) –

    The region coordinates.

  • img (ndarray) –

    The image.

Returns:
  • numpy.ndarray: The region coordinates within the image bounds.

Examples:

Remove coordinates outside of the image bounds:

>>> new_coords = remove_out_of_image_coords(region_coords, img)