@@ -237,6 +237,56 @@ def add_intertrial_licking(df_trials, df_licks):
237237 return df_trials
238238
239239
240+ def get_average_signal_window_multi (
241+ nwbs ,
242+ alignment_event ,
243+ offsets ,
244+ channel ,
245+ data_column = 'data_z' ,
246+ censor = True ,
247+ output_col = None
248+ ):
249+ """
250+ Wrapper for get_average_signal_window to process a
251+ list of nwb objects and concatenate the results.
252+
253+ Parameters
254+ ----------
255+ nwbs : list
256+ List of nwb-like objects (each with .df_trials and .df_fip).
257+ alignment_event : str
258+ The event column in df_trials to align to.
259+ offsets : list or tuple of float
260+ [start, end] offsets (in seconds) relative to alignment_event.
261+ channel : str
262+ The value in df_fip['event'] to filter for.
263+ data_col : str
264+ Column in df_fip to extract (default 'data_z').
265+ censor, censor important timepoints before and after aligned timepoints
266+ output_col : str or None
267+ Name for the new column. If None, will be generated automatically.
268+
269+ Returns
270+ -------
271+ pd.DataFrame
272+ Concatenated DataFrame of all trials with the new signal window column.
273+ """
274+ all_trials_avg_signal = []
275+ for nwb in nwbs :
276+ df_trials = get_average_signal_window (
277+ nwb ,
278+ alignment_event = alignment_event ,
279+ offsets = offsets ,
280+ channel = channel ,
281+ data_column = data_column ,
282+ censor = censor ,
283+ output_col = output_col
284+ )
285+ cols_needed = ['trial' , 'ses_idx' , df_trials .columns [- 1 ]]
286+ all_trials_avg_signal .append (df_trials [cols_needed ])
287+ return pd .concat (all_trials_avg_signal , ignore_index = True )
288+
289+
240290def get_average_signal_window (
241291 nwb ,
242292 alignment_event ,
0 commit comments