Browse Source

Restructured pinwheel map scripts

moritz 3 years ago
parent
commit
a8c2b9289d

+ 1 - 1
scripts/spatial_maps/correlation_length_fit/correlation_length_fit.py

@@ -40,7 +40,7 @@ def correlation_length_fit_dict(traj, map_type='perlin_map', load=True):
     if load:
         try:
             fit_correlation_lengths_dict = np.load(DATA_FOLDER + map_type + traj_name + '_fit_correlation_lengths_dict.npy')
-            all_values_there = [scale in fit_correlation_lengths_dict for scale in scale_list]
+            all_values_there = [scale in fit_correlation_lengths_dict.item().keys() for scale in scale_list]
             if all(all_values_there):
                 return fit_correlation_lengths_dict.item()
             print('Some scale values missing in corr. len. fit dictionary, new one will be generated')

+ 22 - 3
scripts/spatial_maps/supplement_max_entropy_rule/figure_max_entropy_rule.py

@@ -1,12 +1,31 @@
 import matplotlib.pyplot as plt
 import numpy as np
 # from scripts.spatial_network.perlin_map.paper_figures_spatial_head_direction_network_perlin_map import FIGURE_SAVE_PATH
-FIGURE_SAVE_PATH = '../../../figures/figure_4_paper_perlin/'
+FIGURE_SAVE_PATH = '../../../figures/supplement_max_entropy/'
 
 from scripts.spatial_network.perlin_map.run_simulation_perlin_map import get_perlin_map
 from scripts.spatial_maps.supplement_max_entropy_rule.spatial_layout import SpatialLayout
-from scripts.spatial_maps.spatial_network_layout import Interneuron, get_excitatory_phases_in_inhibitory_axon, get_position_mesh, plot_neural_sheet
+from scripts.spatial_maps.spatial_network_layout import Interneuron, get_excitatory_phases_in_inhibitory_axon, get_position_mesh
 from scripts.spatial_maps.supplement_max_entropy_rule.spatial_layout import get_entropy
+
+def plot_neural_sheet(ex_positions, ex_tunings, axonal_clouds=None):
+    X, Y = get_position_mesh(ex_positions)
+
+    n_ex = int(np.sqrt(len(ex_positions)))
+    head_dir_preference = np.array(ex_tunings).reshape((n_ex, n_ex))
+
+    fig = plt.figure(figsize=(4, 4))
+    ax = fig.add_subplot(111)
+
+    c = ax.pcolor(X, Y, head_dir_preference, vmin=-np.pi, vmax=np.pi, cmap="twilight")
+    fig.colorbar(c, ax=ax, label="Orientation")
+    if axonal_clouds is not None:
+        for i, p in enumerate(axonal_clouds):
+            ell = p.get_ellipse()
+            # print(ell)
+            ax.add_artist(ell)
+
+
 # Get input map
 
 seed = 1
@@ -70,7 +89,7 @@ import matplotlib
 # In[20]:
 
 
-plt.style.use('../../spatial_network/perlin_map/figures.mplstyle')
+plt.style.use('../../model_figure/figures.mplstyle')
 
 # In[21]:
 

+ 1 - 1
scripts/spatial_maps/supplement_max_entropy_rule/spatial_layout.py

@@ -72,7 +72,7 @@ class SpatialLayout(object):
         self.short_axis = short_axis
         self.sheet_size = sheet_size
 
-        ex_positions, ex_tunings = create_grid_of_excitatory_neurons(sheet_size, sheet_size, int(np.sqrt(NE)),
+        ex_positions, ex_tunings = create_grid_of_excitatory_neurons(sheet_size, int(np.sqrt(NE)),
                                                                      orientation_map)
         self.ex_positions = ex_positions
         self.ex_tunings = ex_tunings