AllenInstitute / sonata

Collaboration between BBP and AIBS
BSD 3-Clause "New" or "Revised" License
54 stars 33 forks source link

NetPyNE simulation results for 9 biophys cell network #63

Open salvadord opened 5 years ago

salvadord commented 5 years ago

Gathering data... Done; gather time = 0.17 s.

Analyzing... Cells: 29 Connections: 180 (6.21 per cell) Synaptic contacts: 755 (26.03 per cell) Spikes: 735 (8.45 Hz) Simulated time: 3.0 s; 1 workers Run time: 3.03 s

wvangeit commented 5 years ago

Would you mind showing the 'expected' bmtk traces in the same plots ?

salvadord commented 5 years ago

comparison

trying to find where differences coming from

I did fix an issue that was preventing v_init from being set, but the results were similar as above.

salvadord commented 5 years ago

9_cell network just with IClamps -- seems like issue must be in reading cell params

comparison

salvadord commented 5 years ago

Checked:

salvadord commented 5 years ago

Would be good to have a SONATA example with simpler cells (eg. just soma or soma+dend) to check the morphology+biophysics more in detail.

wvangeit commented 5 years ago

Could you change the y-scale of the plots a bit, so that we can see the voltage before the stimulus ?

There is already a soma-only cell in here: https://github.com/AllenInstitute/sonata/pull/64 (the run bmtk with this example, this first has to be solved https://github.com/AllenInstitute/bmtk/issues/50)

salvadord commented 5 years ago

Updated y-scale: comparison

wvangeit commented 5 years ago

Did you check the temperature of the simulation ?

salvadord commented 5 years ago

Yes: In [6]: h.celsius Out[6]: 34.0

wvangeit commented 5 years ago

Maybe reversal of sodium / potassium ?

salvadord commented 5 years ago

they match the .nml values:

In [12]: sim.net.cells[0].secs['soma_0']'hObj'.ena Out[12]: 53.0

In [13]: sim.net.cells[0].secs['soma_0']'hObj'.ek Out[13]: -107.0

wvangeit commented 5 years ago

The last thing I can think of atm are the calcium dynamics. (e.g. the calcium concentration at the beginning of the simulation)

salvadord commented 5 years ago

@kaeldai - any update converting the cell biophys params from json to neuroml?

Also in bmtk how would I access the h.Section() objects? I wanna try to inspect them manually (from python terminal) using the new sec.psection() command which gives you detailed info, and compare to the sections in netpyne.

thanks

kaeldai commented 5 years ago

@salvadord - I just did a merge so that the 5_cell_iclamp example uses NeuroML files instead of json. Now every example should use NeuroML.

By default the bmtk (calls the function NMLLoad)[https://github.com/AllenInstitute/bmtk/blob/develop/bmtk/simulator/bionet/default_setters/cell_models.py#L401)] for every cell. Probably the best way to inspect it is to iterate through all the hobj sections before the function returns

for sec in hobj.all:
     # check sec properties here

One thing I noticed is that if I don't cut the axon, ie call aibs_periosomatic, it looks like the bmtk traces match closer to your results (at least gid 6 now has 2 spikes at the end). I want to investigate this further, could you attach (or email me) your voltage traces? If we can get them to line up I think it should be fine to ignore axon-cutting in this example.

salvadord commented 5 years ago

@kaeldai just sent you the netpyne traces by email.

Is there any way in bmtk to access the NEURON Section() of a particular cell instead of iterating over all? Or some way to related the hobj to the cell's gid and connections? eg. similar to netpyne's sim.net.cells[0].secs['soma_0']['hObj'] and sim.net.cells[0].conns

thanks

salvadord commented 5 years ago

@kaeldai can you also post here or upload the bmtk traces without cutting the axon? In theory I'm also cutting the axon in my netpyne code, but I will compare with your results too. thx

salvadord commented 5 years ago

@kaeldai - ok nevermind, just figured out that hobj is inside each cell: e.g. net._rank_node_gids[0]._hobj.all

salvadord commented 5 years ago

@pgleeson - I identified at least one of the issues. The following nml line is not being read by the neuroml.loaders.read_neuroml2_file function: https://github.com/AllenInstitute/sonata/blob/master/examples/shared_components/biophysical_neuron_templates/nml/Cell_472363762.cell.nml#L2

Or at least I cannot find them inside the structure returned (nml_doc.cells[0]).

This results in several of the CaDynamics mech params not being set, eg. decay, gamma, etc.

Any suggestions? Otherwise I'll try to use the same code that BMTK uses to read nml files. thx

pgleeson commented 5 years ago

@salvadord The root cause of this is that the concentrationModel with attributes gamma and depth is not valid NeuroML2. It's a custom ComponentType (see type="CaDynamics") that's defined in a new ComponentType in LEMS for use in the NeuroML file. See here for the definition of the type and examples of Components using it: https://github.com/OpenSourceBrain/BlueBrainProjectShowcase/blob/master/NMC/NeuroML2/CaDynamics_E2_NML2.nml

That file (CaDynamics_E2_NML2.nml) is not technically valid NeuroML, but can of course be included in other NeuroML files, meaning the cell files which use this are valid (the <species concentrationModel="CaDynamics" in the NML chunk used by Sonata is also valid). jNeuroML can load in such valid cell files (e.g. this), interpreting them as LEMS and translate them to Neuron mod & hoc files.

One option might be to try to load the file with PyLEMS (examples: https://github.com/LEMS/pylems/tree/master/examples; though you might have some issue if the root element is <neuroml> not <Lems>) and then you can get the Component CaDynamics and ask what it's Parameters are...

salvadord commented 5 years ago

Adapted the bmtk code to read NeuroML and got a closer match! comparison_v3

Will keep checking to see what's missing now.

wvangeit commented 5 years ago

I see there is a difference at t=0. Could it be that the value of v_init (initial voltage) is set differently ?

salvadord commented 5 years ago

Got perfect match for the 9_cells_iclamp and 9_cells example.

The last issue fixed was in the v_init, which was being set correctly globally, but netpyne was incorrectly importing v_init=-65 for each section. I also fixed some discrepancies in the morphologies, although still some differences. They actually didn't affect these sim results, but could be causing the differences in the 300 example.

9_cells_iclamp: comparison_v4

9_cells: comparison_v4

wvangeit commented 5 years ago

Great !