Skip to content

Commit

Permalink
fix plot analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
campagnola committed Sep 20, 2022
1 parent 6f61578 commit 75ad332
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions neurodemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@


if __name__ == '__main__':
if '--dbg' in sys.argv:
import pyqtgraph as pg
pg.dbg()

win = DemoWindow(multiprocessing=False)
if (sys.flags.interactive != 1) or not hasattr(QtCore, "PYQT_VERSION"):
QtWidgets.QApplication.instance().exec()
2 changes: 1 addition & 1 deletion neurodemo/clampparam.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,6 @@ def new_result(self, result):
self.triggers.pop(0)
if len(time_arr) > npts:
# If there is data left over, try feeding it to the next trigger
result = dict([(k, result[k][trigger_index+npts :]) for k in result])
result = result[trigger_index+npts:]
self.new_result(result)

23 changes: 21 additions & 2 deletions neurodemo/neuronsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def set_state(self, difeq_state):
self.state = difeq_state

def __getitem__(self, key):
if isinstance(key, slice):
return self.get_slice(key)
# allow lookup by (object, var)
if isinstance(key, tuple):
key = key[0].name + "." + key[1]
Expand All @@ -215,6 +217,9 @@ def __getitem__(self, key):
else:
return self.extra[key]

def keys(self):
return list(self.indexes.keys()) + list(self.dep_vars.keys()) + list(self.extra.keys())

def __contains__(self, key):
# allow lookup by (object, var)
if isinstance(key, tuple):
Expand Down Expand Up @@ -261,8 +266,22 @@ def get_state_at_index(self, index):

return state

def copy(self):
return SimState(self.difeq_vars, self.dep_vars, self.state, self.integrator, **self.extra)
def get_slice(self, sl):
kwds = {'difeq_state': self.state[:, sl]}
for k,v in self.extra.items():
kwds[k] = v[sl]
return self.copy(**kwds)

def copy(self, **kwds):
default_kwds = {
'difeq_vars': self.difeq_vars,
'dep_vars': self.dep_vars,
'difeq_state': self.state,
'integrator': self.integrator,
}
default_kwds.update(self.extra)
default_kwds.update(kwds)
return SimState(**default_kwds)


class SimObject(object):
Expand Down

0 comments on commit 75ad332

Please sign in to comment.