Exemple #1
0
def laser_tuning_curve(bdata, ephysData, gs):
    plt.subplot(gs[3, 1])

    freqEachTrial = bdata['currentFreq']
    laserEachTrial = bdata['laserOn']
    intEachTrial = bdata['currentIntensity']
    
    eventOnsetTimes = ephysData['events']['stimOn']
    spikeTimeStamps = ephysData['spikeTimes']

    timeRange = [0.0, 0.1]

    possiblefreqs = np.unique(freqEachTrial)
    freqLabels = [round(x/1000, 1) for x in possiblefreqs]
    possiblelaser = np.unique(laserEachTrial)
    possibleInts = np.unique(intEachTrial)

    laserTrialsEachCond = behavioranalysis.find_trials_each_combination(freqEachTrial, possiblefreqs, laserEachTrial, possiblelaser)
    intTrialsEachCond = behavioranalysis.find_trials_each_combination(freqEachTrial, possiblefreqs, intEachTrial, possibleInts)
    spikeTimesFromEventOnset, trialIndexForEachSpike, indexLimitsEachTrial = spikesanalysis.eventlocked_spiketimes(
        spikeTimeStamps, eventOnsetTimes, timeRange)
   

    for intInd, inten in enumerate(possibleInts):
        line = '-'
        if intInd == 0:
            line = '--'
        for indLaser in possiblelaser:
            color = 'black'
            if indLaser == 1:
                color = 'blue'

            laser = 'No Laser - '
            if indLaser == 1:
                laser = 'Laser - '
            curveName = laser + str(inten) + ' dB'

            trialsEachCond = laserTrialsEachCond[:,:,indLaser] & intTrialsEachCond[:,:,intInd]

            try:
                freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, indexLimitsEachTrial)
            except:
                behavIndexLimitsEachTrial = indexLimitsEachTrial[0:2,:-1]
                freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, behavIndexLimitsEachTrial)
            
            xpoints = [x for x in range(0, len(possiblefreqs))]
            #plt.semilogx(possiblefreqs, freq_avgs, linestyle = line, color = color, label = curveName)
            #plt.plot(xvalues, freq_avgs, linestyle = line, color = 'black', label = curveName, xlabels = possiblefreqs)
            plt.plot(xpoints, freq_avgs, linestyle = line, color = color, marker = 'o', label = curveName)
            plt.xticks(xpoints, freqLabels)
            plt.hold(True)
    plt.title('Frequency Tuning Curve - Laser Session')
    plt.legend(fontsize = 'x-small')
    plt.hold(False)
Exemple #2
0
def laser_tuning_curve(bdata, ephysData, gs):
    plt.subplot(gs[3, 1])

    freqEachTrial = bdata['currentFreq']
    laserEachTrial = bdata['laserOn']
    intEachTrial = bdata['currentIntensity']
    
    eventOnsetTimes = ephysData['events']['stimOn']
    spikeTimeStamps = ephysData['spikeTimes']

    timeRange = [0.0, 0.1]

    possiblefreqs = np.unique(freqEachTrial)
    freqLabels = [round(x/1000, 1) for x in possiblefreqs]
    possiblelaser = np.unique(laserEachTrial)
    possibleInts = np.unique(intEachTrial)

    laserTrialsEachCond = behavioranalysis.find_trials_each_combination(freqEachTrial, possiblefreqs, laserEachTrial, possiblelaser)
    intTrialsEachCond = behavioranalysis.find_trials_each_combination(freqEachTrial, possiblefreqs, intEachTrial, possibleInts)
    spikeTimesFromEventOnset, trialIndexForEachSpike, indexLimitsEachTrial = spikesanalysis.eventlocked_spiketimes(
        spikeTimeStamps, eventOnsetTimes, timeRange)
   

    for intInd, inten in enumerate(possibleInts):
        line = '-'
        if intInd == 0:
            line = '--'
        for indLaser in possiblelaser:
            color = 'black'
            if indLaser == 1:
                color = 'blue'

            laser = 'No Laser - '
            if indLaser == 1:
                laser = 'Laser - '
            curveName = laser + str(inten) + ' dB'

            trialsEachCond = laserTrialsEachCond[:,:,indLaser] & intTrialsEachCond[:,:,intInd]

            try:
                freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, indexLimitsEachTrial)
            except:
                behavIndexLimitsEachTrial = indexLimitsEachTrial[0:2,:-1]
                freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, behavIndexLimitsEachTrial)
            
            xpoints = [x for x in range(0, len(possiblefreqs))]
            #plt.semilogx(possiblefreqs, freq_avgs, linestyle = line, color = color, label = curveName)
            #plt.plot(xvalues, freq_avgs, linestyle = line, color = 'black', label = curveName, xlabels = possiblefreqs)
            plt.plot(xpoints, freq_avgs, linestyle = line, color = color, marker = 'o', label = curveName)
            plt.xticks(xpoints, freqLabels)
            plt.hold(True)
    plt.title('Frequency Tuning Curve - Laser Session')
    plt.legend(fontsize = 'x-small')
    plt.hold(False)
