aggregation.get_aggregated_raw_features
aggregation.get_aggregated_raw_features(
snippet_df,
output_dir=None,
n_jobs=-1,
verbose=1,
)Process and aggregate raw features for multiple probe IDs (PIDs) across all their snippets.
This function takes a DataFrame containing snippet information for multiple PIDs, processes each PID individually in parallel using get_aggregated_features_per_pid, and combines all results into a single DataFrame. The final result is indexed by (‘pid’, ‘channel’) and optionally saved to a Parquet file.
Args: snippet_df (pandas.DataFrame): DataFrame containing snippet information for multiple PIDs. Must have columns: - ‘pid’: Probe ID - ‘base_level_dir’: Base directory path for each snippet - ‘snippet_level_dir’: Relative path to the snippet directory output_dir (Path or None, optional): If provided, the aggregated DataFrame is saved as ‘raw_ephys_features.pqt’ in this directory. The directory is created if it does not exist. Default is None (no file is written). n_jobs (int, optional): Number of parallel jobs to run. -1 means using all processors. Default is -1. verbose (int, optional): Verbosity level for joblib.Parallel. 0 means no messages, 1 means progress messages, >1 means more detailed messages. Default is 1.
Returns: pandas.DataFrame: A DataFrame indexed by (‘pid’, ‘channel’) containing aggregated raw electrophysiological features and channel metadata for all PIDs. Each row represents one channel from one PID.
Example: >>> import pandas as pd >>> from pathlib import Path >>> snippet_df = pd.DataFrame({ … ‘pid’: [‘probe1’, ‘probe1’, ‘probe2’, ‘probe2’], … ‘base_level_dir’: [‘/data/probe1’, ‘/data/probe1’, ‘/data/probe2’, ‘/data/probe2’], … ‘snippet_level_dir’: [‘snippet_001’, ‘snippet_002’, ‘snippet_001’, ‘snippet_002’] … }) >>> agg_df = get_aggregated_raw_features(snippet_df, output_dir=Path(‘output’)) >>> print(agg_df.head())
Note: - Each PID is processed independently using get_aggregated_features_per_pid. - The function groups the input DataFrame by ‘pid’ and processes each group in parallel using joblib. - If output_dir is provided, the result is saved as ‘raw_ephys_features.pqt’. - The function handles multiple PIDs efficiently by aggregating the features for a PID before concatting across multiple pids.