Skip to content

Commit d829715

Browse files
2 parents dee0935 + 5c080f7 commit d829715

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

examples/analysis_pipeline.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
3+
import imageio.v3 as imageio
14
import napari
25
import pandas as pd
36
import 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+
131141
def 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

Comments
 (0)