print str(len(spikeTimestamps)) + " Spikes loaded" #Load spikewaveform and averagespikewaveform all 4 channels spikeWFCh0 = list(processedData['spikeWFCh0']) spikeWFCh1 = list(processedData['spikeWFCh1']) spikeWFCh2 = list(processedData['spikeWFCh2']) spikeWFCh3 = list(processedData['spikeWFCh3']) averageSpikeWFCh0 = list(processedData['averageSpikeWFCh0']) averageSpikeWFCh1 = list(processedData['averageSpikeWFCh1']) averageSpikeWFCh2 = list(processedData['averageSpikeWFCh2']) averageSpikeWFCh3 = list(processedData['averageSpikeWFCh3']) print "SpikeWaveform Data Loaded" print 'Generating Rate Map...' #get the raw rateMap, spikeMap and occupancy map rateMap, spikeMap, occMap, rawSpikeMap, posSpikeX, posSpikeY, angleSpike = rateMapUtils.generateRateMap(piCameraData,spikeTimestamps,k=bin_width) print 'Rate Map generated for ' + filename #function to generate gaussian smoothed rate map, calculate spatial info, mean firing rate, peak firing rate occMapPlot, spikeMapPlot, gaussRateMap, spatialInfoScore, meanFiringRate, peakFiringRate = rateMapUtils.generateGaussRateMap(occMap, spikeMap, samplingRate, occMapThreshold) print 'Spatial Information Score: ' + str(spatialInfoScore) print 'Mean Firing Rate: ' + str(meanFiringRate) print 'Peak Firing Rate: ' + str(peakFiringRate) print 'Gaussian Smoothed Rate Map Generated' #save the rate map for the processed data, remember this will over write the rate map from Run#1 filename = filename.split('_ProcessedData.mat')[0] rateMapFileName = os.path.join(filename + '_rawMap_k' + str(bin_width) + '.mat') sio.savemat(rateMapFileName, mdict={'rateMap':rateMap, 'spikeMap': spikeMap, 'occMap': occMap,'gaussRateMap':gaussRateMap}) print 'Rate Map ' + rateMapFileName + ' saved! \n'
nlxData['pos_y'] = list(processedData['nlx_posY'][0]) nlxData['pos_t'] = list(processedData['nlx_time'][0]) nlxData['angle'] = [] nlxData['width'] = int(processedData['nlx_width'][0]) nlxData['height'] = int(processedData['nlx_height'][0]) print "Position Data loaded" #load the spike times spikeTimestamps = list(processedData['spikeTimestamps'][0]) spikeMaxHeight = list(processedData['spikeMaxHeight'][0]) spikeMaxWidth = list(processedData['spikeMaxWidth'][0]) print str(len(spikeTimestamps)) + " Spikes loaded" print 'Generating Rate Map...' #get the raw rateMap, spikeMap and occupancy map rateMap, spikeMap, occMap, rawSpikeMap, posSpikeX, posSpikeY, angleSpike = rateMapUtils.generateRateMap(nlxData,spikeTimestamps,k=bin_width) print 'Rate Map generated for ' + filename #function to generate gaussian smoothed rate map, calculate spatial info, mean firing rate, peak firing rate occMapPlot, spikeMapPlot, gaussRateMap, spatialInfoScore, meanFiringRate, peakFiringRate = rateMapUtils.generateGaussRateMap(occMap, spikeMap, samplingRate, occMapThreshold) print 'Spatial Information Score: ' + str(spatialInfoScore) print 'Mean Firing Rate: ' + str(meanFiringRate) print 'Peak Firing Rate: ' + str(peakFiringRate) print 'Gaussian Smoothed Rate Map Generated' #save the rate map for the processed data, remember this will over write the rate map from Run#1 filename = filename.split('_nlx_ProcessedData.mat')[0] rateMapFileName = os.path.join(filename + '_nlx_rawMap_k' + str(bin_width) + '.mat') sio.savemat(rateMapFileName, mdict={'rateMap':rateMap, 'spikeMap': spikeMap, 'occMap': occMap, 'gaussRateMap':gaussRateMap}) print 'Rate Map ' + rateMapFileName + ' saved! \n\n' else:
Pos['width'] = piCameraData['width'][0] Pos['height'] = piCameraData['height'][0] distance = sio.loadmat(PICAMERA_DISTANCE_FILE_NAME) distance = distance['distance'][0][piCameraStartMazeIndex:piCameraEndMazeIndex] Pos['red_x'] = Pos['red_x'][distance > 0.35] Pos['red_y'] = Pos['red_y'][distance > 0.35] Pos['pos_t'] = Pos['pos_t'][distance > 0.35] print "\nPosition Data loaded" # load the spikedata SpikeData = pickle.load(open(SPIKE_FILE_NAME)) print "\nSpike Data loaded" #get the raw rateMap, spikeMap and occupancy map rateMap, spikeMap, occMap = rateMapUtils.generateRateMap(Pos, SpikeData, k=1) rateMap_k5, spikeMap_k5, occMap_k5 = rateMapUtils.generateRateMap(Pos, SpikeData, k=5) #save the raw maps in .npy format sio.savemat(RAW_MAP_FILE_NAME, mdict={ 'rateMap': rateMap, 'spikeMap': spikeMap, 'occMap': occMap }) sio.savemat(RAW_MAP_K5_FILE_NAME, mdict={ 'rateMap': rateMap_k5, 'spikeMap': spikeMap_k5,