generate_overlap_matrices.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import numpy as np
  2. from conmorph.connections import save_overlap
  3. from conmorph.neurons import NeuronType, NeuralTissue
  4. from interneuron_polarity.model.morphology.positions import Uniform, Deterministic, UniformOrientation
  5. from interneuron_polarity.model.morphology.shapes import Ellipsoid, NeuralProcess
  6. from interneuron_polarity.model.morphology.volume import NeuralVolume
  7. ### Define the neural volume
  8. voxel_size = 10
  9. v_x = 300
  10. v_y = 300
  11. v_z = 300
  12. V = NeuralVolume(v_x, v_y, v_z, voxel_size)
  13. ### Define neural types with their somata distribution and the axon and dendritic tree shapes
  14. somata_distribution = Uniform(np.array([0,0,0]), np.array([v_x, v_y, v_z]))
  15. excitatory_axon_shape = Ellipsoid(100, 100)
  16. excitatory_axon_orientation = Deterministic(np.array([0, 0, 1]))
  17. excitatory_axon = NeuralProcess(excitatory_axon_shape, excitatory_axon_orientation)
  18. excitatory_dendrite_shape = Ellipsoid(100, 100)
  19. excitatory_dendrite_orientation = Deterministic(np.array([0, 0, 1]))
  20. excitatory_dendrite = NeuralProcess(excitatory_dendrite_shape, excitatory_dendrite_orientation)
  21. circular_inhibitory_axon_shape = Ellipsoid(80, 80)
  22. polar_inhibitory_axon_shape = Ellipsoid(200, 50) #approximately same volume
  23. inhibitory_axon_orientation = UniformOrientation(0, np.pi/2.0, 0, 2*np.pi)
  24. circular_inhibitory_axon = NeuralProcess(circular_inhibitory_axon_shape, inhibitory_axon_orientation)
  25. polar_inhibitory_axon = NeuralProcess(polar_inhibitory_axon_shape, inhibitory_axon_orientation)
  26. inhibitory_dendrite_shape = Ellipsoid(100, 100)
  27. inhibitory_dendrite_orientation = Deterministic(np.array([0, 0, 1]))
  28. inhibitory_dendrite = NeuralProcess(inhibitory_dendrite_shape, inhibitory_dendrite_orientation)
  29. excitatory_population = NeuronType(somata_distribution, excitatory_axon, excitatory_dendrite)
  30. inhibitory_populations = [NeuronType(somata_distribution, inhibitory_axon, inhibitory_dendrite) for inhibitory_axon in [circular_inhibitory_axon, polar_inhibitory_axon]]
  31. ### Calculate the axon-dendrite overlap between all pairs of neurons
  32. number_of_excitatory_neurons = 500
  33. number_of_inhibitory_neurons = 250
  34. tissues = [ NeuralTissue(V, excitatory_population, inhibitory_population) for inhibitory_population in inhibitory_populations]
  35. file_path = "/home/pfeiffer/Projects/subiculum_interneuron_polarity/data"
  36. number_of_overlap_matrices = 2
  37. for tissue, type in zip(tissues, ["circular_inhibitory_neurons", "polar_inhibitory_neurons"]):
  38. for idx in range(number_of_overlap_matrices):
  39. print("Calculate {:s} overlap matrix {:d}/{:d}".format(type, idx+1, number_of_overlap_matrices))
  40. file_name = "{:s}_overlap_matrix_{:d}.pickle".format(type, idx)
  41. path_to_store = file_path + "/" + file_name
  42. overlap_matrix = tissue.calculate_overlap_matrix(number_of_excitatory_neurons, number_of_inhibitory_neurons)
  43. save_overlap(path_to_store, overlap_matrix)