package signal
This package provides digital signal processing functions.
- Alphabetic
- By Inheritance
- signal
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract class OptDesignMethod extends Opt
- abstract class OptFilterTaps extends Opt
- abstract class OptMethod extends Opt
Option values: how to deal with convolution and filter padding.
- abstract class OptOverhang extends Opt
Option values: how to deal with convolution overhangs.
- abstract class OptPadding extends Opt
Option values: how to deal with convolution and filter padding.
- abstract class OptRange extends Opt
slices specific result ranges out of results for convolve, etc
- abstract class OptWindowFunction extends Opt
Option values: window function for filter design.
Value Members
- def convolve[Input, KernelType, Output](data: Input, kernel: KernelType, range: OptRange = OptRange.All, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Zero, method: OptMethod = OptMethod.Automatic)(implicit canConvolve: CanConvolve[Input, KernelType, Output]): Output
Convolves DenseVectors.
Convolves DenseVectors. Implementation is via the implicit trait CanConvolve[ InputType, OutputType ], which is found in breeze.signal.support.CanConvolve.scala.
- data
DenseVector or DenseMatrix to be convolved
- kernel
DenseVector or DenseMatrix kernel
- canConvolve
implicit delegate which is used for implementation. End-users should not use this argument.
- def correlate[Input, KernelType, Output](data: Input, kernel: KernelType, range: OptRange = OptRange.All, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Zero, method: OptMethod = OptMethod.Automatic)(implicit canConvolve: CanConvolve[Input, KernelType, Output]): Output
Correlates DenseVectors.
Correlates DenseVectors. Implementation is via the implicit trait CanConvolve[ InputType, OutputType ], which is found in breeze.signal.support.CanConvolve.scala. See breeze.signal.convolve for options and other information.
- def designFilterDecimation[Output](factor: Int, multiplier: Double = 1d, optDesignMethod: OptDesignMethod = OptDesignMethod.Firwin, optWindow: OptWindowFunction = OptWindowFunction.Hamming(), optFilterOrder: OptFilterTaps = OptFilterTaps.Automatic)(implicit canDesignFilterDecimation: CanDesignFilterDecimation[Output]): Output
- def designFilterFirwin[Output](taps: Int, omegas: DenseVector[Double], nyquist: Double = 1d, zeroPass: Boolean = true, scale: Boolean = true, multiplier: Double = 1d, optWindow: OptWindowFunction = OptWindowFunction.Hamming())(implicit canFirwin: CanFirwin[Output]): FIRKernel1D[Output]
FIR filter design using the window method.
FIR filter design using the window method.
This function computes the coefficients of a finite impulse response filter. The filter will have linear phase; it will be Type I if
numtaps
is odd and Type II ifnumtaps
is even.Type II filters always have zero response at the Nyquist rate, so a ValueError exception is raised if firwin is called with
numtaps
even and having a passband whose right end is at the Nyquist rate.Portions of the code are translated from scipy (scipy.org) based on provisions of the BSD license.
- omegas
Cutoff frequencies of the filter, specified in units of "nyquist." The frequencies should all be positive and monotonically increasing. The frequencies must lie between (0, nyquist). 0 and nyquist should not be included in this array.
- nyquist
The nyquist frequency, default is 1.
- zeroPass
If true (default), the gain at frequency 0 (ie the "DC gain") is 1, if false, 0.
- scale
Whether to scale the coefficiency so that frequency response is unity at either (A) 0 if zeroPass is true or (B) at nyquist if the first passband ends at nyquist, or (C) the center of the first passband. Default is true.
- optWindow
Currently supports a hamming window breeze.signal.OptWindowFunction.Hamming, a specified window breeze.signal.OptWindowFunction.User, or no window breeze.signal.OptWindowFunction.None.
- def filter[Input, Kernel, Output](data: Input, kernel: Kernel, overhang: OptOverhang = OptOverhang.PreserveLength, padding: OptPadding = OptPadding.Zero)(implicit canFilter: CanFilter[Input, Kernel, Output]): Output
Filter input data with the specified kernel and options.
Filter input data with the specified kernel and options.
- data
data to be filtered
- kernel
filter kernel (argument of DenseVector[Double] will specify a FIR kernel with specified values).
- overhang
whether to have overhanging values. See breeze.signal.OptOverhang
- padding
how to pad the values. See breeze.signal.OptPadding
- canFilter
(implicit delegate to perform filtering on specific Input data types)
- def filterBP[Input, Output](data: Input, omegas: (Double, Double), sampleRate: Double = 2d, taps: Int = 512, kernelDesign: OptDesignMethod = OptDesignMethod.Firwin, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Boundary)(implicit canFilterBPBS: CanFilterBPBS[Input, Output]): Output
Bandpass filter the input data.
Bandpass filter the input data.
- data
data to be filtered
- omegas
sequence of two filter band parameters, in units of the Nyquist frequency, or in Hz if the sampleRate is set to a specific value other than 2d.
- sampleRate
default of 2.0 means that the Nyquist frequency is 1.0
- taps
number of taps to use (default = 512)
- kernelDesign
currently only supports OptKernelType.Firwin. See breeze.signal.OptDesignMethod
- overhang
whether to have overhanging values when filtering. See breeze.signal.OptOverhang
- padding
how to pad the values when filtering. See breeze.signal.OptPadding
- canFilterBPBS
(implicit delegate to perform filtering on specific Input data types)
- def filterBS[Input, Output](data: Input, omegas: (Double, Double), sampleRate: Double = 2d, taps: Int = 512, kernelDesign: OptDesignMethod = OptDesignMethod.Firwin, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Boundary)(implicit canFilterBPBS: CanFilterBPBS[Input, Output]): Output
Bandstop filter the input data.
Bandstop filter the input data.
- data
data to be filtered
- omegas
sequence of two filter band parameters, in units of the Nyquist frequency, or in Hz if the sampleRate is set to a specific value other than 2d.
- sampleRate
default of 2.0 means that the Nyquist frequency is 1.0
- taps
number of taps to use (default = 512)
- kernelDesign
currently only supports OptKernelType.Firwin. See breeze.signal.OptDesignMethod
- overhang
whether to have overhanging values when filtering. See breeze.signal.OptOverhang
- padding
how to pad the values when filtering. See breeze.signal.OptPadding
- canFilterBPBS
(implicit delegate to perform filtering on specific Input data types)
- def filterHP[Input, Output](data: Input, omega: Double, sampleRate: Double = 2d, taps: Int = 512, kernelDesign: OptDesignMethod = OptDesignMethod.Firwin, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Boundary)(implicit canFilterLPHP: CanFilterLPHP[Input, Output]): Output
Highpass filter the input data.
Highpass filter the input data.
- data
data to be filtered
- omega
cutoff frequency, in units of the Nyquist frequency, or in Hz if the sampleRate is set to a specific value other than 2d.
- sampleRate
default of 2.0 means that the Nyquist frequency is 1.0
- taps
number of taps to use (default = 512)
- kernelDesign
currently only supports OptKernelType.Firwin. See breeze.signal.OptDesignMethod
- overhang
whether to have overhanging values when filtering. See breeze.signal.OptOverhang
- padding
how to pad the values when filtering. See breeze.signal.OptPadding
- canFilterLPHP
(implicit delegate to perform filtering on specific Input data types)
- def filterLP[Input, Output](data: Input, omega: Double, sampleRate: Double = 2d, taps: Int = 512, kernelDesign: OptDesignMethod = OptDesignMethod.Firwin, overhang: OptOverhang = OptOverhang.None, padding: OptPadding = OptPadding.Boundary)(implicit canFilterLPHP: CanFilterLPHP[Input, Output]): Output
Lowpass filter the input data.
Lowpass filter the input data.
- data
data to be filtered
- omega
cutoff frequency, in units of the Nyquist frequency, or in Hz if the sampleRate is set to a specific value other than 2d.
- sampleRate
default of 2.0 means that the Nyquist frequency is 1.0
- taps
number of taps to use (default = 512)
- kernelDesign
currently only supports OptKernelType.Firwin. See breeze.signal.OptDesignMethod
- overhang
whether to have overhanging valueswhen filtering. See breeze.signal.OptOverhang
- padding
how to pad the values when filtering. See breeze.signal.OptPadding
- canFilterLPHP
(implicit delegate to perform filtering on specific Input data types)
- def filterMedian[Input](data: DenseVector[Input], windowLength: Int)(implicit canFilterMedian: CanFilterMedian[Input]): DenseVector[Input]
- def filterMedian[Input](data: DenseVector[Input], windowLength: Int, overhang: OptOverhang = OptOverhang.PreserveLength)(implicit canFilterMedian: CanFilterMedian[Input]): DenseVector[Input]
Median filter the input data.
Median filter the input data.
- windowLength
only supports odd windowLength values, since even values would cause half-frame time shifts in one or the other direction, and would also lead to floating point values even for integer input
- overhang
specify OptOverhang.PreserveLength (default) or OptOverhang.None (result will be (windowLength -1) shorter) for OptOverhang.PreserveLength, the edges will feature symmetrical odd windows of increasing size, ie ( median( {0} ), median( {0, 1, 2} ), median( {0, 1, 2, 3, 4} )... )
- def fourierFreq(windowLength: Int, fs: Double = -1, dt: Double = -1, shifted: Boolean = false): DenseVector[Double]
Returns the frequencies for each tap in a discrete Fourier transform, useful for plotting.
Returns the frequencies for each tap in a discrete Fourier transform, useful for plotting. You must specify either an fs or a dt argument. If you specify both, which is redundant, fs == 1.0/dt must be true.
f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (dt*n) if n is even f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (dt*n) if n is odd
- windowLength
window length of discrete Fourier transform
- fs
sampling frequency (1.0/dt; specify default of -1 if using dt)
- dt
time step (CAUTION: 1.0/fs; specify default of -1 if using fs)
- shifted
whether to return fourierShift'ed frequencies, default=false
- val fourierTransform: fourierTr.type
- def haarTr[Input, Output](v: Input)(implicit canHaarTransform: CanHaarTr[Input, Output]): Output
Return the padded fast haar transformation of a DenseVector or DenseMatrix.
Return the padded fast haar transformation of a DenseVector or DenseMatrix. Note that the output will always be padded to a power of 2. A matrix will cause a 2D fht. The 2D haar transformation is defined for squared power of 2 matrices. A new matrix will thus be created and the old matrix will be placed in the upper-left part of the new matrix. Avoid calling this method with a matrix that has few cols / many rows or many cols / few rows (e.g. 1000000 x 3) as this will cause a very high memory consumption.
- v
DenseVector or DenseMatrix to be transformed.
- canHaarTransform
implicit delegate which is used for implementation. End-users should not use this argument.
- returns
DenseVector or DenseMatrix
- See also
https://en.wikipedia.org/wiki/Haar_wavelet
- def haarTransform[Input, Output](v: Input)(implicit canHaarTransform: CanHaarTr[Input, Output]): Output
- def iHaarTr[Input, Output](v: Input)(implicit canInverseHaarTransform: CanIHaarTr[Input, Output]): Output
Returns the inverse fast haar transform for a DenseVector or DenseMatrix.
- val inverseFourierTransform: iFourierTr.type
- def inverseHaarTransform[Input, Output](v: Input)(implicit canInverseHaarTransform: CanIHaarTr[Input, Output]): Output
- object JavaCompatible
This class is a converter for using breeze.signal functions on Arrays of Double and Complex, from Java/Matlab/Mathematica.
- object OptDesignMethod
- object OptFilterTaps
- object OptMethod
- object OptOverhang
- object OptPadding
- object OptRange
- object OptWindowFunction
- object fourierShift extends UFunc
Shift the zero-frequency component to the center of the spectrum.
Shift the zero-frequency component to the center of the spectrum. This function swaps half-spaces for all axes listed (defaults to all). Note that y[0] is the Nyquist component only if len(x) is even.
- object fourierTr extends UFunc
Returns the discrete fourier transform of a DenseVector or DenseMatrix.
Returns the discrete fourier transform of a DenseVector or DenseMatrix. Currently, DenseVector/DenseMatrix types of Double and Complex are supported. Scaling follows the common signal processing convention, i.e. no scaling on forward DFT, and 1/n scaling for the inverse DFT. Of note, fft(x: DenseMatrix[Double]) will perform the 2D fft in both row and column dimensions, as opposed to the MatLab toolbox syntax, which performs column-wise 1D fft. Implementation is via the implicit trait fft.Impl[ InputType, OutputType ], which is found in breeze.signal.support.fft.Impl.scala.
- object iFourierShift extends UFunc
Inverse shift the zero-frequency component to the center of the spectrum.
Inverse shift the zero-frequency component to the center of the spectrum. For odd sequences, this is not equivalent to breeze.signal.fourierShift
- object iFourierTr extends UFunc
Returns the inverse fast fourier transform of a DenseVector or DenseMatrix.
Returns the inverse fast fourier transform of a DenseVector or DenseMatrix. Currently, DenseVector/DenseMatrix types of Double and Complex are supported. Scaling follows the common signal processing convention, i.e. no scaling on forward DFT, and 1/n scaling for the inverse DFT. Of note, ifft(x: DenseMatrix[Double]) will perform the 2D ifft in both row and column dimensions, as opposed to the MatLab toolbox syntax, which performs column-wise 1D ifft. Implementation is via the implicit trait CanIFFT[ InputType, OutputType ], which is found in breeze.signal.support.CanIFFT.scala.
- object rootMeanSquare extends UFunc
Root mean square of a vector.