@@ -370,7 +370,8 @@ def run(params):
370
370
371
371
# Collect tab names from first file
372
372
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 )
374
375
real_tab_names_ref_tmp = change_duplicate_tab_names (real_tab_names_ref )
375
376
376
377
# First table in final table
@@ -692,6 +693,10 @@ def close_GUI_callback():
692
693
_ , object_set = get_split_name (k )
693
694
if object_set == '' : # If only one object set, name is not present
694
695
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 ('' )
695
700
696
701
if not k .endswith ('Summary' ) and not any ([k .endswith (cgref ) for cgref in class_group_cut_ref ]):
697
702
if object_set != object_set_ref :
@@ -1009,7 +1014,10 @@ def combine_tabs(df_raw):
1009
1014
elif k != 'Summary' and df_temp .empty is True :
1010
1015
# Determines what type of Aivia objects (i.e. Mesh, Slice of Cell, etc.) and measurement
1011
1016
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--' :
1013
1021
meas_name = df_raw [k ].columns [0 ]
1014
1022
1015
1023
# Copying the sheet
@@ -1025,14 +1033,18 @@ def combine_tabs(df_raw):
1025
1033
else :
1026
1034
# Determines what type of Aivia objects (i.e. Mesh, Slice of Cell, etc.) and measurement
1027
1035
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--' :
1029
1040
meas_name = (df_raw [k ].columns [0 ])[len (object_name_temp ) + 1 :] \
1030
1041
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 } ' )
1031
1043
1032
1044
# Check if object name changed or not
1033
1045
if object_name_temp != object_name and object_name_temp != '' :
1034
1046
# 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
1036
1048
1037
1049
# Now using new name as the new reference
1038
1050
object_name = object_name_temp
@@ -1194,7 +1206,7 @@ def clean_tab_name(ta_name):
1194
1206
1195
1207
# Limit tab name to 30 characters because Excel can't handle more!!!
1196
1208
if len (ta_name ) > 30 :
1197
- ta_name = ta_name [0 :28 ] + '..'
1209
+ ta_name = ta_name [0 :27 ] + '. ..'
1198
1210
1199
1211
return ta_name
1200
1212
@@ -1241,16 +1253,22 @@ def get_split_name(txt: str):
1241
1253
obj_name = txt .split ('.' )[0 ]
1242
1254
meas_name = '.' .join (txt .split ('.' )[1 :])
1243
1255
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--'
1252
1259
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 } ' )
1254
1272
1255
1273
return meas_name , obj_name
1256
1274
@@ -1418,6 +1436,8 @@ def Mbox(title, text, style):
1418
1436
# - Stop message if combination of choices is not valid for this script
1419
1437
# - IMPORTANT: do_extract_stats_only choice was removed. Stats are provided anyway with big tables.
1420
1438
# 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
1421
1441
1422
1442
# TODO: progress bar with file in Recipes folder: '_progress_bar_file 1_from 10_'
1423
1443
# TODO: Warning message when Neuron set detected but no ID
0 commit comments