@@ -370,7 +370,8 @@ def run(params):
370370
371371 # Collect tab names from first file
372372 tab_names_ref = df_raw_1 .keys ()
373- real_tab_names_ref = [clean_tab_name (df_raw_1 [tmp_t ].columns [0 ], ) for tmp_t in df_raw_1 .keys ()]
373+ # real_tab_names_ref = [clean_tab_name(df_raw_1[tmp_t].columns[0], ) for tmp_t in df_raw_1.keys()]
374+ real_tab_names_ref = list (tab_names_ref )
374375 real_tab_names_ref_tmp = change_duplicate_tab_names (real_tab_names_ref )
375376
376377 # First table in final table
@@ -692,6 +693,10 @@ def close_GUI_callback():
692693 _ , object_set = get_split_name (k )
693694 if object_set == '' : # If only one object set, name is not present
694695 object_set = 'Object 1'
696+ elif object_set == '--incomplete--' :
697+ Mbox ('Error' , 'An unexpected error occurred, please contact Aivia team.\n \n Error message:\n '
698+ 'Incomplete object set detected in "do_multiple_files_as_cols" bloc (line~700).' , 0 )
699+ sys .exit ('' )
695700
696701 if not k .endswith ('Summary' ) and not any ([k .endswith (cgref ) for cgref in class_group_cut_ref ]):
697702 if object_set != object_set_ref :
@@ -1009,7 +1014,10 @@ def combine_tabs(df_raw):
10091014 elif k != 'Summary' and df_temp .empty is True :
10101015 # Determines what type of Aivia objects (i.e. Mesh, Slice of Cell, etc.) and measurement
10111016 meas_name , object_name = get_split_name (k )
1012- if meas_name == '--incomplete--' :
1017+ if object_name == '--incomplete--' and meas_name == '--incomplete--' :
1018+ object_name = df_raw [k ].columns [0 ].split ('.' )[0 ]
1019+ meas_name = '.' .join (df_raw [k ].columns [0 ].split ('.' )[1 :])
1020+ elif meas_name == '--incomplete--' :
10131021 meas_name = df_raw [k ].columns [0 ]
10141022
10151023 # Copying the sheet
@@ -1025,14 +1033,18 @@ def combine_tabs(df_raw):
10251033 else :
10261034 # Determines what type of Aivia objects (i.e. Mesh, Slice of Cell, etc.) and measurement
10271035 meas_name , object_name_temp = get_split_name (k )
1028- if meas_name == '--incomplete--' :
1036+ if object_name_temp == '--incomplete--' and meas_name == '--incomplete--' :
1037+ object_name_temp = df_raw [k ].columns [0 ].split ('.' )[0 ]
1038+ meas_name = '.' .join (df_raw [k ].columns [0 ].split ('.' )[1 :])
1039+ elif meas_name == '--incomplete--' :
10291040 meas_name = (df_raw [k ].columns [0 ])[len (object_name_temp ) + 1 :] \
10301041 if len (object_name_temp ) > 0 else df_raw [k ].columns [0 ]
1042+ print (f'> Real measurement name was collected within the sheet: { meas_name } ' )
10311043
10321044 # Check if object name changed or not
10331045 if object_name_temp != object_name and object_name_temp != '' :
10341046 # Adding prepared sheet to main series to create a new sheet
1035- df_combined [object_name ] = df_temp
1047+ df_combined [object_name [: 31 ]] = df_temp # Limiting tab name to 31 characters
10361048
10371049 # Now using new name as the new reference
10381050 object_name = object_name_temp
@@ -1194,7 +1206,7 @@ def clean_tab_name(ta_name):
11941206
11951207 # Limit tab name to 30 characters because Excel can't handle more!!!
11961208 if len (ta_name ) > 30 :
1197- ta_name = ta_name [0 :28 ] + '..'
1209+ ta_name = ta_name [0 :27 ] + '. ..'
11981210
11991211 return ta_name
12001212
@@ -1241,16 +1253,22 @@ def get_split_name(txt: str):
12411253 obj_name = txt .split ('.' )[0 ]
12421254 meas_name = '.' .join (txt .split ('.' )[1 :])
12431255
1244- # Check if text doesn't end with '...' or other variations
1245- re_search = re .search (r'.+[^\.](\.{2,3}|\.[2-9])' , txt )
1246- if re_search :
1247- txt = txt .removesuffix (re_search .groups ()[0 ])
1248- if '.' not in txt :
1249- obj_name = ''
1250- else :
1251- obj_name = txt .split ('.' )[0 ]
1256+ # Aivia 14/15 change: '...' in the middle of the tab name, cutting sometimes both object and meas names
1257+ if '...' in txt [1 :- 1 ]:
1258+ obj_name = '--incomplete--'
12521259 meas_name = '--incomplete--'
1253- print ('{}: name can\' t be retrieved from this text.' .format (txt ))
1260+
1261+ else : # pre-Aivia 14
1262+ # Check if text doesn't end with '...' or other variations
1263+ re_search = re .search (r'.+[^\.](\.{2,3}|\.[2-9])' , txt )
1264+ if re_search :
1265+ txt = txt .removesuffix (re_search .groups ()[0 ])
1266+ if '.' not in txt :
1267+ obj_name = ''
1268+ else :
1269+ obj_name = txt .split ('.' )[0 ]
1270+ meas_name = '--incomplete--'
1271+ print (f'> Measurement name can\' t be retrieved from this text: { txt } ' )
12541272
12551273 return meas_name , obj_name
12561274
@@ -1418,6 +1436,8 @@ def Mbox(title, text, style):
14181436# - Stop message if combination of choices is not valid for this script
14191437# - IMPORTANT: do_extract_stats_only choice was removed. Stats are provided anyway with big tables.
14201438# v2.33: - Better handling of measurement names from Aivia 15.0, to avoid truncated names (such as "Class Confidence")
1439+ # - Dismissed use of clean tab name function as it is introducing errors with Aivia 14/15 tab name format.
1440+ # - Change in get_split_name function as Aivia 14/15 introduce '...' in the middle of tab names
14211441
14221442# TODO: progress bar with file in Recipes folder: '_progress_bar_file 1_from 10_'
14231443# TODO: Warning message when Neuron set detected but no ID
0 commit comments