Skip to content

Commit b8d5d80

Browse files
author
Corentin
committed
SDH export stats
1 parent 0fa7f17 commit b8d5d80

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

myoquant/SDH_analysis.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def run_sdh_analysis(image_array, model_SDH, mask_cellpose):
9292
class_predicted_all, proba_predicted_all = predict_all_cells(
9393
image_array, df_cellpose, model_SDH
9494
)
95-
95+
df_cellpose["class_predicted"] = class_predicted_all
96+
df_cellpose["proba_predicted"] = proba_predicted_all
9697
count_per_label = np.unique(class_predicted_all, return_counts=True)
9798
class_and_proba_df = pd.DataFrame(
9899
list(zip(class_predicted_all, proba_predicted_all)),
@@ -114,4 +115,4 @@ def run_sdh_analysis(image_array, model_SDH, mask_cellpose):
114115
result_df = pd.DataFrame(columns=headers, data=data)
115116
# Paint The Full Image
116117
full_label_map = paint_full_image(image_array, df_cellpose, class_predicted_all)
117-
return result_df, full_label_map
118+
return result_df, full_label_map, df_cellpose

myoquant/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def sdh_analysis(
152152

153153
model_SDH = load_sdh_model(model_path)
154154
console.print("SDH Model loaded !", style="blue")
155-
result_df, full_label_map = run_sdh_analysis(
155+
result_df, full_label_map, df_cellpose_details = run_sdh_analysis(
156156
image_ndarray_sdh, model_SDH, mask_cellpose
157157
)
158158
console.print("Analysis completed ! ", style="green")
@@ -174,6 +174,16 @@ def sdh_analysis(
174174
console.print(
175175
f"Table saved as a .csv file named {output_path/csv_name}", style="green"
176176
)
177+
if export_stats:
178+
cell_details_name = image_path.stem + "_cell_details.csv"
179+
df_cellpose_details.drop("image", axis=1).to_csv(
180+
output_path / cell_details_name,
181+
index=False,
182+
)
183+
console.print(
184+
f"Cell Table saved as a .csv file named {output_path/cell_details_name}",
185+
style="green",
186+
)
177187
label_map_name = image_path.stem + "_label_map.tiff"
178188
Image.fromarray(full_label_map).save(output_path / label_map_name)
179189
console.print(

0 commit comments

Comments
 (0)