Exemple #1
0
def animated_barplot(file,step,how_muc,size):
    # http://www.scipy.org/Cookbook/Matplotlib/Animations
    print("l")
    a=CSV_Extractor.CSVExtractor(file)
    b=a.get_data_from_sensor("FC5", how_much)
    chunk0=0
    chunk1=size
    print("G")
    rects = plt.bar(range(1), 0,  align = 'center')
    rect1=plt.bar(2, 0,  align = 'center')
    rect2=plt.bar(3, 0,  align = 'center')
    rect3=plt.bar(4, 0,  align = 'center')
    print(len(b)/128)
    for i in range(int(len(b)/step)):
        dat=b[chunk0:chunk1]
        r=PreprocessUtils.butter_highpass_filter(dat,0.16,128,5)
        c=PreprocessUtils.basic_window(r)
        #print((len(c),i))
        er=PreprocessUtils.bin_power(c, [1,4,7,13,30], 128)
        j.append(er[1][0])
        for rect in rects:
            #print(er[1][0])
            rect.set_height(er[1][0])
        for rect in rect1:
            rect.set_height(er[1][1])
        for rect in rect2:
            rect.set_height(er[1][2])
        for rect in rect3:
            rect.set_height(er[1][3])
        chunk0+=step
        chunk1+=step
        fig.canvas.draw()
        time.sleep(0.0625)
Exemple #2
0
def rollingbarplot(file, step, size,sensor):
    a=CSV_Extractor.CSVExtractor(file)
    proc=Preprocessers.DataProcessor()
    temproc=Preprocessers.DataProcessor()
    rects = plt.bar(range(1), 0,  align = 'center')
    rect1=plt.bar(2, 0,  align = 'center')
    rect2=plt.bar(3, 0,  align = 'center')
    rect3=plt.bar(4, 0,  align = 'center')
    tree={'F3': [], 'FC5': [], 'T7': [], 'F7': [], 'P7': [], 'P8': [], 'AF4': [], 'O2': [], 'O1': [], 'T8': [], 'AF3': [], 'FC6': [], 'F4': [], 'F8': []}
    step=False
    binnedstuff=dict()
    while not len(tree["F3"])==size:
        for i in a.sensor2column:
            fed=a.get128more(i)
           # fed={i:fed}
            fed=PreprocessUtils.butter_highpass_filter(fed,0.16, 128,1)
            #temproc.update_data(fed)
            #temproc.do_high_pass()
            #fed=temproc.data_dict
            tree[i]+=fed
    while True:
        if len(tree[0])==size:
                #Now it is time to actually do the calculations
            proc.update_data(tree)
            proc.do_hann_wndow()
            proc.do_bin_power()
            binnedstuff=proc.data_dict
            interestingbinnedstuff=proc.data_dict[sensor][1]
        else:break
        for rect in rects:
            #print(er[1][0])
            rect.set_height(interestingbinnedstuff[0])
        for rect in rect1:
            rect.set_height(interestingbinnedstuff[1])
        for rect in rect2:
            rect.set_height(interestingbinnedstuff[2])
        for rect in rect3:
            rect.set_height(interestingbinnedstuff[3])
        for i in tree:
            del tree[i][0:16]            
        time.sleep(16/128)
        for i in tree:
            tree[i]+=a.get16more(i)
Exemple #3
0
 def do_high_pass(self):
     for item in self.data_dict.keys():
         self.data_dict[item] = PreprocessUtils.butter_highpass_filter(
             self.data_dict[item], 0.16, 128, 5)
 def do_high_pass(self):
     for item in self.data_dict.keys():
         self.data_dict[item] = PreprocessUtils.butter_highpass_filter(self.data_dict[item], 0.16, 128, 5)