From aeb8c6ed44b7a6a2ad335bcc7648034cf4f345f0 Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Wed, 10 May 2023 15:43:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(data=5Fprocessing.py):?= =?UTF-8?q?=20rename=20function=20parameter=20to=20improve=20semantics=20T?= =?UTF-8?q?he=20function=20parameter=20`update=5Fprogress=5Fbar`=20has=20b?= =?UTF-8?q?een=20renamed=20to=20`progressbar=5Fplaceholder`=20to=20improve?= =?UTF-8?q?=20the=20semantics=20of=20the=20function.=20This=20change=20doe?= =?UTF-8?q?s=20not=20affect=20the=20functionality=20of=20the=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨ feat(data_processing.py): add new morphological indicators to the output of the `get_advanced_data` function The `get_advanced_data` function now calculates and returns the following morphological indicators: - MI_mR: the ratio of the maximum radius to the mean radius - MI_mH: the ratio of the maximum radius to the height of the object - V_scan: the volume of the scanned object - R_V_scan: the radius of a sphere with the same volume as the scanned object - S_V_scan: the surface area of a sphere with the same volume as the scanned object - R_h: the hydraulic radius of the object - HI: the hydraulic index of the object --- utils/data_processing/data_processing.py | 48 ++++++++++++++++-------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/utils/data_processing/data_processing.py b/utils/data_processing/data_processing.py index 7a6f5ad..04ef41b 100644 --- a/utils/data_processing/data_processing.py +++ b/utils/data_processing/data_processing.py @@ -107,7 +107,7 @@ def get_discrete_data(obj:ScannedObject, ndigits:int, delta_z:float=1, update_pr progress += 1 return data -def get_advanced_data(discrete_data:dict, update_progress_bar= progressbar_placeholder)->dict: +def get_advanced_data(discrete_data:dict, V_scan = 0, update_progress_bar= progressbar_placeholder)->dict: """ Calculates morphological indicators from the given discrete data @@ -122,20 +122,20 @@ def get_advanced_data(discrete_data:dict, update_progress_bar= progressbar_place - Tortuosite - Volume en mm3 - Surface en mm2 - - Moyenne des rayons moyens - - Ecart-type des rayons moyens - - Sigma r tot + - Moyenne des rayons moyens 〈R〉 + - Ecart-type des rayons moyens σ_〈R〉 + - σ_〈R〉^tot - MI_l - MI_p + - Rayon hydraulique R_h """ - + all_R = discrete_data["Rayon moyen (en mm)"] # Tortusity l = 0 L = 0 vertices = list(zip(discrete_data["X moy (en mm)"], discrete_data["Y moy (en mm)"], discrete_data["Z moy (en mm)"])) - for index in range(len(vertices)-1): l += de.get_distance_between_two_vertices(vertices[index], vertices[index+1]) L = de.get_distance_between_two_vertices(vertices[0], vertices[-1]) @@ -144,26 +144,44 @@ def get_advanced_data(discrete_data:dict, update_progress_bar= progressbar_place # Volume and surface H = discrete_data["Z moy (en mm)"][-1] - discrete_data["Z moy (en mm)"][0] - R = de.get_mean([np.power(r,2) for r in discrete_data["Rayon moyen (en mm)"]]) - V = np.pi * R * H - S = 2 * np.pi * R * H + R2_mean = de.get_mean([np.power(r,2) for r in all_R]) + V = np.pi * R2_mean * H + S = 2 * np.pi * R2_mean * H update_progress_bar(30) # Morphological indicators - R_mean = de.get_mean(discrete_data["Rayon moyen (en mm)"]) - R_mean_std = de.get_standard_deviation(discrete_data["Rayon moyen (en mm)"]) + R_mean = de.get_mean(all_R) + R_mean_std = de.get_standard_deviation(all_R) mean_sigma_r_squared = de.get_mean([np.power(r,2) for r in discrete_data["Rayon ecart type (en mm)"]]) sigma_r_tot = np.sqrt(np.power(R_mean_std,2) + mean_sigma_r_squared ) MI_l = R_mean_std/R_mean MI_p = np.sqrt(mean_sigma_r_squared)/R_mean + + R_max = max(all_R) + MI_mR = R_max/R_mean + MI_mH = R_max/H + #MI_mr_in = R_max/R_in + # TODO understand what is R_in + R_V_scan = np.sqrt(V_scan/np.pi*H) + S_V_scan = 2 * np.sqrt(np.pi * H * V_scan) + R_h = R2_mean/ R_mean + HI = R_mean * R_V_scan / R2_mean update_progress_bar(100) return { "Tortuosité":T, "Volume en mm3":V, "Surface en mm2":S, - "Moyenne des rayons moyens":R_mean, - "Ecart-type des rayons moyens":R_mean_std, - "Sigma r tot":sigma_r_tot, + "Moyenne des rayons moyens 〈R〉":R_mean, + "Ecart-type des rayons moyens σ_〈R〉":R_mean_std, + "σ_〈R〉^tot":sigma_r_tot, "MI_l":MI_l, - "MI_p":MI_p + "MI_p":MI_p, + "MI_mR":MI_mR, + "MI_mH":MI_mH, + # "MI_mr_in":MI_mr_in, + "V_scan":V_scan, + "R_V_scan":R_V_scan, + "S_V_scan":S_V_scan, + "Rayon hydraulique R_h":R_h, + "HI":HI }