From 1ac931fa105191380f7fdfbcf77d3e6d594bf53f Mon Sep 17 00:00:00 2001 From: Artem Sokolov Date: Fri, 4 Mar 2022 14:02:15 -0500 Subject: [PATCH] Robust handling of filenames with dots (`.`) in them (#35) * Robust handling of filenames with dots in them * Minor Fixes --- SingleCellDataExtraction.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SingleCellDataExtraction.py b/SingleCellDataExtraction.py index 0eceeac..faf29b9 100644 --- a/SingleCellDataExtraction.py +++ b/SingleCellDataExtraction.py @@ -236,8 +236,12 @@ def ExtractSingleCells(masks,image,channel_names,output, mask_props=None, intens scdata_z = MaskZstack(masks_loaded,image,channel_names_loaded_checked, mask_props=mask_props, intensity_props=intensity_props) #Write the singe cell data to a csv file using the image name + # Determine the image name by cutting off its extension im_full_name = os.path.basename(image) - im_name = im_full_name.split('.')[0] + im_tokens = im_full_name.split(os.extsep) + if len(im_tokens) < 2: im_name = im_tokens[0] + elif im_tokens[-2] == "ome": im_name = os.extsep.join(im_tokens[0:-2]) + else: im_name = os.extsep.join(im_tokens[0:-1]) # iterate through each mask and export csv with mask name as suffix for k,v in scdata_z.items():