Skip to content

Commit

Permalink
properly accumulate 'LFPPops' data from nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
vvbragin committed Apr 15, 2022
1 parent b71e8a6 commit 12ce252
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions netpyne/sim/gather.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def gatherData(gatherLFP=True, gatherDipole=True):
for k in list(gather[0]['simData'].keys()): # initialize all keys of allSimData dict
if gatherLFP and k == 'LFP':
sim.allSimData[k] = np.zeros((gather[0]['simData']['LFP'].shape))
elif gatherLFP and k == 'LFPPops':
sim.allSimData[k] = {p: np.zeros(gather[0]['simData']['LFP'].shape) for p in gather[0]['simData']['LFPPops'].keys()}
elif gatherDipole and k == 'dipoleSum':
sim.allSimData[k] = np.zeros((gather[0]['simData']['dipoleSum'].shape))
elif sim.cfg.recordDipolesHNN and k == 'dipole':
Expand Down Expand Up @@ -136,6 +138,9 @@ def gatherData(gatherLFP=True, gatherDipole=True):
sim.allSimData[key] = list(sim.allSimData[key])+list(val) # udpate simData dicts which are Vectors
elif gatherLFP and key == 'LFP':
sim.allSimData[key] += np.array(val)
elif gatherLFP and key == 'LFPPops':
for p in val:
sim.allSimData[key][p] += np.array(val[p])
elif gatherDipole and key == 'dipoleSum':
sim.allSimData[key] += np.array(val)
elif key not in singleNodeVecs:
Expand Down Expand Up @@ -175,6 +180,8 @@ def gatherData(gatherLFP=True, gatherDipole=True):
for k in list(gather[0]['simData'].keys()): # initialize all keys of allSimData dict
if gatherLFP and k == 'LFP':
sim.allSimData[k] = np.zeros((gather[0]['simData']['LFP'].shape))
elif gatherLFP and k == 'LFPPops':
sim.allSimData[k] = {p: np.zeros(gather[0]['simData']['LFP'].shape) for p in gather[0]['simData']['LFPPops'].keys()}
elif gatherDipole and k == 'dipoleSum':
sim.allSimData[k] = np.zeros((gather[0]['simData']['dipoleSum'].shape))
elif sim.cfg.recordDipolesHNN and k == 'dipole':
Expand Down Expand Up @@ -208,6 +215,9 @@ def gatherData(gatherLFP=True, gatherDipole=True):
sim.allSimData[key] = list(sim.allSimData[key])+list(val) # udpate simData dicts which are Vectors
elif gatherLFP and key == 'LFP':
sim.allSimData[key] += np.array(val)
elif gatherLFP and key == 'LFPPops':
for p in val:
sim.allSimData[key][p] += np.array(val[p])
elif gatherDipole and key == 'dipoleSum':
sim.allSimData[key] += np.array(val)
elif key not in singleNodeVecs:
Expand Down
7 changes: 6 additions & 1 deletion netpyne/sim/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ def intervalSave(simTime, gatherLFP=True):
for k in list(gather[0]['simData'].keys()): # initialize all keys of allSimData dict
if gatherLFP and k == 'LFP':
sim.allSimData[k] = np.zeros((gather[0]['simData']['LFP'].shape))
elif gatherLFP and k == 'LFPPops':
sim.allSimData[k] = {p: np.zeros(gather[0]['simData']['LFP'].shape) for p in gather[0]['simData']['LFPPops'].keys()}
elif sim.cfg.recordDipolesHNN and k == 'dipole':
for dk in sim.cfg.recordDipolesHNN:
sim.allSimData[k][dk] = np.zeros(len(gather[0]['simData']['dipole'][dk]))
Expand Down Expand Up @@ -439,7 +441,10 @@ def intervalSave(simTime, gatherLFP=True):
sim.allSimData[key] = list(sim.allSimData[key])+list(val) # udpate simData dicts which are Vectors
elif gatherLFP and key == 'LFP':
sim.allSimData[key] += np.array(val)
elif sim.cfg.recordDipole and key == 'dipoleSum':
elif gatherLFP and key == 'LFPPops':
for p in val:
sim.allSimData[key][p] += np.array(val[p])
elif key == 'dipoleSum':
sim.allSimData[key] += val
elif key not in singleNodeVecs:
sim.allSimData[key].update(val) # update simData dicts which are not Vectors
Expand Down

0 comments on commit 12ce252

Please sign in to comment.