pyrasa.utils.peak_utils.get_band_info#
- pyrasa.utils.peak_utils.get_band_info(df_peaks: DataFrame, freq_range: tuple[int, int], ch_names: list) DataFrame [source]#
Extract peak information within a specified frequency range from a DataFrame of peak parameters.
This function filters peaks found in the periodic spectrum or spectrogram to those within a specified frequency range.It ensures that every channel is represented in the output, filling in missing channels (i.e., channels without detected peaks in the specified range) with NaN values.
- Parameters:
df_peaks (pd.DataFrame) – DataFrame containing peak parameters obtained from the
get_peak_params
function. The DataFrame should include columns for ‘ch_name’ (channel name), ‘cf’ (center frequency), ‘bw’ (bandwidth), and ‘pw’ (peak height).freq_range (tuple of (int, int)) – Tuple specifying the lower and upper frequency bounds (in Hz) to filter peaks by. Only peaks with center frequencies (cf) within this range will be included in the output.
ch_names (list) – List of channel names used in the computation of the periodic spectrum. This list ensures that every channel is accounted for in the output, even if no peaks were found in the specified range for certain channels.
- Returns:
DataFrame containing the peak parameters (‘cf’, ‘bw’, ‘pw’) for each channel within the specified frequency range. Channels without detected peaks in this range will have NaN values for these parameters. The DataFrame includes: - ‘ch_name’: Channel name - ‘cf’: Center frequency of the peak within the specified range - ‘bw’: Bandwidth of the peak within the specified range - ‘pw’: Peak height (power) within the specified range
- Return type:
pd.DataFrame
Notes
This function is useful for isolating and analyzing peaks that occur within specific canonical frequency bands (e.g., alpha, beta, gamma) across multiple channels in a periodic spectrum. The inclusion of NaN entries for channels without detected peaks ensures that the output DataFrame is complete and aligned with the original channel list.