1+ import  os 
2+ 
3+ import  imageio .v3  as  imageio 
14import  napari 
25import  pandas  as  pd 
36import  numpy  as  np 
@@ -128,6 +131,13 @@ def save_analysis(segmentations, vesicle_attributes, save_path):
128131    vesicle_attributes .to_excel (save_path , index = False )
129132
130133
134+ def  save_segmentations (segmentations ):
135+     output_folder  =  "segmentations" 
136+     os .makedirs (output_folder , exist_ok = True )
137+     for  name , segmentation  in  segmentations .items ():
138+         imageio .imwrite (os .path .join (output_folder , f"{ name }  .tif" ), segmentation , compression = "zlib" )
139+ 
140+ 
131141def  main ():
132142    """This script implements an example analysis pipeline with SynapseNet and applies it to a tomogram. 
133143    Here, we analyze docked and non-attached vesicles in a sample tomogram.""" 
@@ -150,7 +160,11 @@ def main():
150160    vesicle_attributes  =  assign_vesicle_pools (vesicle_attributes )
151161
152162    # Visualize the results. 
153-     visualize_results (tomogram , segmentations , vesicle_attributes )
163+     # visualize_results(tomogram, segmentations, vesicle_attributes) 
164+ 
165+     # Save the segmentation results to tif files so that they can be re-used later. 
166+     # They will be saved to the folder 'segmentations'. 
167+     save_segmentations (segmentations )
154168
155169    # Compute the vesicle radii and combine and save all measurements. 
156170    save_path  =  "analysis_results.xlsx" 
0 commit comments