d1c59de2e9 | ||
---|---|---|
.. | ||
CalculatingFeatures | ||
cf_tests | ||
eda_explorer | ||
example_data | ||
.gitignore | ||
README.md | ||
__init__.py | ||
pyproject.toml | ||
setup.cfg | ||
usage_examples.ipynb |
README.md
Calculating features
Usage
- Install the library with:
pip install pep517 python -m pep517.build . ternative: p install build thon -m build
- Basic usage is:
from calculatingfeatures.CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, frequencyFeatureNames, hrvFeatureNames from calculatingfeatures.CalculatingFeatures.calculate_features import calculateFeatures import pandas as pd pathToHrvCsv = "example_data/S2_E4_Data/BVP.csv" windowLength = 500 # get an array of values from HRV empatica file hrv_data, startTimeStamp, sampleRate = convert1DEmpaticaToArray(pathToHrvCsv) # Convert the HRV data into 2D array hrv_data_2D = convertInputInto2d(hrv_data, windowLength) # Create a list with feature names featureNames = [] featureNames.extend(hrvFeatureNames) featureNames.extend(frequencyFeatureNames) pd.set_option('display.max_columns', None) # Calculate features calculatedFeatures = calculateFeatures(hrv_data_2D, fs=int(sampleRate), featureNames=featureNames)
- More usage examples are located in usage_examples.ipynb file
Features
- Features are returned (from calculateFeatures() function) in a Pandas DataFrame object.
- In the case if a feature couldn't be calculated (for example, if input signal is invalid), NaN value is returned.
- Further in this section, the list with descriptions of all possible features is presented.
GSR features:
These features are useful for 1D GSR(EDA) signals
mean
: mean of the signalstd
: standard deviation of signalq25
: 0.25 quantileq75
: 0.75 quantileqd
: q75 - q25deriv
: sum of gradients of the signalpower
: power of the signal (mean of squared signal)numPeaks
: number of EDA peaksratePeaks
: average number of peaks per secondpowerPeaks
: power of peaks (mean of signal at indexes of peaks)sumPosDeriv
: sum of positive derivatives divided by number of all derivativespropPosDeriv
: proportion of positive derivatives per all derivativesderivTonic
: sum of gradients of the tonicsigTonicDifference
: mean of tonic subtracted from signalfreqFeats
:maxPeakAmplitudeChangeBefore
: maximum peak amplitude change before peakmaxPeakAmplitudeChangeAfter
: maximum peak amplitude change after peakavgPeakAmplitudeChangeBefore
: average peak amplitude change before peakavgPeakAmplitudeChangeAfter
: average peak amplitude change after peakavgPeakChangeRatio
: avg_peak_increase_time / avg_peak_decrease_timemaxPeakIncreaseTime
: maximum peak increase timemaxPeakDecreaseTime
: maximum peak decrease timemaxPeakDuration
: maximum peak durationmaxPeakChangeRatio
: max_peak_increase_time / max_peak_decrease_timeavgPeakIncreaseTime
: average peak increase timeavgPeakDecreaseTime
: average peak decreade timeavgPeakDuration
: average peak durationmaxPeakResponseSlopeBefore
: maximum peak response slope before peakmaxPeakResponseSlopeAfter
: maximum peak response slope after peaksignalOverallChange
: maximum difference between samples (max(sig)-min(sig))changeDuration
: duration between maximum and minimum valueschangeRate
: change_duration / signal_overall_changesignificantIncrease
:significantDecrease
:
HRV features:
These features are useful for 1D HRV(BVP) signals.
If number of RR intervals (numRR) is less than length of sample / (2 * sampling rate)
(30 BPM) or greater than length of sample / (sampling rate / 4)
(240 BPM), BPM value is incorrect and thus, all other HRV features are set to NaN.
meanHr
: mean heart rateibi
: mean interbeat intervalsdnn
: standard deviation of the ibisdsd
: standard deviation of the differences between all subsequent R-R intervalsrmssd
: root of the mean of the list of squared differencespnn20
: the proportion of NN20 intervals to all intervalspnn50
: the proportion of NN50 intervals to all intervalssd
:sd2
:sd1/sd2
: sd / sd2 rationumRR
: number of RR intervals
Accelerometer features:
These features are useful for 3D signals from accelerometer
meanLow
: mean of low-pass filtered signalareaLow
: area under the low-pass filtered signaltotalAbsoluteAreaBand
: sum of absolute areas under the band-pass filtered x, y and z signaltotalMagnitudeBand
: square root of sum of squared band-pass filtered x, y and z componentsentropyBand
: entropy of band-pass filtered signalskewnessBand
: skewness of band-pass filtered signalkurtosisBand
: kurtosis of band-pass filtered signalpostureDistanceLow
: calculates difference between mean values for a given sensor (low-pass filtered)absoluteMeanBand
: mean of band-pass filtered signalabsoluteAreaBand
: area under the band-pass filtered signalquartilesBand
: quartiles of band-pass filtered signalinterQuartileRangeBand
: inter quartile range of band-pass filtered signalvarianceBand
: variance of band-pass filtered signalcoefficientOfVariationBand
: dispersion of band-pass filtered signalamplitudeBand
: difference between maximum and minimum sample of band-pass filtered signaltotalEnergyBand
: total magnitude of band-pass filtered signaldominantFrequencyEnergyBand
: ratio of energy in dominant frequencymeanCrossingRateBand
: the number of signal crossings with mean of band-pass filtered signalcorrelationBand
: Pearson's correlation between band-pass filtered axisquartilesMagnitudesBand
: quartiles at 25%, 50% and 75% per band-pass filtered signalinterQuartileRangeMagnitudesBand
: interquartile range of band-pass filtered signalareaUnderAccelerationMagnitude
: area under acceleration magnitudepeaksDataLow
: number of peaks, sum of peak values, peak avg, amplitude avgsumPerComponentBand
: sum per component of band-pass filtered signalvelocityBand
: velocity of the band-pass filtered signalmeanKineticEnergyBand
: mean kinetic energy 1/2*mV^2 of band-pass filtered signaltotalKineticEnergyBand
: total kinetic energy 1/2*mV^2 for all axes (band-pass filtered)squareSumOfComponent
: squared sum of componentsumOfSquareComponents
: sum of squared componentsaverageVectorLength
: mean of magnitude vectoraverageVectorLengthPower
: square mean of magnitude vectorrollAvgLow
: maximum difference of low-pass filtered roll samplespitchAvgLow
: maximum difference of low-pass filtered pitch samplesrollStdDevLow
: standard deviation of roll (calculated from low-pass filtered signal)pitchStdDevLow
: standard deviation of pitch (calculated from low-pass filtered signal)rollMotionAmountLow
: amount of wrist roll (from low-pass filtered signal) motionrollMotionRegularityLow
: regularity of wrist roll motionmanipulationLow
: manipulation of low-pass filtered signalsrollPeaks
: number of roll peaks, sum of roll peak values, roll peak avg, roll amplitude avgpitchPeaks
: number of pitch peaks, sum of pitch peak values, pitch peak avg, pitch amplitude avgrollPitchCorrelation
: correlation between roll and peak (obtained from low-pass filtered signal)
Gyroscope features:
These features are useful for 3D signals from gyroscope
meanLow
: mean of low-pass filtered signalareaLow
: area under the low-pass filtered signaltotalAbsoluteAreaLow
: sum of absolute areas under the low-pass filtered x, y and z signaltotalMagnitudeLow
: square root of sum of squared band-pass filtered x, y and z componentsentropyLow
: entropy of low-pass filtered signalskewnessLow
: skewness of low-pass filtered signalkurtosisLow
: kurtosis of low-pass filtered signalquartilesLow
: quartiles of low-pass filtered signalinterQuartileRangeLow
: inter quartile range of low-pass filtered signalvarianceLow
: variance of low-pass filtered signalcoefficientOfVariationLow
: dispersion of low-pass filtered signalamplitudeLow
: difference between maximum and minimum sample of low-pass filtered signaltotalEnergyLow
: total magnitude of low-pass filtered signaldominantFrequencyEnergyLow
: ratio of energy in dominant frequencymeanCrossingRateLow
: the number of signal crossings with mean of low-pass filtered signalcorrelationLow
: Pearson's correlation between low-pass filtered axisquartilesMagnitudeLow
: quartiles at 25%, 50% and 75% per low-pass filtered signalinterQuartileRangeMagnitudesLow
: interquartile range of band-pass filtered signalareaUnderMagnitude
: area under magnitudepeaksCountLow
: number of peaks in low-pass filtered signalaverageVectorLengthLow
: mean of low-pass filtered magnitude vectoraverageVectorLengthPowerLow
: square mean of low-pass filtered magnitude vector
Generic features:
These are generic features, useful for many different types of signals
autocorrelations
: autocorrelations of the given signal with lags 5, 10, 20, 30, 50, 75 and 100countAboveMean
: number of values in signal that are higher than the mean of signalcountBelowMean
: number of values in signal that are lower than the mean of signalmaximum
: maximum value of the signalminimum
: minimum value of the signalmeanAbsChange
: the mean of absolute differences between subsequent time series valueslongestStrikeAboveMean
: longest part of signal above meanlongestStrikeBelowMean
: longest part of signal below meanstdDev
: standard deviation of the signalmedian
: median of the signalmeanChange
: the mean over the differences between subsequent time series valuesnumberOfZeroCrossings
: number of crossings of signal on 0absEnergy
: the absolute energy of the time series which is the sum over the squared valueslinearTrendSlope
: a linear least-squares regression for the values of the time series versus the sequence from 0 to length of the time series minus oneratioBeyondRSigma
: ratio of values that are more than r*std(x) (so r sigma) away from the mean of signal. r in this case is 2.5binnedEntropy
: entropy of binned valuesnumOfPeaksAutocorr
: number of peaks of autocorrelationsnumberOfZeroCrossingsAutocorr
: number of crossings of autocorrelations on 0areaAutocorr
: area under autocorrelationscalcMeanCrossingRateAutocorr
: the number of autocorrelation crossings with meancountAboveMeanAutocorr
: umber of values in signal that are higher than the mean of autocorrelationsumPer
: sum per componentsumSquared
: squared sum per componentsquareSumOfComponent
: square sum of componentsumOfSquareComponents
:sum of square components
Frequency features:
These are frequency features, useful for many different types of signals. The signal is converted to power spectral density signal and features are calculated on this signal
fqHighestPeakFreqs
: three frequencies corresponding to the largest peaks added to featuresfqHighestPeaks
: three largest peaks added to featuresfqEnergyFeat
: energy calculated as the sum of the squared FFT component magnitudes, and normalizedfqEntropyFeat
: entropy of the FFT of the signalfqHistogramBins
: Binned distribution (histogram)fqAbsMean
: absolute mean of the raw signalfqSkewness
: skewness of the power spectrum of the datafqKurtosis
: kurtosis of the power spectrum of the datafqInterquart
: inter quartile range of the raw signal