Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'hoc.HocObject' object has no attribute 'instatiate' #289

Open
alexandrapierri opened this issue Sep 6, 2019 · 10 comments
Open

'hoc.HocObject' object has no attribute 'instatiate' #289

alexandrapierri opened this issue Sep 6, 2019 · 10 comments

Comments

@alexandrapierri
Copy link

Hello

I use a hoc cell template with Bluepyopt, called 'class_axoaxoniccell_temp.hoc' attached below, and I run into the following issue when I run my bluepyopt script 'test.py' using my hoc cell template.
error:

  File "/usr/local/lib/python2.7/dist-packages/bluepyopt/ephys/locations.py", line 205, in instantiate
    isectionlist = getattr(icell, self.seclist_name)
AttributeError: 'hoc.HocObject' object has no attribute 'soma_list'

According to locations.py in ephys, 'hoc.HocObject namely 'icell' reflects 'my_cell[0]' in my case. 'my_cell[0]' does have a soma_list attribute which can be found in the hoc code. If for example I explicitly define "somatic_loc=my_cell.soma_list" in the python script, then the code runs just fine, it is when I define somatic_loc using the "class NrnSeclistLocation" as shown in the python script below, that I get the error mentioned above. To me both methods should ultimately call the same object: "my_cell.soma_list" but they don't. Any help with this would be much appreciated.

thank you,
Alexandra

test.py:

"""Expsyn synapse parameter fitting"""

# pylint: disable=R0914

import os

import bluepyopt as bpopt
import bluepyopt.ephys as ephys
import neuron
from neuron import h, gui
import matplotlib.pyplot as plt

h.load_file('class_axoaxoniccell_temp.hoc')
my_cell=h.axoaxoniccell_temp()

morph = ephys.morphologies.NrnFileMorphology('class_axoaxoniccell_temp.hoc') 

somatic_loc = ephys.locations.NrnSeclistLocation('somatic', seclist_name='soma_list')
basal_loc = ephys.locations.NrnSeclistLocation('basal', seclist_name='basal_list')
axonal_loc = ephys.locations.NrnSeclistLocation('axonal', seclist_name='axonal_list')

soma_loc=my_cell.soma[0]
#somatic_loc=my_cell.soma_list  #alternatively if I use this line it works 

ch_KvA_mech = ephys.mechanisms.NrnMODMechanism(
     name='ch_KvA',
     suffix='ch_KvA',
     locations=[soma_loc])#[somatic_loc])
# Non-Frozen Mechanism Parameters
gmax_ch_KvA_param = ephys.parameters.NrnSectionParameter(
    name ='gmax_ch_KvA',
    param_name ='gmax_ch_KvA',
    locations = [somatic_loc],
    value = h.axoaxoniccell_temp().gKvA,
    bounds=[0.00005, 0.00055],
    frozen = False
)

simple_cell = ephys.models.CellModel(
        name='my_cell',
        morph=morph,
        mechs=[ch_KvA_mech],
        params=[gmax_ch_KvA_param])
.....etc

class_axoaxonicell_temp.hoc

begintemplate axoaxoniccell_temp
public init, connect_sections, size_sections, append_sections, define_synapses
public mechinit, insert_mechs, set_biophys, get_root
public pre_list, connect_pre, is_art, is_connected, gid, randi
public soma, dend
public all, basal_list, apical_list, soma_list, axon_list, dendrite_list
public x, y, z, position, myroot, myrootsec, Vrest
public NumSoma, NumApical, NumBasal, NumAxon
public ExpSyn
public celsius


// strings
strdef myroot

// objects
objref syn, pre_list, templist, rootlist, myrootsec, this

// external variables
//external numCellTypes, cellType

// create the sections[segments]
NumSoma=1
NumApical=16
NumBasal=0
NumAxon=0

create soma[NumSoma], dend[NumApical]

proc init() {
        gid = 1
        randi = 2

        // morphology
        connect_sections()      // local fcn: connect soma, dendrites, axon initial segment
        size_sections()         // local fcn: set the size dimensions of each section
        define_shape()          // builtin fcn: fill in 3d info for sections defined by only L and diam, translate 3d points for consistency with their connections
        append_sections()       // local fcn: append all sections to the section list
        set_nseg()                      // local fcn: set the number of segments in each section
        get_root()                      // local fcn: perform morphology checks

        // electrophysiology
        mechinit()                      // local fcn: set values for max conductances and reversal potentials of ion channels and other ephys parameters that are subject to fitting
        insert_mechs()          // local fcn: insert ion channels and actually set values determined in the mechinit fcn
        set_chanparams()        // local fcn: after all channels have been inserted, then their other parameters can be set

        // synapses
        //pre_list = new List() // define a list for the presynaptic connections
        //define_synapses($3)   // local fcn: define all possible synaptic connections received by this cell
        NumSoma=1
        celsius = 37
}
......etc
@wvangeit
Copy link
Contributor

Mmm, if icell really points to your cell template I don't really see what can be wrong.
But are you really sure about ?
"'hoc.HocObject namely 'icell' reflects 'my_cell[0]'" ?
I'm not completely sure about the exact code you use to create the morphology, but could it be that there is maybe some other template involved, that e.g. wraps your template.
I wonder if this
https://github.com/BlueBrain/BluePyOpt/blob/master/bluepyopt/ephys/models.py#L142
is still executed in your case.

@alexandrapierri
Copy link
Author

alexandrapierri commented Sep 11, 2019 via email

@wvangeit
Copy link
Contributor

ok, and if you add print(self.icell.soma_list) it crashes ?
and, print(getattr(self.icell, 'soma_list') ?

@alexandrapierri
Copy link
Author

alexandrapierri commented Sep 12, 2019 via email

@alexandrapierri
Copy link
Author

alexandrapierri commented Sep 12, 2019 via email

@alexandrapierri
Copy link
Author

alexandrapierri commented Sep 12, 2019 via email

@alexandrapierri
Copy link
Author

alexandrapierri commented Sep 12, 2019 via email

@wvangeit
Copy link
Contributor

At least it's used to create the 'icell', as in:
https://github.com/BlueBrain/BluePyOpt/blob/master/bluepyopt/ephys/models.py#L212

Maybe you need to overwrite the create_empty_cell method to make sure it loads your hoc file ?

@wvangeit
Copy link
Contributor

Is there a chance you can send me the code that causes the problem by email ? Then I could see if I can find a solution.

@wvangeit
Copy link
Contributor

Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants