def shuffle_weight(path): # path = "/Users/clemens/Documents/Code/ModelClemens/output/11_29-01_52_white_circle_l_vs_r_ALS_smallSTDP/initial" network_architecture = dict(num_inh_neurons_per_layer=32 * 32, num_exc_neurons_per_layer=64 * 64, num_layers=4) synapses = data.load_network(path, True, True) new_weights = synapse_analysis.shuffle_weights_within_layer( synapses, network_architecture, 128**2) raw_new_weights = new_weights.weights.values raw_new_weights.tofile("{}/shuffled_weights.bin".format(path))
def test_paths_to_neuron(): path = "/Users/clemens/Documents/Code/ModelClemens/output/11_29-01_52_white_circle_l_vs_r_ALS_smallSTDP/initial" network_architecture = dict(num_inh_neurons_per_layer=32 * 32, num_exc_neurons_per_layer=64 * 64, num_layers=4) synapses = data.load_network(path, True, True) mask = synapse_analysis.Synapse_Mask(network_architecture, synapses) filter_path = "/Users/clemens/Documents/Code/ModelClemens/Data/MatlabGaborFilter/centered_inputs/Filtered" all_filter = data.load_filter_all_obj(filter_path) bla = synapse_analysis.paths_to_neurons([-3485], synapses, 0.9, max_path_length=3) return bla
def test_masks(self): path = "/Users/clemens/Documents/Code/ModelClemens/output/10_26-18_14_short_test_loc1/initial" synapses = data.load_network(path, True, True) mask = synapse_analyis.Synapse_Mask( dict(num_exc_neurons_per_layer=64 * 64, num_inh_neurons_per_layer=32 * 32, num_layers=4), synapses) exc_FF = mask.exc_feed_forward() exc_FB = mask.exc_feed_back() exc_L = mask.exc_lateral() inh_L = mask.inh_lateral() exc_to_inh_L = mask.exc_to_inhibitory() unique = exc_FF ^ exc_FB ^ exc_L ^ inh_L ^ exc_to_inh_L assert (np.all(unique))
def test_trace_to_gabor(): path = "/Users/clemens/Documents/Code/ModelClemens/output/01_19-18_02_rounded_trained_after_random_pretraining/multi_e275" network_architecture = dict(num_inh_neurons_per_layer=32 * 32, num_exc_neurons_per_layer=64 * 64, num_layers=4) synapses = data.load_network(path, True, True) mask = synapse_analysis.Synapse_Mask(network_architecture, synapses) e2e_ff = mask.exc_feed_forward() bt = synapse_analysis.BackTracer( synapses, network_architecture, percentage_thresholds=[0.1, 0.1, 0.1, 0.1], mask=e2e_ff) result = bt.trace_back(3, 32, 32) return result
def test_spike_correlations(): path = "/Users/clemens/Documents/Code/ModelClemens/output" experiment = "01_11-15_00_long_test_with_trace" extension = "trained_e285" stimuli_ids = data.load_testing_stimuli_dict(path + "/" + experiment + "/" + extension) network_architecture = dict(num_exc_neurons_per_layer=64 * 64, num_inh_neurons_per_layer=32 * 32, num_layers=4) neuron_mask = helper.NeuronMask(network_architecture) synapses = data.load_network(path + "/" + experiment + "/" + extension) spikes = data.load_spikes_from_subfolders(path, [experiment], [extension], False) seperated = helper.splitstimuli(spikes[0][0], 2) selected = helper.take_multiple_elements_from_list(seperated, stimuli_ids["1wcr"]) target_id = helper.position_to_id((1, 19, 10), True, network_architecture) target_id = 9186 # pre_ids = neuron_mask.get_ids_of_random_neurons_of_type(200, neuron_mask.is_excitatory) pre_ids = synapses.pre.values[synapses.post.values == target_id] pre_ids = np.sort(np.unique(pre_ids)) normed_hist, times = poly.population_normalised_pre_spike_hist( stimuli_spikes=selected, target_neuron=target_id, max_time_delay=0.2, time_step=0.002, network_architecture=network_architecture, preneurons=pre_ids, start_time=1.0, multiple_spikes_per_bin_possible=True) hist_new, times = poly.pre_spike_hist( stimuli_spikes=selected, target_neuron=target_id, max_time_delay=0.2, time_step=0.1, preneurons=pre_ids, start_time=1.0, multiple_spikes_per_bin_possible=True) hist_old, times = poly.pre_spike_hist( stimuli_spikes=selected, target_neuron=target_id, max_time_delay=0.02, time_step=0.1, preneurons=pre_ids, start_time=1.0, multiple_spikes_per_bin_possible=False) assert (np.all(hist_new >= hist_old)) print(hist_new.shape)