def tuning_curve(bdata, ephysData, gs):
    plt.subplot(gs[3, 0])

    freqEachTrial = bdata['currentFreq']
    intEachTrial = bdata['currentIntensity']
    
    eventOnsetTimes = ephysData['events']['stimOn']
    spikeTimeStamps = ephysData['spikeTimes']

    timeRange = [0.0, 0.1]

    possiblefreqs = np.unique(freqEachTrial)
    freqLabels = [round(x/1000, 1) for x in possiblefreqs]
    possibleInts = np.unique(intEachTrial)

    intTrialsEachCond = behavioranalysis.find_trials_each_combination(freqEachTrial, possiblefreqs, intEachTrial, possibleInts)
    spikeTimesFromEventOnset, trialIndexForEachSpike, indexLimitsEachTrial = spikesanalysis.eventlocked_spiketimes(
            spikeTimeStamps, eventOnsetTimes, timeRange)

    for intInd, inten in enumerate(possibleInts):
        line = '-'
        if intInd == 0 and len(possibleInts) > 1:
            line = '--'
        curveName = str(inten) + ' dB'

        trialsEachCond = intTrialsEachCond[:,:,intInd]

        try:
            freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, indexLimitsEachTrial)
        except:
            behavIndexLimitsEachTrial = indexLimitsEachTrial[0:2,:-1]
            freq_avgs = spikesanalysis.avg_num_spikes_each_condition(trialsEachCond, behavIndexLimitsEachTrial)
        
        xpoints = [x for x in range(0, len(possiblefreqs))]
        xpointticks = [x for x in range(1, len(possiblefreqs), 2)]
        freqticks = [freqLabels[x] for x in range(1, len(freqLabels), 2)]
        #plt.semilogx(possiblefreqs, freq_avgs, linestyle = line, color = 'black', label = curveName)
        #plt.plot(log(possiblefreqs), freq_avgs, linestyle = line, color = 'black', label = curveName, xlabels = possiblefreqs)
        plt.plot(xpoints, freq_avgs, linestyle = line, color = 'black', marker = 'o', label = curveName)
        plt.xticks(xpointticks, freqticks)
        plt.hold(True)

    xlabel = 'Frequency (kHz)'
    ylabel = 'Firing Rate (spikes/s)'
    
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.title('Frequency Tuning Curve')
    plt.legend(fontsize = 'x-small', loc = 'upper left')
    plt.hold(False)
possibleIntensity = np.array(possibleIntensity)

#--------------- THIS PART PRODUCES THE ARRAY TO PLOT ---------------
timeRange = [0, 6]
(spikeTimesFromEventOnset, trialIndexForEachSpike,
 indexLimitsEachTrial) = spikesanalysis.eventlocked_spiketimes(
     spikeTimestamps, eventOnsetTimes, timeRange)
CASE = 1
if CASE == 0:  #Freq/intensity
    trialsEachCond = behavioranalysis.find_trials_each_combination(
        intensityEachTrial, possibleIntensity, freqEachTrial, possibleFreq)
elif CASE == 1:  #Only a single sorting variable, frequency
    trialsEachCond = behavioranalysis.find_trials_each_type(
        freqEachTrial, possibleFreq)

avgSpikesArray = spikesanalysis.avg_num_spikes_each_condition(
    indexLimitsEachTrial, trialsEachCond)

#--------------- THIS PART PLOTS THE ARRAY ---------------
plt.clf()
if CASE == 0:
    #for F/I data, the spike array is more understandable if we flip it upside down
    #to make the higher intensities on the top of the plot
    avgSpikesArray = np.flipud(avgSpikesArray)
    plt.imshow(avgSpikesArray, interpolation='none', cmap='Blues')
    ax = plt.gca()
    ax.set_xticks(possibleFreq)
    ax.set_xticklabels(possibleFreq)
    ax.set_xlabel('Freq')
    ax.set_yticks(possibleIntensity)
    ax.set_yticklabels(possibleIntensity[::-1])
    ax.set_ylabel('Intensity')