def loadData(self): self.trainingData = self.dataController.loadSampleData() import logic.dimreduce.paa as PAA p = PAA.paa() data = p.process(self.trainingData["PIR"][:], 100) r = np.array(range(len(data))).reshape(len(data), 1) s = np.array(data).reshape(len(data), 1) rs = np.hstack((s, s)) print rs import logic.featurex.kmeans as km k = km.kmeans() labels = k.process(rs, 2) print labels self.plot.add_item(make.curve(range(0, len(data)), data)) from guiqwt.styles import AnnotationParam i = 0 i_beg = 0 i_end = 0 while i < len(labels): cur = labels[i_end] if i < len(labels) - 1: if labels[i_end + 1] != cur: i_end = i from guiqwt.annotations import AnnotatedRectangle param = AnnotationParam() param.title = str(labels[int(i_beg)]) param.show_computations = False anno = AnnotatedRectangle(r[int(i_beg)], 0.5, r[int(i_end)], 0.2, param) # TODO: y axis scaling self.plot.add_item(anno) i_beg = i_end print "s1" else: i_end = i print "s2" print "s3" print "s4", i_end, len(labels) i += 1 # param = AnnotationParam() # param.title = "alright" # param.show_computations = False ##anno = AnnotatedRectangle(0., 1., 1.5, 0.5, param) # anno.set_style("plot", "shape/drag") # anno.set_style("shape/drag/fill/color", "white") # self.plot.add_item(anno) # self.rangeSelection = make.range(-2, 2) # disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", # title="Range infos") # self.plot.add_item(self.rangeSelection) # self.plot.add_item(disp0) self.plot.replot()
def process(self): params = {} for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = int(b.text()) print "params", params outpN = self.tableWidget.item(0, 0) #params = {"none": "none", "output_length": outpN} r = np.array(range(len(self.dc.dimrecprocData))).reshape(len(self.dc.dimrecprocData), 1) s = np.array(self.dc.dimrecprocData).reshape(len(self.dc.dimrecprocData), 1) rs = np.hstack((s, s)) labels = self.fec.extractFeature(rs, params) print labels self.plot.del_all_items() self.plot.replot() self.plot.add_item( make.curve(range(0, len(self.dc.dimrecprocData)), self.dc.dimrecprocData)) from guiqwt.styles import AnnotationParam i = 0 i_beg = 0 i_end = 0 while i < len(labels): cur = labels[i_end] if i < len(labels) - 1: if labels[i_end + 1] != cur: i_end = i from guiqwt.annotations import AnnotatedRectangle param = AnnotationParam() param.title = str(labels[int(i_beg)]) param.show_computations = False anno = AnnotatedRectangle(r[int(i_beg)], self.dc.dimrecprocData[int(i_beg)], int(i_end), self.dc.dimrecprocData[r[int(i_end)]], param) #TODO: y axis scaling self.plot.add_item(anno) i_beg = i_end print "s1" else: i_end = i print "s2" print "s3" print "s4", i_end, len(labels) i += 1 self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") #self.plot.add_item(self.rangeSelection) #self.plot.add_item(disp0) #self.dc.setCurrentDataFlowObject(self.flowData) self.dc.featureexData = self.flowData self.dc.setCurrentLabels(labels) print(self.dc.setCurrentLabels) #ToDo: Check that following line, make property in data controller self.dc.dimrecprocData = rs self.plot.replot() self.currentdata = np.reshape(labels, (-1, 1))