ultrasound_metrics.metrics.utils#
Utility functions for ultrasound metrics calculations.
Helper functions for dimension handling, indexing, and interpolation used by various metrics.
Functions#
|
Calculate linear interpolation between two points. |
Find maximum index within expected target radius. |
|
Get subscript index of maximum value within ROI. |
|
Reduce image to 1D at specified point. |
|
Reduce image to only specified measurement dimensions. |
|
Reduce maximum index to only measurement dimensions. |
|
Reorder measured dimensions into original image shape. |
|
Set default measurement dimensions based on image shape. |
Module Contents#
- ultrasound_metrics.metrics.utils.calculate_linear_interpolation( ) float[source]#
Calculate linear interpolation between two points.
- Parameters:
a – Value at first point.
b – Value at second point.
a_idx – Index of first point.
b_idx – Index of second point.
interp_val – Value to interpolate to.
- Returns:
Interpolated index value.
- Return type:
- ultrasound_metrics.metrics.utils.find_max_idx_within_expected_target_radius(
- img: numpy.typing.NDArray[numpy.floating],
- img_max_idx: tuple[int, Ellipsis],
- radius: int,
Find maximum index within expected target radius.
- Parameters:
img – Input image array.
img_max_idx – Initial maximum index.
radius – Search radius around the initial maximum.
- Returns:
Index of maximum value within the specified radius.
- Return type:
- ultrasound_metrics.metrics.utils.get_subscript_idx_of_target_max_within_roi(
- img: numpy.typing.NDArray[numpy.floating],
- roi_indices: numpy.typing.NDArray[numpy.integer],
Get subscript index of maximum value within ROI.
- Parameters:
img – Input image array.
roi_indices – Indices defining the region of interest.
- Returns:
Subscript index of the maximum value within the ROI.
- Return type:
- ultrasound_metrics.metrics.utils.reduce_image_to_1D_at_point(
- img: numpy.typing.NDArray[numpy.floating],
- point: tuple[int, Ellipsis],
- keep_dim: int,
Reduce image to 1D at specified point.
- Parameters:
img – Input image array.
point – Point coordinates to extract.
keep_dim – Dimension to keep (others will be sliced at the point).
- Returns:
1D array extracted from the image at the specified point.
- Return type:
ndarray
- ultrasound_metrics.metrics.utils.reduce_image_to_only_measurement_dimensions(
- img: numpy.typing.NDArray[numpy.floating],
- measurement_dimensions: numpy.typing.NDArray[numpy.integer],
- img_max_idx: tuple[int, Ellipsis],
Reduce image to only specified measurement dimensions.
- Parameters:
img – Input image array.
measurement_dimensions – Dimensions to keep in the output.
img_max_idx – Index of maximum value in the image.
- Returns:
Image reduced to measurement dimensions only.
- Return type:
ndarray
- ultrasound_metrics.metrics.utils.reduce_max_idx_to_only_measurement_dimensions(
- img_max_idx: numpy.typing.NDArray[numpy.integer],
- dims_to_measure: numpy.typing.NDArray[numpy.integer],
Reduce maximum index to only measurement dimensions.
- Parameters:
img_max_idx – Index of maximum value in the image.
dims_to_measure – Dimensions to keep.
- Returns:
Maximum index reduced to measurement dimensions only.
- Return type:
- ultrasound_metrics.metrics.utils.reorder_measured_dims_into_original_shape(
- sll_of_measured_dims: numpy.typing.NDArray[numpy.floating],
- n_dim_of_input_image: int,
- measurement_dimensions: numpy.typing.NDArray[numpy.integer],
Reorder measured dimensions into original image shape.
- Parameters:
sll_of_measured_dims – Measured values for each dimension.
n_dim_of_input_image – Number of dimensions in the original image.
measurement_dimensions – Dimensions that were measured.
- Returns:
List of measured values reordered to match original image dimensions.
- Return type:
- ultrasound_metrics.metrics.utils.set_default_measurement_dims( ) numpy.typing.NDArray[numpy.integer][source]#
Set default measurement dimensions based on image shape.
- Parameters:
img_shape – Shape of the input image.
- Returns:
Array of valid measurement dimensions.
- Return type:
ndarray