def filter(self, sf, x, axis=-1, ftype='phase', keepfilt=False, njobs=-1):
"""Filt the data in the specified frequency bands.
Parameters
----------
sf: float
The sampling frequency.
x: array_like
Array of data.
axis : int | -1
Location of the time axis.
ftype : {'phase', 'amplitude'}
Specify if you want to extract phase ('phase') or the amplitude
('amplitude').
njobs : int | -1
Number of jobs to compute PAC in parallel. For very large data,
set this parameter to 1 in order to prevent large memory usage.
keepfilt : bool | False
Specify if you only want the filtered data (True). This parameter
is only avaible with dcomplex='hilbert' and not wavelet.
Returns
-------
xfilt : array_like
The filtered data of shape (n_frequency, ...)
"""
# Sampling frequency :
if not isinstance(sf, (int, float)):
raise ValueError("The sampling frequency must be a float number.")
else:
sf = float(sf)
# Compatibility between keepfilt and wavelet :
if (keepfilt is True) and (self._dcomplex is 'wavelet'):
raise ValueError("Using wavelet for the complex decomposition do "
"not allow to get filtered data only. Set the "
"keepfilt parameter to False or set dcomplex to "
"'hilbert'.")
# 1D signals :
if x.ndim == 1:
x = x.reshape(1, -1)
axis = 1
# Switch between phase or amplitude :
if ftype is 'phase':
tosend = 'pha' if not keepfilt else None
xfilt = spectral(x, sf, self.fpha, axis, tosend, self._dcomplex,
self._filt, self._filtorder, self._cycle[0],
self._width, njobs)
elif ftype is 'amplitude':
tosend = 'amp' if not keepfilt else None
xfilt = spectral(x, sf, self.famp, axis, tosend, self._dcomplex,
self._filt, self._filtorder, self._cycle[1],
self._width, njobs)
else:
raise ValueError("ftype must either be None, 'phase' or "
"'amplitude.'")
return xfilt
评论列表
文章目录