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: continue else: #if processed data does not exist, generate the data #remember the winclust spike times file should be in format TT**-cl-maze1.1 for this script to work for filename in os.listdir(os.getcwd()): if filename.startswith('TT') and 'maze' in filename: #load spikedata, start maze time, end maze time from winclust file with times adjusted for clock drift spikeTimestamps, StartMazeTime, EndMazeTime, spikeMaxHeight, spikeMaxWidth = rateMapUtils.getSpikeTimeFromIndividualClusters(dirname, filename, None, None) print str(len(spikeTimestamps)) + " Spikes loaded" #get current directory currentDir = os.getcwd() #load picamera relative time, date time from NTP, start time with times adjusted for clock drift NlxPos = rateMapUtils.getNlxPositionData(currentDir, StartMazeTime, EndMazeTime) print "Position Data loaded" print 'Generating Rate Map...' #get the raw rateMap, spikeMap and occupancy map after binning according to value of k rateMap, spikeMap, occMap, rawSpikeMap, posSpikeX, posSpikeY, angleSpike = rateMapUtils.generateRateMap(NlxPos,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
#Function to generate analysis report same as the Jim's code #INPUT: pos data, spike data, occmap, spikemap, ratemap, spikewaveforms, gaussian smoothed rate map, spatial info, mean firing rate, peak firing rate analysisReport.generateAnalysisReport(filename,piCameraData['width'],piCameraData['height'], piCameraData['pos_x'],piCameraData['pos_y'], piCameraData['pos_t'],spikeMaxHeight, spikeMaxWidth, spikeTimestamps, spikeMap, occMap, rateMap, rawSpikeMap, posSpikeX, posSpikeY, spikeWFCh0, spikeWFCh1, spikeWFCh2, spikeWFCh3, averageSpikeWFCh0, averageSpikeWFCh1, averageSpikeWFCh2, averageSpikeWFCh3, occMapPlot, spikeMapPlot, gaussRateMap, spatialInfoScore, meanFiringRate, peakFiringRate,piCameraData['angle'],angleSpike) else: continue else: #if processed data does not exist, generate the data #remember the winclust spike times file should be in format TT**-cl-maze1.1 for this script to work for filename in os.listdir(os.getcwd()): if filename.startswith('TT') and 'maze' in filename: #load spikedata, start maze time, end maze time from winclust file with times adjusted for clock drift spikeTimestamps, StartMazeTime, EndMazeTime, spikeMaxHeight, spikeMaxWidth = rateMapUtils.getSpikeTimeFromIndividualClusters(dirname, filename, START_ACQ_SXBOX_TIME, nlxDriftSlope) print str(len(spikeTimestamps)) + " Spikes loaded" #get current directory currentDir = os.getcwd() #function to load spikewaveform and averagespikewaveform all 4 channels spikeWFCh0,spikeWFCh1, spikeWFCh2, spikeWFCh3, averageSpikeWFCh0, averageSpikeWFCh1, averageSpikeWFCh2, averageSpikeWFCh3 = rateMapUtils.getSpikeWaveformData(currentDir, spikeTimestamps, START_ACQ_SXBOX_TIME, nlxDriftSlope, StartMazeTime, EndMazeTime) print "SpikeWaveform Data Loaded" #load picamera relative time, date time from NTP, start time with times adjusted for clock drift piCameraTimestamps, piCameraDateTime, piCameraStartTime = rateMapUtils.getPiCameraTimestamps(currentDir, START_ACQ_NTP_TIME, picamDriftSlope, nlxDriftSlope) #find the index and nearest value from the picamera time list to the start maze time and end maze time calculated above from nev file piCameraStartMazeIndex, piCameraStartMazeTime = rateMapUtils.nearestTimestamp(piCameraTimestamps, StartMazeTime) piCameraEndMazeIndex, piCameraEndMazeTime = rateMapUtils.nearestTimestamp(piCameraTimestamps, EndMazeTime)