- syncopy.resampledata(data, resamplefs=1.0, method='resample', lpfreq=None, order=None, parallel=None, select=None, **kwargs)[source]#
Performs resampling or downsampling of
AnalogDataobjects, representing uniformly sampled time series data.
Two methods are supported:
- “downsample”Take every nth sample
The new sampling rate resamplefs must be an integer division of the old sampling rate, e. g., 500Hz to 250Hz. NOTE: No anti-aliasing filtering is performed before downsampling, it is strongly recommended to apply a low-pass filter via explicitly setting lpfreq to the new Nyquist frequency (resamplefs / 2) as cut-off. Alternatively filter the data with
- “resample”Resample to a new sampling rate
The new sampling rate resamplefs can be any (rational) fraction of the original sampling rate (data.samplerate). Automatic anti-aliasing FIRWS filtering with the new Nyquist frequency is performed before resampling. Optionally set lpfreq in Hz for manual control over the low-pass filtering.
The parameters listed below can be provided as is or a via a cfg configuration ‘structure’, see Notes for details.
data (~syncopy.AnalogData) – A non-empty Syncopy
resamplefs (float) – The new sampling rate, needs to be an integer division of the original sampling rate for method=’downsample’
lpfreq (None or float, optional) – Leave at None for standard anti-alias filtering with the new Nyquist for method=’resample’ or set explicitly in Hz
order (None or int, optional) – Order (length) of the firws anti-aliasing filter The default None will create a filter with a length of 1000 samples
parallel (None or bool) – If None (recommended), processing is automatically performed in parallel (i.e., concurrently across trials/channel-groups), provided a dask parallel processing client is running and available. Parallel processing can be manually disabled by setting parallel to False. If parallel is True but no parallel processing client is running, computing will be performed sequentially.
select (dict or
StructDictor str) – In-place selection of subset of input data for processing. Please refer to
syncopy.selectdata()for further usage details.
resampled – The resampled dataset with the same shape and dimord as the input data
- Return type
In the following adata is an instance of
AnalogDatawith a samplerate of 2kHz.
Downsample (decimate) to 1kHz without low-pass filtering:
>>> downsampled = spy.resampledata(adata, method='downsample', resamplefs=1000)
Repeat, but this time remove aliases via explicit low-pass filter:
>>> downsampled = spy.resampledata(adata, method='downsample', resamplefs=1000, lpfreq=500)
Resample to 600Hz, low-pass filtering to new Nyquist is implicit:
>>> resampled = spy.resampledata(adata, resamplefs=600)