Pārlūkot izejas kodu

Merge branch 'master' of itbgit.biologie.hu-berlin.de:compneurophys/subiculum_polar_interneurons

moritz 4 gadi atpakaļ
vecāks
revīzija
aa339aa633

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 230 - 0
notebooks/2020-04-06-pfeiffer-avoiding-spatial-overlap-using-differential-evolution-algorithm.ipynb


+ 10 - 24
scripts/spatial_network/run_entropy_maximisation_orientation_map.py

@@ -18,8 +18,6 @@ LOG_FOLDER = "../../logs/"
 
 TRAJ_NAME = "entropy_maximisation_over_different_input_correlation_lengths"
 
-n_exc_test_print = 465
-
 
 def get_orientation_map(correlation_length, seed, sheet_size, N_E):
     traj = Trajectory(filename=DATA_FOLDER + TRAJ_NAME_ORIENTATION_MAPS + ".hdf5")
@@ -44,12 +42,10 @@ def get_orientation_map(correlation_length, seed, sheet_size, N_E):
                          corr_len, sheet_size, sheet_size, seed)
     map.angle_grid = map_angle_grid
 
-    tuning_map = lambda x, y: map.orientation_map(x, y)
-    return tuning_map
+    return map.orientation_map
 
 
-# TODO: Rename to avoid namespace conflicts
-def experiment(traj):
+def spatial_network_with_entropy_maximisation(traj):
     sheet_size = traj.orientation_map.sheet_size
 
     N_E = traj.network.N_E
@@ -64,7 +60,6 @@ def experiment(traj):
     inhibitory_axon_long_axis = traj.morphology.long_axis
     inhibitory_axon_short_axis = traj.morphology.short_axis
 
-    # TODO: Remove one step for circles as it's unnecessary
     entropy_maximisation_steps = traj.simulation.entropy_maximisation.steps if inhibitory_axon_long_axis != \
                                                                                inhibitory_axon_short_axis else 1
 
@@ -79,7 +74,7 @@ def experiment(traj):
     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:
+            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")
@@ -116,16 +111,15 @@ def experiment(traj):
         net.run(traj.simulation.duration * ms)
 
         direction_id = 'dir{:d}'.format(idx)
-        # print(net["excitatory_spike_monitor"].spike_trains()[n_exc_test_print])
         traj.f_add_result(Brian2MonitorResult, '{:s}.spikes.e'.format(direction_id), net["excitatory_spike_monitor"],
                           comment='The spiketimes of the excitatory population')
         traj.f_add_result(Brian2MonitorResult, '{:s}.spikes.i'.format(direction_id), net["inhibitory_spike_monitor"],
                           comment='The spiketimes of the inhibitory population')
     traj.f_add_result('ex_positions', np.array(ex_positions),
-                      comment='The positioons of the excitatory neurons on the sheet')
+                      comment='The positions of the excitatory neurons on the sheet')
     traj.f_add_result('ex_tunings', np.array(ex_tunings),
                       comment='The input tunings of the excitatory neurons')
-    # TODO: Switch to pandas? Nested lists dont work unfortunately
+
     ie_connections_save_array = np.zeros((N_I, N_E))
     for i_idx, ie_conn in enumerate(ie_connections):
         for e_idx in ie_conn:
@@ -133,7 +127,6 @@ def experiment(traj):
     traj.f_add_result('ie_adjacency', ie_connections_save_array,
                       comment='Recurrent connection adjacency matrix')
 
-    # TODO: Somewhat ugly, since the objects can not be saved
     axon_cloud_save_list = [[p.x, p.y, p.phi] for p in inhibitory_axonal_clouds]
     axon_cloud_save_array = np.array(axon_cloud_save_list)
     traj.f_add_result('inhibitory_axonal_cloud_array', axon_cloud_save_array,
@@ -172,10 +165,7 @@ if __name__ == "__main__":
     traj.f_add_parameter("input.number_of_directions", 12, comment="Number of probed directions")
 
     traj.f_add_parameter_group("morphology")
-    traj.f_add_parameter("morphology.long_axis", 100.0, comment="Long axis of axon ellipsoid")  # Should
-    # this rather
-    # be a
-    # parameter, so that it is part of the comparison?
+    traj.f_add_parameter("morphology.long_axis", 100.0, comment="Long axis of axon ellipsoid")
     traj.f_add_parameter("morphology.short_axis", 25.0, comment="Short axis of axon ellipsoid")
 
     traj.f_add_parameter_group("simulation")
@@ -183,8 +173,6 @@ if __name__ == "__main__":
     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")
 
-    # TODO: The Orientation Maps need to be precalculated for these values
-    # TODO: Random seeds need to be added to exploration
     ellipsoid_parameter_exploration = {
         "morphology.long_axis": [100.0],
         "morphology.short_axis": [25.0],
@@ -222,13 +210,11 @@ if __name__ == "__main__":
                                                            no_conn_parameter_exploration]]
     final_dict = {}
 
-    for key in ellipsoid_parameter_exploration.keys():
-        final_dict[key] = [value for l in list(zip(expanded_dicts[0][key], expanded_dicts[1][key], expanded_dicts[2][key])) for value in l]
+    for key in expanded_dicts[0].keys():
+        list_of_parameter_lists = [dict[key] for dict in expanded_dicts]
+        final_dict[key] = sum(list_of_parameter_lists, [])
 
     traj.f_explore(final_dict)
-
-    print(final_dict)
-
-    env.run(experiment)
+    env.run(spatial_network_with_entropy_maximisation)
 
     env.disable_logging()