Parcourir la source

maps with different lengths in new layout

Paul Pfeiffer il y a 3 ans
Parent
commit
d4de122705

+ 1 - 1
graphics/fig4.sla

@@ -138,7 +138,7 @@
             <para/>
             <PageItemAttributes/>
         </PAGEOBJECT>
-        <PAGEOBJECT OwnPage="0" PTYPE="2" XPOS="524.201771682677" YPOS="397.020669333858" WIDTH="127.55905511811" HEIGHT="33.5003579" RADRECT="0" FRTYPE="0" CLIPEDIT="0" PWIDTH="1" PCOLOR="None" PCOLOR2="None" COLUMNS="1" COLGAP="0" NAMEDLST="" SHADE="100" SHADE2="100" GRTYP="0" ROT="-270" PLINEART="1" PLINEEND="0" PLINEJOIN="0" LOCALSCX="0.0354330708661417" LOCALSCY="0.0354330708661417" LOCALX="0" LOCALY="0" PICART="1" PLTSHOW="0" BASEOF="0" textPathType="0" textPathFlipped="0" FLIPPEDH="0" FLIPPEDV="0" SCALETYPE="0" RATIO="1" PRINTABLE="1" ANNOTATION="0" ANNAME="" TEXTFLOWMODE="0" TEXTFLOW="0" TEXTFLOW2="0" TEXTFLOW3="0" AUTOTEXT="0" EXTRA="0" TEXTRA="0" BEXTRA="0" REXTRA="0" FLOP="0" PFILE="../figures/figure_4_paper_perlin/orientation_maps_diff_scales_with_ellipse.png" PFILE2="" PFILE3="" PRFILE="" EPROF="" IRENDER="0" EMBEDDED="0" LOCK="0" LOCKR="0" REVERS="0" TransValue="0" TransValueS="0" TransBlend="0" TransBlendS="0" isTableItem="0" TopLine="0" LeftLine="0" RightLine="0" BottomLine="0" isGroupControl="0" NUMDASH="0" DASHS="" DASHOFF="0" NUMPO="16" POCOOR="0 0 0 0 127.559 0 127.559 0 127.559 0 127.559 0 127.559 33.5004 127.559 33.5004 127.559 33.5004 127.559 33.5004 0 33.5004 0 33.5004 0 33.5004 0 33.5004 0 0 0 0 " NUMCO="16" COCOOR="0 0 0 0 127.559 0 127.559 0 127.559 0 127.559 0 127.559 33.5004 127.559 33.5004 127.559 33.5004 127.559 33.5004 0 33.5004 0 33.5004 0 33.5004 0 33.5004 0 0 0 0 " NUMGROUP="0" GROUPS="" startArrowIndex="0" endArrowIndex="0" OnMasterPage="" ImageClip="" ImageRes="1" Pagenumber="0" isInline="0" fillRule="1" doOverprint="0" gXpos="0" gYpos="0" gWidth="0" gHeight="0" LAYER="0" BOOKMARK="0" NEXTITEM="-1" BACKITEM="-1">
+        <PAGEOBJECT OwnPage="0" PTYPE="2" XPOS="462.835275590551" YPOS="382.835905511811" WIDTH="90.7086614173228" HEIGHT="136.062992125984" RADRECT="0" FRTYPE="0" CLIPEDIT="0" PWIDTH="1" PCOLOR="None" PCOLOR2="None" COLUMNS="1" COLGAP="0" NAMEDLST="" SHADE="100" SHADE2="100" GRTYP="0" ROT="0" PLINEART="1" PLINEEND="0" PLINEJOIN="0" LOCALSCX="0.240393979021174" LOCALSCY="0.240393979021174" LOCALX="0" LOCALY="0" PICART="1" PLTSHOW="0" BASEOF="0" textPathType="0" textPathFlipped="0" FLIPPEDH="0" FLIPPEDV="0" SCALETYPE="0" RATIO="1" PRINTABLE="1" ANNOTATION="0" ANNAME="" TEXTFLOWMODE="0" TEXTFLOW="0" TEXTFLOW2="0" TEXTFLOW3="0" AUTOTEXT="0" EXTRA="0" TEXTRA="0" BEXTRA="0" REXTRA="0" FLOP="0" PFILE="../figures/figure_4_paper_perlin/F_orientation_maps_diff_scales_with_ellipse.png" PFILE2="" PFILE3="" PRFILE="" EPROF="" IRENDER="0" EMBEDDED="0" LOCK="0" LOCKR="0" REVERS="0" TransValue="0" TransValueS="0" TransBlend="0" TransBlendS="0" isTableItem="0" TopLine="0" LeftLine="0" RightLine="0" BottomLine="0" isGroupControl="0" NUMDASH="0" DASHS="" DASHOFF="0" NUMPO="16" POCOOR="0 0 0 0 90.7087 0 90.7087 0 90.7087 0 90.7087 0 90.7087 136.063 90.7087 136.063 90.7087 136.063 90.7087 136.063 0 136.063 0 136.063 0 136.063 0 136.063 0 0 0 0 " NUMCO="16" COCOOR="0 0 0 0 90.7087 0 90.7087 0 90.7087 0 90.7087 0 90.7087 136.063 90.7087 136.063 90.7087 136.063 90.7087 136.063 0 136.063 0 136.063 0 136.063 0 136.063 0 0 0 0 " NUMGROUP="0" GROUPS="" startArrowIndex="0" endArrowIndex="0" OnMasterPage="" ImageClip="" ImageRes="1" Pagenumber="0" isInline="0" fillRule="1" doOverprint="0" gXpos="0" gYpos="0" gWidth="0" gHeight="0" LAYER="0" BOOKMARK="0" NEXTITEM="-1" BACKITEM="-1">
             <trail/>
             <PageItemAttributes/>
         </PAGEOBJECT>

+ 51 - 26
scripts/spatial_network/perlin/paper_figures_spatial_head_direction_network_perlin_map.py

@@ -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,