Skip to content

Commit

Permalink
added a comment and error message
Browse files Browse the repository at this point in the history
  • Loading branch information
RukiyyeE committed Jul 19, 2024
1 parent 1479875 commit 51a37ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cellpose/gui/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,13 @@ def _save_features_csv(parent):
Args:
parent: GUI object with filename and NZ attributes.
"""

if not parent.filename:
raise FileNotFoundError("ERROR: No file loaded. Please load a file before attempting to save features.")

filename = parent.filename
base = os.path.splitext(filename)[0] + "_features.csv"
# check if the dataset is 2D (NZ == 1 implies a single z-layer)
if parent.NZ == 1:
print("GUI_INFO: saving features to CSV file")
save_features_csv(parent.filename)
Expand Down
3 changes: 2 additions & 1 deletion cellpose/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ def masks_flows_to_seg(images, masks, flows, file_names, diams=30., channels=Non
np.save(base + "_seg.npy", dat)

def save_features_csv(file_name):
""" save features to .csv file and remove if it already exists
"""
Save features to .csv file and remove if it already exists
Args:
file_name (str): Target CSV file name
Expand Down

0 comments on commit 51a37ad

Please sign in to comment.