Error in loading morphology from swc file

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
Feanor
Posts: 26
Joined: Fri Nov 28, 2014 3:03 pm

Error in loading morphology from swc file

Post by Feanor »

Hello everyone!

I just installed NEURON 8.0 on a fresh installation of Ubuntu 20, and am trying to run already existing code. While loading a morphology of a spiny projection neuron I get the following error which did not appear on my previous installation of Ubuntu and NEURON. I am wondering if I have omitted something during the installation.

Code: Select all

error ./morphology/MSN_morphology_D1.swc line 2192: could not parse: 3002 2   7  60  0   0.5  3001
NEURON: Arg out of range in user function
 near line 0
 ^
        Import3d_Section[0].Matrix(3, 0)
      Import3d_Section[0].init(0, 0)
    Import3d_SWC_read[0].mksection(0, 0, 0)
  Import3d_SWC_read[0].mksections()
and others
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/Documents/PhD Studies/Work/Plasticity/Error Backprop/single_run.py in <module>
     24 cell_ID = 70
     25 variables = model_sets[cell_ID]['variables']
---> 26 cell = msn.MSN(variables = variables)
     27 
     28 for d in p.input_dends:

~/Documents/PhD Studies/Work/Plasticity/Error Backprop/d1msn.py in __init__(self, variables)
     21 class MSN(n.Neuron):
     22     def __init__(self, variables = None):
---> 23         self.create_morphology()
     24         self.insert_channels(variables)
     25         self.esyn = []

~/Documents/PhD Studies/Work/Plasticity/Error Backprop/d1msn.py in create_morphology(self)
     30     def create_morphology(self):
     31         Import = h.Import3d_SWC_read()
---> 32         Import.input(morphology)
     33         imprt = h.Import3d_GUI(Import, 0)
     34         imprt.instantiate(None)

RuntimeError: hoc error


I have clipped the error output since it does not fit in a single post. It contains many more error messages of the type "could not parse" (such as the first line of the output).

Thanks!
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Error in loading morphology from swc file

Post by ted »

trying to run already existing code. While loading a morphology of a spiny projection neuron I get the following error
Very strange. The Import3d GUI tool had no problem with this swc file under Linux Mint 20.1 (NEURON 8.0.0 HEAD (429d11ef) 2021-04-30 installed yesterday via pip3) or CentOS 7 with latest updates (NEURON 8.0a-575-gd9462cc master (d9462cc) 2021-05-27 installed a couple months ago from source code). The resulting model cell produced identical responses to an injected current step (Ra 100 ohm cm, cm 1 uf/cm2, pas inserted with e_pas -70 mV and g_pas 1e-4, discretized with d_lambda 0.1 at 100 Hz, IClamp attached to soma with del 1 ms, dur 1e9 ms, amp 0.8 nA).

I guess the next step is to see the code you used to import the swc file.
Feanor
Posts: 26
Joined: Fri Nov 28, 2014 3:03 pm

Re: Error in loading morphology from swc file

Post by Feanor »

Strange indeed. Maybe something in this code I am using has changed throughout different NEURON versions? Hopefully something easy to spot. Here is the code. It is a class that creates a spiny projection neuron (also medium spiny neuron, hence the class name MSN). I am pasting just the beginning of the class where the error shows up.

Code: Select all

from neuron import h
from math import exp
import numpy as np
import json
import neuron_cls as n
import spine as sp
import parameters as p

mod        = "./mod/"
params  = "./params_dMSN.json"
morphology = "./morphology/MSN_morphology_D1.swc"

h.load_file('stdlib.hoc')
h.load_file('import3d.hoc')
h.nrn_load_dll(mod + 'x86_64/.libs/libnrnmech.so')

# ======================= the MSN class ==================================================

class MSN(n.Neuron):
    def __init__(self, variables = None):
        self.create_morphology()
        self.insert_channels(variables)
        self.esyn = []
        self.isyn = []
        self.spines = []
        self.num_spines_on_dends = np.zeros(len(self.dendlist))
        
    def create_morphology(self):    
        Import = h.Import3d_SWC_read()
        Import.input(morphology)
        imprt = h.Import3d_GUI(Import, 0)
        imprt.instantiate(None)
        h.define_shape()
        self.create_sectionlists()
        self.set_nsegs()
                
        h.celsius = 35
        self.v_init = -80
This can be cross-referenced with the error in the beginning of the thread. Let me know if you need the calling script which in line 26 in the error output creates a cell of the MSN class. The error is from the very first function in the __init__ method of the class, i.e. in creating the morphology.

Let me know if this is enough info, or you would like to get a minimal code to reproduce the error.

Thank you!
Feanor
Posts: 26
Joined: Fri Nov 28, 2014 3:03 pm

Re: Error in loading morphology from swc file

Post by Feanor »

OK, I can mark this as resolved now ... I restarted the computer and the same code works now. I have NO idea what happened.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Error in loading morphology from swc file

Post by ted »

Truly a mystery wrapped in an enigma.

A cautionary note:
The MSN class definition contains the statement
h.celsius = 35
It may well be that the MSN class involves one or more mechanisms that assume an operating temperature of 35 deg C, but unfortunately h.celsius is a global variable. What do you think will happen if h.celsius is assigned a different value somewhere in your code, e.g. in some other class definition? You certainly don't want your model's behavior to depend on which
h.celsius = some_value
assignment statement is the last one executed before you initialize and run a simulation.

There are many possible ways to prevent or resolve operating temperature conflicts. One would be for each class to have a built-in local parameter that holds its preferred operating temperature, and built-in functions for discovering and, if necessary, changing that value. Each temperature-sensitive mod file would have to abandon its reference to celsius, and instead use a GLOBAL or RANGE parameter for temperature (why RANGE? suppose you're studying the effects of local temperature variations on excitability or spike propagation). Carrying this to its logical conclusion might also require that each mod file calculate its own ionic equilibrium potentials from a Nernst formula that references the class-specific preferred operating temperature, not celsius. I write "might" because many models simply assume concentrations and equilibrium potentials are constant.
Post Reply