Resampling

process_nwb.resample.resample(X, new_freq, old_freq, real=True, axis=0, npad='fast', precision='single', loop=True)[source]

Resamples the timeseries from the original sampling frequency to a new frequency.

Parameters
  • X (ndarray) – Input timeseries.

  • new_freq (float) – New sampling frequency

  • old_freq (float) – Original sampling frequency

  • real (bool) – Whether rfft should be used for resampling or fft.

  • axis (int) – Which axis to resample.

  • npad (int) – Padding to add to beginning and end of timeseries. Default ‘fast’, which pads to the next fastest length.

  • precision (str) – Either single for float32/complex64 or double for float/complex.

  • loop (bool) – Whether or not to loop across channels when resampling.

Returns

Xds – Downsampled data, dimensions (n_time_new, …)

Return type

array

process_nwb.resample.resample_func(X, num, npad='fast', pad='reflect_limited', real=True, precision='single')[source]

Resample an array. Operates along the first dimension of the array. This is the low-level code. Users shoud likely use resample() rather than this function.

Parameters
  • X (ndarray, (n_time, ...)) – Signal to resample.

  • num (int) – Number of samples in resampled signal.

  • npad (int) – Padding to add to beginning and end of timeseries. Default ‘fast’, which pads to the next fastest length.

  • pad (str) – Type of padding. The default is 'reflect_limited'.

  • real (bool) – Whether rfft should be used for resampling or fft.

  • precision (str) – Either single for float32/complex64 or double for float/complex.

Returns

y – The x array resampled.

Return type

array

Notes

This uses edge padding to improve scipy.signal.resample’s resampling method, which we have adapted for our use here.

process_nwb.resample.store_resample(elec_series, processing, new_freq, axis=0, scaling=None, npad='fast', precision='single')[source]

Resamples the ElectricalSeries from the original sampling frequency to a new frequency and store the results in a new ElectricalSeries.

Parameters
  • elec_series (ElectricalSeries) – ElectricalSeries to process.

  • processing (Processing module) – NWB Processing module to save processed data.

  • new_freq (float) – New sampling frequency

  • axis (int) – Which axis to downsample. Default is 0.

  • scaling (float) – Scale the values by this. Can help with accuracy of downstream operations if the raw values are too small. Default = 1e6.

  • npad (int) – Padding to add to beginning and end of timeseries. Default ‘fast’, which pads to the next fastest length.

  • precision (str) – Either single for float32/complex64 or double for float/complex.

Returns

  • X_ds (ndarray, (n_time_new, …)) – Downsampled data.

  • elec_series_ds (ElectricalSeries) – ElectricalSeries that holds X_ds.