pgleeson commited on
Commit
db52738
·
1 Parent(s): cdb94e2

Added ploting nml outout

Browse files
Files changed (4) hide show
  1. .gitignore +5 -0
  2. app.py +15 -4
  3. model.py +14 -7
  4. requirements.txt +2 -1
.gitignore CHANGED
@@ -1 +1,6 @@
1
  /__pycache__
 
 
 
 
 
 
1
  /__pycache__
2
+ /models/IClamp_GenericMuscleCell.net.nml
3
+ /models/IClamp_GenericNeuronCell.net.nml
4
+ /models/LEMS_Sim_IClamp_GenericMuscleCell.xml
5
+ /report.Sim_IClamp_GenericMuscleCell.txt
6
+ /report.Sim_IClamp_GenericNeuronCell.txt
app.py CHANGED
@@ -127,22 +127,33 @@ with tab_model:
127
  with st.form("form_model"):
128
 
129
  from model import run_model
 
130
 
131
  text = st.text_area("Current injection level:", "4.1 pA")
 
132
 
133
  submitted = st.form_submit_button("Submit")
134
 
135
  if submitted:
 
 
136
  try:
137
- response = run_model(text)
138
- st.info(response)
139
 
140
  import numpy as np
141
  import matplotlib.pyplot as plt
142
 
143
- arr = np.random.normal(1, 1, size=100)
144
  fig, ax = plt.subplots()
145
- ax.hist(arr, bins=20)
 
 
 
 
 
 
 
 
 
 
146
 
147
  st.pyplot(fig)
148
  except Exception as e:
 
127
  with st.form("form_model"):
128
 
129
  from model import run_model
130
+ from model import MODELS
131
 
132
  text = st.text_area("Current injection level:", "4.1 pA")
133
+ model_to_sim = st.selectbox('Model to simulate', list(MODELS.keys()))
134
 
135
  submitted = st.form_submit_button("Submit")
136
 
137
  if submitted:
138
+ response, traces, events = run_model(text, model_to_sim)
139
+ st.info(response)
140
  try:
 
 
141
 
142
  import numpy as np
143
  import matplotlib.pyplot as plt
144
 
 
145
  fig, ax = plt.subplots()
146
+
147
+ for key in sorted(traces.keys()):
148
+ if key != "t":
149
+ ts = traces['t']
150
+ vs = traces[key]
151
+ ax.plot(ts,vs, label=key)
152
+ ax.legend()
153
+
154
+ plt.xlabel("Time (ms)")
155
+ plt.ylabel("(SI units)")
156
+
157
 
158
  st.pyplot(fig)
159
  except Exception as e:
model.py CHANGED
@@ -9,14 +9,19 @@ from neuromllite.utils import load_simulation_json
9
  from neuromllite.utils import load_network_json
10
  from neuromllite.NetworkGenerator import generate_and_run
11
 
12
- def run_model(text, verbose = False):
 
13
 
14
- info = '''Running models with: [%s]...
15
 
16
- '''%text
17
 
18
- sim_file = "models/Sim_IClamp_GenericMuscleCell.json"
19
- net_file = "models/IClamp_GenericMuscleCell.json"
 
 
 
 
20
 
21
  sim = load_simulation_json(sim_file)
22
  net = load_network_json(net_file)
@@ -37,14 +42,16 @@ def run_model(text, verbose = False):
37
  network=net,
38
  simulator="jNeuroML",
39
  base_dir='./models',
 
40
  return_results=True)
41
 
42
- info+="""Results returned: %s"""%(list(traces.keys()))
 
43
 
44
 
45
 
46
  print(info)
47
 
48
- return info
49
 
50
 
 
9
  from neuromllite.utils import load_network_json
10
  from neuromllite.NetworkGenerator import generate_and_run
11
 
12
+ MODELS = {'Muscle model': ["models/Sim_IClamp_GenericMuscleCell.json","models/IClamp_GenericMuscleCell.json"],
13
+ 'Neuron model': ["models/Sim_IClamp_GenericNeuronCell.json","models/IClamp_GenericNeuronCell.json"]}
14
 
15
+ def run_model(text, model, verbose = False):
16
 
17
+ info = '''Running [%s] with parameter: [%s]...
18
 
19
+ '''%(model,text)
20
+
21
+ print(info)
22
+
23
+ sim_file = MODELS[model][0]
24
+ net_file = MODELS[model][1]
25
 
26
  sim = load_simulation_json(sim_file)
27
  net = load_network_json(net_file)
 
42
  network=net,
43
  simulator="jNeuroML",
44
  base_dir='./models',
45
+ target_dir='./models',
46
  return_results=True)
47
 
48
+ #info+="""Results returned: %s"""%(list(traces.keys()))
49
+ info+="""Finished simulation!"""
50
 
51
 
52
 
53
  print(info)
54
 
55
+ return info, traces, events
56
 
57
 
requirements.txt CHANGED
@@ -6,4 +6,5 @@ asyncio
6
  langchain_experimental
7
  wormneuroatlas
8
  neuromllite
9
- matplotlib
 
 
6
  langchain_experimental
7
  wormneuroatlas
8
  neuromllite
9
+ matplotlib
10
+ pylems