コード例 #1
0
ファイル: ttImport.py プロジェクト: somaproject/synthsoma
	def getSpike(self):
		#Has the header been read? If not read it!
		if not self.headerParsed: self.readHeader()

		line = self.file.read(260) #read 262 bytes as there are 262 bytes per spike
		if len(line)<260:
			return "%ENDFILE"

		#TS in tt file is in AD units, to convert to soma units multiply by 5
		timeStamp = struct.unpack('I', line[0:4])[0]*5 
		spike = TSpike(timeStamp)

		line = line[4:len(line)] #cut off first 6 bytes of fluff
		chans = [ [], [], [], [] ]

		for i in range(0,32):  
			offset = i * 4 * 2
			for chanNum in range(0,8,2):
				if self.gains[chanNum/2] == 0:
					sample = 0
				else:
					sample = struct.unpack('h', line[ offset+chanNum : offset+chanNum+2 ])[0]
					sample = sample/4096.0 * 10.0 / self.gains[int(chanNum/2)] * 1e9
				chans[int(chanNum/2)].append(int(sample))

		VALID, FILID = 1, 0
		chanNum=0
		for chanNum in range(0,4):
			spike.addChannel(chanNum, VALID, FILID, self.tholds[chanNum], chans[chanNum])
		
		return spike
コード例 #2
0
ファイル: spikeLoader.py プロジェクト: somaproject/synthsoma
def genFakeSpikes(numSpikes, seqStart, srcChn):
	print "Generating fake spikes"
	seq = seqStart
	sList = []
	type = 0
	for i in range(numSpikes):
		spike = TSpike(time.clock())
		chan1 = [30000 * (((i+0)%4)+4) -100000] * 32;
		chan2 = [30000 * (((i+2)%4)+4) -100000] * 32;
		chan3 = [30000 * (((i+3)%4)+4) -100000] * 32;
		chan4 = [30000 * (((i+4)%4)+4) -100000] * 32;
		spike.addChannel(0, 1, 0, 250, chan1)
		spike.addChannel(1, 1, 0, 250, chan2)
		spike.addChannel(2, 1, 0, 250, chan3)
		spike.addChannel(3, 1, 0, 250, chan4)
		s = dataPacketHandler.encodePacket(seq, spike.toBinary(srcChn, type))
		sList.append(s)
		seq += 1
	print "Fake Spike data GENERATED!"
	return sList