Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip empty outlines and display a message in the console. #829

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions cellpose/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ def save_rois(masks, file_name):

"""
outlines = utils.outlines_list(masks)
rois = [ImagejRoi.frompoints(outline) for outline in outlines]
nonempty_outlines = [outline for outline in outlines if len(outline)!=0]
if len(outlines)!=len(nonempty_outlines):
print(f"empty outlines found, saving {len(nonempty_outlines)} ImageJ ROIs to .zip archive.")
rois = [ImagejRoi.frompoints(outline) for outline in nonempty_outlines]
file_name = os.path.splitext(file_name)[0] + '_rois.zip'

# Delete file if it exists; the roifile lib appends to existing zip files.
Expand Down Expand Up @@ -609,4 +612,4 @@ def save_server(parent=None, filename=None):
"File {} uploaded to {}.".format(
source_file_name, destination_blob_name
)
)
)