plot_connectivy_matrices.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. morphologies =["polar", "circular"]
  4. image_folder="../reports/images/"
  5. data_folder ="../../data/"
  6. connectivity_dict={}
  7. for c in connectivity:
  8. connectivity_dict[c]={}
  9. for morphology in morphologies:
  10. connectivity_dict[c][morphology] = np.load("{:s}{:s}_connectivity_{:s}.npy".format(data_folder, c, morphology))
  11. connectivity_dict[c]["distances"] = np.load("{:s}{:s}_connectivity_{:s}.npy".format(data_folder, c,
  12. "distance_bins"))
  13. # Plot connectivity matrix with neuron index sorted by their (x,y) coords?
  14. fig=plt.figure()
  15. ax = fig.add_subplot(111)
  16. colors = ["blue", "orange"]
  17. linestyle = ["-", "--" ]
  18. for c, morphology in zip(connectivity, morphologies):
  19. distance_bins = connectivity_dict[c]["distances"]
  20. for morphology, color in zip(morphologies, colors):
  21. number_of_connections = connectivity_dict[c][morphology]
  22. ax.plot(distance_bins[:-1], number_of_connections, label="{:s} {:s}".format(c, morphology), color=color, ls=ls)
  23. ax.grid()
  24. ax.legend()
  25. ax.set_xlabel("Distance (um)")
  26. ax.set_ylabel("Average number of connections")
  27. fig.savefig(image_folder+"distance_dependent_connectivity.png", dpi=300)
  28. # Effective interaction
  29. interaction_first_order = -1.0
  30. interaction_second_order = -interaction_first_order/10.0
  31. fig=plt.figure()
  32. ax = fig.add_subplot(111)
  33. interaction_weights = [interaction_first_order, interaction_second_order]
  34. for morphology, color in zip(morphologies, colors):
  35. distance_bins = connectivity_dict[connectivity[1]]["distances"]
  36. effective_interaction = np.zeros((distance_bins[:-1].shape))
  37. first_order_interaction = interaction_weights[0]*connectivity_dict[connectivity[0]][morphology]
  38. second_order_interaction = interaction_weights[1]*connectivity_dict[connectivity[1]][morphology]
  39. effective_interaction[:first_order_interaction.shape[0]] = first_order_interaction
  40. effective_interaction = effective_interaction+second_order_interaction
  41. ax.plot(distance_bins[1:], effective_interaction, label="weight_fo {:.1f} weight_so {:.1f} {:s}".format(
  42. interaction_first_order, interaction_second_order, morphology),
  43. color=color, ls=ls)
  44. ax.grid()
  45. ax.legend()
  46. ax.set_xlabel("Distance (um)")
  47. ax.set_ylabel("Effective interaction (a.u.)")
  48. fig.savefig(image_folder+"effective_interaction.png", dpi=300)