In [1]:

    import sys
    sys.path.append("../")
    from Linearity import Neuron
    import numpy as np
    import scipy.stats as ss
    import matplotlib
    import matplotlib.pyplot as plt
    from matplotlib.font_manager import findfont, FontProperties
    # print(plt.style.available)
    plt.style.use('seaborn-white')
    matplotlib.rcParams['font.family']
    print(findfont(FontProperties(family=['sans-serif'])))

    /usr/share/fonts/truetype/msttcorefonts/Arial.ttf

In [2]:

    figAspect = 1.

In [4]:

    #fileList = glob.glob("/media/sahil/NCBS_Shares_BGStim/patch_data/**/c?/plots/*.pkl")
    neuronList = []
    with open("/media/sahil/NCBS_Shares_BGStim/patch_data/CPP_files.txt", 'r') as fp:
        fileList = fp.read().splitlines()
        for i,filename in enumerate(fileList):
            fileList[i] += "plots/" + filename.split('/')[-2] + ".pkl"
            try:
                print ("Reading ", fileList[i])
                neuronList.append(Neuron.load(fileList[i]))
            except:
                print ("Couldn't read", fileList[i])
    print ("Read {} files.".format(len(fileList)))

    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/150828/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/150902/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/150902/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/150904/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/150904/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160126/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160209/c4/plots/c4.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160219/c5/plots/c5.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160223/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160223/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160513/c5/plots/c5.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160617/c5/plots/c5.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160817/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160817/c4/plots/c4.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160830/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160920/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160927/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160927/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160927/c5/plots/c5.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160928/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/160928/c4/plots/c4.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161013/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161026/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161027/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161109/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161110/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161116/c1_CS/plots/c1_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161116/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161117/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161117/c2_CS/plots/c2_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161117/c3_CS/plots/c3_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161123/c1_CS/plots/c1_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161123/c2_CS/plots/c2_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/161228/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170104/c4/plots/c4.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170124/c2_CS/plots/c2_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170124/c3_CS/plots/c3_CS.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170208/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170208/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170220/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170222/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170222/c2/plots/c2.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170303/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c1/plots/c1.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c1_spikes/plots/c1_spikes.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c3/plots/c3.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c3_spikes/plots/c3_spikes.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c4/plots/c4.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/170317/c4_spikes/plots/c4_spikes.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/RS_Analysis/Patch_Recording/Control_RS_short/1_c4_150827/plots/1_c4_150827.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/RS_Analysis/Patch_Recording/Control_RS_short/2_c1_150828/plots/2_c1_150828.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/RS_Analysis/Patch_Recording/Control_RS_short/3_c1_150929/plots/3_c1_150929.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/RS_Analysis/Patch_Recording/Control_RS_short/6_c2_160513/plots/6_c2_160513.pkl')
    ('Reading ', '/media/sahil/NCBS_Shares_BGStim/patch_data/RS_Analysis/Patch_Recording/RS_TBS_short/5_c4_160122/plots/5_c4_160122.pkl')
    Read 54 files.

In [5]:

    def figure1(feature = 0):
        ''' Plotting to show sublinearity of CA3 inputs at CA1. '''
        ratio = []
        numNeurons = 0
        numBins = 500
        for neuron in neuronList:
            for experiment in neuron.experiment:
                if experiment == "Control":
                    numNeurons+=1
                    for numSq in neuron.experiment[experiment]:
                        if numSq > 1:
                            #if 5 in neuron.experiment[experiment]: # If one vs five required
                            coords = neuron.experiment[experiment][numSq].coordwise
                            for coord in coords:
                                try:
                                    if feature in coords[coord].average_feature and coords[coord].expected_feature:
                                        if not np.isnan(coords[coord].average_feature[feature]/coords[coord].expected_feature[feature]) and not np.isinf(coords[coord].average_feature[feature]/coords[coord].expected_feature[feature]):
                                            ratio.append(coords[coord].average_feature[feature]/coords[coord].expected_feature[feature])
                                except:
                                    print ("Couldn't append to ratio, perhaps feature not found")
        ratio = np.array(ratio)
        gt_one = ratio[np.where(ratio>1)]
        frac_gt_one = round(float(len(gt_one))/len(ratio)*1e2,2)
        #print [x for x in ratio]
        f, ax = plt.subplots()
        ax.hist(ratio, bins=numBins)
        ax.set_title("Sublinearity of input summation")
        ax.axvline(1.0, linestyle='dashed', linewidth=2)
        ax.set_xlabel("O/E")
        ax.set_ylabel("Frequency")
        ax.annotate("{} \%".format(frac_gt_one), xy=(1, 100), xytext=(1.5, 100), textcoords='data', arrowprops=dict(connectionstyle="arc3", arrowstyle = "<-"))
        plt.figaspect(figAspect) #Length/width
        plt.show()
        print ("Legend text: Number of cells: {}, number of points: {}, fraction of points greater than one: {}".format(numNeurons, len(ratio), frac_gt_one ))

In [6]:

    figure1()

    /usr/local/lib/python2.7/dist-packages/ipykernel_launcher.py:17: RuntimeWarning: divide by zero encountered in double_scalars

    Legend text: Number of cells: 53, number of points: 6175, fraction of points greater than one: 10.93