def saveUVDistanceForPost(filename, name, p_index, c_index): """ Saves connection length data but for incoming connections of a given post-synaptic neuron, name and p_index therefore also refer to the post-synaptic layer """ object = bpy.data.objects[name] uvs = getUVs(object, p_index) distances = [] axon_lengths = [] number_particles = len(object.particle_systems[p_index].particles) for i, p in enumerate(object.particle_systems[p_index].particles): logger.info('%i / %i' % (i, number_particles)) pre_neurons, synapses = model.getPreIndicesOfPostIndex(c_index, i) distance = [] axon_length = [] for j in range(len(pre_neurons)): distance.append(model.CONNECTION_RESULTS[c_index]['d'][pre_neurons[j]][synapses[j]]) axon_length.append(pam.computeDistance_PreToSynapse(c_index, pre_neurons[j], [synapses[j]])[0]) distances.append(np.mean(distance)) axon_lengths.append(np.mean(axon_length)) f = open(filename, 'w') writer = csv.writer( f, delimiter=";", quoting=csv.QUOTE_NONNUMERIC ) for i, uv in enumerate(uvs): #for d in distances[i]: writer.writerow([uv[0], uv[1], distances[i], axon_lengths[i]]) f.close()
def saveUVDistanceForPost(filename, name, p_index, c_index): """ Saves connection length data but for incoming connections of a given post-synaptic neuron, name and p_index therefore also refer to the post-synaptic layer """ object = bpy.data.objects[name] uvs = getUVs(object, p_index) distances = [] axon_lengths = [] number_particles = len(object.particle_systems[p_index].particles) for i, p in enumerate(object.particle_systems[p_index].particles): logger.info('%i / %i' % (i, number_particles)) pre_neurons, synapses = model.getPreIndicesOfPostIndex(c_index, i) distance = [] axon_length = [] for j in range(len(pre_neurons)): distance.append(model.CONNECTION_RESULTS[c_index]['d'][ pre_neurons[j]][synapses[j]]) axon_length.append( pam.computeDistance_PreToSynapse(c_index, pre_neurons[j], [synapses[j]])[0]) distances.append(np.mean(distance)) axon_lengths.append(np.mean(axon_length)) f = open(filename, 'w') writer = csv.writer(f, delimiter=";", quoting=csv.QUOTE_NONNUMERIC) for i, uv in enumerate(uvs): #for d in distances[i]: writer.writerow([uv[0], uv[1], distances[i], axon_lengths[i]]) f.close()
def saveUVDistance(filename, name, p_index, c_index): uvs, distances = getUVDistance(name, p_index, c_index) no_particles = len(bpy.data.objects[name].particle_systems[p_index].particles) axon_length = [pam.computeDistance_PreToSynapse(c_index, i)[0] for i in range(no_particles)] f = open(filename, 'w') writer = csv.writer( f, delimiter=";", quoting=csv.QUOTE_NONNUMERIC ) for i, uv in enumerate(uvs): #for d in distances[i]: writer.writerow([uv[0], uv[1], distances[i], axon_length[i]]) f.close()
def saveUVDistance(filename, name, p_index, c_index): uvs, distances = getUVDistance(name, p_index, c_index) no_particles = len( bpy.data.objects[name].particle_systems[p_index].particles) axon_length = [ pam.computeDistance_PreToSynapse(c_index, i)[0] for i in range(no_particles) ] f = open(filename, 'w') writer = csv.writer(f, delimiter=";", quoting=csv.QUOTE_NONNUMERIC) for i, uv in enumerate(uvs): #for d in distances[i]: writer.writerow([uv[0], uv[1], distances[i], axon_length[i]]) f.close()