'hoc.HocObject' object has no attribute 'instatiate'
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
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.
thanks Werner
yes the line you pointed to is still present in my version of the code.
I know that my icell =my_cell[0] because I added a line "print self.icell" in models.py to see what my icell reflects.
I'll try to resolve the problem thanks for all help.
Alexandra
From: Werner Van Geit [email protected] Sent: Wednesday, September 11, 2019 9:34 AM To: BlueBrain/BluePyOpt Cc: alexandrapierri; Author Subject: Re: [BlueBrain/BluePyOpt] 'hoc.HocObject' object has no attribute 'instatiate' (#289)
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.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BlueBrain/BluePyOpt/issues/289?email_source=notifications&email_token=ACUVHBBTNJJ5A2MKBWY5643QJDXXRA5CNFSM4IUEEBYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6OQAFA#issuecomment-530382868, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACUVHBFCVOA72EKPMXDRKUDQJDXXRANCNFSM4IUEEBYA.
ok, and if you add print(self.icell.soma_list) it crashes ? and, print(getattr(self.icell, 'soma_list') ?
that's correct.
" print self.icell.soma_list AttributeError: 'hoc.HocObject' object has no attribute 'soma_list'"
I am using your initial version of the code actually. The only changes I have implemented are on the morphology.py such that it can accept "hoc" morphologies.
Alexandra
From: Werner Van Geit [email protected] Sent: Thursday, September 12, 2019 3:47 AM To: BlueBrain/BluePyOpt Cc: alexandrapierri; Author Subject: Re: [BlueBrain/BluePyOpt] 'hoc.HocObject' object has no attribute 'instatiate' (#289)
ok, and if you add print(self.icell.soma_list) it crashes ? and, print(getattr(self.icell, 'soma_list') ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BlueBrain/BluePyOpt/issues/289?email_source=notifications&email_token=ACUVHBGUYIID3OG24YJOHMTQJHX2LA5CNFSM4IUEEBYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Q7QRY#issuecomment-530708551, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACUVHBEP64SPFW75BE7ALYLQJHX2LANCNFSM4IUEEBYA. that's
.... and it is really interesting because the following script (in which I bypass the bluepyopt definitions) works jut fine. I would like to define my hoc object using the bluepyopt classes workflow though for consistency.
" from neuron import h, gui
h.load_file('example.hoc') cell=h.example()#create an instance of this class soma_py=cell.soma[0] soma_list_py=cell.soma_list print cell print soma_py print soma_list_py
stim = h.IClamp(0.5, sec=soma_py) "
Alexandra
From: Werner Van Geit [email protected] Sent: Thursday, September 12, 2019 3:47 AM To: BlueBrain/BluePyOpt Cc: alexandrapierri; Author Subject: Re: [BlueBrain/BluePyOpt] 'hoc.HocObject' object has no attribute 'instatiate' (#289)
ok, and if you add print(self.icell.soma_list) it crashes ? and, print(getattr(self.icell, 'soma_list') ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BlueBrain/BluePyOpt/issues/289?email_source=notifications&email_token=ACUVHBGUYIID3OG24YJOHMTQJHX2LA5CNFSM4IUEEBYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Q7QRY#issuecomment-530708551, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACUVHBEP64SPFW75BE7ALYLQJHX2LANCNFSM4IUEEBYA.
Hi again Werner
I think the problem is that the code creates an empty cell named: my_cell[0] , which is a new empty object that doesn't carry the sections of my initial "my_cell[0]" template. Still investigating but I think I am on a track now.
thanks, Alexandra
From: Werner Van Geit [email protected] Sent: Thursday, September 12, 2019 3:47 AM To: BlueBrain/BluePyOpt Cc: alexandrapierri; Author Subject: Re: [BlueBrain/BluePyOpt] 'hoc.HocObject' object has no attribute 'instatiate' (#289)
ok, and if you add print(self.icell.soma_list) it crashes ? and, print(getattr(self.icell, 'soma_list') ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BlueBrain/BluePyOpt/issues/289?email_source=notifications&email_token=ACUVHBGUYIID3OG24YJOHMTQJHX2LA5CNFSM4IUEEBYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Q7QRY#issuecomment-530708551, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACUVHBEP64SPFW75BE7ALYLQJHX2LANCNFSM4IUEEB
do you think that "def create_empty_cell" creates an empty object that has the name "my_cell" but doesn't actually point to my "my_cell" template? If so any ideas on how I can make it point to it?
thanks a lot, Alexandra
From: Werner Van Geit [email protected] Sent: Thursday, September 12, 2019 3:47 AM To: BlueBrain/BluePyOpt Cc: alexandrapierri; Author Subject: Re: [BlueBrain/BluePyOpt] 'hoc.HocObject' object has no attribute 'instatiate' (#289)
ok, and if you add print(self.icell.soma_list) it crashes ? and, print(getattr(self.icell, 'soma_list') ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BlueBrain/BluePyOpt/issues/289?email_source=notifications&email_token=ACUVHBGUYIID3OG24YJOHMTQJHX2LA5CNFSM4IUEEBYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6Q7QRY#issuecomment-530708551, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACUVHBEP64SPFW75BE7ALYLQJHX2LANCNFSM4IUEEBYA
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 ?
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.
Is this still an issue?