Beispiel #1
0
    def visualizeAllAcc(self, correlated=False):
        '''
    Visualizes all datastreams of the Accelerometer
    Arguments:
      correlated: set correlated to True if you want to autocorrelate the data before graphing.
    '''
        time = np.linspace(
            0, self.data.shape[0], self.data.shape[0]
        )  # from 0 to 10 seconds with [amount of datapoints] steps

        f, (ax4, ax5, ax6) = plt.subplots(3, sharex=True, sharey=True)

        ax4.plot(time, self.data.accX)
        ax4.set_title("accX", y=0.65, size='smaller')
        ax5.plot(time, self.data.accY)
        ax5.set_title("accY", y=0.65, size='smaller')
        ax6.plot(time, self.data.accZ)
        ax6.set_title("accZ", y=0.65, size='smaller')

        if correlated:
            analyzer = DataAnalyzer.DataAnalyzer(self.data.accX)
            ax4.plot(time, analyzer.getAutocorrelation())
            analyzer = DataAnalyzer.DataAnalyzer(self.data.accY)
            ax5.plot(time, analyzer.getAutocorrelation())
            analyzer = DataAnalyzer.DataAnalyzer(self.data.accZ)
            ax6.plot(time, analyzer.getAutocorrelation())

        # Fine-tune figure; make subplots close to each other and hide x ticks for
        # all but bottom plot.
        f.subplots_adjust(hspace=0)
        plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)

        plt.show()
Beispiel #2
0
    def visualizeStream(self,
                        dataStream,
                        correlated=False,
                        title='Data',
                        vLine=None):
        '''Visualizes a particular datastream
      Arguments
        data: single datastream
        title: [optional]
    '''

        time = np.linspace(0, dataStream.shape[0], dataStream.shape[0])
        f, ax1 = plt.subplots(1)
        ax1.plot(time, dataStream)
        ax1.set_title(title)
        if correlated:
            analyzer = DataAnalyzer.DataAnalyzer(dataStream)
            ax1.plot(time, analyzer.getAutocorrelation())

        if (vLine):
            plt.axvline(vLine)
        plt.show()
Beispiel #3
0
# Helper functions:


# get all the data files from the directory
def getDataFileNames(dataType, movement="", dataFolder=DATA_FOLDER):
    files = os.listdir(dataFolder)
    output = []
    for file in files:
        if dataType in file and movement in file:
            output.append(file)
    return output


# ------------------- MAIN ------------------------------------

analyzer = DataAnalyzer.DataAnalyzer()

print("Doing " + str(ITERATIONS) + " iterations with a " +
      str(TEST_SIZE_PERCENT) + " test ratio")

# -- training --

data_data = []
data_labels = []
data_data_length = []

files = getDataFileNames("training")
for trainingFile in files:
    dataFile = pd.read_csv(DATA_FOLDER + trainingFile, header=0)
    #data = [dataFile['alpha'], dataFile['beta'], dataFile['gamma'], dataFile['accX'], dataFile['accY'], dataFile['accZ']]
    dataFile = analyzer.normalize(dataFile)
Beispiel #4
0
from helpers import DataAnalyzer

import matplotlib.pyplot as plt
import numpy as np

from sklearn.preprocessing import normalize as skNorm

#dataFile = pd.read_csv("../../data/testing-leftright-qsMbpdsd6zQTqlrKAADi-1-72BPM.csv", header=0)
#dataFile = pd.read_csv("../../data/training-rotateclockwise-avkfxrmpauHdDpeaAAAa-6.csv", header=0)
#dataFile = pd.read_csv("../../data/training-updown-avkfxrmpauHdDpeaAAAa-1.csv", header=0)
#normal data

dataFile = pd.read_csv(
    "../data/FLAWED/lessthan1period/updown-35-49-R53P95G3cV93UMlKAAB0-3_1.csv",
    header=0)
da = DataAnalyzer.DataAnalyzer()

#Normalize each stream individually:
'''
dataNorm = dataFile.copy()
dataNorm['accX'] = skNorm(dataNorm['accX'])[0]
dataNorm['accY'] = skNorm(dataNorm['accY'])[0]
dataNorm['accZ'] = skNorm(dataNorm['accZ'])[0]
'''

#dataFile = da.normalize(dataFile)
#dataFile = da.autoCorrelate(dataFile)

daa = DataAnalyzer.AutoAnalyzer(dataFile)

visualizer = Visualizer.Visualizer(dataFile)