parameter_scan_merged_micro_circuit.py 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import matplotlib.pyplot as plt
  2. from brian2.units import *
  3. from scripts.models import hodgkin_huxley_params, hodgkin_huxley_eqs_with_synaptic_conductance, ih_params, eqs_ih, \
  4. exponential_synapse, exponential_synapse_on_pre, exponential_synapse_params
  5. from scripts.prc_and_iterative_diagram.timed_inhibition import TimedInhibition, bistability_from_iterative_map_merged
  6. from numpy import ndarray,meshgrid
  7. ### With conductance based delta synapse
  8. neuron_eqs = hodgkin_huxley_eqs_with_synaptic_conductance + eqs_ih
  9. synapse_model = exponential_synapse
  10. synapse_on_pre = exponential_synapse_on_pre
  11. synapse_params = exponential_synapse_params
  12. neuron_params = hodgkin_huxley_params
  13. neuron_params.update(ih_params)
  14. neuron_params.update({"E_i": -120 * mV})
  15. spike_threshold = -40 * mV
  16. inhibition_off = 0.0 * nS
  17. inhibition_on = 150 * nS
  18. record_variables = ['v', 'r', 'g_syn']
  19. integration_method = 'exponential_euler'
  20. initial_states = {
  21. "v": hodgkin_huxley_params["El"]
  22. }
  23. current_drive = 0.15 * nA
  24. n_simulations = 50
  25. before_spike = 1 * ms
  26. after_spike = 1 * ms
  27. n_ghbar = 15
  28. ghbar_range = linspace(0.0,50.0,n_ghbar)*nS
  29. n_syn_strength = 15
  30. synaptic_strength_range = linspace(0.0,160.0,n_syn_strength)*nS
  31. bistable_array = ndarray((n_ghbar,n_syn_strength), dtype=float)
  32. # Incredibly, enumerate doesn't work with Quantity objects
  33. syn_str_id = 0
  34. timed_inhibition_experiment = TimedInhibition(neuron_eqs, synapse_model, synapse_on_pre, neuron_params,
  35. synapse_params, initial_states, spike_threshold, integration_method,
  36. current_drive, record_variables)
  37. for synaptic_strength_val in synaptic_strength_range:
  38. inhibition_on = synaptic_strength_val
  39. ghbar_id = 0
  40. for ghbar_val in ghbar_range:
  41. timed_inhibition_experiment.net.restore()
  42. timed_inhibition_experiment.network_params['ghbar'] = ghbar_val
  43. timed_inhibition_experiment.net.store()
  44. period_unperturbed, inhibitory_delay, periods = timed_inhibition_experiment.measure_response_curve(n_simulations,
  45. inhibition_on,
  46. offset_before_spike_peak=before_spike,
  47. offset_after_spike_peak=after_spike)
  48. isbistable = bistability_from_iterative_map_merged(period_unperturbed, inhibitory_delay, periods)
  49. print(synaptic_strength_val,ghbar_val,isbistable)
  50. bistable_array[ghbar_id,syn_str_id] = isbistable
  51. ghbar_id = ghbar_id + 1
  52. syn_str_id = syn_str_id + 1
  53. print(bistable_array)
  54. ### Visualization of the h current role
  55. x,y = meshgrid(ghbar_range / nS,synaptic_strength_range / nS)
  56. # levels = MaxNLocator(nbins=2).tick_values(0.0,1.0)
  57. # cmap = plt.get_cmap('PiYG')
  58. # norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)
  59. fig, ax = plt.subplots(1, 1)
  60. im = ax.pcolormesh(x,y,bistable_array)#, cmap=cmap, norm=norm)
  61. ax.set_title('bistability via iter. map')
  62. ax.set_xlabel('ghbar (nS)')
  63. ax.set_ylabel('syn_strength (nS)')
  64. fig.colorbar(im, ax=ax)
  65. fig.tight_layout()
  66. plt.show()