curvature#

Calculate various curvature metrics for traces.

Attributes#

Functions#

angle_diff_signed(v1, v2)

Calculate the signed angle difference between two point vecrtors in 2D space.

discrete_angle_difference_per_nm_circular(...)

Calculate the discrete angle difference per nm along a trace.

discrete_angle_difference_per_nm_linear(...)

Calculate the discrete angle difference per nm along a trace.

calculate_curvature_stats_image(→ dict)

Perform curvature analysis for a whole image of grains.

Module Contents#

curvature.LOGGER#
curvature.angle_diff_signed(v1: numpy.typing.NDArray[numpy.number], v2: numpy.typing.NDArray[numpy.number])#

Calculate the signed angle difference between two point vecrtors in 2D space.

Positive angles are clockwise, negative angles are counterclockwise.

Parameters:
  • v1 (npt.NDArray[np.number]) – First vector.

  • v2 (npt.NDArray[np.number]) – Second vector.

Returns:

The signed angle difference in radians.

Return type:

float

curvature.discrete_angle_difference_per_nm_circular(trace_nm: numpy.typing.NDArray[numpy.number]) numpy.typing.NDArray[numpy.number]#

Calculate the discrete angle difference per nm along a trace.

Parameters:

trace_nm (npt.NDArray[np.number]) – The coordinate trace, in nanometre units.

Returns:

The discrete angle difference per nm.

Return type:

npt.NDArray[np.number]

curvature.discrete_angle_difference_per_nm_linear(trace_nm: numpy.typing.NDArray[numpy.number]) numpy.typing.NDArray[numpy.number]#

Calculate the discrete angle difference per nm along a trace.

Parameters:

trace_nm (npt.NDArray[np.number]) – The coordinate trace, in nanometre units.

Returns:

The discrete angle difference per nm.

Return type:

npt.NDArray[np.number]

curvature.calculate_curvature_stats_image(all_grain_smoothed_data: dict, pixel_to_nm_scaling: float) dict#

Perform curvature analysis for a whole image of grains.

Parameters:
  • all_grain_smoothed_data (dict) – Dictionary containing grain traces in pixel units.

  • pixel_to_nm_scaling (float) – Pixel to nm scaling factor.

Returns:

The curvature statistics for each grain. Indexes are grain indexes.

Return type:

dict