|
21 | 21 | "metadata": {}, |
22 | 22 | "outputs": [], |
23 | 23 | "source": [ |
24 | | - "from itertools import product\n", |
25 | 24 | "from pathlib import Path\n", |
26 | | - "from typing import Any\n", |
27 | 25 | "from random import choice\n", |
28 | 26 | "\n", |
29 | 27 | "import numpy as np\n", |
|
36 | 34 | "from evdplanner.generation import measure_kocher\n", |
37 | 35 | "from evdplanner.geometry import Mesh\n", |
38 | 36 | "from evdplanner.linalg import Vec3\n", |
39 | | - "from evdplanner.markups import DisplaySettings, MarkupManager\n", |
| 37 | + "from evdplanner.markups import MarkupManager\n", |
40 | 38 | "from evdplanner.rendering import find_target, Ray, IntersectionSort\n", |
41 | 39 | "\n", |
42 | 40 | "skin_mesh_file = \"mesh_skin.stl\"\n", |
|
51 | 49 | "\n", |
52 | 50 | "scores_file = Path(r\"S:\\E_ResearchData\\evdplanner\\MajorityVoting.csv\")\n", |
53 | 51 | "\n", |
54 | | - "set_verbosity(0)\n" |
| 52 | + "set_verbosity(0)" |
55 | 53 | ] |
56 | 54 | }, |
57 | 55 | { |
|
110 | 108 | " except:\n", |
111 | 109 | " print(f\"Skin Mesh or landmarks not found for patient {patient.name}.\")\n", |
112 | 110 | " continue\n", |
113 | | - " \n", |
| 111 | + "\n", |
114 | 112 | " gt_nasion = Vec3(*gt_landmarks.find_fiducial(\"Nasion\").position)\n", |
115 | 113 | " gt_left_ear = Vec3(*gt_landmarks.find_fiducial(\"Pre-Auricle Left\").position)\n", |
116 | 114 | " gt_right_ear = Vec3(*gt_landmarks.find_fiducial(\"Pre-Auricle Right\").position)\n", |
|
125 | 123 | "\n", |
126 | 124 | " print(\"Finding GT target points...\")\n", |
127 | 125 | " gt_left_tp, _ = find_target(\n", |
128 | | - " ventricles_mesh,\n", |
129 | | - " gt_left_kp,\n", |
130 | | - " check_radially=check_radially,\n", |
131 | | - " radius=radius,\n", |
132 | | - " objective_distance_weight=objective_distance_weight,\n", |
133 | | - " thickness_threshold=thickness_threshold,\n", |
134 | | - " depth_threshold=depth_threshold,\n", |
135 | | - " )\n", |
| 126 | + " ventricles_mesh,\n", |
| 127 | + " gt_left_kp,\n", |
| 128 | + " check_radially=check_radially,\n", |
| 129 | + " radius=radius,\n", |
| 130 | + " objective_distance_weight=objective_distance_weight,\n", |
| 131 | + " thickness_threshold=thickness_threshold,\n", |
| 132 | + " depth_threshold=depth_threshold,\n", |
| 133 | + " )\n", |
136 | 134 | " gt_right_tp, _ = find_target(\n", |
137 | 135 | " ventricles_mesh,\n", |
138 | 136 | " gt_right_kp,\n", |
|
154 | 152 | " \"Patient\": patient.name,\n", |
155 | 153 | " \"Side\": \"Right\",\n", |
156 | 154 | " }\n", |
157 | | - " \n", |
| 155 | + "\n", |
158 | 156 | " wiggle_nasion = gt_nasion + Vec3(\n", |
159 | | - " np.random.uniform(-max_error, max_error), \n", |
160 | | - " np.random.uniform(-max_error, max_error), \n", |
161 | | - " np.random.uniform(-max_error, max_error)\n", |
| 157 | + " np.random.uniform(-max_error, max_error),\n", |
| 158 | + " np.random.uniform(-max_error, max_error),\n", |
| 159 | + " np.random.uniform(-max_error, max_error),\n", |
162 | 160 | " )\n", |
163 | 161 | " wiggle_left_ear = gt_left_ear + Vec3(\n", |
164 | 162 | " np.random.uniform(-max_error, max_error),\n", |
165 | 163 | " np.random.uniform(-max_error, max_error),\n", |
166 | | - " np.random.uniform(-max_error, max_error)\n", |
| 164 | + " np.random.uniform(-max_error, max_error),\n", |
167 | 165 | " )\n", |
168 | 166 | " wiggle_right_ear = gt_right_ear + Vec3(\n", |
169 | 167 | " np.random.uniform(-max_error, max_error),\n", |
170 | 168 | " np.random.uniform(-max_error, max_error),\n", |
171 | | - " np.random.uniform(-max_error, max_error)\n", |
| 169 | + " np.random.uniform(-max_error, max_error),\n", |
172 | 170 | " )\n", |
173 | 171 | "\n", |
174 | 172 | " # Project the wiggled points to the skin mesh\n", |
|
188 | 186 | " if wiggle_nasion is None or wiggle_left_ear is None or wiggle_right_ear is None:\n", |
189 | 187 | " print(f\"Intersection failed for patient {patient.name}.\")\n", |
190 | 188 | " continue\n", |
191 | | - " \n", |
| 189 | + "\n", |
192 | 190 | " wiggle_nasion = wiggle_nasion.position\n", |
193 | 191 | " wiggle_left_ear = wiggle_left_ear.position\n", |
194 | 192 | " wiggle_right_ear = wiggle_right_ear.position\n", |
|
319 | 317 | " constrained_layout=True,\n", |
320 | 318 | ")\n", |
321 | 319 | "\n", |
322 | | - "for ax, (x, y) in zip(axs, pairs):\n", |
| 320 | + "for ax, (x, y) in zip(axs, pairs, strict=False):\n", |
323 | 321 | " # Calculate Spearman correlation coefficient\n", |
324 | 322 | " res = spearmanr(df[x], df[y])\n", |
325 | 323 | " corr = res.statistic\n", |
|
336 | 334 | " )\n", |
337 | 335 | " p.set_title(f\"{y} vs {x}\")\n", |
338 | 336 | " p.set_xlabel(x)\n", |
339 | | - " p.set_ylabel(y)\n" |
| 337 | + " p.set_ylabel(y)" |
340 | 338 | ] |
341 | 339 | }, |
342 | 340 | { |
|
378 | 376 | " corr = f\"+{corr}\"\n", |
379 | 377 | " else:\n", |
380 | 378 | " corr = f\"{corr}\"\n", |
381 | | - " \n", |
| 379 | + "\n", |
382 | 380 | " if p_values.iloc[i, j] < 0.001:\n", |
383 | 381 | " p_val = r\"$^{*}$\"\n", |
384 | 382 | " elif p_values.iloc[i, j] < 0.01:\n", |
|
443 | 441 | " median = df[col].median()\n", |
444 | 442 | " low_ci = df[col].quantile(0.025)\n", |
445 | 443 | " high_ci = df[col].quantile(0.975)\n", |
446 | | - " print(f\"{col}: {mean:.2f} ± {std:.2f} (median: {median:.2f}, 95% CI: [{low_ci:.2f}, {high_ci:.2f}])\")" |
| 444 | + " print(\n", |
| 445 | + " f\"{col}: {mean:.2f} ± {std:.2f} (median: {median:.2f}, 95% CI: [{low_ci:.2f}, {high_ci:.2f}])\"\n", |
| 446 | + " )" |
447 | 447 | ] |
448 | 448 | }, |
449 | 449 | { |
|
0 commit comments