1
+ import os
2
+
3
+ import imageio .v3 as imageio
1
4
import napari
2
5
import pandas as pd
3
6
import numpy as np
@@ -128,6 +131,13 @@ def save_analysis(segmentations, vesicle_attributes, save_path):
128
131
vesicle_attributes .to_excel (save_path , index = False )
129
132
130
133
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
+
131
141
def main ():
132
142
"""This script implements an example analysis pipeline with SynapseNet and applies it to a tomogram.
133
143
Here, we analyze docked and non-attached vesicles in a sample tomogram."""
@@ -150,7 +160,11 @@ def main():
150
160
vesicle_attributes = assign_vesicle_pools (vesicle_attributes )
151
161
152
162
# 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 )
154
168
155
169
# Compute the vesicle radii and combine and save all measurements.
156
170
save_path = "analysis_results.xlsx"
0 commit comments