22import matplotlib .pyplot as plt
33import json
44import os
5-
65def compare_all ():
76 dat_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/RE_reduced_cell_step_test.RE_reduced_cell_pop.v.dat"
87 json_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/RE_reduced_itre_data.json"
98 m_itre_dat_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/m_itre_state.dat"
109 h_itre_dat_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/h_itre_state.dat"
11-
10+ ica_itre_dat_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/itre_iDensity.dat"
11+ caConc_dat_file = "/home/gluciferd/Macaque_auditory_thalamocortical_model_data/NeuroML2/compare_MC/RE/caConc.dat"
12+
1213 dat_data = np .loadtxt (dat_file )
1314 time_dat = dat_data [:, 0 ]
1415 voltage_dat = dat_data [:, 1 ] * 1000
15-
1616 m_itre_dat_data = np .loadtxt (m_itre_dat_file )
1717 time_m_itre_dat = m_itre_dat_data [:, 0 ]
1818 m_itre_dat = m_itre_dat_data [:, 1 ]
19-
2019 h_itre_dat_data = np .loadtxt (h_itre_dat_file )
2120 time_h_itre_dat = h_itre_dat_data [:, 0 ]
2221 h_itre_dat = h_itre_dat_data [:, 1 ]
23-
22+ ica_itre_dat_data = np .loadtxt (ica_itre_dat_file )
23+ time_ica_itre_dat = ica_itre_dat_data [:, 0 ]
24+ ica_itre_dat = ica_itre_dat_data [:, 1 ]
25+ caConc_dat_data = np .loadtxt (caConc_dat_file )
26+ time_caConc_dat = caConc_dat_data [:, 0 ]
27+ caConc_dat = caConc_dat_data [:, 1 ]
28+
2429 with open (json_file , 'r' ) as f :
2530 json_data = json .load (f )
26-
2731 voltage_json = json_data ['simData' ]['V_soma' ]['cell_0' ]
2832 h_itre_json = json_data ['simData' ]['h_itre' ]['cell_0' ]
2933 m_itre_json = json_data ['simData' ]['m_itre' ]['cell_0' ]
30-
34+ ica_itre_json = json_data ['simData' ]['ica_itre' ]['cell_0' ]
35+ caConc_json = json_data ['simData' ]['caConc_itre' ]['cell_0' ]
36+
3137 dt = 1e-5
3238 time_json = np .arange (len (voltage_json )) * dt
33-
34- plt .figure (figsize = (15 , 5 ))
35-
36- plt .subplot (1 , 3 , 1 )
37- plt .plot (time_dat , voltage_dat , 'b-' , label = 'nml Voltage' , linewidth = 2 )
38- plt .plot (time_json , voltage_json , 'r--' , label = 'netpyne Voltage' , linewidth = 1.5 )
39- plt .xlabel ('Time (s)' , fontsize = 10 )
40- plt .ylabel ('Voltage (mV)' , fontsize = 10 )
41- plt .title ('Voltage Comparison' , fontsize = 12 )
42- plt .legend (fontsize = 8 )
43- plt .grid (True , linestyle = '--' , alpha = 0.7 )
44-
45- plt .subplot (1 , 3 , 2 )
46- plt .plot (time_h_itre_dat , h_itre_dat , 'b-' , label = 'nml h_itre' , linewidth = 2 )
47- plt .plot (time_json , h_itre_json , 'r--' , label = 'netpyne h_itre' , linewidth = 1.5 )
48- plt .xlabel ('Time (s)' , fontsize = 10 )
49- plt .ylabel ('h_itre' , fontsize = 10 )
50- plt .title ('h_itre Comparison' , fontsize = 12 )
51- plt .legend (fontsize = 8 )
52- plt .grid (True , linestyle = '--' , alpha = 0.7 )
53-
54- plt .subplot (1 , 3 , 3 )
55- plt .plot (time_m_itre_dat , m_itre_dat , 'b-' , label = 'nml m_itre' , linewidth = 2 )
56- plt .plot (time_json , m_itre_json , 'r--' , label = 'netpyne m_itre' , linewidth = 1.5 )
57- plt .xlabel ('Time (s)' , fontsize = 10 )
58- plt .ylabel ('m_itre' , fontsize = 10 )
59- plt .title ('m_itre Comparison' , fontsize = 12 )
60- plt .legend (fontsize = 8 )
61- plt .grid (True , linestyle = '--' , alpha = 0.7 )
62-
39+
40+ fig , axes = plt .subplots (3 , 2 , figsize = (15 , 15 ))
41+ axes [0 , 0 ].plot (time_dat , voltage_dat , 'b-' , label = 'nml Voltage' , linewidth = 2 )
42+ axes [0 , 0 ].plot (time_json , voltage_json , 'r--' , label = 'netpyne Voltage' , linewidth = 1.5 )
43+ axes [0 , 0 ].set_xlabel ('Time (s)' , fontsize = 10 )
44+ axes [0 , 0 ].set_ylabel ('Voltage (mV)' , fontsize = 10 )
45+ axes [0 , 0 ].set_title ('Voltage Comparison' , fontsize = 12 )
46+ axes [0 , 0 ].legend (fontsize = 8 )
47+ axes [0 , 0 ].grid (True , linestyle = '--' , alpha = 0.7 )
48+ axes [0 , 1 ].plot (time_h_itre_dat , h_itre_dat , 'b-' , label = 'nml h_itre' , linewidth = 2 )
49+ axes [0 , 1 ].plot (time_json , h_itre_json , 'r--' , label = 'netpyne h_itre' , linewidth = 1.5 )
50+ axes [0 , 1 ].set_xlabel ('Time (s)' , fontsize = 10 )
51+ axes [0 , 1 ].set_ylabel ('h_itre' , fontsize = 10 )
52+ axes [0 , 1 ].set_title ('h_itre Comparison' , fontsize = 12 )
53+ axes [0 , 1 ].legend (fontsize = 8 )
54+ axes [0 , 1 ].grid (True , linestyle = '--' , alpha = 0.7 )
55+ axes [1 , 0 ].plot (time_m_itre_dat , m_itre_dat , 'b-' , label = 'nml m_itre' , linewidth = 2 )
56+ axes [1 , 0 ].plot (time_json , m_itre_json , 'r--' , label = 'netpyne m_itre' , linewidth = 1.5 )
57+ axes [1 , 0 ].set_xlabel ('Time (s)' , fontsize = 10 )
58+ axes [1 , 0 ].set_ylabel ('m_itre' , fontsize = 10 )
59+ axes [1 , 0 ].set_title ('m_itre Comparison' , fontsize = 12 )
60+ axes [1 , 0 ].legend (fontsize = 8 )
61+ axes [1 , 0 ].grid (True , linestyle = '--' , alpha = 0.7 )
62+ axes [1 , 1 ].plot (time_ica_itre_dat , ica_itre_dat , 'b-' , label = 'nml ica_itre' , linewidth = 2 )
63+ axes [1 , 1 ].plot (time_json , ica_itre_json , 'r--' , label = 'netpyne ica_itre' , linewidth = 1.5 )
64+ axes [1 , 1 ].set_xlabel ('Time (s)' , fontsize = 10 )
65+ axes [1 , 1 ].set_ylabel ('ica_itre' , fontsize = 10 )
66+ axes [1 , 1 ].set_title ('ica_itre Comparison' , fontsize = 12 )
67+ axes [1 , 1 ].legend (fontsize = 8 )
68+ axes [1 , 1 ].grid (True , linestyle = '--' , alpha = 0.7 )
69+ axes [2 , 0 ].plot (time_caConc_dat , caConc_dat , 'b-' , label = 'nml caConc' , linewidth = 2 )
70+ axes [2 , 0 ].plot (time_json , caConc_json , 'r--' , label = 'netpyne caConc' , linewidth = 1.5 )
71+ axes [2 , 0 ].set_xlabel ('Time (s)' , fontsize = 10 )
72+ axes [2 , 0 ].set_ylabel ('caConc' , fontsize = 10 )
73+ axes [2 , 0 ].set_title ('caConc Comparison' , fontsize = 12 )
74+ axes [2 , 0 ].legend (fontsize = 8 )
75+ axes [2 , 0 ].grid (True , linestyle = '--' , alpha = 0.7 )
76+ axes [2 , 1 ].axis ('off' )
6377 plt .tight_layout ()
6478 current_dir = os .getcwd ()
6579 save_path = os .path .join (current_dir , "compare_all.png" )
6680 plt .savefig (save_path , dpi = 300 , bbox_inches = 'tight' )
6781 plt .show ()
68-
6982if __name__ == "__main__" :
7083 compare_all ()
0 commit comments