From b71e8a6a7fd2ac968617221c9ddec040276db11a Mon Sep 17 00:00:00 2001 From: Valeriy Bragin Date: Thu, 31 Mar 2022 22:48:54 +0300 Subject: [PATCH 1/2] added saving and loading 'dipoleSum' where it was missing --- netpyne/sim/gather.py | 6 ++++++ netpyne/sim/save.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/netpyne/sim/gather.py b/netpyne/sim/gather.py index f093ecbd0..598cafa73 100644 --- a/netpyne/sim/gather.py +++ b/netpyne/sim/gather.py @@ -469,6 +469,12 @@ def sort(popKeyAndValue): for p in value: allSimData['LFPPops'][p] += np.array(value[p]) + elif key == 'dipoleSum': + if key not in allSimData.keys(): + allSimData[key] = value + else: + allSimData[key] += value + elif key not in singleNodeVecs: allSimData[key].update(value) diff --git a/netpyne/sim/save.py b/netpyne/sim/save.py index b2299336d..9b4517b6e 100644 --- a/netpyne/sim/save.py +++ b/netpyne/sim/save.py @@ -409,6 +409,8 @@ def intervalSave(simTime, gatherLFP=True): 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])) + elif sim.cfg.recordDipole and k == 'dipoleSum': + sim.allSimData[k] = np.zeros(gather[0]['simData']['dipoleSum'].shape) else: sim.allSimData[k] = {} @@ -437,6 +439,8 @@ 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': + sim.allSimData[key] += val elif key not in singleNodeVecs: sim.allSimData[key].update(val) # update simData dicts which are not Vectors if 'xElectrodeTransferResistances' in node: From 12ce2520e0577cd18d9fa87ab4419c796eaa3ca4 Mon Sep 17 00:00:00 2001 From: Valeriy Bragin Date: Fri, 15 Apr 2022 12:06:38 +0300 Subject: [PATCH 2/2] properly accumulate 'LFPPops' data from nodes --- netpyne/sim/gather.py | 10 ++++++++++ netpyne/sim/save.py | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/netpyne/sim/gather.py b/netpyne/sim/gather.py index 598cafa73..b4e0eb36b 100644 --- a/netpyne/sim/gather.py +++ b/netpyne/sim/gather.py @@ -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': @@ -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: @@ -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': @@ -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: diff --git a/netpyne/sim/save.py b/netpyne/sim/save.py index 9b4517b6e..41fc028e0 100644 --- a/netpyne/sim/save.py +++ b/netpyne/sim/save.py @@ -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])) @@ -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