|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.android.activityminer.logic.filter.AdaptiveLowPassFilter
public final class AdaptiveLowPassFilter
An adaptive low pass filter implementation based on the 1 Euro Filter algorithm.
| Field Summary | |
|---|---|
private double |
beta
The cutoff slope |
private double[] |
currentVariation
The current signal variation in time (signal changes over time as signal derivative). |
private double[] |
cutOffFreq
The dynamically calculated cutoff frequency for the signal. |
static double |
DEFAULT_BETA
The default cut-off slope for the signal used by the adaptive filter. |
static double |
DEFAULT_DERIVATIVE_CUTOFF_FREQ
The default minimum cutoff frequency for the signal derivative. |
static double |
DEFAULT_MIN_CUTOFF_FREQ
The default minimum cutoff frequency for the signal used by the adaptive filter. |
private double |
frequency
The current frequency in Hz. |
private long |
lastTs
The last time stamp. |
private double[] |
lastVariation
The last signal variation in time. |
private double[] |
lastX
The last input signal. |
private double |
minCutOffFreq
The minimum cutoff frequency. |
private String |
msgInvalidBeta
The message for invalid beta values. |
private String |
msgInvalidCutOff
The message for invalid minimum cut-off frequency values. |
private double |
variationCutOffFreq
The cutoff frequency for the signal variation in time (the derivative cut-off frequency). |
| Constructor Summary | |
|---|---|
AdaptiveLowPassFilter(Context context,
double minCutOffFreq,
double beta)
Constructor with a variation cutoff of 1.0. |
|
AdaptiveLowPassFilter(Context context,
double rate,
double minCutOffFreq,
double beta,
double variationCutOffFreq)
Constructor |
|
| Method Summary | |
|---|---|
void |
apply(List<Double> x,
List<Double> y,
List<Double> z,
List<Long> ts)
Does apply this filter to an accelerometer time series stream. |
private double[] |
calculateCurrentVariation(double[] x,
double[] y)
Method to calculate the current signal variation in time. |
double |
getAlpha(double cutOffFreq)
Getter for the smoothing factor alpha using a single cutoff frequencies for all dimension. |
private double[] |
getAlpha(double[] cutOffFreq)
Getter for the smoothing factor alpha using a different cutoff frequencies for each signal dimension. |
double |
getBeta()
Getter for the beta value ( cutoff scope ) |
double |
getMinCutOffFreq()
Getter for the the minimum cutoff frequency |
double[] |
lowPass(double[] x,
double[] y,
long currentTs)
The filter function. |
void |
reset()
Does reset the filter |
void |
setBeta(double beta)
Setter for the beta value ( cutoff scope ) |
void |
setCutOffFrequency(double cf)
Setter for the cut-off frequency |
protected void |
setFrequency(double frequency)
Setter for the frequency |
void |
setMinCutOffFreq(double minCutOffFreq)
Setter for the minimum cutoff frequency |
void |
updateConfiguration(RuntimeConfiguration config)
Does update the filter settings by the given configuration. |
private double[] |
updateCutOffFrequency(double[] estimatedVariation)
Method to update the cutOffFrequency based in the estimated signal variation in time. |
static boolean |
validateBeta(double beta)
Test method for valid beta values. |
static boolean |
validateMinCutOffFreq(double minCutOffFreq)
Test method for minimum cutoff frequency values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final String msgInvalidCutOff
private final String msgInvalidBeta
public static final double DEFAULT_MIN_CUTOFF_FREQ
public static final double DEFAULT_DERIVATIVE_CUTOFF_FREQ
public static final double DEFAULT_BETA
private long lastTs
private double[] currentVariation
private double[] lastVariation
private double[] lastX
private double[] cutOffFreq
private double frequency
private double beta
private double minCutOffFreq
private final double variationCutOffFreq
| Constructor Detail |
|---|
public AdaptiveLowPassFilter(Context context,
double minCutOffFreq,
double beta)
context - the contextminCutOffFreq - the minimum cutoff frequency for the signalbeta - the cutoff slope for the signal
public AdaptiveLowPassFilter(Context context,
double rate,
double minCutOffFreq,
double beta,
double variationCutOffFreq)
context - the contextrate - the estimated initial sample rate in millisecondsminCutOffFreq - the minimum cutoff frequency for the signalbeta - the cutoff slope for the signalvariationCutOffFreq - the cutoff frequency for the signal variation in time| Method Detail |
|---|
protected final void setFrequency(double frequency)
frequency - the frequency to setpublic final void setMinCutOffFreq(double minCutOffFreq)
minCutOffFreq - the minimum cutoff frequency to setpublic static final boolean validateMinCutOffFreq(double minCutOffFreq)
minCutOffFreq - the minimum cutoff frequency to test
public final void setBeta(double beta)
beta - the beta to setpublic static final boolean validateBeta(double beta)
beta - the beta value to test
public final double getBeta()
public final double getMinCutOffFreq()
public final double getAlpha(double cutOffFreq)
cutOffFreq - the cut of frequency in Hz
private final double[] getAlpha(double[] cutOffFreq)
cutOffFreq - the cut of frequencies per signal dimension in Hz
private final double[] calculateCurrentVariation(double[] x,
double[] y)
x - the actual input signaly - the last output signal
private final double[] updateCutOffFrequency(double[] estimatedVariation)
estimatedVariation - the estimated variation
public final double[] lowPass(double[] x,
double[] y,
long currentTs)
LowPassFilter
lowPass in interface LowPassFilterx - the actual input signaly - the last output signalcurrentTs - the current time stamp
public final void apply(List<Double> x,
List<Double> y,
List<Double> z,
List<Long> ts)
LowPassFilter
apply in interface LowPassFilterx - the x axis signal streamy - the y axis signal streamz - the z axis signal streamts - the time stampspublic final void updateConfiguration(RuntimeConfiguration config)
LowPassFilter
updateConfiguration in interface LowPassFilterconfig - the configuration to update from.public void reset()
LowPassFilter
reset in interface LowPassFilterpublic void setCutOffFrequency(double cf)
LowPassFilter
setCutOffFrequency in interface LowPassFiltercf - the cut-off frequencyy
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||