Skip to content

Conversation

rafaelscsilva
Copy link
Member

@rafaelscsilva rafaelscsilva commented Jul 3, 2025

This PR adds the resample_signal function to the signals.tools module.

The function allows resampling of a signal from its original sampling rate to a new target sampling rate using scipy.signal.resample, by calculating required number of output samples with the original and new sampling frequencies. It supports both single- and multi-channel inputs.

Working Example

from biosppy import storage, signals

# load ecg signal from examples
ecg_signal, mdata = storage.load_txt('examples/ecg.txt')

# resample the signal to 500 Hz
resampled_ecg, = signals.tools.resample_signal(signal=ecg_signal,
                                               sampling_rate=mdata['sampling_rate'],
                                               resampling_rate=500)

@rafaelscsilva rafaelscsilva requested a review from sofia3ms July 3, 2025 11:52
@rafaelscsilva rafaelscsilva self-assigned this Jul 3, 2025
It applies a low-pass filter before downsampling a signal to avoid aliasing. Filter type and order can be passed to the function.
@rafaelscsilva rafaelscsilva added the enhancement New feature or request label Aug 5, 2025
@rafaelscsilva
Copy link
Member Author

@sofia3ms I reverted the last commit, for the moment we can use the scipy's default behavior for resampling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant