def plot_bars(ax, dataMat, label):
    for indSubject, subject in enumerate(subjects):
        for indCond, condition in enumerate(conditions):
            sessionsThisCondThisSubject = dataMat[indSubject, :, indCond]
            ax.plot(np.zeros(len(sessionsThisCondThisSubject)) + (indSubject + 0.5*width + indCond*width) + pointShift,
                    sessionsThisCondThisSubject, marker='o', linestyle='none', mec=condColors[indCond], mfc='none')
            ax.hold(1)

    rects1 = ax.bar(ind, dataMat[:, :, 0].mean(1)-0.5, width, bottom=0.5, edgecolor='k', facecolor='w', lw=2, label='Saline')
    rects2 = ax.bar(ind+width+0.015, dataMat[:, :, 1].mean(1)-0.5, width, bottom=0.5, edgecolor=muscimolColor, lw=2, facecolor='w', label='Muscimol')

    ax.set_xticks(ind + width)
    ax.set_xticklabels(np.arange(6)+1, fontsize=fontSizeLabels)
    ax.set_xlabel('Mouse', fontsize=fontSizeLabels)
    ax.axhline(y=0.5, color='0.5', linestyle='-')
    # ax.set_ylim([0.45, 1])
    ax.set_xlim([ind[0]-0.5*width, ind[-1]+2.5*width ])
    ax.set_ylabel('Number of trials', fontsize=fontSizeLabels)
    # ax.set_yticks([0.5, 1])

    extraplots.set_ticks_fontsize(plt.gca(),fontSizeTicks)
    extraplots.boxoff(ax)

    ax.legend(bbox_to_anchor=(0.95, 0.6),
            loc=3,
            numpoints=1,
            fontsize=fontSizeLabels,
            ncol=1,
            columnspacing=1.5,
            frameon=False)

    for i in [1, 3, 4]:
        extraplots.significance_stars([i+0.5*width,i+1.5*width], 1000, 50, starSize=6, gapFactor=0.4, color='0.5')
def plot_bars(ax, dataMat, label):
    for indSubject, subject in enumerate(subjects):
        for indCond, condition in enumerate(conditions):
            sessionsThisCondThisSubject = dataMat[indSubject, :, indCond]
            ax.plot(np.zeros(len(sessionsThisCondThisSubject)) +
                    (indSubject + 0.5 * width + indCond * width) + pointShift,
                    sessionsThisCondThisSubject,
                    marker='o',
                    linestyle='none',
                    mec=condColors[indCond],
                    mfc='none')
            ax.hold(1)

    rects1 = ax.bar(ind,
                    dataMat[:, :, 0].mean(1) - 0.5,
                    width,
                    bottom=0.5,
                    edgecolor='k',
                    facecolor='w',
                    lw=2,
                    label='Saline')
    rects2 = ax.bar(ind + width + 0.015,
                    dataMat[:, :, 1].mean(1) - 0.5,
                    width,
                    bottom=0.5,
                    edgecolor=muscimolColor,
                    lw=2,
                    facecolor='w',
                    label='Muscimol')

    ax.set_xticks(ind + width)
    ax.set_xticklabels(np.arange(6) + 1, fontsize=fontSizeLabels)
    ax.set_xlabel('Mouse', fontsize=fontSizeLabels)
    ax.axhline(y=0.5, color='0.5', linestyle='-')
    # ax.set_ylim([0.45, 1])
    ax.set_xlim([ind[0] - 0.5 * width, ind[-1] + 2.5 * width])
    ax.set_ylabel('Number of trials', fontsize=fontSizeLabels)
    # ax.set_yticks([0.5, 1])

    extraplots.set_ticks_fontsize(plt.gca(), fontSizeTicks)
    extraplots.boxoff(ax)

    ax.legend(bbox_to_anchor=(0.95, 0.6),
              loc=3,
              numpoints=1,
              fontsize=fontSizeLabels,
              ncol=1,
              columnspacing=1.5,
              frameon=False)

    for i in [1, 3, 4]:
        extraplots.significance_stars([i + 0.5 * width, i + 1.5 * width],
                                      1000,
                                      50,
                                      starSize=6,
                                      gapFactor=0.4,
                                      color='0.5')
