suny-downstate-medical-center / netpyne

A Python package to facilitate the development, parallel simulation, optimization and analysis of multiscale biological neuronal networks in NEURON.
http://www.netpyne.org
MIT License
144 stars 135 forks source link

Creating network for M1Detailed fails #733

Closed ddelpiano closed 1 year ago

ddelpiano commented 1 year ago

Describe the bug

Error while instantiating the NetPyNE model
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/git/netpyne-ui/netpyne_ui/netpyne_geppetto.py in instantiateNetPyNEModelInGeppetto(self=<netpyne_ui.netpyne_geppetto.NetPyNEGeppetto object>, args={})
    196                     if self.doIhaveInstOrSimData()['haveInstance']:
    197                         sim.clearAll()
--> 198                     netpyne_model = self.instantiateNetPyNEModel()
        netpyne_model = undefined
        self.instantiateNetPyNEModel = <bound method NetPyNEGeppetto.instantiateNetPyNEModel of <netpyne_ui.netpyne_geppetto.NetPyNEGeppetto object at 0x7feb153431d0>>
    199                     self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
    200 

~/git/netpyne-ui/netpyne_ui/netpyne_geppetto.py in instantiateNetPyNEModel(self=<netpyne_ui.netpyne_geppetto.NetPyNEGeppetto object>)
    696             #netcoded = jsonpickle.encode(self.netParams, unpicklable=False)
    697             #simcoded = jsonpickle.encode(self.simConfig, unpicklable=False)
--> 698             sim.create(self.netParams, self.simConfig)
        global sim.create = <function create at 0x7feac72bcb00>
        self.netParams = <netpyne.specs.netParams.NetParams object at 0x7feac92ac2d0>
        self.simConfig = <netpyne.specs.simConfig.SimConfig object at 0x7feac5f29bd0>
    699             sim.net.defineCellShapes()  # creates 3d pt for cells with stylized geometries
    700             sim.gatherData(gatherLFP=False)

~/git/netpyne-ui/src/netpyne/netpyne/sim/wrappers.py in create(netParams=<netpyne.specs.netParams.NetParams object>, simConfig=<netpyne.specs.simConfig.SimConfig object>, output=False, clearAll=False)
     56     pops = sim.net.createPops()  # instantiate network populations
     57     cells = sim.net.createCells()  # instantiate network cells based on defined populations
---> 58     conns = sim.net.connectCells()  # create connections between cells based on params
        conns = undefined
        sim.net.connectCells = <bound method connectCells of <netpyne.network.network.Network object at 0x7feac973d150>>
     59     stims = sim.net.addStims()  # add external stimulation to cells (IClamps etc)
     60     rxd = sim.net.addRxD()  # add reaction-diffusion (RxD)

~/git/netpyne-ui/src/netpyne/netpyne/network/conn.py in connectCells(self=<netpyne.network.network.Network object>)
    144                 cell.addStimsNEURONObj()
    145                 # cell.addSynMechsNEURONObj()
--> 146                 cell.addConnsNEURONObj()
        cell.addConnsNEURONObj = <bound method CompartCell.addConnsNEURONObj of compartCell_IT_HH_reduced_0>
    147 
    148     nodeSynapses = sum([len(cell.conns) for cell in sim.net.cells])

~/git/netpyne-ui/src/netpyne/netpyne/cell/compartCell.py in addConnsNEURONObj(self=compartCell_IT_HH_reduced_0)
    702 
    703             if not synMech:
--> 704                 synMech = self.addSynMech(conn['synMech'], conn['sec'], conn['loc'])
        synMech = None
        self.addSynMech = <bound method CompartCell.addSynMech of compartCell_IT_HH_reduced_0>
        global conn = undefined
    705                 # continue  # go to next conn
    706 

~/git/netpyne-ui/src/netpyne/netpyne/cell/compartCell.py in addSynMech(self=compartCell_IT_HH_reduced_0, synLabel='AMPA', secLabel='Adend1', loc=0.3333333333333333, preLoc=None)
    829                     sec['synMechs'].append(synMech)
    830                 # add the NEURON object
