|
@@ -324,15 +324,11 @@ def plot_axonal_clouds(traj, plot_run_names):
|
|
|
cluster_sizes = [4, 4, 4]
|
|
|
selected_neurons = []
|
|
|
|
|
|
+ inhibitory_positions = traj.results.runs[plot_run_names[0]].inhibitory_axonal_cloud_array[:, :2]
|
|
|
for cluster_position, number_of_neurons_in_cluster in zip(cluster_positions, cluster_sizes):
|
|
|
- position = np.array(cluster_position)
|
|
|
-
|
|
|
- inhibitory_positions = traj.results.runs[plot_run_names[0]].inhibitory_axonal_cloud_array[:, :2]
|
|
|
- distance_vectors = inhibitory_positions - np.expand_dims(position, 0).repeat(inhibitory_positions.shape[0],
|
|
|
- axis=0)
|
|
|
- distances = np.linalg.norm(distance_vectors, axis=1)
|
|
|
- selected_neurons.extend(list(np.argpartition(distances, number_of_neurons_in_cluster)[
|
|
|
- :number_of_neurons_in_cluster]))
|
|
|
+ selection = get_neurons_close_to_given_position(cluster_position, number_of_neurons_in_cluster,
|
|
|
+ inhibitory_positions)
|
|
|
+ selected_neurons.extend(selection)
|
|
|
|
|
|
fig = plt.figure(figsize=(width, height))
|
|
|
|
|
@@ -386,14 +382,7 @@ def plot_axonal_clouds(traj, plot_run_names):
|
|
|
start_scale_y = -70
|
|
|
end_scale_y = start_scale_y
|
|
|
|
|
|
- scale_bar = axes[0].add_artist(plt.Line2D([start_scale_x, end_scale_x], [start_scale_y, end_scale_y], linewidth=2,
|
|
|
- color='black'))
|
|
|
- scale_bar.set_clip_on(False)
|
|
|
- # axes[0].text(start_scale_x+scale_length/2.0, start_scale_y, , va="top",
|
|
|
- # ha="center", color="k")
|
|
|
- axes[0].annotate("{:.0f} um".format(scale_length), xy=(start_scale_x + scale_length / 2.0, start_scale_y),
|
|
|
- xytext=(0, -3),
|
|
|
- xycoords="data", textcoords="offset points", va="top", ha="center", annotation_clip=False)
|
|
|
+ add_length_scale(axes[0], scale_length, start_scale_x, end_scale_x, start_scale_y, end_scale_y)
|
|
|
|
|
|
axes[1].set_yticklabels([])
|
|
|
axes[2].set_yticklabels([])
|
|
@@ -404,6 +393,26 @@ def plot_axonal_clouds(traj, plot_run_names):
|
|
|
plt.savefig(FIGURE_SAVE_PATH + 'B_i_axonal_clouds.png')
|
|
|
|
|
|
|
|
|
+def get_neurons_close_to_given_position(cluster_position, number_of_neurons_in_cluster, positions):
|
|
|
+ position = np.array(cluster_position)
|
|
|
+ distance_vectors = positions - np.expand_dims(position, 0).repeat(positions.shape[0],
|
|
|
+ axis=0)
|
|
|
+ distances = np.linalg.norm(distance_vectors, axis=1)
|
|
|
+ selection = list(np.argpartition(distances, number_of_neurons_in_cluster)[:number_of_neurons_in_cluster])
|
|
|
+ return selection
|
|
|
+
|
|
|
+
|
|
|
+def add_length_scale(ax, scale_length, start_scale_x, end_scale_x, start_scale_y, end_scale_y):
|
|
|
+ scale_bar = ax.add_artist(plt.Line2D([start_scale_x, end_scale_x], [start_scale_y, end_scale_y], linewidth=2,
|
|
|
+ color='black'))
|
|
|
+ scale_bar.set_clip_on(False)
|
|
|
+ # axes[0].text(start_scale_x+scale_length/2.0, start_scale_y, , va="top",
|
|
|
+ # ha="center", color="k")
|
|
|
+ ax.annotate("{:.0f} um".format(scale_length), xy=(start_scale_x + scale_length / 2.0, start_scale_y),
|
|
|
+ xytext=(0, -3),
|
|
|
+ xycoords="data", textcoords="offset points", va="top", ha="center", annotation_clip=False)
|
|
|
+
|
|
|
+
|
|
|
def plot_orientation_maps_diff_scales(traj):
|
|
|
n_ex = int(np.sqrt(traj.N_E))
|
|
|
|
|
@@ -436,14 +445,25 @@ def plot_orientation_maps_diff_scales_with_ellipse(traj):
|
|
|
n_ex = int(np.sqrt(traj.N_E))
|
|
|
|
|
|
scale_run_names = []
|
|
|
- plot_scales = [0.0, 200.0, 400.0, 600.0, 800.0]
|
|
|
+ plot_scales = [0.0, 400.0, 800.0]
|
|
|
+ real_scales = [get_closest_correlation_length(traj, scale) for scale in plot_scales]
|
|
|
for scale in plot_scales:
|
|
|
par_dict = {'seed': 1, 'correlation_length': get_closest_correlation_length(traj, scale), 'long_axis': 100.}
|
|
|
scale_run_names.append(*filter_run_names_by_par_dict(traj, par_dict))
|
|
|
print(scale_run_names)
|
|
|
|
|
|
- fig, axes = plt.subplots(1, 5, figsize=(18., 4.5))
|
|
|
- for ax, run_name, scale in zip(axes, scale_run_names, plot_scales):
|
|
|
+ inhibitory_positions = traj.results.runs[scale_run_names[1]].inhibitory_axonal_cloud_array[:, :2]
|
|
|
+ selected_polar_neuron = get_neurons_close_to_given_position((300, 300), 1, inhibitory_positions)[0]
|
|
|
+ print(selected_polar_neuron)
|
|
|
+ selected_circular_neuron = get_neurons_close_to_given_position((600, 600), 1, inhibitory_positions)[0]
|
|
|
+
|
|
|
+ width = panel_size
|
|
|
+ height = 1.5*panel_size
|
|
|
+ fig = plt.figure(figsize=(width, height))
|
|
|
+
|
|
|
+ axes = ImageGrid(fig, 111, axes_pad=0.15,
|
|
|
+ nrows_ncols=(len(plot_scales), 1))
|
|
|
+ for ax, run_name, scale in zip(axes, scale_run_names, real_scales):
|
|
|
traj.f_set_crun(run_name)
|
|
|
|
|
|
X, Y = get_position_mesh(traj.results.runs[run_name].ex_positions)
|
|
@@ -460,25 +480,30 @@ def plot_orientation_maps_diff_scales_with_ellipse(traj):
|
|
|
ax.set_xticks([])
|
|
|
ax.set_yticks([])
|
|
|
|
|
|
- p1 = axonal_clouds[44]
|
|
|
+ p1 = axonal_clouds[selected_polar_neuron]
|
|
|
ell = p1.get_ellipse()
|
|
|
- ell._linewidth = 5.
|
|
|
+ ell._linewidth = 2.
|
|
|
ax.add_artist(ell)
|
|
|
|
|
|
- p2 = axonal_clouds[77]
|
|
|
- circ_r = 2 * np.sqrt(2500.)
|
|
|
+ p2 = axonal_clouds[selected_circular_neuron]
|
|
|
+ circ_r = 2 * np.sqrt(p2.a*p2.b)
|
|
|
circ = Ellipse((p2.x, p2.y), circ_r, circ_r, fill=False, zorder=2, edgecolor='k')
|
|
|
- circ._linewidth = 5.
|
|
|
+ circ._linewidth = 2.
|
|
|
|
|
|
ax.add_artist(circ)
|
|
|
+ ax.annotate("{:.0f}".format(scale), xy=(1.0, 0.5), xytext=(2,0), xycoords="axes fraction", textcoords="offset "
|
|
|
+ "points",
|
|
|
+ va="center", ha="left" )
|
|
|
+ remove_frame(ax)
|
|
|
|
|
|
# fig.suptitle('axonal cloud', fontsize=16)
|
|
|
traj.f_restore_default()
|
|
|
-
|
|
|
+ add_length_scale(axes[1], 200, -300, -100, 50, 50)
|
|
|
+ axes[0].annotate("input maps", xy=(-0.5, 1.0), xycoords="axes fraction", rotation=90, ha="left", va="top")
|
|
|
fig.tight_layout()
|
|
|
|
|
|
if save_figs:
|
|
|
- plt.savefig(FIGURE_SAVE_PATH + 'orientation_maps_diff_scales_with_ellipse.png', dpi=200)
|
|
|
+ plt.savefig(FIGURE_SAVE_PATH + 'F_orientation_maps_diff_scales_with_ellipse.png')
|
|
|
|
|
|
|
|
|
def plot_polar_plot_excitatory(traj, plot_run_names, selected_neuron_idx,
|