aggregation.get_aggregated_features_per_pid
aggregation.get_aggregated_features_per_pid(snippet_df_per_pid)Process and aggregate raw features for a single probe ID (PID) across all its snippets.
This function takes a DataFrame containing snippet information for a single PID, concatenates all raw features from those snippets, aggregates them by channel, and enriches the result with channel metadata (axial and lateral positions). The function ensures that only one PID is processed at a time and that the required channel metadata file exists.
Args: snippet_df_per_pid (pandas.DataFrame): DataFrame containing snippet information for a single PID. Must have columns: - ‘pid’: Probe ID (must be unique across all rows) - ‘base_level_dir’: Base directory path for each snippet - ‘snippet_level_dir’: Relative path to the snippet directory
Returns: pandas.DataFrame: A DataFrame with one row per channel for the PID, containing: - Aggregated raw electrophysiological features - Channel metadata (axial_um, lateral_um) - pid and channel columns as regular columns (not index)
Raises: AssertionError: If the DataFrame contains more than one unique PID. FileNotFoundError: If the channels.pqt file is not found in the snippet directory’s parent.
Example: >>> import pandas as pd >>> snippet_df = pd.DataFrame({ … ‘pid’: [‘probe1’, ‘probe1’], … ‘base_level_dir’: [‘/data/probe1’, ‘/data/probe1’], … ‘snippet_level_dir’: [‘snippet_001’, ‘snippet_002’] … }) >>> agg_df = get_aggregated_features_per_pid(snippet_df) >>> print(agg_df.head())
Note: - The function requires that all rows have the same PID value. - Channel metadata is loaded from channels.pqt in the snippet directory’s parent. - Channels with bad alpha are filtered out. And those values are set to NaN. - The result includes both aggregated features and channel position information.