<commit_before>"""
analysis.py

Functions to plot and analyse results

Version: 2014July9
"""
from pylab import scatter, figure, hold, subplot, axes, shape, imshow, colorbar, plot, xlabel, ylabel, title, xlim, ylim, clim, show, zeros, legend, savefig, cm, specgram, get_cmap
from scipy.io import loadmat
from scipy import loadtxt, size, array, linspace, ceil
from bicolormap import bicolormap
from datetime import datetime
from time import time

def plotraster(allspiketimes, allspikecells, EorI, ncells, connspercell, backgroundweight, firingrate, duration): # Define a function for plotting a raster
    plotstart = time() # See how long it takes to plot
    EorIcolors = array([(1,0.4,0) , (0,0.2,0.8)]) # Define excitatory and inhibitory colors -- orange and turquoise
    cellcolors = EorIcolors[array(EorI)[array(allspikecells,dtype=int)]] # Set each cell to be either orange or turquoise
    figure() # Open a new figure
    scatter(allspiketimes,allspikecells,10,cellcolors,linewidths=0.5,marker='|') # Create raster  
    xlabel('Time (ms)')
    ylabel('Cell ID')
    title('cells=%i syns/cell=%0.1f noise=%0.1f rate=%0.1f Hz' % (ncells,connspercell,backgroundweight[0],firingrate),fontsize=12)
    xlim(0,duration)
    ylim(0,ncells)
    plottime = time()-plotstart # See how long it took
    print('  Done; time = %0.1f s' % plottime)
    #show()


## For diagnostic purposes -- plot connectivity. Based on conndiagram.py.
def plotconn(p):
    # Create plot
    figh = figure(figsize=(8,6))
    figh.subplots_adjust(left=0.02) # Less space on left
    figh.subplots_adjust(right=0.98) # Less space on right
    figh.subplots_adjust(top=0.96) # Less space on bottom
    figh.subplots_adjust(bottom=0.02) # Less space on bottom
    figh.subplots_adjust(wspace=0) # More space between
    figh.subplots_adjust(hspace=0) # More space between
    h = axes()
    connprobs = p.setconnprobs()
    connweights = p.setconnweights()
    npops = p.npops
    popnames = p.popnames
    totalconns = zeros(shape(connprobs))
    for c1 in range(size(connprobs,0)):
        for c2 in range(size(connprobs,1)):
            for w in range(p.nreceptors):
                totalconns[c1,c2] += connprobs[c1,c2]*connweights[c1,c2,w]*(-1 if w>=2 else 1)
    imshow(totalconns,interpolation='none',cmap=bicolormap(gap=0))

    # Plot grid lines
    hold(True)
    for pop in range(npops):
        plot(array([0,npops])-0.5,array([pop,pop])-0.5,'-',c=(0.7,0.7,0.7))
        plot(array([pop,pop])-0.5,array([0,npops])-0.5,'-',c=(0.7,0.7,0.7))
<commit_msg>testing muscskel arm in ma<commit_after>"""
analysis.py

Functions to plot and analyse results

Version: 2014July9
"""
from pylab import scatter, figure, hold, subplot, axes, shape, imshow, colorbar, plot, xlabel, ylabel, title, xlim, ylim, clim, show, zeros, legend, savefig, cm, specgram, get_cmap
from scipy.io import loadmat
from scipy import loadtxt, size, array, linspace, ceil
from bicolormap import bicolormap
from datetime import datetime
from time import time

def plotraster(allspiketimes, allspikecells, EorI, ncells, connspercell, backgroundweight, firingrate, duration): # Define a function for plotting a raster
    plotstart = time() # See how long it takes to plot
    EorIcolors = array([(1,0.4,0) , (0,0.2,0.8)]) # Define excitatory and inhibitory colors -- orange and turquoise
    cellcolors = EorIcolors[array(EorI)[array(allspikecells,dtype=int)]] # Set each cell to be either orange or turquoise
    figure() # Open a new figure
    scatter(allspiketimes,allspikecells,10,cellcolors,linewidths=0.5,marker='|') # Create raster  
    xlabel('Time (ms)')
    ylabel('Cell ID')
    title('cells=%i syns/cell=%0.1f noise=%0.1f rate=%0.1f Hz' % (ncells,connspercell,backgroundweight[0],firingrate),fontsize=12)
    xlim(0,duration)
    ylim(0,ncells)
    plottime = time()-plotstart # See how long it took
    print('  Done; time = %0.1f s' % plottime)
    #show()


## For diagnostic purposes -- plot connectivity. Based on conndiagram.py.
def plotconn(p):
    # Create plot
    figh = figure(figsize=(8,6))
    figh.subplots_adjust(left=0.02) # Less space on left
    figh.subplots_adjust(right=0.98) # Less space on right
    figh.subplots_adjust(top=0.96) # Less space on bottom
    figh.subplots_adjust(bottom=0.02) # Less space on bottom
    figh.subplots_adjust(wspace=0) # More space between
    figh.subplots_adjust(hspace=0) # More space between
    h = axes()
    connprobs = p.setconnprobs()
    connweights = p.setconnweights()
    npops = p.npops
    popnames = p.popnames
    totalconns = zeros(shape(connprobs))
    for c1 in range(size(connprobs,0)):
        for c2 in range(size(connprobs,1)):
            for w in range(p.nreceptors):
                totalconns[c1,c2] += connprobs[c1,c2]*connweights[c1,c2,w]*(-1 if w>=2 else 1)
    imshow(totalconns,cmap=bicolormap(gap=0))

    # Plot grid lines
    hold(True)
    for pop in range(npops):
        plot(array([0,npops])-0.5,array([pop,pop])-0.5,'-',c=(0.7,0.7,0.7))
        plot(array([pop,pop])-0.5,array([0,npops])-0.5,'-',c=(0.7,0.7,0.7))

{'fraction_non_alphanumeric': 0.13485804416403785, 'fraction_numerical': 0.032728706624605676, 'mean_word_length': 4.067932067932068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5782966', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1831, 'n_words': 450}