AllenInstitute / AllenSDK

code for reading and processing Allen Institute for Brain Science data
https://allensdk.readthedocs.io/en/latest/
Other
343 stars 149 forks source link

e_pas and cm does not appear to be set in class AllActiveUnits? #1752

Closed torbjone closed 3 years ago

torbjone commented 4 years ago

Describe the bug I could not reproduce the simulated resting potentials of the cell models, like this one: http://celltypes.brain-map.org/experiment/electrophysiology/490387590
(See also this issue: https://github.com/AllenInstitute/bmtk/issues/146 )

After a bit of debugging, I found that it seems that e_pas and cm is not set in the class AllActiveUnits: https://github.com/AllenInstitute/AllenSDK/blob/7dd9dfeb7e7c75172d907d4a95bce3e55e2b3f82/allensdk/model/biophysical/utils.py#L402

They are however set in the corresponding method from the super-class (but this is the overwritten): https://github.com/AllenInstitute/AllenSDK/blob/7dd9dfeb7e7c75172d907d4a95bce3e55e2b3f82/allensdk/model/biophysical/utils.py#L177

Am I using it wrong, or is this a bug?

To Reproduce

import os import neuron from allensdk.model.biophys_sim.config import Config from allensdk.model.biophysical.utils import AllActiveUtils

download_model = True if download_model: from allensdk.api.queries.biophysical_api import BiophysicalApi bp = BiophysicalApi() bp.cache_stimulus = False # change to False to not download the large stimulus NWB file neuronal_model_id = 491623973 # get this from the web site as above bp.cache_data(neuronal_model_id, working_directory='neuronal_model')

model_folder = os.path.join("neuronal_model") neuron.load_mechanisms(model_folder) os.chdir(model_folder) description = Config().load('manifest.json') utils = AllActiveUtils(description, axon_type='stub') h = utils.h manifest = description.manifest morphology_path = manifest.get_path('MORPHOLOGY') utils.generate_morphology(morphology_path.encode('ascii', 'ignore').decode("utf-8")) utils.load_cell_parameters() for sec in neuron.h.allsec(): print(sec.e_pas)

Expected behavior The printed sec.e_pas should have been -93.19329071044922

Actual Behavior The printed sec.e_pas was instead -70.0

Environment (please complete the following information):

tmchartrand commented 3 years ago

@torbjone I believe the problem is that you're using the AllActiveUtils class for a perisomatic model (the cell page you linked only had a perisomatic model available). The create_utils function will create the correct Utils class for a given model, and in your case you'd need the base Utils class. The e_pas variable is specified slightly differently depending on the class of model, so I believe is set later in the load_cell_params function, after the commented out line. If you've seen this issue for all active models also please clarify, otherwise I think it's unrelated to your BMTK issue (which is likely just a junction potential correction, but I'm not positive so will let someone else respond there.)

torbjone commented 3 years ago

Thank you very much! You are right in that if I instead use "from allensdk.model.biophysical.utils import Utils", and then "utils = Utils(description)", then sec.e_pas is indeed set. However, the resting potential of the cell is then about -93.3 mV, insted of the given value of -79.2 mV, which I still find very confusing. I will close this issue, and open another issue on that then. Thanks again!