Skip to content

Commit

Permalink
test(grainstats): Removes min/max feret co-ordinates from output
Browse files Browse the repository at this point in the history
Further to #823 this reverts the GrainStats output to its previous form and removes the feret co-ordinates from the
output as discussed in this mornings meeting.
  • Loading branch information
ns-rse committed Apr 17, 2024
1 parent c7111af commit 9fd3eb8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret max_feret_coords min_feret_coords image
molecule_number
0 7.500895e-08 4.775362e-08 4.044948e-09 2.542964e-08 1.600048e-08 1.647888e-08 1.006306e-09 2.696640e-09 1.597337e-09 1.596062e-09 1.084371e-24 6.794043e-16 1.319762e-15 2.053897e-08 5.037861e-08 1.034725e-15 2.452830 above 5.037861e-08 2.053897e-08 [[10, 0], [5, 25]] [[10.1923076923077, 15.0384615384615], [0.0, 13.0]] None
1 8.028649e-08 7.895237e-08 6.658610e-09 2.623645e-08 1.609777e-08 1.573693e-08 1.009513e-09 2.480685e-09 1.668932e-09 1.683197e-09 1.031843e-24 6.130257e-16 1.526707e-15 2.017441e-08 4.942135e-08 9.970467e-16 2.449704 above 4.987228e-08 2.017441e-08 [[1, 1], [15, 22]] [[10.2518248175182, 6.6824817518248], [1.0, 11.0]] None
2 4.001424e-08 7.585689e-08 9.745734e-09 2.369314e-08 1.746942e-08 1.818722e-08 1.006681e-09 2.139365e-09 1.646541e-09 1.598842e-09 1.123717e-24 7.028320e-16 1.546230e-15 3.359220e-08 4.149625e-08 1.393950e-15 1.235294 above 4.440534e-08 3.176819e-08 [[21, 6], [0, 14]] [[11.1834319526627, 14.8402366863905], [5.0, 0.0]] None
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image
molecule_number
0 7.500895e-08 4.775362e-08 4.044948e-09 2.542964e-08 1.600048e-08 1.647888e-08 1.006306e-09 2.696640e-09 1.597337e-09 1.596062e-09 1.084371e-24 6.794043e-16 1.319762e-15 2.053897e-08 5.037861e-08 1.034725e-15 2.452830 above 5.037861e-08 2.053897e-08 None
1 8.028649e-08 7.895237e-08 6.658610e-09 2.623645e-08 1.609777e-08 1.573693e-08 1.009513e-09 2.480685e-09 1.668932e-09 1.683197e-09 1.031843e-24 6.130257e-16 1.526707e-15 2.017441e-08 4.942135e-08 9.970467e-16 2.449704 above 4.987228e-08 2.017441e-08 None
2 4.001424e-08 7.585689e-08 9.745734e-09 2.369314e-08 1.746942e-08 1.818722e-08 1.006681e-09 2.139365e-09 1.646541e-09 1.598842e-09 1.123717e-24 7.028320e-16 1.546230e-15 3.359220e-08 4.149625e-08 1.393950e-15 1.235294 above 4.440534e-08 3.176819e-08 None
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
image_size_x_m image_size_y_m image_area_m2 image_size_x_px image_size_y_px image_area_px2 grains_number_above grains_per_m2_above grains_number_below grains_per_m2_below rms_roughness
image
image
minicircle_small 1.2646e-07 1.2646e-07 1.5993e-14 64 64 4096 3 1.8758e+14 0 0.0000e+00 6.8208e-10
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret max_feret_coords min_feret_coords image contour_length circular end_to_end_distance
molecule_number
0 7.5100e-08 4.7559e-08 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 2.4528e+00 above 5.0379e-08 2.0539e-08 [[10, 0], [5, 25]] [[10.1923076923077, 15.0384615384615], [0.0, 13.0]] minicircle_small 6.0226e-08 False 8.6738e-09
1 8.0241e-08 7.8677e-08 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 2.5385e+00 above 5.1262e-08 2.0174e-08 [[2, 0], [14, 23]] [[10.2518248175182, 6.6824817518248], [1.0, 11.0]] minicircle_small 6.6355e-08 True 0.0000e+00
2 4.0012e-08 7.5644e-08 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 1.2353e+00 above 4.4405e-08 3.2528e-08 [[21, 6], [0, 14]] [[10.3313609467456, 15.1952662721894], [4.0, 0.0]] minicircle_small 9.6106e-08 True 0.0000e+00
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image contour_length circular end_to_end_distance
molecule_number
0 7.5100e-08 4.7559e-08 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 2.4528e+00 above 5.0379e-08 2.0539e-08 minicircle_small 6.0226e-08 False 8.6738e-09
1 8.0241e-08 7.8677e-08 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 2.5385e+00 above 5.1262e-08 2.0174e-08 minicircle_small 6.6355e-08 True 0.0000e+00
2 4.0012e-08 7.5644e-08 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 1.2353e+00 above 4.4405e-08 3.2528e-08 minicircle_small 9.6106e-08 True 0.0000e+00
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
image_size_x_m image_size_y_m image_area_m2 image_size_x_px image_size_y_px image_area_px2 grains_number_above grains_per_m2_above grains_number_below grains_per_m2_below rms_roughness
image
image
minicircle_small 1.2646e-07 1.2646e-07 1.5993e-14 64 64 4096 0 0.0000e+00 1 6.2526e+13 6.8208e-10
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret max_feret_coords min_feret_coords image contour_length circular end_to_end_distance
molecule_number
0 3.2366e-08 1.4036e-08 7.7690e-10 1.2272e-08 6.4301e-09 6.4170e-09 -3.7937e-10 -2.1207e-10 -2.4477e-10 -2.6816e-10 -3.0364e-26 1.1323e-16 3.0066e-16 7.0841e-09 2.1505e-08 1.5234e-16 3.0357e+00 below 2.2092e-08 7.0841e-09 [[10, 5], [0, 0]] [[5.7049180327869, 5.7540983606557], [8.0, 3.0]] minicircle_small NaN NaN NaN
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image contour_length circular end_to_end_distance
molecule_number
0 3.2366e-08 1.4036e-08 7.7690e-10 1.2272e-08 6.4301e-09 6.4170e-09 -3.7937e-10 -2.1207e-10 -2.4477e-10 -2.6816e-10 -3.0364e-26 1.1323e-16 3.0066e-16 7.0841e-09 2.1505e-08 1.5234e-16 3.0357e+00 below 2.2092e-08 7.0841e-09 minicircle_small NaN NaN NaN
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
image_size_x_m image_size_y_m image_area_m2 image_size_x_px image_size_y_px image_area_px2 grains_number_above grains_per_m2_above grains_number_below grains_per_m2_below rms_roughness
image
image
minicircle_small 1.2646e-07 1.2646e-07 1.5993e-14 64 64 4096 3 1.8758e+14 1 6.2526e+13 6.8208e-10
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret max_feret_coords min_feret_coords image contour_length circular end_to_end_distance
molecule_number
0 3.2366e-08 1.4036e-08 7.7690e-10 1.2272e-08 6.4301e-09 6.4170e-09 -3.7937e-10 -2.1207e-10 -2.4477e-10 -2.6816e-10 -3.0364e-26 1.1323e-16 3.0066e-16 7.0841e-09 2.1505e-08 1.5234e-16 3.0357e+00 below 2.2092e-08 7.0841e-09 [[10, 5], [0, 0]] [[5.7049180327869, 5.7540983606557], [8.0, 3.0]] minicircle_small NaN NaN NaN
0 7.5100e-08 4.7559e-08 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 2.4528e+00 above 5.0379e-08 2.0539e-08 [[10, 0], [5, 25]] [[10.1923076923077, 15.0384615384615], [0.0, 13.0]] minicircle_small 6.0226e-08 0.0000e+00 8.6738e-09
1 8.0241e-08 7.8677e-08 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 2.5385e+00 above 5.1262e-08 2.0174e-08 [[2, 0], [14, 23]] [[10.2518248175182, 6.6824817518248], [1.0, 11.0]] minicircle_small 6.6355e-08 1.0000e+00 0.0000e+00
2 4.0012e-08 7.5644e-08 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 1.2353e+00 above 4.4405e-08 3.2528e-08 [[21, 6], [0, 14]] [[10.3313609467456, 15.1952662721894], [4.0, 0.0]] minicircle_small 9.6106e-08 1.0000e+00 0.0000e+00
centre_x centre_y radius_min radius_max radius_mean radius_median height_min height_max height_median height_mean volume area area_cartesian_bbox smallest_bounding_width smallest_bounding_length smallest_bounding_area aspect_ratio threshold max_feret min_feret image contour_length circular end_to_end_distance
molecule_number
0 3.2366e-08 1.4036e-08 7.7690e-10 1.2272e-08 6.4301e-09 6.4170e-09 -3.7937e-10 -2.1207e-10 -2.4477e-10 -2.6816e-10 -3.0364e-26 1.1323e-16 3.0066e-16 7.0841e-09 2.1505e-08 1.5234e-16 3.0357e+00 below 2.2092e-08 7.0841e-09 minicircle_small NaN NaN NaN
0 7.5100e-08 4.7559e-08 3.9431e-09 2.5631e-08 1.6016e-08 1.6680e-08 9.1991e-10 2.6422e-09 1.5338e-09 1.5341e-09 1.0543e-24 6.8721e-16 1.3198e-15 2.0539e-08 5.0379e-08 1.0347e-15 2.4528e+00 above 5.0379e-08 2.0539e-08 minicircle_small 6.0226e-08 0.0000e+00 8.6738e-09
1 8.0241e-08 7.8677e-08 6.8951e-09 2.7188e-08 1.6272e-08 1.6263e-08 9.0630e-10 2.4586e-09 1.6144e-09 1.6264e-09 1.0352e-24 6.3645e-16 1.5931e-15 2.0174e-08 5.1212e-08 1.0332e-15 2.5385e+00 above 5.1262e-08 2.0174e-08 minicircle_small 6.6355e-08 1.0000e+00 0.0000e+00
2 4.0012e-08 7.5644e-08 9.9461e-09 2.3654e-08 1.7561e-08 1.8364e-08 9.0641e-10 2.1066e-09 1.5939e-09 1.5493e-09 1.1192e-24 7.2236e-16 1.5462e-15 3.3592e-08 4.1496e-08 1.3940e-15 1.2353e+00 above 4.4405e-08 3.2528e-08 minicircle_small 9.6106e-08 1.0000e+00 0.0000e+00
4 changes: 2 additions & 2 deletions tests/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def test_process_scan_align_grainstats_dnatracing(
)
tracing_to_check = ["contour_length", "circular", "end_to_end_distance"]

assert results.shape == (3, 27)
assert results.shape == (3, 25)
assert np.isnan(results.loc[2, "contour_length"])
assert np.isnan(sum(results.loc[2, tracing_to_check]))

Expand Down Expand Up @@ -497,7 +497,7 @@ def test_run_grainstats(process_scan_config: dict, tmp_path: Path) -> None:

assert isinstance(grainstats_df, pd.DataFrame)
assert grainstats_df.shape[0] == 13
assert len(grainstats_df.columns) == 23
assert len(grainstats_df.columns) == 21


def test_run_dnatracing(process_scan_config: dict, tmp_path: Path) -> None:
Expand Down
3 changes: 2 additions & 1 deletion topostats/grainstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ def calculate_stats(self) -> tuple(pd.DataFrame, dict):
"smallest_bounding_area": smallest_bounding_length * smallest_bounding_width * area_scaling_factor,
"aspect_ratio": aspect_ratio,
"threshold": self.direction,
**feret_statistics,
"max_feret": feret_statistics["max_feret"],
"min_feret": feret_statistics["min_feret"],
}
stats_array.append(stats)
if len(stats_array) > 0:
Expand Down

0 comments on commit 9fd3eb8

Please sign in to comment.