Ejemplo n.º 3
0
    yLims = [45, 100]
    plt.ylim(yLims)
    plt.xlim(xLocs[0] - 0.3, xLocs[-1] + 0.3)
    plt.ylabel('Accuracy (%)')
    plt.xlabel('Masker bandwidth (oct)')
    axScatter.set_xticks(xLocs)
    axScatter.set_xticklabels(np.tile(possibleBands, len(xLocs) // 2))
    extraplots.boxoff(axScatter)

    # -- stats!! --
    pVal = stats.wilcoxon(accuracy[:, 0], accuracy[:, 1])[1]
    print("Change in accuracy between bandwidths p val: {}".format(pVal))

    extraplots.significance_stars(xLocs,
                                  yLims[1] * 0.99,
                                  yLims[1] * 0.02,
                                  gapFactor=0.25)

if PANELS[3]:
    dataFullPath = os.path.join(dataDir, fileName)
    data = np.load(dataFullPath)

    bias = data['allBias']
    accuracy = data['allPercentCorrect']
    possibleBands = data['possibleBands']

    axScatter = plt.subplot(gs[1, 2])

    barWidth = 0.2
    xLocs = np.arange(len(possibleBands))
    indsToIgnore = []
                 color='k')
    ax2.set_xticks([0, 1])
    ax2.set_xticklabels([])
    ax2.set_ylabel('Rightward trials (%)', fontsize=fontSizeLabels)
    ax2.set_yticks([0, 25])
    ax2.set_xlim([-0.5, 1.5])
    ax2.set_xticklabels(['More left', 'More right'], fontsize=fontSizeLabels)
    #ax2.set_xticklabels(['More\nleft', 'More\nright'], fontsize=fontSizeLabels) #conditions[firstCondToPlot:]
    ax2.set_xlabel('Reward amount', fontsize=fontSizeLabels)
    ax2.set_ylim([-5, 30])
    #ax2.text(0, 30,'Lowest frequency')
    ax2.set_title('Lowest frequency', fontsize=fontSizeLabels)
    plt.sca(ax2)
    extraplots.significance_stars([0, 1],
                                  26,
                                  1,
                                  starSize=8,
                                  gapFactor=0.2,
                                  color='0.5')
    extraplots.set_ticks_fontsize(ax2, fontSizeTicks)
    extraplots.boxoff(ax2)

    freqToPlot = numFreqs / 2  # middle freq
    rChoiceEachConcThisFreqEachAnimal = dataMat[firstCondToPlot:,
                                                freqToPlot, :]
    for animalInd in range(len(subjects)):
        ax3.plot(rChoiceEachConcThisFreqEachAnimal[:, animalInd],
                 marker='o',
                 color='k')
    ax3.set_xticks([0, 1])
    ax3.set_xticklabels(['More left', 'More right'], fontsize=fontSizeLabels)
    #ax3.set_xticklabels(['More\nleft', 'More\nright'], fontsize=fontSizeLabels)
#rightStimChange = np.concatenate((right015,right016))
meanLeftStim = np.mean(leftStimChange)
meanRightStim = np.mean(rightStimChange)
ax1.plot(0.3*np.array([-1,1])+1, 100*np.tile(meanLeftStim,2), lw=3, color=PHOTOSTIMCOLORS['laser_left'])
ax1.plot(0.3*np.array([-1,1])+3, 100*np.tile(meanRightStim,2), lw=3, color=PHOTOSTIMCOLORS['laser_right'])

controlLeftStimChange = np.concatenate((left048,left056))
controlRightStimChange = np.concatenate((right048,right056))
meanLeftStimCtrl = np.mean(controlLeftStimChange)
meanRightStimCtrl = np.mean(controlRightStimChange)
ax1.plot(0.3*np.array([-1,1])+2, 100*np.tile(meanLeftStimCtrl,2), lw=3, color=PHOTOSTIMCOLORS['laser_left'])
ax1.plot(0.3*np.array([-1,1])+4, 100*np.tile(meanRightStimCtrl,2), lw=3, color=PHOTOSTIMCOLORS['laser_right'])

(Z, pVal) = stats.ranksums(leftStimChange, controlLeftStimChange)
print 'p value between d1pi and control left hemi stim bias is {}'.format(pVal)
extraplots.significance_stars([1,2], 48, 2, starSize=10, gapFactor=0.12, color='0.5')
(Z, pVal) = stats.ranksums(rightStimChange, controlRightStimChange)
print 'p value between d1pi and control right hemi stim bias is {}'.format(pVal)
extraplots.significance_stars([3,4], 48, 2, starSize=10, gapFactor=0.12, color='0.5')

xlim = [0.5, 4.5]
ylim = [-50, 50]
plt.xlim(xlim)
plt.ylim(ylim)
xticks = [1,2,3,4]
xticklabels = ['Left\nstim', 'Control\nleft stim', 'Right\nstim', 'Control\nright stim']
plt.xticks(xticks, xticklabels, fontsize=fontSizeTicks)
plt.yticks(range(-40,60,10))
labelDis = 0.1
#plt.xlabel('Photostimulation', fontsize=fontSizeLabels) # labelpad=labelDis
plt.ylabel('Rightward bias (%)\nstim - control', fontsize=fontSizeLabels) # labelpad=labelDis
Ejemplo n.º 6
0
        plt.hold(True)
        plt.plot(xval, sustainedSuppressionVals[category], 'o', mec=edgeColour, mfc='none', clip_on=False)
        median = np.median(sustainedSuppressionVals[category])
        #sem = stats.sem(vals[category])
        plt.plot([category+0.7,category+1.3], [median,median], '-', color='k', mec=cellTypeColours[category], lw=3)  
    
    axScatter.annotate(panelLabel, xy=(labelPosX[3],labelPosY[0]), xycoords='figure fraction',
                         fontsize=fontSizePanel, fontweight='bold')
    plt.xlim(0,len(sustainedSuppressionVals)+1)
    plt.ylim(-0.05,1.05)
    plt.ylabel('Suppression Index',fontsize=fontSizeLabels)
    axScatter.set_xticks(range(1,len(sustainedSuppressionVals)+1))
    axScatter.set_xticklabels(categoryLabels, fontsize=fontSizeLabels, rotation=-45)
    extraplots.boxoff(axScatter)
    yLims = np.array(plt.ylim())
    extraplots.significance_stars([1,3], yLims[1]*1.07, yLims[1]*0.02, gapFactor=0.25)
    extraplots.significance_stars([1,2], yLims[1]*1.03, yLims[1]*0.02, gapFactor=0.25)
    plt.hold(0)
    
    ExcPV = stats.ranksums(ACsustainedSuppression, PVsustainedSuppression)[1]
    ExcSOM = stats.ranksums(ACsustainedSuppression, SOMsustainedSuppression)[1]
    PVSOM = stats.ranksums(PVsustainedSuppression, SOMsustainedSuppression)[1]
    print "Difference in suppression p vals: \nExc-PV: {0}\nExc-SOM: {1}\nPV-SOM: {2}".format(ExcPV,ExcSOM,PVSOM)
    
    
    
# -- Summary plots comparing preferred bandwidth of PV, SOM, and excitatory cells for sustained responses --    
if PANELS[4]:
    summaryDataFullPath = os.path.join(dataDir,summaryFileName)
    summaryData = np.load(summaryDataFullPath)
    
Ejemplo n.º 7
0
        [1, 2],
        [meanReactionTimeLeftwardLeftMore, meanReactionTimeLeftwardRightMore],
        marker='o',
        color='k')
ax0.set_ylabel('Reaction time (s)', fontsize=fontSizeLabels)
ax0.set_xlim([0.8, 2.2])
ax0.set_xticks([1, 2])
ax0.set_xticklabels([])
ax0.set_yticks([0, 0.1, 0.2])
ax0.set_ylim([-0.03, 0.23])
ax0.set_title('Leftward trials', fontsize=fontSizeLabels + 1)
plt.sca(ax0)
extraplots.significance_stars([1, 2],
                              0.2,
                              0.01,
                              starSize=12,
                              starString='n.s.',
                              gapFactor=0.2,
                              color='0.5')
extraplots.set_ticks_fontsize(ax0, fontSizeTicks)
extraplots.boxoff(ax0)
zScore, pVal = stats.wilcoxon(allMiceMeanLeftMore, allMiceMeanRightMore)
print('reaction time leftward p={}'.format(pVal))

ax1.annotate('C',
             xy=(labelPosX[2], labelPosY[0]),
             xycoords='figure fraction',
             fontsize=fontSizePanel,
             fontweight='bold')
allMiceMeanLeftMore = []
allMiceMeanRightMore = []
Ejemplo n.º 8
0
rects2 = ax3.bar(ind+width+0.015, 1000*subjectMeans[:,1], width, bottom=0.5, edgecolor=muscimolColor, lw=2, facecolor='w', label='Muscimol', align='edge')

# plt.ylim([250,730])
ymax = 730
ymin = 250
plt.ylim([ymin,ymax])
xticks = range(5)
xticklabels = range(1,6)
plt.ylabel('Time from center port exit\nto reward port entry (ms)')
plt.xlabel('Mouse')
ax3.set_xlim([ind[0]-0.5*width, ind[-1]+2.5*width ])
ax3.set_xticks(ind + width)
ax3.set_xticklabels(np.arange(6)+1, fontsize=fontSizeTicks)
extraplots.boxoff(ax3)
for sigSubjectInd in [4]:
    extraplots.significance_stars([sigSubjectInd+0.5*width,sigSubjectInd+1.5*width], ymax, (ymax-ymin)*starLineHeightFactor, starSize=6, gapFactor=0.4, color='0.5')
    # extraplots.significance_stars(sigSubjectInd+np.array([-0.25,0.25]), 710, 25, starSize=6, gapFactor=0.4, color='0.5')

# -- Stats -- #
for inds, subject in enumerate(subjects):
    zScore, pVal = stats.ranksums(centerToSideFile['{}validmeansaline'.format(subject)], centerToSideFile['{}validmeanmuscimol'.format(subject)])
    print 'For mouse {}, using only mean of valid trials in saline condition and in muscimol condition in a ranksums test, p value for the difference in time from centerOut to sideIn is {}.'.format(inds+1, pVal)

# -- Panel C: response times -- #
ax4 = plt.subplot(gs[1, 0])
soundToCoutFilename = 'muscimol_response_time_summary.npz'
soundToCoutFullPath = os.path.join(dataDir,soundToCoutFilename)
soundToCoutFile = np.load(soundToCoutFullPath)

subjects = soundToCoutFile['subjects']
conditions = soundToCoutFile['conditions']
        plt.setp(bplot['medians'][box], color='k', linewidth=3)

    plt.setp(bplot['medians'], color='k')

    plt.xlim(0, len(responseRates) + 1)
    plt.ylim(top=50)
    axScatter.set_xticks(range(1, len(responseRates) + 1))
    axScatter.set_xticklabels(categoryLabels, fontsize=fontSizeLabels)
    extraplots.boxoff(axScatter)
    plt.ylabel('High bandwidth \n'
               r'onset response ($\Delta$spk/s)',
               fontsize=fontSizeLabels)
    extraplots.boxoff(axScatter)
    yLims = np.array(plt.ylim())
    extraplots.significance_stars([1, 2],
                                  yLims[1] * 0.98,
                                  yLims[1] * 0.04,
                                  gapFactor=0.25)
    #extraplots.significance_stars([2,3], yLims[1]*0.98, yLims[1]*0.04, gapFactor=0.25)
    plt.hold(0)
    axScatter.annotate(panelLabel,
                       xy=(labelPosX[1], labelPosY[0]),
                       xycoords='figure fraction',
                       fontsize=fontSizePanel,
                       fontweight='bold')

    PVSOM = stats.ranksums(PVhighBandRate, SOMhighBandRate)[1]
    print "Difference in PV-SOM high bandwidth onset sound response p val: {}".format(
        PVSOM)

    ExcPV = stats.ranksums(ExcHighBandRate, PVhighBandRate)[1]
    print "Difference in Exc-PV high bandwidth onset sound response p val: {}".format(
        #         xs = np.linspace(-5,5,200)
        #
        # #         laserDensity.covariance_factor = lambda : .25
        # #         laserDensity._compute_covariance()
        # #         controlDensity.covariance_factor = lambda : .25
        # #         controlDensity._compute_covariance()
        #
        #         plt.plot(xs,laserDensity(xs),color=cellTypeColours[indType])
        #         plt.plot(xs,controlDensity(xs),color=ExcColour)

        #extraplots.boxoff(axInset, keep='right')
        axInset.yaxis.tick_right()
        axInset.yaxis.set_ticks_position('right')
        plt.locator_params(axis='y', nbins=4)
        axInset.spines['left'].set_visible(False)
        axInset.spines['top'].set_visible(False)
        plt.ylabel(r'$\Delta$FR (%)',
                   fontsize=fontSizeLegend,
                   rotation=-90,
                   labelpad=12)
        axInset.yaxis.set_label_position('right')

        yLims = np.array(plt.ylim())
        extraplots.significance_stars([barWidth / 2, 1 + barWidth / 2],
                                      yLims[1] * 1.09,
                                      yLims[1] * 0.04,
                                      gapFactor=0.35,
                                      starSize=6)

if SAVE_FIGURE:
    extraplots.save_figure(figFilename, figFormat, figSize, outputDir)
                     edgecolor='k',
                     facecolor='w',
                     lw=2,
                     align='edge')
    rects2 = ax2.bar(ind + width,
                     100 * (dataMat[:, :, 1].mean(1) - 0.5),
                     width,
                     bottom=50,
                     edgecolor=muscimolColor,
                     facecolor='w',
                     lw=2,
                     align='edge')
    for i in ind:
        extraplots.significance_stars([i + 0.5 * width, i + 1.5 * width],
                                      95,
                                      1,
                                      starSize=6,
                                      gapFactor=0.4,
                                      color='0.5')

    ax2.set_xticks(ind + width)
    ax2.set_xticklabels(np.arange(6) + 1, fontsize=fontSizeLabels)
    ax2.set_xlabel('Mouse', fontsize=fontSizeLabels)
    ax2.axhline(y=50, color='k', linestyle='-')
    ax2.set_ylim([48, 100])
    ax2.set_xlim([ind[0] - 0.75 * width, ind[-1] + 2.5 * width])
    ax2.set_ylabel('Correct trials (%)', fontsize=fontSizeLabels)
    ax2.set_yticks([50, 75, 100])

    extraplots.set_ticks_fontsize(plt.gca(), fontSizeTicks)
    extraplots.boxoff(ax2)
    ax2.annotate('C',
Ejemplo n.º 12
0
'''
Test significant stars from extraplots.
'''

from jaratoolbox import extraplots
reload(extraplots)
from matplotlib import pyplot as plt

plt.clf()
plt.bar([1, 2], [4, 5], align='center', fc='0.5')

xRange = [1, 2]
yPos = 6
yLength = 0.5
#extraplots.significance_stars(xRange, yPos, yLength, color='k', starMarker='*', starSize=10, gapFactor=0.1)
extraplots.significance_stars(xRange,
                              yPos,
                              yLength,
                              color='k',
                              starString='n.s.',
                              starSize=14,
                              gapFactor=0.1)
#extraplots.new_significance_stars(xRange, yPos, yLength, color='k', starMarker='n.s.', fontSize=10, gapFactor=0.1, ax=None)
plt.ylim([0, 10])

plt.show()
Ejemplo n.º 13
0
                 lw=3)

    axScatter.annotate(panelLabel,
                       xy=(labelPosX[1], labelPosY[0]),
                       xycoords='figure fraction',
                       fontsize=fontSizePanel,
                       fontweight='bold')
    plt.xlim(0, len(sustainedSuppressionVals) + 1)
    plt.ylim(-0.05, 1.05)
    plt.ylabel('Suppression Index', fontsize=fontSizeLabels)
    axScatter.set_xticks(range(1, len(sustainedSuppressionVals) + 1))
    axScatter.set_xticklabels(categoryLabels, fontsize=fontSizeLabels)
    extraplots.boxoff(axScatter)
    yLims = np.array(plt.ylim())
    extraplots.significance_stars([1, 3],
                                  yLims[1] * 1.08,
                                  yLims[1] * 0.02,
                                  gapFactor=0.25)
    extraplots.significance_stars([1, 2],
                                  yLims[1] * 1.04,
                                  yLims[1] * 0.02,
                                  gapFactor=0.25)
    plt.hold(0)

    ExcPV = stats.ranksums(ACsustainedSuppression, PVsustainedSuppression)[1]
    ExcSOM = stats.ranksums(ACsustainedSuppression, SOMsustainedSuppression)[1]
    PVSOM = stats.ranksums(PVsustainedSuppression, SOMsustainedSuppression)[1]
    print "Difference in suppression p vals: \nExc-PV: {0}\nExc-SOM: {1}\nPV-SOM: {2}".format(
        ExcPV, ExcSOM, PVSOM)

# -- plots of "Anna index" --
if PANELS[2]:
Ejemplo n.º 14
0
    xlim = [0.5, 2.5]
    ylim = [-50, 50]
    plt.xlim(xlim)
    plt.ylim(ylim)
    xticks = [1,2]
    xticklabels = ['Left\nstim', 'Right\nstim']
    plt.xticks(xticks, xticklabels, fontsize=fontSizeTicks)
    labelDis = 0.1
    #plt.xlabel('Photostimulation', fontsize=fontSizeLabels) # labelpad=labelDis
    plt.ylabel('Rightward bias (%)\n stim - control', fontsize=fontSizeLabels) # labelpad=labelDis
    
    extraplots.boxoff(ax5)
    ax5.spines['bottom'].set_visible(False)
    [t.set_visible(False) for t in ax5.get_xticklines()]

    extraplots.significance_stars([1,2], 52, 3, starSize=10, gapFactor=0.12, color='0.5')
    
    #(T, leftpVal) = stats.wilcoxon(leftStimChange)
    #(T, rightpVal) = stats.wilcoxon(rightStimChange)
    #print 'p value for change in percent rightward in left hemi photostim is: ', leftpVal,  '\np value for change in percent rightward in left hemi photostim is: ', rightpVal

    # -- Grouped left and right hemi data separately for all three mice, compare bias resulting from left vs right hemi stim -- #
    (Z, pVal) = stats.ranksums(leftStimChange, rightStimChange)
    print 'Using 10 sessions for each animal in each hemi, the overall p value for the difference of the changes of percent rightward choice from left vs. right hemi photostim is: ', pVal, ' (ranksums test)'

plt.show()

if SAVE_FIGURE:
    extraplots.save_figure(figFilename, figFormat, figSize, outputDir)

Ejemplo n.º 15
0
'''
Testing a plot with significance stars
'''

from jaratoolbox import extraplots
reload(extraplots)
import numpy as np
from matplotlib import pyplot as plt

plt.clf()
plt.bar([0, 1], [2, 3], color='0.5', align='center')
extraplots.significance_stars([0, 1], 4, 0.2, starSize=10, gapFactor=0.1)

plt.xlim([-1, 2])
plt.ylim([0, 5])
plt.show()
Ejemplo n.º 16
0
    #FIXME: Hardcoded number of points per animal here
    pointShift = np.array([-shiftAmt, shiftAmt, -shiftAmt, shiftAmt])

    for indSubject, subject in enumerate(subjects):
        for indCond, condition in enumerate(conditions):
            sessionsThisCondThisSubject = dataMat[indSubject, :, indCond]
            ax2.plot(np.zeros(len(sessionsThisCondThisSubject)) + (indSubject + 0.5*width + indCond*width) + pointShift,
                     100*sessionsThisCondThisSubject, marker='o', linestyle='none', mec=condColors[indCond], mfc='none',
                     clip_on=False)
            ax2.hold(1)

    rects1 = ax2.bar(ind, 100*(dataMat[:, :, 0].mean(1)-0.5), width, bottom=50, edgecolor='k', facecolor='w', lw=2, align='edge')
    rects2 = ax2.bar(ind+width, 100*(dataMat[:, :, 1].mean(1)-0.5), width, bottom=50, edgecolor=muscimolColor, facecolor='w', lw=2, align='edge')
    for i in ind:
        extraplots.significance_stars([i+0.5*width,i+1.5*width], 95, 1, starSize=6, gapFactor=0.4, color='0.5')
    
    ax2.set_xticks(ind + width)
    ax2.set_xticklabels(np.arange(6)+1, fontsize=fontSizeLabels)
    ax2.set_xlabel('Mouse', fontsize=fontSizeLabels)
    ax2.axhline(y=50, color='k', linestyle='-')
    ax2.set_ylim([48, 100])
    ax2.set_xlim([ind[0]-0.75*width, ind[-1]+2.5*width ])
    ax2.set_ylabel('Correct trials (%)', fontsize=fontSizeLabels)
    ax2.set_yticks([50, 75, 100])

    extraplots.set_ticks_fontsize(plt.gca(),fontSizeTicks)
    extraplots.boxoff(ax2)
    ax2.annotate('C', xy=(labelPosX[0],labelPosY[0]), xycoords='axes fraction', fontsize=fontSizePanel, fontweight='bold')

    #ax2.axes.get_xaxis().set_visible(False)
    #         plt.setp(bplot['boxes'][box], color=cellTypeColours[box])
    #         plt.setp(bplot['whiskers'][2*box:2*(box+1)], linestyle='-', color=cellTypeColours[box])
    #         plt.setp(bplot['caps'][2*box:2*(box+1)], color=cellTypeColours[box])
    #         plt.setp(bplot['medians'][box], color='k', linewidth=2)
    #
    #     plt.setp(bplot['medians'], color='k')
    #     axBox.set_xticks([1,2])
    #     axBox.set_xticklabels(cellLabels)

    plt.xlim(-0.2, 1.9)
    axBar.set_xticks(ind + width / 2)
    axBar.set_xticklabels(cellLabels)
    yLims = (-0.15, 0.1)
    plt.ylim(yLims)
    extraplots.significance_stars([width / 2, 1 + width / 2],
                                  yLims[1] * 0.92,
                                  yLims[1] * 0.07,
                                  gapFactor=0.2)
    extraplots.boxoff(axBar)
    plt.ylabel('Change in suppression index', fontsize=fontSizeLabels)

    axBar.annotate(panelLabel,
                   xy=(labelPosX[1], labelPosY[0]),
                   xycoords='figure fraction',
                   fontsize=fontSizePanel,
                   fontweight='bold')

if PANELS[2]:
    summaryDataFullPath = os.path.join(dataDir, summaryFileName)
    summaryData = np.load(summaryDataFullPath)

    PVpeakChange = summaryData['fitMeanPVpeakChangePureTone']
Ejemplo n.º 18
0
    #sem = stats.sem(vals[category])
    plt.plot([category + 0.7, category + 1.3], [median, median],
             '-',
             color='k',
             mec=cellTypeColours[category],
             lw=3)

plt.xlim(0, len(suppressionVals) + 1)
plt.ylim(-0.05, 1.05)
plt.ylabel('Onset Suppression Index', fontsize=FONTSIZE)
axScatter.set_xticks(range(1, len(suppressionVals) + 1))
axScatter.set_xticklabels(categoryLabels, fontsize=FONTSIZE)  #, rotation=-45)
extraplots.boxoff(axScatter)
yLims = np.array(plt.ylim())
extraplots.significance_stars([1, 2],
                              yLims[1] * 1.03,
                              yLims[1] * 0.02,
                              gapFactor=0.25)
plt.hold(0)

ExcPV = scipy.stats.ranksums(excOnsetSIs, PVonsetSIs)[1]
ExcSOM = scipy.stats.ranksums(excOnsetSIs, SOMonsetSIs)[1]
PVSOM = scipy.stats.ranksums(PVonsetSIs, SOMonsetSIs)[1]
print "Difference in suppression p vals: \nExc-PV: {0}\nExc-SOM: {1}\nPV-SOM: {2}".format(
    ExcPV, ExcSOM, PVSOM)

dbFilename2 = os.path.join(settings.FIGURES_DATA_PATH, '2018acsup',
                           'inactivation_cells_full.h5')
