|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.openuat.features.Coherence
public class Coherence
This class implements computation of the coherence function. It is modelled after the Matlab/Octave "coher" function, but en explanation can e.g. be found at http://ccrma.stanford.edu/~jos/mdft/Coherence_Function_Matlab.html It uses the FFT class. The coherence is estimated as the power spectrum correlation between two signals split into overlapping slices. For each slice, the Fourier coefficients are computed and the magnitudes of these slices are averaged to compute the power spectra. Note: This class does not yet implement estimation of confidence intervals or de-trending like the Matlab/Octave implementations do. It is not necessary in the current use cases and has thus been omitted.
| Constructor Summary | |
|---|---|
Coherence()
|
|
| Method Summary | |
|---|---|
static double[] |
cohere(double[] s1,
double[] s2,
int windowsize,
int overlap)
Compute the coherence between two signals. |
static int |
getNumSlices(int signalLength,
int windowsize,
int overlap)
This is a small helper function to compute how many slices will be used. |
static double[] |
hann(int windowsize)
This function just generates a von-Hann window of specified size, as defined at http://www.mathworks.com/access/helpdesk/help/toolbox/signal/hann.html |
static double |
l2Norm(double[] vector)
Helper function: calculates the L2-norm of a vector. |
static double |
mean(double[] vector,
int max_ind)
Helper function: calculates the mean of the vector elements, up to a maximum index (or the whole vector if max_ind is set to -1 or larger than the vector length). |
static double |
weightedCoherenceMean(double[] s1,
double[] s2,
int windowsize,
int overlap,
int max_ind)
This is a helper function that computes the average over the coherence values, weighted by the number of slices that were used to compute the coherence. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Coherence()
| Method Detail |
|---|
public static int getNumSlices(int signalLength,
int windowsize,
int overlap)
public static double[] cohere(double[] s1,
double[] s2,
int windowsize,
int overlap)
s1 - Signal 1. Both signals must have equal length.s2 - Signal 2. Both signals must have equal length.windowsize - The window size to use, i.e. the number of FFT coefficients to compute. Defaults to
min(256, s1.length) if set to <= 0.overlap - The overlap of the windows to compute. Defaults to windowsize/2 when set to < 0.
public static double[] hann(int windowsize)
windowsize - The size of the von-Hann window to generate.
public static double l2Norm(double[] vector)
public static double mean(double[] vector,
int max_ind)
public static double weightedCoherenceMean(double[] s1,
double[] s2,
int windowsize,
int overlap,
int max_ind)
s1 - Signal 1. Both signals must have equal length.s2 - Signal 2. Both signals must have equal length.windowsize - The window size to use, i.e. the number of FFT coefficients to compute. Defaults to
min(256, s1.length) if set to <= 0.overlap - The overlap of the windows to compute. Defaults to windowsize/2 when set to <= 0.max_ind - The maximum index of the FFT coefficient vectors to compare to. This can be used
to only compare up to a specifiv frequency, and ignore higher frequencies. Set to
-1 to use all coefficients.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||