def Plot_Button_Clicked(self): Parameters = oct2py.Struct() FilePath = self.FilePath_LineEdit.text() RawPath = FeatAConfig.RawDataFunctions Mu_Min = self.MuMin_SpinBox.value() Mu_Max = self.MuMax_SpinBox.value() Beta_Min = self.BetaMin_SpinBox.value() Beta_Max = self.BetaMax_SpinBox.value() Time_Min = self.TimeRangeStart_SpinBox.value() Time_Max = self.TimeRangeEnd_SpinBox.value() if (self.RemoveNoise_CheckBox.isChecked()): RemoveNoise = 'true' else: RemoveNoise = 'false' cmd = "DataOut = GetDataAnalysis('{0}', '{1}', {2}, {3}, {4}, {5}, {6}, {7}, {8});".format( FilePath, RawPath, Mu_Min, Mu_Max, Beta_Min, Beta_Max, Time_Min, Time_Max, RemoveNoise) self.octave.eval(cmd) self.NavigateWindow.show() self.ui_navigate.plot()
def detect(self, TrialData): DetectIn = oct2py.Struct() DetectIn['TrialData'] = TrialData DetectIn['TrainOut'] = self.TrainOut self.DetectThread.startDetect(DetectIn)
def Struct(self): return oct2py.Struct()
def struct(self, dict): return oct2py.Struct(dict)
def run(self): #"../Osama Mohamed.csv",1,1,0,0,0,0,0,0,1,0,0,0,4 #TrainOut = KNN_Generic(directory, noiseFlag, f1FLag,f2FLag,f3FLag,f4FLag,f5FLag,f6FLag,LDAFLag,PCAFlag,CSP_LDAFlag,NoneFlag,startD,endD) #TODO: change f*FLag to f*Flag! #settig the feature selection method flags if (self.selectedFeatureExtractionMethod == "mean"): self.f1FLag = 1 else: self.f1FLag = 0 if (self.selectedFeatureExtractionMethod == "Min MU and Max Beta"): self.f3FLag = 1 else: self.f3FLag = 0 if (self.selectedFeatureExtractionMethod == "Min Mu, Max Beta, Mean Mu, Mean Beta"): self.f4FLag = 1 else: self.f4FLag = 0 if (self.selectedFeatureExtractionMethod == "Min Mu Max Mu Min Beta Max Beta"): self.f5FLag = 1 else: self.f5FLag = 0 if (self.selectedFeatureExtractionMethod == "Min Mu, max Mu, Min Beta, Max Beta, Mean Mu, Mean Beta"): self.f6FLag = 1 else: self.f6FLag = 0 #preprocessing is not done yet self.idealFlag = 0 self.butterFlag = 0 self.NoneFilterFlag = 0 if (self.selectedPreprocessingMethod == "ideal"): self.idealFlag = 1 print("Ideal") elif (self.selectedPreprocessingMethod == "butter"): self.butterFlag = 1 print("BUTTER") elif (self.selectedPreprocessingMethod == "None"): self.NoneFilterFlag = 1 print("None") else: print "undetermined pre-processing type" #setting the feature enhancement flags if (self.FeatureEnhancementSelectedMethod == "PCA"): self.PCAFlag = 1 else: self.PCAFlag = 0 if (self.FeatureEnhancementSelectedMethod == "LDA"): self.LDAFlag = 1 else: self.LDAFlag = 0 if (self.FeatureEnhancementSelectedMethod == "None"): self.NoneFlag = 1 else: self.NoneFlag = 0 #unused flags for now self.CSP_LDAFlag = 0 self.f2FLag = 0 #define the output structures self.knnTrainOut = oct2py.Struct() self.fisherTrainOut = oct2py.Struct() self.leastSquaresTrainOut = oct2py.Struct() self.likelihoodTrainOut = oct2py.Struct() self.likelihoodClass = oct2py.Struct() self.knnResult = oct2py.Struct() self.knnResultInput = oct2py.Struct() self.fisherResult = oct2py.Struct() self.fisherResultInput = oct2py.Struct() self.likelihoodResult = oct2py.Struct() self.likelihoodResultInput = oct2py.Struct() self.leastSquaresResult = oct2py.Struct() self.leastSquaresResultInput = oct2py.Struct() #calling the classifer selected according #if (self.trainTestFlag == True): if (self.classifierFile == "KNN"): self.knnTrainOut = self.octave.feval( 'KNN_Generic.m', self.dataFile, self.removeNoiseFlag, self.idealFlag, self.butterFlag, self.NoneFilterFlag, self.f1FLag, self.f2FLag, self.f3FLag, self.f4FLag, self.f5FLag, self.f6FLag, self.LDAFlag, self.PCAFlag, self.CSP_LDAFlag, self.NoneFlag, self.SignalStart, self.SignalEnd) self.LDAData = self.knnTrainOut.LDAData self.PCAData = self.knnTrainOut.PCAData self.NoneData = self.knnTrainOut.NoneData self.dataLength = self.knnTrainOut.datalength print("KNN training done!") ###>--- using either of them is ok for debugging ---<### #print(self.knnTrainOut.KPCA) #print(self.knnTrainOut['KPCA']) elif (self.classifierFile == "Fisher"): print(self.idealFlag) print(self.butterFlag) self.fisherTrainOut = self.octave.feval( 'Fisher_Generic.m', self.dataFile, self.removeNoiseFlag, self.idealFlag, self.butterFlag, self.NoneFilterFlag, self.f1FLag, self.f2FLag, self.f3FLag, self.f4FLag, self.f5FLag, self.f6FLag, self.LDAFlag, self.PCAFlag, self.CSP_LDAFlag, self.NoneFlag, self.SignalStart, self.SignalEnd) self.LDAData = self.fisherTrainOut.LDAData self.PCAData = self.fisherTrainOut.PCAData self.NoneData = self.fisherTrainOut.NoneData self.dataLength = self.fisherTrainOut.datalength print("Fisher training done!") elif (self.classifierFile == "Likelihood"): self.likelihoodTrainOut = self.octave.feval( 'Likelihood_Generic.m', self.dataFile, self.removeNoiseFlag, self.idealFlag, self.butterFlag, self.NoneFilterFlag, self.f1FLag, self.f2FLag, self.f3FLag, self.f4FLag, self.f5FLag, self.f6FLag, self.LDAFlag, self.PCAFlag, self.CSP_LDAFlag, self.NoneFlag, self.SignalStart, self.SignalEnd) self.LDAData = self.likelihoodTrainOut.LDAData self.PCAData = self.likelihoodTrainOut.PCAData self.NoneData = self.likelihoodTrainOut.NoneData self.dataLength = self.likelihoodTrainOut.datalength print("Likelihood training done!") elif (self.classifierFile == "Least Squares"): self.leastSquaresTrainOut = self.octave.feval( 'Leastsquares_Generic.m', self.dataFile, self.removeNoiseFlag, self.idealFlag, self.butterFlag, self.NoneFilterFlag, self.f1FLag, self.f2FLag, self.f3FLag, self.f4FLag, self.f5FLag, self.f6FLag, self.LDAFlag, self.PCAFlag, self.CSP_LDAFlag, self.NoneFlag, self.SignalStart, self.SignalEnd) self.LDAData = self.leastSquaresTrainOut.LDAData self.PCAData = self.leastSquaresTrainOut.PCAData self.NoneData = self.leastSquaresTrainOut.NoneData self.dataLength = self.leastSquaresTrainOut.datalength print("Least Square training done!") if (self.trainTestFlag == False): if (self.detectFile != None): self.detectData() else: print "Detection failed cause of a missing detection file!"
def run(self): octave = oct2py.Oct2Py() octave.addpath('octave2') #"../Osama Mohamed.csv",1,1,0,0,0,0,0,0,1,0,0,0,4 #TrainOut = KNN_Generic(directory, noiseFlag, f1FLag,f2FLag,f3FLag,f4FLag,f5FLag,f6FLag,LDAFLag,PCAFlag,CSP_LDAFlag,CSPFlag,startD,endD) #settig the feature selection method flags if(self.selectedFeatureExtractionMethod =="mean"): self.f1FLag = 1 else: self.f1FLag = 0 if(self.selectedFeatureExtractionMethod =="Min MU and Max Beta"): self.f3FLag = 1 else: self.f3FLag = 0 if(self.selectedFeatureExtractionMethod =="Min Mu, Max Beta, Mean Mu, Mean Beta"): self.f4FLag = 1 else: self.f4FLag = 0 if(self.selectedFeatureExtractionMethod =="Min Mu Max Mu Min Beta Max Beta"): self.f5FLag = 1 else: self.f5FLag = 0 if(self.selectedFeatureExtractionMethod =="Min Mu, max Mu, Min Beta, Max Beta, Mean Mu, Mean Beta"): self.f6FLag = 1 else: self.f6FLag = 0 #preprocessing is not done yet if(self.selectedPreprocessingMethod == ""): pass #setting the feature enhancement flags if(self.FeatureEnhancementSelectedMethod == "PCA"): self.PCAFlag = 1 else: self.PCAFlag = 0 if(self.FeatureEnhancementSelectedMethod == "LDA"): self.LDAFlag = 1 else: self.LDAFlag = 0 if(self.FeatureEnhancementSelectedMethod == "CSP"): self.CSPFlag = 1 else: self.CSPFlag = 0 #unused flags for now self.CSP_LDAFlag =0 self.f2FLag =0 #define the output structures self.knnTrainOut = oct2py.Struct() self.fisherTrainOut = oct2py.Struct() self.leastSquaresTrainOut = oct2py.Struct() self.likelihoodTrainOut = oct2py.Struct() #calling the classifer selected according if(self.classifierFile == "KNN"): self.knnTrainOut = octave.call('KNN_Generic.m', self.dataFile, self.removeNoiseFlag, self.f1FLag,self.f2FLag,self.f3FLag,self.f4FLag,self.f5FLag,self.f6FLag,self.LDAFlag,self.PCAFlag,self.CSP_LDAFlag,self.CSPFlag,self.SignalStart,self.SignalEnd) print("KNN training done!") ###>--- using either of them is ok for debugging ---<### #print(self.knnTrainOut.KPCA) #print(self.knnTrainOut['KPCA']) elif (self.classifierFile == "Fisher"): self.fisherTrainOut = octave.call('Fisher_Generic.m', self.dataFile, self.removeNoiseFlag, self.f1FLag,self.f2FLag,self.f3FLag,self.f4FLag,self.f5FLag,self.f6FLag,self.LDAFlag,self.PCAFlag,self.CSP_LDAFlag,self.CSPFlag,self.SignalStart,self.SignalEnd) print("Fisher training done!") elif(self.classifierFile == "Likelihood"): self.likelihoodTrainOut = octave.call('Likelihood_Generic.m', self.dataFile, self.removeNoiseFlag, self.f1FLag,self.f2FLag,self.f3FLag,self.f4FLag,self.f5FLag,self.f6FLag,self.LDAFlag,self.PCAFlag,self.CSP_LDAFlag,self.CSPFlag,self.SignalStart,self.SignalEnd) print("Likelihood training done!") elif(self.classifierFile == "Least Squares"): self.leastSquaresTrainOut = octave.call('Leastsquares_Generic.m', self.dataFile, self.removeNoiseFlag, self.f1FLag,self.f2FLag,self.f3FLag,self.f4FLag,self.f5FLag,self.f6FLag,self.LDAFlag,self.PCAFlag,self.CSP_LDAFlag,self.CSPFlag,self.SignalStart,self.SignalEnd) print("Least Square training done!")
"double_compress_params_octave.sav",verbose=False) params=loadout.pdc Nlinmax=Nlinac else:#curently not working set readfile to True Nlinmax=10 gun=linac.Gun_Param() linp_arr=linac.Linac_Param_Array(Nlinmax) for l in range(Nlinmax): lin=linac.Linac_Param() print 'here' linp_arr[l]=lin params=oct2py.Struct() params.Ev=[None] params.lamv=[None] params.Lv=[None] params.av=[None] params.R56v=[None] params.T566v=[None] params.phiv=[None] params.s0v=[None] params.Ev[0]=Nlinmax*[None] params.lamv[0]=Nlinmax*[None] params.Lv[0]=Nlinmax*[None] params.av[0]=Nlinmax*[None] params.R56v[0]=Nlinmax*[None] params.T566v[0]=Nlinmax*[None]