# db2 = celldatabase.load_hdf(dbFilename)
db2 = celldatabase.load_hdf('/tmp/inactivation_cells_full.h5')
bestCells2 = db2.query('isiViolations<0.02')
bestCells2 = bestCells2.query(
Ejemplo n.º 19
0
            meanEachCondEachSubject[indc].append(meanVal)
            subjectIndFromAll = list(possibleSubjects).index(oneSubject)
            #print samples
            dataEachCondEachSubject[subjectIndFromAll][indc] = samples
            #[pline,pcap,pbar] = plt.errorbar(xPos[indc]+0.1*indSubject-0.2, meanVal, seVal, color=colorThisCond)
            pmark = plt.plot(xPos[indc]+0.1*indSubject-0.1, meanVal,markerThisCond,mfc=colorThisCond,mec='None')
    extraplots.boxoff(ax3)
    plt.ylabel('Change in angle (deg)')
    ax3.set_yticks(np.arange(-200,300,100))
    #plt.ylim([-200,200])
    plt.ylim(300*np.array([-1,1]))
    plt.xlim([-0.7,4.1])
    ax3.axes.get_xaxis().set_visible(False)
    ax3.spines['bottom'].set_visible(False)
    signifYpos = 300 #220
    extraplots.significance_stars([xPos[0],xPos[1]], signifYpos, 20, starSize=10, gapFactor=0.2, color='0.5')
    extraplots.significance_stars([xPos[2],xPos[3]], signifYpos, 20, starSize=10, gapFactor=0.2, color='0.5')
    plt.text(np.mean(xPos[0:2]), -signifYpos, 'Left', ha='center', fontsize=fontSizeLabels+2)
    plt.text(np.mean(xPos[2:4]), -signifYpos, 'Right', ha='center', fontsize=fontSizeLabels+2)
    plt.show()

    
    # -- Statistics --
    (st,pval) = stats.ranksums(meanEachCondEachSubject[0],meanEachCondEachSubject[1])
    print 'Comparison LEFT front vs back: p = {0:0.3}'.format(pval)
    (st,pval) = stats.ranksums(meanEachCondEachSubject[2],meanEachCondEachSubject[3])
    print 'Comparison RIGHT front vs back: p = {0:0.3}'.format(pval)
    (st,pval) = stats.ranksums(meanEachCondEachSubject[0],meanEachCondEachSubject[3])
    print 'Comparison FRONT left vs right: p = {0:0.3}'.format(pval)
    (st,pval) = stats.ranksums(meanEachCondEachSubject[1],meanEachCondEachSubject[3])
    print 'Comparison BACK left vs right: p = {0:0.3}'.format(pval)
Ejemplo n.º 20
0
    axBar.add_patch(SOMpatch)
    axBar.annotate('control', (legendXY[0]+0.6, legendXY[1]+18), fontsize=fontSizeLabels)
    axBar.annotate('laser', (legendXY[0]+0.6, legendXY[1]), fontsize=fontSizeLabels)
    
    plt.plot([-5,5],[0,0], 'k-', zorder=-10)
    plt.ylabel('Percentage change in \nspontaneous firing rate')
    plt.ylim(-20,210)
    plt.xlim(-0.1,1.8)
    
    pNoPV = stats.ranksums(controlPVChange, noPVChange)[1]
    pNoSOM = stats.ranksums(controlSOMChange, noSOMChange)[1]
    
    print "Change in FR (control vs laser) p values:\nno PV: {0}\nno SOM: {1}".format(pNoPV,pNoSOM)
    
    yLims = np.array(plt.ylim())
    extraplots.significance_stars([ind[0]+width/2,ind[0]+3*width/2], yLims[1]*0.94, yLims[1]*0.02, gapFactor=0.25)
    extraplots.significance_stars([ind[1]+width/2,ind[1]+3*width/2], yLims[1]*0.55, yLims[1]*0.02, gapFactor=0.25)
    
    axBar.annotate(panelLabel, xy=(labelPosX[0],labelPosY[0]), xycoords='figure fraction',
                             fontsize=fontSizePanel, fontweight='bold')
    
if PANELS[1]:
    panelLabels = ['b', 'c']
    cellLabels = ['no PV+', 'no SOM+']
    
    cellTypeData = [[PVNoLaser, PVLaser], [SOMNoLaser, SOMLaser]]
    controlCellTypeData = [[controlPVNoLaser, controlPVLaser], [controlSOMNoLaser, controlSOMLaser]]
    cellTypeColours = [PVcolour, SOMcolour]
    
    for indType in range(2):
        axScatter = plt.subplot(gs[0,indType+1])
Ejemplo n.º 21
0
            plt.plot([xLocs[indBand] + barLoc[indType], xLocs[indBand] + barLoc[indType]], biasCI,
                     color=cellTypeColours[indType], linewidth=1.5)  # error bars
            plt.plot([xLocs[indBand] + barLoc[indType] - width / 8, xLocs[indBand] + barLoc[indType] + width / 8],
                     [biasCI[0], biasCI[0]], color=cellTypeColours[indType], linewidth=1.5)  # bottom caps
            plt.plot([xLocs[indBand] + barLoc[indType] - width / 8, xLocs[indBand] + barLoc[indType] + width / 8],
                     [biasCI[1], biasCI[1]], color=cellTypeColours[indType], linewidth=1.5)  # top caps

    axBar.set_xlim(xLocs[0] + barLoc[0] - 0.3, xLocs[1] + barLoc[1] + 0.3)
    axBar.set_xticks(xLocs)
    axBar.set_xticklabels(possibleBands)
    axBar.set_xlabel('Masker bandwidth (octaves)')

    yLims = (-0.5, 0.3)
    axBar.set_ylim(yLims)
    axBar.set_ylabel('Change in bias')

    extraplots.boxoff(axBar)

    # calculate those stats!
    for band in range(len(possibleBands)):
        pVal = stats.ranksums(PVchange[:,band], SOMchange[:,band])
        print(f'PV bias change vs SOM bias change for bw {possibleBands[band]} p val: {pVal}')

    extraplots.significance_stars(barLoc + xLocs[0], yLims[1] * 1.03, yLims[1] * 0.02, gapFactor=0.25)
    extraplots.significance_stars(barLoc + xLocs[1], yLims[1] * 1.03, yLims[1] * 0.02, gapFactor=0.25)

if SAVE_FIGURE:
    extraplots.save_figure(figFilename, figFormat, figSize, outputDir)

# plt.show()
Ejemplo n.º 22
0
meanLeftStimCtrl = np.mean(controlLeftStimChange)
meanRightStimCtrl = np.mean(controlRightStimChange)
ax1.plot(0.3 * np.array([-1, 1]) + 2,
         100 * np.tile(meanLeftStimCtrl, 2),
         lw=3,
         color=PHOTOSTIMCOLORS['laser_left'])
ax1.plot(0.3 * np.array([-1, 1]) + 4,
         100 * np.tile(meanRightStimCtrl, 2),
         lw=3,
         color=PHOTOSTIMCOLORS['laser_right'])

(Z, pVal) = stats.ranksums(leftStimChange, controlLeftStimChange)
print 'p value between d1pi and control left hemi stim bias is {}'.format(pVal)
extraplots.significance_stars([1, 2],
                              48,
                              2,
                              starSize=10,
                              gapFactor=0.12,
                              color='0.5')
(Z, pVal) = stats.ranksums(rightStimChange, controlRightStimChange)
print 'p value between d1pi and control right hemi stim bias is {}'.format(
    pVal)
extraplots.significance_stars([3, 4],
                              48,
                              2,
                              starSize=10,
                              gapFactor=0.12,
                              color='0.5')

xlim = [0.5, 4.5]
ylim = [-50, 50]
plt.xlim(xlim)
Ejemplo n.º 23
0
    #         plt.setp(bplot['caps'][2*box:2*(box+1)], color='none')
    #         plt.setp(bplot['medians'][box], color='k', linewidth=3)
    #
    #     plt.setp(bplot['medians'], color='k')
    axBox.set_xticks([1, 2])
    axBox.set_xticklabels(cellLabels)

    #plt.plot([-5,5], [0,0], 'k-', zorder=-10)
    plt.xlim(0.4, 2.6)
    axBox.set_xticks(range(1, len(supDiffs) + 1))
    axBox.set_xticklabels(cellLabels, fontsize=fontSizeLabels, rotation=-45)
    yLims = (-0.2, 0.1)
    #yLims = (-0.15, 0.1)
    plt.ylim(yLims)
    extraplots.significance_stars([1, 2],
                                  yLims[1] * 0.92,
                                  yLims[1] * 0.07,
                                  gapFactor=0.2)
    extraplots.boxoff(axBox)
    plt.ylabel('Change in Suppression Index', fontsize=fontSizeLabels)

    axBox.annotate(panelLabel,
                   xy=(labelPosX[3], labelPosY[2]),
                   xycoords='figure fraction',
                   fontsize=fontSizePanel,
                   fontweight='bold')

    pVal = stats.ranksums(noPVsupDiff, noSOMsupDiff)[1]
    print "PV vs SOM change in SI p val: {}".format(pVal)

# --- plot peak vs white noise change in firing rate with inactivation ---
if PANELS[4]:
Ejemplo n.º 24
0
    plt.ylim(ylim)
    xticks = [1, 2]
    xticklabels = ['Left\nstim', 'Right\nstim']
    plt.xticks(xticks, xticklabels, fontsize=fontSizeTicks)
    labelDis = 0.1
    #plt.xlabel('Photostimulation', fontsize=fontSizeLabels) # labelpad=labelDis
    plt.ylabel('Rightward bias (%)\n stim - control',
               fontsize=fontSizeLabels)  # labelpad=labelDis

    extraplots.boxoff(ax5)
    ax5.spines['bottom'].set_visible(False)
    [t.set_visible(False) for t in ax5.get_xticklines()]

    extraplots.significance_stars([1, 2],
                                  52,
                                  3,
                                  starSize=10,
                                  gapFactor=0.12,
                                  color='0.5')

    #(T, leftpVal) = stats.wilcoxon(leftStimChange)
    #(T, rightpVal) = stats.wilcoxon(rightStimChange)
    #print 'p value for change in percent rightward in left hemi photostim is: ', leftpVal,  '\np value for change in percent rightward in left hemi photostim is: ', rightpVal

    # -- Grouped left and right hemi data separately for all three mice, compare bias resulting from left vs right hemi stim -- #
    (Z, pVal) = stats.ranksums(leftStimChange, rightStimChange)
    print 'Using 10 sessions for each animal in each hemi, the overall p value for the difference of the changes of percent rightward choice from left vs. right hemi photostim is: ', pVal, ' (ranksums test)'

plt.show()

if SAVE_FIGURE:
    extraplots.save_figure(figFilename, figFormat, figSize, outputDir)
Ejemplo n.º 25
0
    extraplots.boxoff(axBW)
    extraplots.set_ticks_fontsize(axBW, fontSizeTicks)
    axBW.set_xticklabels(tickLabels, fontsize=fontSizeLabels, rotation=45)

    zstat, pVal = stats.mannwhitneyu(nD1PopStat, D1PopStat, alternative='two-sided')  # Nick used stats.ranksum

    messages.append("{} p={}".format(popStatCol, pVal))

    yDataMax = max([max(D1PopStat), max(nD1PopStat)])
    # yStars = yDataMax + yDataMax*starYfactor
    yStars = max(ylim) * 1.05
    yStarHeight = (yDataMax*starYfactor)*starHeightFactor
    plt.sca(axBW)
    starString = None if pVal < 0.05 else 'n.s.'
    extraplots.significance_stars([0, 1], yStars, yStarHeight, starMarker='*',
                                  starSize=fontSizeStars+2, starString=starString,
                                  gapFactor=starGapFactor)
    #plt.hold(1)
#
#plt.hold(True)

# ======================= Beginning of plotting for threshold ================================
if PANELS[3]:

    popStatCol = 'thresholdFRA'
    D1PopStat = D1[popStatCol][pd.notnull(D1[popStatCol])]
    nD1PopStat = nD1[popStatCol][pd.notnull(nD1[popStatCol])]

    plt.sca(axThresh)

    spacing = 0.05
# plt.ylim([250,730])
ymax = 730
ymin = 250
plt.ylim([ymin, ymax])
xticks = range(5)
xticklabels = range(1, 6)
plt.ylabel('Time from center port exit\nto reward port entry (ms)')
plt.xlabel('Mouse')
ax3.set_xlim([ind[0] - 0.5 * width, ind[-1] + 2.5 * width])
ax3.set_xticks(ind + width)
ax3.set_xticklabels(np.arange(6) + 1, fontsize=fontSizeTicks)
extraplots.boxoff(ax3)
for sigSubjectInd in [4]:
    extraplots.significance_stars(
        [sigSubjectInd + 0.5 * width, sigSubjectInd + 1.5 * width],
        ymax, (ymax - ymin) * starLineHeightFactor,
        starSize=6,
        gapFactor=0.4,
        color='0.5')
    # extraplots.significance_stars(sigSubjectInd+np.array([-0.25,0.25]), 710, 25, starSize=6, gapFactor=0.4, color='0.5')

# -- Stats -- #
for inds, subject in enumerate(subjects):
    zScore, pVal = stats.ranksums(
        centerToSideFile['{}validmeansaline'.format(subject)],
        centerToSideFile['{}validmeanmuscimol'.format(subject)])
    print 'For mouse {}, using only mean of valid trials in saline condition and in muscimol condition in a ranksums test, p value for the difference in time from centerOut to sideIn is {}.'.format(
        inds + 1, pVal)

# -- Panel C: response times -- #
ax4 = plt.subplot(gs[1, 0])
soundToCoutFilename = 'muscimol_response_time_summary.npz'