示例#1
0
def plot_different_distances(modelClass):
    """
    Plot the distribution of different distances. Helps for construction of the network.
    :param modelClass: A Network model that has PC elements.
    :type modelClass: Either ThresholdModel or FairhallModel
    """

    n = modelClass.p['rows'] * modelClass.p['cols']
    list1 = []
    list2 = []
    for j in range(n):
        list1.append(2 -
                     2 * exp(-((modelClass.PC.x[50] - modelClass.PC.x[j])**2 +
                               (modelClass.PC.y[50] - modelClass.PC.y[j])**2) /
                             ((60 * meter)**2)))
        list2.append((((modelClass.PC.x[50] - modelClass.PC.x[j])**2 +
                       (modelClass.PC.y[50] - modelClass.PC.y[j])**2) /
                      ((2 * 15 * meter)**2)) / 10)

    BasicFunctions.plot_distrib(list1, "2 - 2 * exp(-||n1 - n2||_2)")
    BasicFunctions.plot_distrib(list2, "||n1 - n2||_2")
示例#2
0
def plot_distance(modelClass):
    """
    Plots the distance of all the pyramidal cell to a the neuron_idx one.
    neuron_idx is an attribute of the class Model.
    :param modelClass: A network model
    :type modelClass: Either ThresholdModel or FairhallModel
    """

    # Computes the distance of all PC cells to the neuron_idx and returns a list.
    my_list = BasicFunctions.list_distance(modelClass.PC,
                                           modelClass.neuron_idx)
    # Plots the distribution of this list of distances.
    BasicFunctions.plot_distrib(my_list, "distances")

    # Marks the neuron_idx
    plot(modelClass.PC.x[modelClass.neuron_idx] / meter,
         modelClass.PC.y[modelClass.neuron_idx] / meter,
         'o',
         mfc='none',
         label=str(modelClass.neuron_idx))
    color = 'b'

    # The alpha allows to "grade" the distance to the neuron cell.
    for i in range(modelClass.p['rows'] * modelClass.p['cols']):
        plot(modelClass.PC.x[i] / meter,
             modelClass.PC.y[i] / meter,
             color + '.',
             alpha=my_list[i])

    xlim(-10, modelClass.p['rows'])
    ylim(0, modelClass.p['cols'])
    xlabel('x')
    ylabel('y', rotation='vertical')
    axis('equal')
    title("Distance plot")
    show()