Skip to content

Commit

Permalink
Added test for net after simulation and resolved bug in cell response
Browse files Browse the repository at this point in the history
  • Loading branch information
raj1701 committed Jun 2, 2023
1 parent 24579aa commit 0053f53
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
21 changes: 19 additions & 2 deletions hnn_core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,8 +1467,16 @@ def _get_cell_response_as_dict(cell_response):
cell_response_data['spike_times'] = cell_response.spike_times
cell_response_data['spike_gids'] = cell_response.spike_gids
cell_response_data['spike_types'] = cell_response.spike_types
cell_response_data['vsec'] = cell_response.vsec
cell_response_data['isec'] = cell_response.isec
vsec_data = cell_response.vsec
cell_response_data['vsec'] = list()
for trial in vsec_data:
trial = dict((str(key), val) for key, val in trial.items())
cell_response_data['vsec'].append(trial)
isec_data = cell_response.isec
cell_response_data['isec'] = list()
for trial in isec_data:
trial = dict((str(key), val) for key, val in trial.items())
cell_response_data['isec'].append(trial)
cell_response_data['times'] = cell_response.times
return cell_response_data

Expand Down Expand Up @@ -1524,6 +1532,15 @@ def _read_cell_response(cell_response_data):
spike_gids=cell_response_data['spike_gids'],
spike_types=cell_response_data['spike_types'])

cell_response._times = cell_response_data['times']
cell_response._vsec = list()
for trial in cell_response_data['vsec']:
trial = dict((int(key), val) for key, val in trial.items())
cell_response._vsec.append(trial)
cell_response._isec = list()
for trial in cell_response_data['isec']:
trial = dict((int(key), val) for key, val in trial.items())
cell_response._isec.append(trial)
return cell_response


Expand Down
14 changes: 14 additions & 0 deletions hnn_core/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@
def test_network_io(tmpdir):
net_jones = jones_2009_model()
add_erp_drives_to_jones_model(net_jones)
net_jones.add_tonic_bias(cell_type='L2_pyramidal', amplitude=1.0)
# Writing network
net_jones.write(tmpdir.join('net_jones.hdf5'))
# Reading network
net_jones_read = read_network(tmpdir.join('net_jones.hdf5'))
assert net_jones == net_jones_read

# Add test to check weights are equal in connections and drives
# Run simulation and simulation output should be same (dipole)

# Simulating network
simulate_dipole(net_jones, tstop=5)
# Writing network
net_jones.write(tmpdir.join('net_jones_sim.hdf5'))
# Reading network
net_jones_sim = read_network(tmpdir.join('net_jones_sim.hdf5'))
assert net_jones == net_jones_sim
# For cell response vsec isec bug
assert net_jones.cell_response.vsec == net_jones_sim.cell_response.vsec


def test_network_models():
""""Test instantiations of the network object"""
Expand Down

0 comments on commit 0053f53

Please sign in to comment.