def Performance_eccentricity_plotter_clustering(distance_array, ecc_pairs, performance_array, performance_array_clustering, dist_value, trace_color, trace_color_clustering, figure_title, file_name): """Performance for clustering selected electrodes Plot performance as a function of eccentricity comparing all vs clustering-selected electrodes """ ecc_values = ecc_pairs[distance_array == dist_value] performance_array_values = performance_array[distance_array == dist_value] performance_array_values_clustering = performance_array_clustering[distance_array == dist_value] y_x, y_x_std = mean_relationship(ecc_values, performance_array_values, np.arange(3, 27, 3)) y_x_clustering, y_x_std_clustering = mean_relationship(ecc_values, performance_array_values_clustering, np.arange(3, 27, 3)) coeff, p_value = pearsonr(ecc_values, performance_array_values) coeff, p_value_clustering = pearsonr(ecc_values, performance_array_values_clustering) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x, linewidth=3.0, marker='o', color=trace_color) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_clustering, linewidth=3.0, marker='o', color=trace_color_clustering) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Eccentricity (deg)', fontweight='bold') plt.legend(('All p-value={0}'.format(np.round_(p_value, 4)), 'Clustering-selected p-value={0}'.format(np.round_(p_value_clustering, 4))), loc='lower right', fontsize=28) plt.title(figure_title, fontweight='bold', loc='center') plt.show() fig.savefig(file_name, dpi=200)
def performance_corticaldistance_plotter_clustering(cortical_distances, performance_array, performance_array_clustering, trace_color, trace_color_clustering, figure_title, file_name): """Performance for clustering selected electrodes Plot performance as a function of cortical distance comparing all vs clustering-selected electrodes """ y_x, y_x_std = mean_relationship(cortical_distances, performance_array, np.arange(0.5, 5.5, 0.5)) y_x_clustering, y_x_std_clustering = mean_relationship(cortical_distances, performance_array_clustering, np.arange(0.5, 5.5, 0.5)) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x, marker='o', linewidth=3.0, color=trace_color) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x-y_x_std,y_x+y_x_std,color=trace_color) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_clustering, marker='o', linewidth=3.0, color=trace_color_clustering) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_clustering-y_x_std_clustering,y_x_clustering+y_x_std_clustering,color=trace_color_clustering) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Cortical distance (mm)', fontweight='bold') plt.title(figure_title, fontweight='bold', loc='center') plt.legend(('All', 'Clustering-selected'), loc='lower right', fontsize=32) plt.show() fig.savefig(file_name, dpi=200)
def performance_corticaldistance_plotter( cortical_distances_wide, cortical_distances_medium, cortical_distances_narrow, performance_array_wide, performance_array_medium, performance_array_narrow, trace_color_wide, trace_color_medium, trace_color_narrow, figure_title, file_name): """Performance vs cortical distance This function plots discrimination performance vs cortical distance and compares resultss for wide, medium, and narrow windows. """ fig = plt.figure(figsize=(12, 10)) y_x_wide, y_x_std_wide = mean_relationship(cortical_distances_wide, performance_array_wide, np.arange(0.5, 5.5, 0.5)) y_x_medium, y_x_std_medium = mean_relationship(cortical_distances_medium, performance_array_medium, np.arange(0.5, 5.5, 0.5)) y_x_narrow, y_x_std_narrow = mean_relationship(cortical_distances_narrow, performance_array_narrow, np.arange(0.5, 5.5, 0.5)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_wide, marker='o', linewidth=3.0, color=trace_color_wide) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_wide-y_x_std_wide,y_x_wide+y_x_std_wide,color=trace_color_wide) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_medium, marker='o', linewidth=3.0, color=trace_color_medium) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_medium-y_x_std_medium,y_x_medium+y_x_std_medium,color=trace_color_medium) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_narrow, marker='o', linewidth=3.0, color=trace_color_narrow) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_narrow-y_x_std_narrow,y_x_narrow+y_x_std_narrow,color=trace_color_narrow) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold', labelpad=30, fontsize=30) plt.xlabel('Cortical distance (mm)', fontweight='bold', labelpad=30, fontsize=30) plt.title(figure_title, fontweight='bold', loc='center') plt.legend(('Wide', 'Medium', 'Narrow'), loc='lower right', fontsize=32) plt.show() fig.savefig(file_name, bbox_inches='tight', dpi=200)
def Performance_eccentricity_onblind_plotter_P3( distance_array, ecc_pairs, performance_array, performance_array_blind, dist_value, trace_color, trace_color_blind, figure_title, file_name): """Performance-eccentricity Plots of performance-eccentricity comparing correlation-aware and correlation-blind decoders """ ecc_values = ecc_pairs[distance_array == dist_value] performance_array_values = performance_array[distance_array == dist_value] performance_array_values_blind = performance_array_blind[distance_array == dist_value] y_x, y_x_std = mean_relationship(ecc_values, performance_array_values, np.arange(3, 21, 3)) y_x_blind, y_x_std_blind = mean_relationship( ecc_values, performance_array_values_blind, np.arange(3, 21, 3)) coeff, p_value = pearsonr(ecc_values, performance_array_values) coeff, p_value_blind = pearsonr(ecc_values, performance_array_values_blind) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(3, 18, 3) + 1.5, y_x, linewidth=3.0, marker='o', color=trace_color) plt.plot(np.arange(3, 18, 3) + 1.5, y_x_blind, linewidth=3.0, marker='o', color=trace_color_blind) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Eccentricity (deg)', fontweight='bold') plt.legend( ('Correlation-aware p-value={0}'.format(np.round_(p_value, 4)), 'Correlation-blind p-value={0}'.format(np.round_(p_value_blind, 4))), loc='lower right', fontsize=28) plt.title(figure_title, fontweight='bold', loc='center') plt.show() fig.savefig(file_name, dpi=200)
def performance_corticaldistance_onblind_plotter( cortical_distances, performance_array, performance_array_blind, trace_color, trace_color_blind, figure_title, file_name): """Performance-cortical distance Plots of performance-cortical distance comparing correlation-aware and correlation-blind decoders """ fig = plt.figure(figsize=(12, 10)) y_x, y_x_std = mean_relationship(cortical_distances, performance_array, np.arange(0.5, 5.5, 0.5)) y_x_blind, y_x_std_blind = mean_relationship(cortical_distances, performance_array_blind, np.arange(0.5, 5.5, 0.5)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x, marker='o', linewidth=3.0, color=trace_color) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_blind, marker='o', linewidth=3.0, color=trace_color_blind) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Cortical distance (mm)', fontweight='bold') plt.title(figure_title, fontweight='bold', loc='center') plt.legend(('Correlation-aware', 'Correlation-blind'), loc='lower right', fontsize=32) plt.show() fig.savefig(file_name, dpi=200)
def Performance_eccentricity_plotter_importance(distance_array, ecc_pairs, performance_array, performance_array_four, performance_array_six, performance_array_eight, performance_array_ten, performance_array_twelve, dist_value, figure_title, file_name): """Performance-eccentricity for the best electrodes Perfromance as a function of eccentricity using the best 4, 6, 8, 10, and 12 electrodes for specific value of probes separation """ ecc_values = ecc_pairs[distance_array == dist_value] performance_array_values = performance_array[distance_array == dist_value] performance_array_values_four = performance_array_four[distance_array == dist_value] performance_array_values_six = performance_array_six[distance_array == dist_value] performance_array_values_eight = performance_array_eight[distance_array == dist_value] performance_array_values_ten = performance_array_ten[distance_array == dist_value] performance_array_values_twelve = performance_array_twelve[distance_array == dist_value] y_x, y_x_std = mean_relationship(ecc_values, performance_array_values, np.arange(3, 27, 3)) y_x_four, y_x_std_four = mean_relationship(ecc_values, performance_array_values_four, np.arange(3, 27, 3)) y_x_six, y_x_std_six = mean_relationship(ecc_values, performance_array_values_six, np.arange(3, 27, 3)) y_x_eight, y_x_std_eight = mean_relationship(ecc_values, performance_array_values_eight, np.arange(3, 27, 3)) y_x_ten, y_x_std_ten = mean_relationship(ecc_values, performance_array_values_ten, np.arange(3, 27, 3)) y_x_twelve, y_x_std_twelve = mean_relationship(ecc_values, performance_array_values_twelve, np.arange(3, 27, 3)) coeff, p_value = pearsonr(ecc_values, performance_array_values) coeff, p_value_four = pearsonr(ecc_values, performance_array_values_four) coeff, p_value_six = pearsonr(ecc_values, performance_array_values_six) coeff, p_value_eight = pearsonr(ecc_values, performance_array_values_eight) coeff, p_value_ten = pearsonr(ecc_values, performance_array_values_ten) coeff, p_value_twelve = pearsonr(ecc_values, performance_array_values_twelve) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x, linewidth=3.0, marker='o', color=(0.031, 0.031, 0.027)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_four, linewidth=3.0, marker='o', color=(0.054, 0.925, 0.964)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_six, linewidth=3.0, marker='o', color=(0.427, 0.964, 0.054)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_eight, linewidth=3.0, marker='o', color=(0.964, 0.937, 0.054)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_ten, linewidth=3.0, marker='o', color=(0.964, 0.054, 0.780)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_twelve, linewidth=3.0, marker='o', color=(0.964, 0.098, 0.054)) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Eccentricity (deg)', fontweight='bold') plt.legend(('All p-value={0}'.format(np.round_(p_value, 4)), '4 p-value={0}'.format(np.round_(p_value_four, 4)), '6 p-value={0}'.format(np.round_(p_value_six, 4)), '8 p-value={0}'.format(np.round_(p_value_eight, 4)), '10 p-value={0}'.format(np.round_(p_value_ten, 4)), '12 p-value={0}'.format(np.round_(p_value_twelve, 4))), loc='lower right', fontsize=26) plt.title(figure_title, fontweight='bold', loc='center') plt.show() fig.savefig(file_name, dpi=200)
def performance_corticaldistance_plotter_importance(cortical_distances, performance_array, performance_array_four, performance_array_six, performance_array_eight, performance_array_ten, performance_array_twelve, file_name): """Performance-cortical distance for the best electrodes Perfromance as a function of cortical distance using the best 4, 6, 8, 10, and 12 electrodes """ y_x, y_x_std = mean_relationship(cortical_distances, performance_array, np.arange(0.5, 5.5, 0.5)) y_x_four, y_x_std_four = mean_relationship(cortical_distances, performance_array_four, np.arange(0.5, 5.5, 0.5)) y_x_six, y_x_std_six = mean_relationship(cortical_distances, performance_array_six, np.arange(0.5, 5.5, 0.5)) y_x_eight, y_x_std_eight = mean_relationship(cortical_distances, performance_array_eight, np.arange(0.5, 5.5, 0.5)) y_x_ten, y_x_std_ten = mean_relationship(cortical_distances, performance_array_ten, np.arange(0.5, 5.5, 0.5)) y_x_twelve, y_x_std_twelve = mean_relationship(cortical_distances, performance_array_twelve, np.arange(0.5, 5.5, 0.5)) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x, marker='o', linewidth=3.0, color=(0.031, 0.031, 0.027)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x-y_x_std,y_x+y_x_std,color=(0.031, 0.031, 0.027)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_four, marker='o', linewidth=3.0, color=(0.054, 0.925, 0.964)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_four-y_x_std_four,y_x_four+y_x_std_four,color=(0.054, 0.925, 0.964)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_six, marker='o', linewidth=3.0, color=(0.427, 0.964, 0.054)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_six-y_x_std_six,y_x_six+y_x_std_six,color=(0.427, 0.964, 0.054)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_eight, marker='o', linewidth=3.0, color=(0.964, 0.937, 0.054)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_eight-y_x_std_eight,y_x_eight+y_x_std_eight,color=(0.964, 0.937, 0.054)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_ten, marker='o', linewidth=3.0, color=(0.964, 0.054, 0.780)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_ten-y_x_std_ten,y_x_ten+y_x_std_ten,color=(0.964, 0.054, 0.780)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_twelve, marker='o', linewidth=3.0, color=(0.964, 0.098, 0.054)) # plt.fill_between(np.arange(0.5,5,0.5)+0.25,y_x_twelve-y_x_std_twelve,y_x_twelve+y_x_std_twelve,color=(0.964, 0.098, 0.054)) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Cortical distance (mm)', fontweight='bold') plt.legend(('All', '4', '6', '8', '10', '12'), loc='lower right', fontsize=32) plt.show() fig.savefig(file_name, dpi=200)
def Bandpass_Performance_eccentricity_plotter( distance_array, ecc_pairs, performance_array_theta, performance_array_alpha, performance_array_beta, performance_array_gamma, performance_array_highgamma, dist_value, figure_title, file_name): """ Plot discrimination performance of LFP versus eccentricity at different frequency bands """ ecc_values = ecc_pairs[distance_array == dist_value] performance_array_values_theta = performance_array_theta[distance_array == dist_value] performance_array_values_alpha = performance_array_alpha[distance_array == dist_value] performance_array_values_beta = performance_array_beta[distance_array == dist_value] performance_array_values_gamma = performance_array_gamma[distance_array == dist_value] performance_array_values_highgamma = performance_array_highgamma[ distance_array == dist_value] y_x_theta, y_x_std_theta = mean_relationship( ecc_values, performance_array_values_theta, np.arange(3, 27, 3)) y_x_alpha, y_x_std_alpha = mean_relationship( ecc_values, performance_array_values_alpha, np.arange(3, 27, 3)) y_x_beta, y_x_std_beta = mean_relationship(ecc_values, performance_array_values_beta, np.arange(3, 27, 3)) y_x_gamma, y_x_std_gamma = mean_relationship( ecc_values, performance_array_values_gamma, np.arange(3, 27, 3)) y_x_highgamma, y_x_std_highgamma = mean_relationship( ecc_values, performance_array_values_highgamma, np.arange(3, 27, 3)) coeff, p_value_theta = pearsonr(ecc_values, performance_array_values_theta) coeff, p_value_alpha = pearsonr(ecc_values, performance_array_values_alpha) coeff, p_value_beta = pearsonr(ecc_values, performance_array_values_beta) coeff, p_value_gamma = pearsonr(ecc_values, performance_array_values_gamma) coeff, p_value_highgamma = pearsonr(ecc_values, performance_array_values_highgamma) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_theta, linewidth=3.0, marker='o', color=(0.035, 0.062, 0.682)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_alpha, linewidth=3.0, marker='o', color=(0.298, 0.662, 0.941)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_beta, linewidth=3.0, marker='o', color=(0.031, 0.568, 0.098)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_gamma, linewidth=3.0, marker='o', color=(0.960, 0.050, 0.019)) plt.plot(np.arange(3, 24, 3) + 1.5, y_x_highgamma, linewidth=3.0, marker='o', color=(0.960, 0.454, 0.019)) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Eccentricity (deg)', fontweight='bold') plt.legend( ('Theta p-value={0}'.format(np.round_( p_value_theta, 4)), 'Alpha p-value={0}'.format( np.round_(p_value_alpha, 4)), 'Beta p-value={0}'.format( np.round_(p_value_beta, 4)), 'Gamma p-value={0}'.format( np.round_(p_value_gamma, 4)), 'High-gamma p-value={0}'.format(np.round_(p_value_highgamma, 4))), loc='upper right', fontsize=26) plt.title(figure_title, fontweight='bold', loc='center') plt.show() fig.savefig(file_name, dpi=200)
def bandpass_performance_corticaldistance_plotter( cortical_distances, performance_array_theta, performance_array_alpha, performance_array_beta, performance_array_gamma, performance_array_highgamma, figure_title, file_name): """ Plot discrimination performance of LFP versus cortical distance at different frequency bands """ fig = plt.figure(figsize=(12, 10)) y_x_theta, y_x_std_theta = mean_relationship(cortical_distances, performance_array_theta, np.arange(0.5, 5.5, 0.5)) y_x_alpha, y_x_std_alpha = mean_relationship(cortical_distances, performance_array_alpha, np.arange(0.5, 5.5, 0.5)) y_x_beta, y_x_std_beta = mean_relationship(cortical_distances, performance_array_beta, np.arange(0.5, 5.5, 0.5)) y_x_gamma, y_x_std_gamma = mean_relationship(cortical_distances, performance_array_gamma, np.arange(0.5, 5.5, 0.5)) y_x_highgamma, y_x_std_highgamma = mean_relationship( cortical_distances, performance_array_highgamma, np.arange(0.5, 5.5, 0.5)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_theta, marker='o', linewidth=3.0, color=(0.035, 0.062, 0.682)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_alpha, marker='o', linewidth=3.0, color=(0.298, 0.662, 0.941)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_beta, marker='o', linewidth=3.0, color=(0.031, 0.568, 0.098)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_gamma, marker='o', linewidth=3.0, color=(0.960, 0.050, 0.019)) plt.plot(np.arange(0.5, 5, 0.5) + 0.25, y_x_highgamma, marker='o', linewidth=3.0, color=(0.960, 0.454, 0.019)) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold') plt.xlabel('Cortical distance (mm)', fontweight='bold') plt.title(figure_title, fontweight='bold', loc='center') plt.legend(('Theta', 'Alpha', 'Beta', 'Gamma', 'High-gamma'), loc='upper right', fontsize=28) plt.show() fig.savefig(file_name, dpi=200)
def Performance_eccentricity_plotter_P3( distance_array_wide, distance_array_medium, distance_array_narrow, ecc_pairs_wide, ecc_pairs_medium, ecc_pairs_narrow, performance_array_wide, performance_array_medium, performance_array_narrow, dist_value, trace_color_wide, trace_color_medium, trace_color_narrow, figure_title, file_name): """ This function plots discrimination performance as a function of probes mean eccentricity for specific probes separation. Then, it calculates linear correlation p-value between performance and eccentricity. """ ecc_values_wide = ecc_pairs_wide[distance_array_wide == dist_value] performance_array_values_wide = performance_array_wide[distance_array_wide == dist_value] ecc_values_medium = ecc_pairs_medium[distance_array_medium == dist_value] performance_array_values_medium = performance_array_medium[ distance_array_medium == dist_value] ecc_values_narrow = ecc_pairs_narrow[distance_array_narrow == dist_value] performance_array_values_narrow = performance_array_narrow[ distance_array_narrow == dist_value] y_x_wide, y_x_std_wide = mean_relationship(ecc_values_wide, performance_array_values_wide, np.arange(3, 21, 3)) y_x_medium, y_x_std_medium = mean_relationship( ecc_values_medium, performance_array_values_medium, np.arange(3, 21, 3)) y_x_narrow, y_x_std_narrow = mean_relationship( ecc_values_narrow, performance_array_values_narrow, np.arange(3, 21, 3)) coeff, p_value_wide = pearsonr(ecc_values_wide, performance_array_values_wide) coeff, p_value_medium = pearsonr(ecc_values_medium, performance_array_values_medium) coeff, p_value_narrow = pearsonr(ecc_values_narrow, performance_array_values_narrow) fig = plt.figure(figsize=(12, 10)) plt.plot(np.arange(3, 18, 3) + 1.5, y_x_wide, linewidth=3.0, marker='o', color=trace_color_wide) plt.plot(np.arange(3, 18, 3) + 1.5, y_x_medium, linewidth=3.0, marker='o', color=trace_color_medium) plt.plot(np.arange(3, 18, 3) + 1.5, y_x_narrow, linewidth=3.0, marker='o', color=trace_color_narrow) plt.axis('tight') plt.tight_layout() plt.ylim(0.3, 1) plt.ylabel('Performance', fontweight='bold', labelpad=30, fontsize=30) plt.xlabel('Eccentricity (deg)', fontweight='bold', labelpad=30, fontsize=30) plt.legend(('Wide p-value={0}'.format(np.round_(p_value_wide, 4)), 'Medium p-value={0}'.format(np.round_(p_value_medium, 4)), 'Narrow p-value={0}'.format(np.round_(p_value_narrow, 4))), loc='lower right', fontsize=32) plt.title(figure_title, fontweight='bold', loc='center') plt.show() fig.savefig(file_name, bbox_inches='tight', dpi=200)