Explorar o código

Aaaaand some more plots

moritz %!s(int64=4) %!d(string=hai) anos
pai
achega
c9779cf3e6

+ 23 - 19
scripts/spatial_network/figures_spatial_head_direction_network_orientation_map.py

@@ -23,6 +23,7 @@ def plot_tuning_curve(traj, direction_idx):
 
     fig, ax = plt.subplots(1, 1)
     for run_idx, run_name in enumerate(traj.f_get_run_names()):
+        label = traj.derived_parameters.runs[run_name].morphology.morph_label
 
         ex_tunings = traj.results.runs[run_name].ex_tunings
         # ex_positions = traj.f_get('ex_positions')
@@ -33,9 +34,6 @@ def plot_tuning_curve(traj, direction_idx):
         sort_ids = ex_tunings_plt.argsort()
         ex_tunings_plt = ex_tunings_plt[sort_ids]
 
-        #TODO: label
-        label = 'still to be done'
-
         firing_rate_array = traj.results[run_name].firing_rate_array
         # firing_rate_array = traj.f_get('firing_rate_array')
 
@@ -52,36 +50,39 @@ def plot_tuning_curve(traj, direction_idx):
     ax.legend()
     ax.set_xlabel("Angles (rad)")
     ax.set_ylabel("f (Hz)")
-
-    plt.show()
+    ax.set_title('tuning curves', fontsize=16)
 
 def plot_firing_rate_map(traj, direction_idx):
 
     fig, axes = plt.subplots(1, 2, figsize=(13.5, 4.5))
     for ax, run_name in zip(axes,traj.f_get_run_names()):
+        label = traj.derived_parameters.runs[run_name].morphology.morph_label
+
         X, Y = get_position_mesh(traj.results.runs[run_name].ex_positions)
         firing_rate_array = traj.results[run_name].firing_rate_array
         number_of_excitatory_neurons_per_row = int(np.sqrt(traj.N_E))
         c = ax.pcolor(X, Y, np.reshape(firing_rate_array[:, direction_idx], (number_of_excitatory_neurons_per_row,
                                                        number_of_excitatory_neurons_per_row)), vmin=0, cmap='hot')
-        ax.set_title('to be done')
+        ax.set_title(label)
         fig.colorbar(c, ax=ax, label="f (Hz)")
+    fig.suptitle('spatial firing rate map', fontsize=16)
 
-    plt.show()
 
 def plot_spatial_hdi_map(traj):
 
     fig, axes = plt.subplots(1, 2, figsize=(13.5, 4.5))
     for ax, run_name in zip(axes,traj.f_get_run_names()):
+        label = traj.derived_parameters.runs[run_name].morphology.morph_label
+
         X, Y = get_position_mesh(traj.results.runs[run_name].ex_positions)
         head_direction_indices = traj.results[run_name].head_direction_indices
         number_of_excitatory_neurons_per_row = int(np.sqrt(traj.N_E))
         c = ax.pcolor(X, Y, np.reshape(head_direction_indices, (number_of_excitatory_neurons_per_row,
                                                        number_of_excitatory_neurons_per_row)), vmin=0, cmap='hot')
-        ax.set_title('to be done')
+        ax.set_title(label)
         fig.colorbar(c, ax=ax, label="f (Hz)")
+    fig.suptitle('spatial HDI map', fontsize=16)
 
-    plt.show()
 
 def plot_neural_sheet(traj):
 
@@ -91,6 +92,8 @@ def plot_neural_sheet(traj):
     for ax, run_name in zip(axes, traj.f_get_run_names()):
         traj.f_set_crun(run_name)
 
+        label = traj.derived_parameters.runs[run_name].morphology.morph_label
+
         X, Y = get_position_mesh(traj.results.runs[run_name].ex_positions)
 
         inhibitory_axonal_cloud_array = traj.results.runs[run_name].inhibitory_axonal_cloud_array
@@ -99,7 +102,7 @@ def plot_neural_sheet(traj):
 
         head_dir_preference = np.array(traj.results.runs[run_name].ex_tunings).reshape((n_ex, n_ex))
         c = ax.pcolor(X, Y, head_dir_preference.T, vmin=-np.pi, vmax=np.pi, cmap='twilight')
-        ax.set_title('to be done')
+        ax.set_title(label)
         fig.colorbar(c, ax=ax, label="Tuning")
 
 