--> 831                 self.addSynMechNEURONObj(synMech, synLabel, synMechParams, sec, loc, preLoc)
        self.addSynMechNEURONObj = <bound method CompartCell.addSynMechNEURONObj of compartCell_IT_HH_reduced_0>
        synMech = {label: 'AMPA', loc: 0.3333333333333333, mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}
        synLabel = 'AMPA'
        synMechParams = {mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}
        sec = {mechs: {kBK: {tau: 1.0, caPmax: 1.0, caPmin: 0.0, caVhh: 0.002, caVhmin: 43.919142291200004, gpeak: 4.45651933019e-05, caPh: 0.002, caPk: 1.0, k: 17.0, caVhmax: 155.67}, pas: {e: -87.1335623948, g: 7.199592136286027e-05}, cat: {gcatbar: 9.29455717585e-07}, ih: {aslope: 7.09800576233, ascale: 0.00320887293027, bscale: 0.285307415701, gbar: 3.3176340367e-05, ashift: 119.696272155, bslope: 23.2995848558}, kap: {tq: -49.7149526489, gbar: 0.0240195239098, sh: 0.0, vhalfl: -36.7754836348, vhalfn: 32.179925527}, can: {gcanbar: 8.13137955053e-07}, kdr: {gbar: 0.00833766634808, sh: 0.0, vhalfn: 11.6427471384}, cal: {gcalbar: 2.39132864454e-06}, nax: {gbar: 0.0768253702194, sh: 0.0}, cadad: {taur: 99.1146852282, depth: 0.119408607923, kd: 0.0, cainf: 0.00024, kt: 0.0}}, ions: {na: {i: 10.0, e: 42.0, o: 140.0}, ca: {i: 5e-05, e: 132.4579341637009, o: 2.0}, k: {i: 54.4, e: -104.0, o: 2.5}}, geom: {diam: 1.5831889597, cm: 2.74242941886, nseg: 1, L: 96.75, Ra: 70.0015514222, pt3d: [[0, 48.4123467666, 0, 1.5831889597], [0, 145.1623467666, 0, 1.5831889597]]}, topol: {childX: 0.0, parentSec: 'soma', parentX: 1.0}, vinit: -88.7986728464, weightNorm: [0.001289511362519787], hObj: compartCell_IT_HH_reduced_0.Adend1, synMechs: [{label: 'AMPA', loc: 0.3333333333333333, mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}]}
        loc = 0.3333333333333333
        preLoc = None
    832             else:
    833                 synMech = None

~/git/netpyne-ui/src/netpyne/netpyne/cell/compartCell.py in addSynMechNEURONObj(self=compartCell_IT_HH_reduced_0, synMech={label: 'AMPA', loc: 0.3333333333333333, mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}, synMechLabel='AMPA', synMechParams={mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}, sec={mechs: {kBK: {tau: 1.0, caPmax: 1.0, caPmin: 0....od: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}]}, loc=0.3333333333333333, preLoc=None)
    547     def addSynMechNEURONObj(self, synMech, synMechLabel, synMechParams, sec, loc, preLoc=None):
    548         if not synMech.get('hObj'):  # if synMech doesn't have NEURON obj, then create
--> 549             synObj = getattr(h, synMechParams['mod'])
        synObj = undefined
        global getattr = undefined
        global h = <TopLevelHocInterpreter>
        synMechParams = {mod: 'MyExp2SynBB', tau1: 0.05, tau2: 5.3, e: 0}
    550             synMech['hObj'] = synObj(loc, sec=sec['hObj'])  # create h Syn object (eg. h.Exp2Syn)
    551             for synParamName, synParamValue in synMechParams.items():  # add params of the synaptic mechanism

AttributeError: 'hoc.HocObject' object has no attribute 'MyExp2SynBB'

Reproducing the bug

Steps to reproduce the behavior:

  1. Using the UI, install this with the command 'python utilities/install.py --dev --netpyne save_model'
  2. Click on file->open
  3. Load the tutorial M1Detailed in the netpyne/examples folder (branch save_model)
  4. Create network and the error above will show up.

Expected behavior

A clear and concise description of what you expected to happen.

System information

vvbragin commented 1 year ago

Solved by introducing ignoreMechAlreadyExistsError flag to saveModel API (https://github.com/suny-downstate-medical-center/netpyne/commit/e25f676a63b5b1e7dd42dfee3b9e1012e01d6480)