@@ -121,14 +121,14 @@ def process_multiple_behaviors(
121121
122122def merge_behavior_tables (
123123 input_tables : List [Path ],
124- output_prefix : str = "merged_behavior" ,
124+ output_prefix : str | None = None ,
125125 overwrite : bool = False ,
126126) -> Tuple [str , str ]:
127127 """Merge multiple behavior tables for the same behavior.
128128
129129 Args:
130130 input_tables: List of paths to behavior table files to merge
131- output_prefix: Prefix for output filenames
131+ output_prefix: Optional prefix for output filenames
132132 overwrite: Whether to overwrite existing files
133133
134134 Returns:
@@ -174,13 +174,17 @@ def merge_behavior_tables(
174174
175175 tables .append (table )
176176
177+ output_file = behavior_name .replace (" " , "_" ).lower ()
178+ if output_prefix :
179+ output_file = f"{ output_prefix } _{ output_file } "
180+
177181 # Merge the tables using the existing combine_data method
178182 if table_type == "bout" :
179183 merged_table = BoutTable .combine_data (tables )
180- output_file = f"{ output_prefix } _ { behavior_name } _bouts_merged.csv"
184+ output_file = f"{ output_file } _bouts_merged.csv"
181185 else :
182186 merged_table = BinTable .combine_data (tables )
183- output_file = f"{ output_prefix } _ { behavior_name } _summaries_merged.csv"
187+ output_file = f"{ output_file } _summaries_merged.csv"
184188
185189 # Write the merged table
186190 merged_table .to_file (output_file , overwrite )
@@ -193,14 +197,14 @@ def merge_behavior_tables(
193197
194198def merge_multiple_behavior_tables (
195199 table_groups : Dict [str , List [Path ]],
196- output_prefix : str = "merged_behavior" ,
200+ output_prefix : str | None = None ,
197201 overwrite : bool = False ,
198202) -> Dict [str , Tuple [str , str ]]:
199203 """Merge multiple sets of behavior tables grouped by behavior.
200204
201205 Args:
202206 table_groups: Dictionary mapping behavior names to lists of table file paths
203- output_prefix: Prefix for output filenames
207+ output_prefix: Optional prefix for output filenames
204208 overwrite: Whether to overwrite existing files
205209
206210 Returns:
@@ -238,15 +242,13 @@ def merge_multiple_behavior_tables(
238242 bout_output = None
239243 if bout_tables :
240244 bout_output , _ = merge_behavior_tables (
241- bout_tables , f" { output_prefix } _ { behavior_name } _bouts" , overwrite
245+ bout_tables , output_prefix , overwrite
242246 )
243247
244248 # Merge bin tables if any exist
245249 bin_output = None
246250 if bin_tables :
247- bin_output , _ = merge_behavior_tables (
248- bin_tables , f"{ output_prefix } _{ behavior_name } _summaries" , overwrite
249- )
251+ bin_output , _ = merge_behavior_tables (bin_tables , output_prefix , overwrite )
250252
251253 results [behavior_name ] = (bout_output , bin_output )
252254
0 commit comments