def getRecord(self, numSample): eegSamples = [] rateNumer = int(self.rate) rateDenom = 1 if len(self.buffer)<numSample: if self.readFromFile()=='%ENDFILE': return "%ENDFILE" for i in range(numSample): eegSamples.append(self.buffer.pop(0)) eegOut = EEGSample(self.chanNum, 1, rateNumer, rateDenom, self.time) eegOut.addChannel(eegSamples) self.time += (500.0 / self.rate *1e4) return eegOut
def genFakeWave(numSamples, seqStart, srcChn): print "Generating fake EEG wave data" import time, math seq = seqStart waveList = [] type = 1 gain = 10000 selChan, rateNumer, rateDenom, filid = 0, 4000, 1, 1 for packet in range(numSamples): wave = EEGSample(selChan, rateNumer, rateDenom, filid, time.clock()) samples = [] for sample in range(100): samples.append(int(math.sin(2*math.pi*sample/100)*gain)) wave.addChannel(samples) wave = dataPacketHandler.encodePacket(seq, wave.toBinary(srcChn,type)) waveList.append(wave) seq += 1 return waveList