@@ -84,6 +84,8 @@ def sdh_analysis(
84
84
load_cellpose ,
85
85
load_sdh_model ,
86
86
run_cellpose ,
87
+ label2rgb ,
88
+ blend_image_with_label ,
87
89
)
88
90
from .SDH_analysis import run_sdh_analysis
89
91
import numpy as np
@@ -183,6 +185,13 @@ def sdh_analysis(
183
185
result_df , full_label_map , df_cellpose_details = run_sdh_analysis (
184
186
image_ndarray_sdh , model_SDH , mask_cellpose
185
187
)
188
+ if export_map :
189
+ console .print ("Blending label and original image together ! " , style = "blue" )
190
+ labelRGB_map = label2rgb (image_ndarray_sdh , full_label_map )
191
+ overlay_img = blend_image_with_label (image_ndarray_sdh , labelRGB_map )
192
+ overlay_filename = image_path .stem + "_label_blend.tiff"
193
+ overlay_img .save (output_path / overlay_filename )
194
+
186
195
console .print ("Analysis completed ! " , style = "green" )
187
196
table .add_column ("Feature" , justify = "left" , style = "cyan" )
188
197
table .add_column ("Raw Count" , justify = "center" , style = "magenta" )
@@ -217,7 +226,6 @@ def sdh_analysis(
217
226
console .print (
218
227
f"Labelled image saved as { output_path / label_map_name } " , style = "green"
219
228
)
220
- painted_img_name = image_path .stem + "_painted.tiff"
221
229
console .print ("--- %s seconds ---" % (time .time () - start_time ))
222
230
223
231
@@ -308,6 +316,8 @@ def he_analysis(
308
316
load_stardist ,
309
317
run_cellpose ,
310
318
run_stardist ,
319
+ label2rgb ,
320
+ blend_image_with_label ,
311
321
)
312
322
from .HE_analysis import run_he_analysis
313
323
import numpy as np
@@ -358,6 +368,7 @@ def he_analysis(
358
368
console .print ("Reading image..." , style = "blue" )
359
369
360
370
image_ndarray = imread (image_path )
371
+
361
372
if fluo_nuc is not None :
362
373
fluo_nuc_ndarray = imread (fluo_nuc )
363
374
@@ -379,6 +390,9 @@ def he_analysis(
379
390
image_ndarray = image_ndarray * mask_ndarray
380
391
if fluo_nuc is not None :
381
392
fluo_nuc_ndarray = fluo_nuc_ndarray * mask_ndarray
393
+ if fluo_nuc is not None :
394
+ mix_cyto_nuc = np .maximum (image_ndarray , fluo_nuc_ndarray )
395
+
382
396
console .print (f"Masking done." , style = "blue" )
383
397
console .print ("Image loaded." , style = "blue" )
384
398
console .print ("Starting the Analysis. This may take a while..." , style = "blue" )
@@ -425,6 +439,17 @@ def he_analysis(
425
439
result_df , full_label_map , df_nuc_analysis , all_nuc_df_stats = run_he_analysis (
426
440
image_ndarray , mask_cellpose , mask_stardist , eccentricity_thresh
427
441
)
442
+ if export_map :
443
+ console .print ("Blending label and original image together ! " , style = "blue" )
444
+ if fluo_nuc is not None :
445
+ labelRGB_map = label2rgb (mix_cyto_nuc , full_label_map )
446
+ overlay_img = blend_image_with_label (mix_cyto_nuc , labelRGB_map , fluo = True )
447
+ else :
448
+ labelRGB_map = label2rgb (image_ndarray , full_label_map )
449
+ overlay_img = blend_image_with_label (image_ndarray , labelRGB_map )
450
+ overlay_filename = image_path .stem + "_label_blend.tiff"
451
+ overlay_img .save (output_path / overlay_filename )
452
+
428
453
console .print ("Analysis completed ! " , style = "green" )
429
454
table .add_column ("Feature" , justify = "left" , style = "cyan" )
430
455
table .add_column ("Raw Count" , justify = "center" , style = "magenta" )
@@ -447,6 +472,11 @@ def he_analysis(
447
472
f"Summary Table saved as a .csv file named { output_path / csv_name } " ,
448
473
style = "green" ,
449
474
)
475
+ if export_map :
476
+ console .print (
477
+ f"Overlay image saved as a .tiff file named { output_path / overlay_filename } " ,
478
+ style = "green" ,
479
+ )
450
480
if export_stats :
451
481
df_nuc_analysis .drop ("image" , axis = 1 ).to_csv (
452
482
output_path / cell_details_name ,
@@ -469,7 +499,6 @@ def he_analysis(
469
499
console .print (
470
500
f"Labelled image saved as { output_path / label_map_name } " , style = "green"
471
501
)
472
- painted_img_name = image_path .stem + "_painted.tiff"
473
502
console .print ("--- %s seconds ---" % (time .time () - start_time ))
474
503
475
504
0 commit comments