Skip to content

Commit

Permalink
tests(processing): Update regression test targets to include dna widt…
Browse files Browse the repository at this point in the history
…h and improved docstring
  • Loading branch information
tcatley committed Nov 15, 2024
1 parent 39305c5 commit 09e10d1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions topostats/tracing/disordered_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,21 @@ def smooth_mask(
@staticmethod
def calculate_dna_width(smoothed_mask: npt.NDArray, pruned_skeleton: npt.NDArray, px2nm: float = 1) -> float:
"""
Calculate the average width in metres of the DNA using the trace and mask.
Calculate the mean width in metres of the DNA using the trace and mask.
Parameters
----------
smoothed_mask : npt.NDArray
Smoothed mask to be measured.
pruned_skeleton : npt.NDArray
Pruned skeleton.
px2nm : float
Scaling of pixels to nanometres.
Returns
-------
float
Width of grain in metres.
"""
# Code will go here
dist_trans = distance_transform_edt(smoothed_mask)
Expand Down Expand Up @@ -375,7 +389,7 @@ def trace_image_disordered( # pylint: disable=too-many-arguments,too-many-local
"grain_endpoints": np.int64((conv_pruned_skeleton == 2).sum()),
"grain_junctions": np.int64((conv_pruned_skeleton == 3).sum()),
"total_branch_lengths": total_branch_length,
"grain_width": disorderedTrace.calculate_dna_width(
"grain_width_mean": disorderedTrace.calculate_dna_width(
disordered_trace_images["smoothed_grain"],
disordered_trace_images["pruned_skeleton"],
pixel_to_nm_scaling,
Expand Down

0 comments on commit 09e10d1

Please sign in to comment.