aggregation.apply_waveform_remap
aggregation.apply_waveform_remap(agg_ephys_features)Apply waveform shape feature remapping to replace ModelSpikeFeatures with ModelSpikeShapeFeatures.
This function takes a DataFrame containing aggregated electrophysiological features and applies the waveform shape feature remapping. It converts the 14 raw spike waveform columns from ModelSpikeFeatures to the 12 columns of ModelSpikeShapeFeatures, which are more interpretable spike-shape metrics.
Args: agg_ephys_features (pandas.DataFrame): DataFrame containing aggregated electrophysiological features, typically indexed by (‘pid’, ‘channel’). Must contain the columns of ModelSpikeFeatures for the remapping to work.
Returns: pandas.DataFrame: A DataFrame with the same structure as the input but with waveform spike features remapped from ModelSpikeFeatures to ModelSpikeShapeFeatures. The 8 shared columns are preserved, while the 6 dropped columns (peak_time_secs, peak_val, recovery_time_secs, tip_time_secs, trough_time_secs, trough_val) are replaced by 4 new columns (spike_width_secs, predepolarisation_width_secs, spike_amplitude, peak_to_trough_ratio_log).
Note: - If the input DataFrame does not contain all required ModelSpikeFeatures columns, the function will log a warning and return the original DataFrame unchanged. - This transform is idempotent: applying it multiple times will produce the same result (after the first application, the old columns are gone and cannot be remapped again).