Skip to content

Commit 48417b2

Browse files
committed
compare individually
1 parent 599e357 commit 48417b2

File tree

7 files changed

+119
-0
lines changed

7 files changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import numpy as np
2+
import matplotlib.pyplot as plt
3+
import json
4+
import os
5+
6+
def plot_individual_comparisons():
7+
dat_file = "RE_reduced_cell_step_test.RE_reduced_cell_pop.v.dat"
8+
json_file = "RE_reduced_hh2_data.json"
9+
ina_hh2_dat_file = "hh2_na_iDensity.dat"
10+
ik_hh2_dat_file = "hh2_k_iDensity.dat"
11+
m_hh2_na_dat_file = "m_hh2_na_state.dat"
12+
h_hh2_na_dat_file = "h_hh2_na_state.dat"
13+
n_hh2_k_dat_file = "n_hh2_k_state.dat"
14+
15+
dat_data = np.loadtxt(dat_file)
16+
time_dat = dat_data[:, 0]
17+
voltage_dat = dat_data[:, 1] * 1000
18+
19+
ina_hh2_dat_data = np.loadtxt(ina_hh2_dat_file)
20+
time_ina_hh2_dat = ina_hh2_dat_data[:, 0]
21+
ina_hh2_dat = ina_hh2_dat_data[:, 1] * -0.1
22+
23+
ik_hh2_dat_data = np.loadtxt(ik_hh2_dat_file)
24+
time_ik_hh2_dat = ik_hh2_dat_data[:, 0]
25+
ik_hh2_dat = ik_hh2_dat_data[:, 1] * -0.1
26+
27+
m_hh2_na_dat_data = np.loadtxt(m_hh2_na_dat_file)
28+
time_m_hh2_na_dat = m_hh2_na_dat_data[:, 0]
29+
m_hh2_na_dat = m_hh2_na_dat_data[:, 1]
30+
31+
h_hh2_na_dat_data = np.loadtxt(h_hh2_na_dat_file)
32+
time_h_hh2_na_dat = h_hh2_na_dat_data[:, 0]
33+
h_hh2_na_dat = h_hh2_na_dat_data[:, 1]
34+
35+
n_hh2_k_dat_data = np.loadtxt(n_hh2_k_dat_file)
36+
time_n_hh2_k_dat = n_hh2_k_dat_data[:, 0]
37+
n_hh2_k_dat = n_hh2_k_dat_data[:, 1]
38+
39+
with open(json_file, 'r') as f:
40+
json_data = json.load(f)
41+
42+
voltage_json = json_data['simData']['V_soma']['cell_0']
43+
ina_hh2_json = json_data['simData']['ina']['cell_0']
44+
ik_hh2_json = json_data['simData']['ik']['cell_0']
45+
m_hh2_na_json = json_data['simData']['m_hh2_na']['cell_0']
46+
h_hh2_na_json = json_data['simData']['h_hh2_na']['cell_0']
47+
n_hh2_k_json = json_data['simData']['n_hh2_k']['cell_0']
48+
49+
dt = 1e-6
50+
time_json = np.arange(len(voltage_json)) * dt
51+
52+
plt.figure(figsize=(10, 6))
53+
plt.plot(time_dat, voltage_dat, 'b-', label='nml Voltage', linewidth=2)
54+
plt.plot(time_json, voltage_json, 'r--', label='netpyne Voltage', linewidth=1.5)
55+
plt.xlabel('Time (s)')
56+
plt.ylabel('Voltage (mV)')
57+
plt.title('Voltage Comparison')
58+
plt.legend()
59+
plt.grid(True, linestyle='--', alpha=0.7)
60+
plt.savefig("voltage_comparison.png", dpi=300, bbox_inches='tight')
61+
plt.close()
62+
63+
plt.figure(figsize=(10, 6))
64+
plt.plot(time_ina_hh2_dat, ina_hh2_dat, 'b-', label='nml ina_hh2', linewidth=2)
65+
plt.plot(time_json, ina_hh2_json, 'r--', label='netpyne ina_hh2', linewidth=1.5)
66+
plt.xlabel('Time (s)')
67+
plt.ylabel('ina_hh2')
68+
plt.title('ina_hh2 Comparison')
69+
plt.legend()
70+
plt.grid(True, linestyle='--', alpha=0.7)
71+
plt.savefig("ina_comparison.png", dpi=300, bbox_inches='tight')
72+
plt.close()
73+
74+
plt.figure(figsize=(10, 6))
75+
plt.plot(time_ik_hh2_dat, ik_hh2_dat, 'b-', label='nml ik_hh2', linewidth=2)
76+
plt.plot(time_json, ik_hh2_json, 'r--', label='netpyne ik_hh2', linewidth=1.5)
77+
plt.xlabel('Time (s)')
78+
plt.ylabel('ik_hh2')
79+
plt.title('ik_hh2 Comparison')
80+
plt.legend()
81+
plt.grid(True, linestyle='--', alpha=0.7)
82+
plt.savefig("ik_comparison.png", dpi=300, bbox_inches='tight')
83+
plt.close()
84+
85+
plt.figure(figsize=(10, 6))
86+
plt.plot(time_m_hh2_na_dat, m_hh2_na_dat, 'b-', label='nml m_hh2_na', linewidth=2)
87+
plt.plot(time_json, m_hh2_na_json, 'r--', label='netpyne m_hh2_na', linewidth=1.5)
88+
plt.xlabel('Time (s)')
89+
plt.ylabel('m_hh2_na')
90+
plt.title('m_hh2_na Comparison')
91+
plt.legend()
92+
plt.grid(True, linestyle='--', alpha=0.7)
93+
plt.savefig("m_hh2_na_comparison.png", dpi=300, bbox_inches='tight')
94+
plt.close()
95+
96+
plt.figure(figsize=(10, 6))
97+
plt.plot(time_h_hh2_na_dat, h_hh2_na_dat, 'b-', label='nml h_hh2_na', linewidth=2)
98+
plt.plot(time_json, h_hh2_na_json, 'r--', label='netpyne h_hh2_na', linewidth=1.5)
99+
plt.xlabel('Time (s)')
100+
plt.ylabel('h_hh2_na')
101+
plt.title('h_hh2_na Comparison')
102+
plt.legend()
103+
plt.grid(True, linestyle='--', alpha=0.7)
104+
plt.savefig("h_hh2_na_comparison.png", dpi=300, bbox_inches='tight')
105+
plt.close()
106+
107+
plt.figure(figsize=(10, 6))
108+
plt.plot(time_n_hh2_k_dat, n_hh2_k_dat, 'b-', label='nml n_hh2_k', linewidth=2)
109+
plt.plot(time_json, n_hh2_k_json, 'r--', label='netpyne n_hh2_k', linewidth=1.5)
110+
plt.xlabel('Time (s)')
111+
plt.ylabel('n_hh2_k')
112+
plt.title('n_hh2_k Comparison')
113+
plt.legend()
114+
plt.grid(True, linestyle='--', alpha=0.7)
115+
plt.savefig("n_hh2_k_comparison.png", dpi=300, bbox_inches='tight')
116+
plt.close()
117+
118+
if __name__ == "__main__":
119+
plot_individual_comparisons()
246 KB
Loading
210 KB
Loading
179 KB
Loading
220 KB
Loading
284 KB
Loading
287 KB
Loading

0 commit comments

Comments
 (0)