コード例 #1
0
def plot_polar_von_mises_fit( direction_rates, fit_curve, title ):
    
    bin_size = 45
    
    spikeFiringRates = direction_rates[:,1]  # select the spikes firing rates     

    # the polar representation is like a circle, so we correct the data
    # in a way that the last element of the array if the same as the first one
    spikeFiringRates = np.append(spikeFiringRates, spikeFiringRates[0])
    
    print( spikeFiringRates )
    # compute the angles . A circle ranges from 0 to 360 deg
    theta = np.append( direction_rates[:,0], np.pi*2+0.01 )
   
    print( len( theta ) )
    print( len(spikeFiringRates) )
    
    plt.subplot(2,2,4,polar=True)
    # plot the polar graph
    plt.polar( theta, spikeFiringRates, 'o' )
    
    spikeFiringRatesFit = fit_curve[:,1]
    spikeFiringRatesFit = np.append(spikeFiringRatesFit, spikeFiringRatesFit[0])
    
    
    theta = np.arange( 0, 2*np.pi, 0.01) 
    
    plt.polar( theta, spikeFiringRatesFit,label='Firing Rate (spikes/s)')
    plt.legend(loc=8)                   # specify the location of the legend
    plt.title('Polar: ' + title)        # add title to the graph
コード例 #2
0
def plot_fits(direction_rates,fit_curve,title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    #print direction_rates
    
    
    
   # print fit_curve
   
    plt.subplots_adjust(hspace = 0.6)   
    y_max = np.max(direction_rates[:,1]) + 5
    plt.subplot(2,2,3)
    plt.axis([0,360,0,y_max])
    plt.plot(direction_rates[:,0], direction_rates[:,1],'o')
    plt.plot(fit_curve[:,0],fit_curve[:,1], '-')
    plt.xlabel("Direction of Motion (degrees)")
    plt.ylabel("Firing Rate (spikes/s)")
    plt.title(title)
    
    plt.subplot(2,2,4,  polar = True)    
    spikecounts = direction_rates[:,1]
    spikecounts2 = np.append(spikecounts, direction_rates[0,1]) 
    r = np.arange(0, 361, 45)*np.pi/180
    plt.polar(r, spikecounts2,'o')
    plt.polar(fit_curve[:,0]*np.pi/180,fit_curve[:,1],'-', label="Firing Rate (spikes/s)")
    plt.title(title)
    plt.legend(loc=8)
コード例 #3
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
        # yank columns and keep in correspondance 
    directions = direction_rates[0:][:,0]
    rates = direction_rates[0:][:,1]
    # histogram plot 
    plt.subplot(2, 2, 1)
    plt.title('Histogram ' + title)
    plt.axis([0, 360, 0, 70])
    plt.xlim(-22.5,337.5)
    plt.xlabel('Directions (in degrees)')
    plt.ylabel('Average Firing Rate (in spikes/s)')
    plt.bar(directions, rates, width=45, align='center')
    plt.xticks(directions)
    # polar plot 
    plt.subplot(2,2,2,polar=True)
    plt.title('Polar plot ' + title)
    #plt.legend('Diring Rate (spikes/s)')
    rates = np.append(rates, rates[0]) 
    theta = np.arange(0,361,45)*np.pi/180
    plt.polar(theta, rates)

    plt.show()
    # end plot_tuning_curves
    return 0
コード例 #4
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    x = direction_rates[:,0]
    y = direction_rates[:,1]
    plt.figure()
    plt.subplot(2,2,1)
    plt.bar(x,y,width=45,align='center')
    plt.xlim(-22.5,337.5)
    plt.xticks(x)
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.title(title)   
        
        
    
    plt.subplot(2,2,2,polar=True)
    r = np.append(y,y[0])
    theta = np.deg2rad(np.append(x, x[0]))
    plt.polar(theta,r,label='Firing Rate (spikes/s)')
    plt.legend(loc=8)
    plt.title(title)
コード例 #5
0
def plot_fits(direction_rates,fit_curve,title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    curve_xs = np.arange(direction_rates[0,0], direction_rates[-1,0])
    fit_ys2 = normal_fit(curve_xs,fit_curve[0],fit_curve[1],fit_curve[2])
    
    
    plt.subplot(2,2,3)
    plt.plot(direction_rates[:,0],direction_rates[:,1],'o',hold=True)
    plt.plot(curve_xs,fit_ys2,'-')
    plt.xlabel('Direction of Motions (Degrees)')
    plt.ylabel('Firing Rates (Spikes/sec)')
    plt.title(title)
    plt.axis([0, 360, 0, 40])
    plt.xticks(direction_rates[:,0])
    
    fit_ys = normal_fit(direction_rates[:,0],fit_curve[0],fit_curve[1],fit_curve[2])
    plt.subplot(2,2,4,polar=True)
    spkiecount = np.append(direction_rates[:,1],direction_rates[0,1])
    plt.polar(np.arange(0,361,45)*np.pi/180,spkiecount,'o',label='Firing Rate (spike/s)')
    plt.hold(True)
    spkiecount_y = np.append(fit_ys,fit_ys[0])
    plt.plot(np.arange(0,361,45)*np.pi/180,spkiecount_y,'-')    
    plt.legend(loc=8)
    plt.title(title)
    
    fit_ys2 = np.transpose(np.vstack((curve_xs,fit_ys2)))    
    
    return(fit_ys2)
コード例 #6
0
def OrientationPlot(OrientationHist_Data,BINS):
    """
    Plot an orienation histogram. For use with OrientationHist function

    Input
    -----
    OrientationHist_Data: computed from OrienationHist function
    BINS: bins used to compute OrientationHist

    Output
    ------
    Produces a polar plot with the orientation histogram data

    """
    RAD_BINS = BINS/(180./np.pi)
    ## Data Plot
    plt.rc('grid', color='gray', linewidth=1, linestyle='-')
    plt.rc('xtick', labelsize=25)
    plt.rc('ytick', labelsize=20)
    width, height = plt.rcParams['figure.figsize']
    size = min(width, height)
    fig = plt.figure(figsize=(size, size))
    ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True, axisbg='w')
    plt.polar(RAD_BINS,OrientationHist_Data/float(sum(OrientationHist_Data)), 'k',linewidth=4, marker='o')
    ax.set_rmax(0.2)
    plt.show()
コード例 #7
0
def display_deg2rad_polar_measures(polar_points):
    """

    :param polar_points: [(theta, rho), ...] with theta in degree
    :return:
    """
    for theta, rho in polar_points:
        pl.polar(math.radians(theta), rho, 'r,')
    pl.show()
コード例 #8
0
def display_polar_measures(polar_points):
    """

    :param polar_points: [(theta, rho), ...] with theta in radian
    :return:
    """
    for theta, rho in polar_points:
        pl.polar(theta, rho, 'r,')
    pl.show()
コード例 #9
0
ファイル: cizi2.py プロジェクト: astar/exploring_neural_data
def plot_fits(direction_rates, fit_curve, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    #plt.figure()
    # create two plots in one figure (1 row, 2 cols)
    plt.subplot(2, 2, 3)

    plt.plot(direction_rates[:, 0], direction_rates[:, 1], 'bo')
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spike/s)')
    plt.title(title)
    plt.xlim(-5, 365)

    plt.plot(fit_curve[:, 0], fit_curve[:, 1], color='g')

    # polar plot
    plt.subplot(2, 2, 4, polar=True)

    # copy the array to a new array
    polar_data = direction_rates * 1

    # convert degrees to radians
    for i in range(0, len(polar_data)):
        polar_data[i, 0] = np.deg2rad(polar_data[i, 0])

    theta = polar_data[:, 0]
    r = polar_data[:, 1]
    # append data to connect 315 to 360
    r2 = np.append(r, r[0])
    theta2 = np.append(theta, theta[0])

    plt.polar(theta2, r2, 'bo')

    # plot fitted curve data
    polar_fdata = fit_curve * 1

    # convert degrees to radians
    for i in range(0, len(polar_fdata)):
        polar_fdata[i, 0] = np.deg2rad(polar_fdata[i, 0])

    theta = polar_fdata[:, 0]
    r = polar_fdata[:, 1]

    # append data to connect 315 to 360
    r2 = np.append(r, r[0])
    theta2 = np.append(theta, theta[0])

    plt.polar(theta2, r2, color='g', label='Firing Rate (spikes/s)')

    plt.legend(loc=0)  # 0 - best, 8- lower center
    plt.title(title)
コード例 #10
0
ファイル: cizi2.py プロジェクト: astar/exploring_neural_data
def plot_fits(direction_rates,fit_curve,title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    #plt.figure()
    # create two plots in one figure (1 row, 2 cols)    
    plt.subplot(2,2,3)
    
    plt.plot(direction_rates[:,0], direction_rates[:,1], 'bo')
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spike/s)')
    plt.title(title)
    plt.xlim(-5, 365)

    plt.plot(fit_curve[:,0], fit_curve[:,1], color='g')
    
    # polar plot
    plt.subplot(2,2,4,polar=True)
    
    # copy the array to a new array
    polar_data = direction_rates*1
    
    # convert degrees to radians 
    for i in range(0, len(polar_data)):
        polar_data[i,0] = np.deg2rad(polar_data[i,0])
    
    theta = polar_data[:,0]
    r = polar_data[:,1]
    # append data to connect 315 to 360 
    r2 = np.append(r,r[0])
    theta2 = np.append(theta,theta[0])
    
    plt.polar(theta2, r2, 'bo')
      
    # plot fitted curve data
    polar_fdata = fit_curve*1
    
    # convert degrees to radians 
    for i in range(0, len(polar_fdata)):
        polar_fdata[i,0] = np.deg2rad(polar_fdata[i,0])
    
    theta = polar_fdata[:,0]
    r = polar_fdata[:,1]
    
    # append data to connect 315 to 360 
    r2 = np.append(r,r[0])
    theta2 = np.append(theta,theta[0])
    
    plt.polar(theta2, r2, color='g', label='Firing Rate (spikes/s)')
    
    plt.legend(loc=0)  # 0 - best, 8- lower center
    plt.title(title)  
コード例 #11
0
def plot_hist(dir_rates):

    # Histogram
    plt.subplot(2, 2, 1)
    plt.bar(dir_rates[:, 0], dir_rates[:, 1], 
        (np.max(dir_rates[:, 0]) - np.min(dir_rates[:, 0])) / (len(dir_rates[:, 0]) - 1))
    plt.xlim(xmax = 360)
    plt.xlabel('Direction of Motion (Degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.title('Neuron Tuning Curve')

    # Polar 
    plt.subplot(2, 2, 2, polar = True)
    plt.polar(np.deg2rad(dir_rates[:, 0]), dir_rates[:, 1], 
        label = 'Neuron Tuning Curve')
    plt.legend(loc = 8)
コード例 #12
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    plt.subplot(2,2,1)
    plt.bar(direction_rates[:,0],direction_rates[:,1],width=45)
    plt.xlabel('Direction of Motions (Degrees)')
    plt.ylabel('Firing Rates (Spikes/sec)')
    plt.title(title)
    plt.axis([0, 360, 0, 40])
    plt.xticks(direction_rates[:,0])
    plt.subplot(2,2,2,polar=True)
    spkiecount = np.append(direction_rates[:,1],direction_rates[0,1])
    plt.polar(np.arange(0,361,45)*np.pi/180,spkiecount,label='Firing Rate (spike/s)')
    plt.legend(loc=8)
    plt.title(title)
コード例 #13
0
ファイル: cizi2.py プロジェクト: astar/exploring_neural_data
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    # create a new figure
    plt.figure()

    # create two plots in one figure (1 row, 2 cols)
    plt.subplot(2, 2, 1)

    # histogram
    plt.bar(direction_rates[:, 0],
            direction_rates[:, 1],
            width=45,
            align='center')
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spike/s)')
    plt.title(title)
    plt.axis([0, 360, 0, max(direction_rates[:, 1]) + 1])
    # formatting for plot x-axis
    plt.xticks(np.arange(0, 360, 45))
    plt.xlim(-22.5, 337.5)

    #   # polar plot
    plt.subplot(2, 2, 2, polar=True)

    # copy the array to a new array
    polar_data = direction_rates * 1

    #   # convert degrees to radians
    for i in range(0, len(polar_data)):
        polar_data[i, 0] = np.deg2rad(polar_data[i, 0])

    theta = polar_data[:, 0]
    r = polar_data[:, 1]
    # append data to connect 315 to 360
    r2 = np.append(r, r[0])
    theta2 = np.append(theta, theta[0])

    plt.polar(theta2, r2, label='Firing Rate (spikes/s)')
    plt.legend(loc=0)  # 0 - best, 8- lower center
    plt.title(title)
コード例 #14
0
def plot_fits(direction_rates,fit_curve,title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    plt.subplot(2,2,3)
    plt.plot(direction_rates[:,0],direction_rates[:,1],'o',hold=True)
    plt.plot(fit_curve[:,0],fit_curve[:,1])
    plt.title(title)
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.xlim(0,360)
    
    plt.subplot(2,2,4,polar=True)
    plt.polar(np.deg2rad(direction_rates[:,0]),direction_rates[:,1],'o')
    plt.polar(np.deg2rad(fit_curve[:,0]),fit_curve[:,1],label='Firing Rate (spikes/s)')
    plt.legend(loc=8)
    plt.title(title)
コード例 #15
0
ファイル: cizi2.py プロジェクト: astar/exploring_neural_data
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    # create a new figure
    plt.figure()    
    
    # create two plots in one figure (1 row, 2 cols)    
    plt.subplot(2,2,1)
    
    # histogram
    plt.bar(direction_rates[:,0],direction_rates[:,1], width=45,align='center')     
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spike/s)')
    plt.title(title)
    plt.axis([0,360,0,max(direction_rates[:,1])+1])
    # formatting for plot x-axis    
    plt.xticks(np.arange(0,360,45))
    plt.xlim(-22.5, 337.5)
    
#   # polar plot
    plt.subplot(2,2,2,polar=True)
    
    # copy the array to a new array
    polar_data = direction_rates*1
    
#   # convert degrees to radians 
    for i in range(0, len(polar_data)):
        polar_data[i,0] = np.deg2rad(polar_data[i,0])
    
    theta = polar_data[:,0]
    r = polar_data[:,1]
    # append data to connect 315 to 360 
    r2 = np.append(r,r[0])
    theta2 = np.append(theta,theta[0])
    
    plt.polar(theta2, r2, label='Firing Rate (spikes/s)')
    plt.legend(loc=0) # 0 - best, 8- lower center
    plt.title(title)
コード例 #16
0
def plot_fits(direction_rates, fit_curve, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates and fit_curve) and plots the 
    actual values with circles, and the curves as lines in both linear and 
    polar plots.
    """
    plt.subplot(2, 2, 3)
    plt.plot(direction_rates[:, 0], direction_rates[:, 1], 'o', hold=True)
    plt.plot(fit_curve[:, 0], fit_curve[:, 1])
    plt.title(title)
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.xlim(0, 360)

    plt.subplot(2, 2, 4, polar=True)
    plt.polar(np.deg2rad(direction_rates[:, 0]), direction_rates[:, 1], 'o')
    plt.polar(np.deg2rad(fit_curve[:, 0]),
              fit_curve[:, 1],
              label='Firing Rate (spikes/s)')
    plt.legend(loc=8)
    plt.title(title)
コード例 #17
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    
    # computes the width of the bars to display
    bin_size = direction_rates[1,0] - direction_rates[0,0]
  
    # histogram
    plt.subplot(2,2,1)  
    
    # plot the histogram
    plt.bar( direction_rates[:,0], direction_rates[:,1],  width = bin_size, align='center' )
    plt.xticks( np.arange(0, 361, bin_size) )       # specify the range of ticks
    
    #plt.xlim( ( min_x,  max_x ) )
    #plt.ylim( ( min_y,  max_y) )
    plt.xlabel('Direction of Motion (degrees)')     # add label to x-axis
    plt.ylabel('Firing Rate (spikes/s)')          # add label to y-axis
    plt.title( 'Histogram: ' +  title)              # add title to histogram
    
    # polar representation
    plt.subplot(2,2,2,polar=True)

    spikeFiringRates = direction_rates[:,1]  # select the spikes firing rates     

    # the polar representation is like a circle, so we correct the data
    # in a way that the last element of the array if the same as the first one
    spikeFiringRates = np.append(spikeFiringRates, spikeFiringRates[0])
   
    # compute the angles . A circle ranges from 0 to 360 deg
    theta = np.deg2rad( np.arange( 0, 361, bin_size ) )
   
    # plot the polar graph
    plt.polar( theta, spikeFiringRates, label='Firing Rate (spikes/s)' )
    #plt.legend(loc=8)                   # specify the location of the legend
    plt.title('Polar: ' + title)        # add title to the graph
コード例 #18
0
def rfr(new_xs, new_ys, roll_degrees):
    # Fitting
    max_y = np.amax(new_ys)
    max_x = new_xs[np.argmax(new_ys)]
    sigma = 90
    p, cov = optimize.curve_fit(normal_fit, new_xs, new_ys, 
        p0 = [max_x, sigma, max_y])

    # Pruning
    new_xs += roll_degrees
    new_xs = np.roll(new_xs, np.argmin(new_xs))
    new_ys = np.roll(new_ys, np.argmin(new_ys))

    # Fitting
    curve_xs = np.arange(new_xs[0], new_xs[-1])
    fit_ys = normal_fit(curve_xs, p[0], p[1], p[2])

    # More pruning
    new_xs = new_xs[0 : len(new_xs) - 1]
    new_ys = new_ys[0 : len(new_ys) - 1]
    

    # Plotting
    plt.subplot(2, 2, 3)
    plt.plot(new_xs, new_ys, 'go', curve_xs, fit_ys, '-')
    plt.xlim(xmax = 360)
    plt.xlabel('Direction of Motion (Degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.title('Neuron Tuning Curve')
    
    plt.subplot(2, 2, 4, polar = True)
    plt.polar(np.deg2rad(new_xs), new_ys, 'go', np.deg2rad(curve_xs), fit_ys, '-',
        label = 'Neuron Tuning Curve')
    plt.legend(loc = 8)

    plt.show()  

    return [curve_xs, fit_ys]
コード例 #19
0
ファイル: kmeans_npmovie.py プロジェクト: florisvb/pymovie
def plot_cluster_means(npmovie, figure=None):    
    cluster_means = npmovie.cluster_means
    cluster_min = npmovie.cluster_min
    cluster_max = npmovie.cluster_max
    cluster_std = npmovie.cluster_std
    
    nclusters = cluster_means.shape[0]
    nfeatures = cluster_means.shape[1]
    colormap = plt.get_cmap('jet')
    
    fig = pylab.figure(figure)
    theta_labels = ['yaw rate', 'speed', 'slip']
    
    for r in range(nclusters):
    
        rmax = np.max(np.abs(cluster_means))*1.2
        ax = fig.add_subplot(2,np.ceil(nclusters/2.),r+1,polar=True)
        ax.set_frame_on(False)
        
        # set cluster color
        backgroundcolor=np.array(list(colormap(r/float(nclusters))))
        theta = np.linspace(0, np.pi*2, 100)
        rad = np.ones_like(theta)*rmax
        pylab.polar( theta, rad, color=backgroundcolor, linewidth=6)
        
        theta_arr = []
        for c in range(nfeatures):
            
            theta = c / float(nfeatures)*np.pi
            theta_arr.append(theta)
            rad = cluster_means[r,c]
            
            print r,c,rad
            
            color = colormap( c / float(nfeatures))
            pylab.polar( theta, rad, 'o', color=color, markersize=7)
            
            std_line = np.linspace(rad+cluster_min[r,c], rad+cluster_max[r,c], 4, endpoint=True)
            theta_line = theta*np.ones_like(std_line)
            pylab.polar( theta_line, std_line, color=color, linewidth=.75 )
            
            std_line = np.linspace(rad-cluster_std[r,c], rad+cluster_std[r,c], 4, endpoint=True)
            theta_line = theta*np.ones_like(std_line)
            pylab.polar( theta_line, std_line, color=color, linewidth=3, )
            
        ax.set_thetagrids(np.array(theta_arr)*180/np.pi, labels=theta_labels)
        ax.set_rgrids([rmax], alpha = 0)
        ax.set_rmax(rmax)
コード例 #20
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    x = direction_rates[:, 0]
    y = direction_rates[:, 1]
    plt.figure()
    plt.subplot(2, 2, 1)
    plt.bar(x, y, width=45, align='center')
    plt.xlim(-22.5, 337.5)
    plt.xticks(x)
    plt.xlabel('Direction of Motion (degrees)')
    plt.ylabel('Firing Rate (spikes/s)')
    plt.title(title)

    plt.subplot(2, 2, 2, polar=True)
    r = np.append(y, y[0])
    theta = np.deg2rad(np.append(x, x[0]))
    plt.polar(theta, r, label='Firing Rate (spikes/s)')
    plt.legend(loc=8)
    plt.title(title)
コード例 #21
0
def plot_tuning_curves(direction_rates, title):
    """
    This function takes the x-values and the y-values  in units of spikes/s 
    (found in the two columns of direction_rates) and plots a histogram and 
    polar representation of the tuning curve. It adds the given title.
    """
    
    plt.subplot(2,2,1)
    plt.bar(direction_rates[:,0],direction_rates[:,1], width=45)
    y_max = np.max(direction_rates[:,1]) + 5
    plt.axis([0,360,0,y_max])
    a=np.arange(0, 360, 45)
    plt.xticks(a+22,a,rotation = 17)
    plt.xlabel("Direction of Motion (degrees)")
    plt.ylabel("Firing Rate (spikes/s)")
    plt.title(title)
    
    plt.subplot(2,2,2, polar = True)    
    spikecounts = direction_rates[:,1]
    spikecounts2 = np.append(spikecounts, direction_rates[0,1]) 
    r = np.arange(0, 361, 45)*np.pi/180
    plt.polar(r, spikecounts2, label="Firing Rate (spikes/s)")
    plt.title(title)
    plt.legend(loc=8)
コード例 #22
0
ファイル: check_hough.py プロジェクト: gobgob/lidar-processor
def reconstruct_image_with_lines_polar(polar_points, angles, dists):
    # print(angles)
    # print(dists)
    # fig = pl.figure()
    # ax = fig.add_subplot(111)
    # ax.clear()
    # # ax.set_xlim(0, distance_max_x_cartesien)
    # ax.set_xlim(-int(distance_max_x_cartesien/2), int(distance_max_x_cartesien/2))
    # # ax.set_ylim(0, distance_max_y_cartesien)
    # ax.set_ylim(-int(distance_max_y_cartesien/2), int(distance_max_y_cartesien/2))
    # ax.axhline(0, 0)
    # ax.axvline(0, 0)
    # # pl.grid()
    #
    xx = []
    yy = []
    # for x, y in points:
    #     xx.append(x)
    #     yy.append(y)
    # pl.plot(xx, yy, 'r.')
    cartesian_good_data = outr.one_turn_to_cartesian_points(polar_points)
    width, height = outr.get_width_height(cartesian_good_data)
    diag_len = int(round(math.sqrt(width * width + height * height)))
    # cartesian_good_data, translation = outr.change_basis(cartesian_good_data)

    for theta, rho in polar_points:
        pl.polar(math.radians(theta), rho, 'r,')
    # pl.show()

    # fig.canvas.draw()
    print("fini ?")
    for theta, rho in zip(angles, dists):
        # print("oui ?")
        xxx, yyy = [], []
        # print(-int(distance_max_x_cartesien / 2), int(distance_max_x_cartesien / 2))
        # cost = math.cos(theta)
        # sint = math.sin(theta)
        # x0 = rho*cost
        # y0 = rho*sint
        # x1 = x0 - 10000*sint
        # y1 = y0 + 10000*cost
        # x2 = x0 + 10000*sint
        # y2 = y0 - 10000*cost
        # pl.plot(x1, y1, 'b-')
        # pl.plot(x2, y2, 'b-')
        # for x in range(0, distance_max_x_cartesien):
        for x in range(-int(distance_max_x_cartesien/2), int(distance_max_x_cartesien/2)):
            # print(x)
            y = rho / math.sin(theta) - (math.cos(theta)/math.sin(theta)) * x - diag_len
            a, d = outr.cartesian_to_polar([x, y])

            # print("y", y)
            # xxx.append(x)
            # yyy.append(y)
            xxx.append(a)
            yyy.append(d)
            # print("cartesian", [x+translation[0], -y-translation[1]])
            # a, d = outr.cartesian_to_polar([x-translation[0], (y-translation[1])])

            # print("polar", a, d)
            # pl.polar(a, d, "b-")
        pl.polar(xxx, yyy, 'b-')
        # pl.plot(xxx, yyy, 'b-')
        # fig.canvas.draw()
    pl.show()
コード例 #23
0
ファイル: check_hough.py プロジェクト: gobgob/lidar-processor
def display_deg2rad_polar_measures(polar_points):

    for theta, rho in polar_points:
        pl.polar(math.radians(theta), rho, 'r,')
    pl.show()
コード例 #24
0
value_L11a_v8=[0.0022737603,0.0136363636,0.0154545455,0.0068181818,0.0045454545,0.0159090909,0.03,0.0186363636,0.0022737603]
value_M14a_v8=[0.0113688017,0.0109090909,0.0145454545,0.0127272727,0.0113636364,0.0072727273,0.0168181818,0.0072727273,0.0113688017]
value_M9c_v8=[0.0009095041,0.0018181818,0.0004545455,0.0004545455,0.0027272727,0.005,0.0036363636,0,0.0009095041]

#250





### Graficado
angle = [0, 45, 90, 135, 180, 225, 270, 315, 0]
angle = np.array(angle)*np.pi/180 

plt.figure('Preferred angles V2')
plt.polar(angle, value_E11a_v2, 'b', linewidth=3, label='E11a_v2')
plt.polar(angle, value_H10b_v2, 'g', linewidth=3, label='H10b_v2')
plt.polar(angle, value_K5a_v2, 'yellow', linewidth=3, label='K5a_v2')
plt.polar(angle, value_F12a_v2, 'r', linewidth=3, label='F12a_v2')
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)

plt.figure('Preferred angles V8')
plt.polar(angle, value_E11a_v8, 'b', linewidth=3, label='E11a_v8')
plt.polar(angle, value_H10b_v8, 'g', linewidth=3, label='H10b_v8')
plt.polar(angle, value_K5a_v8, 'yellow', linewidth=3, label='K5a_v8')
#plt.polar(angle, value_F12a_v8, 'r', linewidth=3, label='F12a_v8')
#plt.polar(angle, value_E7b_v8, 'orange', linewidth=3, label='E7b_v8')
#plt.polar(angle, value_E8a_v8, 'black', linewidth=3, label='E8a_v8')
plt.polar(angle, value_K10b_v8, 'cyan', linewidth=3, label='K10b_v8')
#plt.polar(angle, value_F11a_v8, 'brown', linewidth=3, label='F11a_v8')
#plt.polar(angle, value_E7a_v8, 'lime', linewidth=3, label='E7a_v8')