org.android.activityminer.logic.features
Class AbstractFeatureExtractorForDBRecordings<T extends Enum<T> & Dimensions>

Package class diagram package AbstractFeatureExtractorForDBRecordings
java.lang.Object
  extended by java.lang.Thread
      extended by de.unikassel.android.sdcframework.util.AbstractWorkerThread
          extended by de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl<SensorObservationCutout<T,Double>,FeatureVector>
              extended by org.android.activityminer.logic.features.AbstractFeatureExtractor<T>
                  extended by org.android.activityminer.logic.features.AbstractCutoutFeatureExtractor<T>
                      extended by org.android.activityminer.logic.features.AbstractFeatureExtractorForDBRecordings<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventDispatcher<SensorObservationCutout<T,Double>,FeatureVector>, EventObserver<FeatureVector>, ObservableEventSource<FeatureVector>, ObserverRegistration<FeatureVector>, WorkerThread, Runnable, ActivatableComponent
Direct Known Subclasses:
FeatureExtractorForAccDBRecordings, FeatureExtractorForDBRecordings

public abstract class AbstractFeatureExtractorForDBRecordings<T extends Enum<T> & Dimensions>
extends AbstractCutoutFeatureExtractor<T>
implements EventObserver<FeatureVector>

A abstract feature extractor implementation to extract features from the labeled time series recordings.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
private  List<FeatureVector> resultList
          The list to store extracted feature while processing samples.
private  long sampleRate
          The sample rate.
protected  ObservableEventSource<SensorObservation<T,Double>> sensorObservationSource
          The observable sensor observation source source to attach to the cutOut creator.
 
Fields inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl
collector
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AbstractFeatureExtractorForDBRecordings(long windowSize, int overlap, FeatureTypes[] featureTypes, long sampleRate, Context context)
          Constructor
 
Method Summary
 Long continuousExtractFeatures(SensorObservationCutout<T,Double> cutOut)
          Method to add a single raw time series cut-out during continuous feature extraction from a recorded sequence.
protected abstract  SensorObservation<T,Double> createObservationFromCutOut(SensorObservationCutout<T,Double> cutOut, int i, Long ts)
          Does create a sensor observation from a cut-out window at a given index with a given time stamp
 List<FeatureVector> extractFeatures(LabeledRecording<T> recording)
          Method to extract the features from a single raw time series recording.
 boolean hasNotDone()
          Method to determinate the finished state.
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void onEvent(ObservableEventSource<? extends FeatureVector> eventSource, FeatureVector observedEvent)
           
 void startContinuousFeatureExtraction(EventObserver<FeatureVector> featureVectorObserver)
          Method to start continuous feature extraction
 void stopContinuousFeatureExtraction(Long lastTs)
          Method to stop continuous feature extraction and wait until last window was processed
 void waitUnitlDone()
          Method to wait until all observations and cut-outs are processed
 
Methods inherited from class org.android.activityminer.logic.features.AbstractCutoutFeatureExtractor
attachSensorObservationSource, detachSensorObservationSource, getCutoutSource, getOverlapSize, getQueuedObservationCount, getWindowSize, onDestroy, setWindowSize
 
Methods inherited from class org.android.activityminer.logic.features.AbstractFeatureExtractor
doWork, featureTypeConfiguration, getExtractionTime, getFactory, getQueuedCutoutCount, isActive, isEctracting, setActivationState
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractEventDispatcherImpl
doCleanUp, getCollector, getEventSource, hasObservers, notify, registerEventObserver, removeAllObservers, unregisterEventObserver
 
Methods inherited from class de.unikassel.android.sdcframework.util.AbstractWorkerThread
doTerminate, hasTerminated, isLogging, isWorking, logMessage, run, setLogging, start, startWork, stopWork
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObservableEventSource
hasObservers, notify
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObserverRegistration
registerEventObserver, removeAllObservers, unregisterEventObserver
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.WorkerThread
doTerminate, hasTerminated, isLogging, isWorking, setLogging, startWork, stopWork
 

Field Detail

resultList

private List<FeatureVector> resultList
The list to store extracted feature while processing samples.


sampleRate

private long sampleRate
The sample rate.


sensorObservationSource

protected final ObservableEventSource<SensorObservation<T extends Enum<T> & Dimensions,Double>> sensorObservationSource
The observable sensor observation source source to attach to the cutOut creator.

Constructor Detail

AbstractFeatureExtractorForDBRecordings

public AbstractFeatureExtractorForDBRecordings(long windowSize,
                                               int overlap,
                                               FeatureTypes[] featureTypes,
                                               long sampleRate,
                                               Context context)
Constructor

Parameters:
windowSize - the size of the window to extract features from, which is moved over the raw time series stream
overlap - the overlap in percent of continuous cut-outs
featureTypes - the types of the features to extract from the time series data
sampleRate - the configured sample rate
context - the context
Method Detail

startContinuousFeatureExtraction

public final void startContinuousFeatureExtraction(EventObserver<FeatureVector> featureVectorObserver)
Method to start continuous feature extraction

Parameters:
featureVectorObserver - the observer for the extracted features vectors

stopContinuousFeatureExtraction

public final void stopContinuousFeatureExtraction(Long lastTs)
Method to stop continuous feature extraction and wait until last window was processed

Parameters:
lastTs - the time stamp of the last processed observation

waitUnitlDone

public void waitUnitlDone()
Method to wait until all observations and cut-outs are processed


continuousExtractFeatures

public final Long continuousExtractFeatures(SensorObservationCutout<T,Double> cutOut)
Method to add a single raw time series cut-out during continuous feature extraction from a recorded sequence. Important: You must have called startContinuousFeatureExtraction(EventObserver) before the first call to this method. After the last call to this method stopContinuousFeatureExtraction(Long) must be called.

Parameters:
cutOut - a segment of continuous sensor observations to create cut-outs and extract features from
Returns:
the time stamp of the last observation in the recording

extractFeatures

public final List<FeatureVector> extractFeatures(LabeledRecording<T> recording)
Method to extract the features from a single raw time series recording.

Parameters:
recording - the recording with the frame holding the raw time series data.
Returns:
a list with the extracted feature vectors

createObservationFromCutOut

protected abstract SensorObservation<T,Double> createObservationFromCutOut(SensorObservationCutout<T,Double> cutOut,
                                                                           int i,
                                                                           Long ts)
Does create a sensor observation from a cut-out window at a given index with a given time stamp

Parameters:
cutOut - the cut-out to create the sensor observation from
i - the index
ts - the time stamp
Returns:
the sensor observation created from recording

hasNotDone

public final boolean hasNotDone()
Method to determinate the finished state.

Returns:
true if still not finished

onEvent

public final void onEvent(ObservableEventSource<? extends FeatureVector> eventSource,
                          FeatureVector observedEvent)
Specified by:
onEvent in interface EventObserver<FeatureVector>

onActivationStateChange

protected final void onActivationStateChange(boolean active)
Description copied from class: AbstractFeatureExtractor
Handler for activation state changes

Overrides:
onActivationStateChange in class AbstractCutoutFeatureExtractor<T extends Enum<T> & Dimensions>
Parameters:
active - the new activation state