@@ -107,7 +110,7 @@ def plot_neural_sheet(traj):
             for i, p in enumerate(axonal_clouds):
                 ell = p.get_ellipse()
                 ax.add_artist(ell)
-    plt.show()
+    fig.suptitle('axonal cloud', fontsize=16)
 
 def plot_degree_on_sheet(traj):
     n_ex = int(np.sqrt(traj.N_E))
@@ -116,19 +119,18 @@ def plot_degree_on_sheet(traj):
     for ax, run_name in zip(axes, traj.f_get_run_names()):
         traj.f_set_crun(run_name)
 
+        label = traj.derived_parameters.runs[run_name].morphology.morph_label
         X, Y = get_position_mesh(traj.results.runs[run_name].ex_positions)
 
         number_of_excitatory_neurons_per_row = int(np.sqrt(traj.N_E))
         ie_adjacency = traj.results.runs[run_name].ie_adjacency
-        print(ie_adjacency.shape)
         exc_degree = np.sum(ie_adjacency,axis=0)
-        print(exc_degree)
         c = ax.pcolor(X, Y, np.reshape(exc_degree, (number_of_excitatory_neurons_per_row,
                                                        number_of_excitatory_neurons_per_row)), cmap='twilight')
-        ax.set_title('to be done')
+        ax.set_title(label)
         fig.colorbar(c, ax=ax, label="Tuning")
+    fig.suptitle('in/out-degree', fontsize=16)
 
-    plt.show()
 
 if __name__ == "__main__":
     traj = Trajectory(TRAJ_NAME, add_time=False, dynamic_imports=Brian2MonitorResult)
@@ -139,14 +141,16 @@ if __name__ == "__main__":
 
     direction_idx = 6
 
-    # plot_tuning_curve(traj, direction_idx)
+    plot_tuning_curve(traj, direction_idx)
 
-    # plot_firing_rate_map(traj, direction_idx)
+    plot_firing_rate_map(traj, direction_idx)
 
-    # plot_spatial_hdi_map(traj)
+    plot_spatial_hdi_map(traj)
 
-    # plot_neural_sheet(traj)
+    plot_neural_sheet(traj)
 
     plot_degree_on_sheet(traj)
 
+    plt.show()
+
     traj.f_restore_default()

+ 16 - 1
scripts/spatial_network/run_entropy_maximisation_orientation_map.py

@@ -76,6 +76,21 @@ def experiment(traj):
     inhibitory_synapse_strength = traj.synapse.inhibitory * nS
     excitatory_synapse_strength = traj.synapse.excitatory * mV
 
+    if inhibitory_synapse_strength != 0.0 * nS and excitatory_synapse_strength != 0.0 * mV \
+        and inhibitory_axon_long_axis == inhibitory_axon_short_axis:
+        print('circular')
+        traj.f_add_derived_parameter("morphology.morph_label", 'circular',
+                                     comment="Interneuron morphology of this run is circular")
+    elif inhibitory_synapse_strength != 0.0 * nS and excitatory_synapse_strength != 0.0 * mV:
+        print('ellipsoid')
+        traj.f_add_derived_parameter("morphology.morph_label", 'ellipsoid',
+                                     comment="Interneuron morphology of this run is ellipsoid")
+    else:
+        # TODO: implement non-connected case for comparison
+        print('no conn')
+        traj.f_add_derived_parameter("morphology.morph_label", 'no conn',
+                                     comment="There are no interneurons")
+
     ex_in_weights, in_ex_weights = get_synaptic_weights(N_E, N_I, ie_connections, excitatory_synapse_strength,
                                                         inhibitory_synapse_strength)
 
@@ -167,7 +182,7 @@ if __name__ == "__main__":
     traj.f_add_parameter_group("simulation")
     traj.f_add_parameter("simulation.entropy_maximisation.steps", 30, comment="Steps for entropy maximisation")
     traj.f_add_parameter("simulation.dt", 0.1, comment="Network simulation time step in ms")
-    traj.f_add_parameter("simulation.duration", 10, comment="Network simulation duration in ms")
+    traj.f_add_parameter("simulation.duration", 1000, comment="Network simulation duration in ms")
 
     # TODO: The Orientation Maps need to be precalculated for these values
     # TODO: Random seeds need to be added to exploration