Help with fixing errors to run modeldb neurons

The basics of how to develop, test, and use models.
Post Reply
fvmillevoi
Posts: 4
Joined: Wed Feb 24, 2021 3:49 pm

Help with fixing errors to run modeldb neurons

Post by fvmillevoi »

Hello!

I am very much a beginner to NEURON with a biology background and little programming experience. I am trying to modify (but firstly run!) the following CA1 models from https://senselab.med.yale.edu/ModelDB/s ... 610#tabs-2 and https://senselab.med.yale.edu/ModelDB/s ... 728#tabs-1.

When I check the files in modlunit, I find several syntax and unit errors. I fixed some of these successfully via previous useful posts but keep hitting errors I don't understand and cannot fix. For example, if i run the start.hoc file (as specified by the creators) from Bloss et al 2016 the following train of errors appear:

Code: Select all

One point section Import3d_Section[2] ending at line 156 has been removed
	and child Import3d_Section[3] reattached
	and child Import3d_Section[4] reattached
/Applications/NEURON-7.8//bin/nrniv: id is not a MECHANISM
 in idMorph.hoc near line 5
 	insert id
          ^
        xopen("idMorph.hoc")
      execute1("{xopen("id...")
    load_file("idMorph.hoc")
/Applications/NEURON-7.8//bin/nrniv: syntax error
 in processMorph.hoc near line 34
 soma.sec { orgSecList.subtree() }
     ^
        xopen("processMor...")
      execute1("{xopen("pr...")
    load_file("processMor...")
/Applications/NEURON-7.8//bin/nrniv: id is not a MECHANISM
 in addChannels.hoc near line 15
 			insert id
            ^
        xopen("addChannels.hoc")
      execute1("{xopen("ad...")
    load_file("addChannels.hoc")
	1 
	0 
/Applications/NEURON-7.8//bin/nrniv: inhSyn is not a template
 in addVgatInhibition.hoc near line 48
 								synVgatAt[synCur-1] = new inhSyn(x)
                                           ^
        xopen("addVgatInh...")
      execute1("{xopen("ad...")
    load_file("addVgatInh...")
/Applications/NEURON-7.8//bin/nrniv: syntax error
 in flagVgatInhibition.hoc near line 127
 		forsec tuftList {
                 ^
        xopen("flagVgatIn...")
      execute1("{xopen("fl...")
    load_file("flagVgatIn...")
/Applications/NEURON-7.8//bin/nrniv: syntax error
 in inhibitionBiophysics.hoc near line 11
 			sstAt_syns(theX) = sstAt_syns(theX) + 1
                     ^
        xopen("inhibition...")
      execute1("{xopen("in...")
    load_file("inhibition...")
/Applications/NEURON-7.8//bin/nrniv: excSyn is not a template
 in addExcitation.hoc near line 50
 								synAmpa[synCur-1] = new excSyn(x)
                                         ^
        xopen("addExcitat...")
      execute1("{xopen("ad...")
    load_file("addExcitat...")
oc>

The morphology loads, but nothing else happens. I am guessing it is due to the fact that the model is not running properly, but the model displays no normal biophysical properties e.g. current injection at the soma makes the neuron model depolarise linearly up to +>100mV!

Then, let's say I take a look at the na3.mod file I tried to modify - I then get this and I have clearly done something very very wrong:

Code: Select all

syntax error:
 Illegal expression:
 Illegal statement:
 Illegal block at line 106 in file /Users/flavia/Desktop/stuff/modeldb/arrayTomography/na3.mod
	a = trap0(vm,tha,Ra,qa)
	 ^
Press 'return' key to close

This is the actual code from the na3.mod file:

Code: Select all

NEURON {
	SUFFIX nax
	USEION na READ ena WRITE ina
	RANGE  gbar, ar2
	GLOBAL minf, hinf, mtau, htau, sinf, taus, qinf, thinf
}

PARAMETER {
	gbar = 0.010   	(mho/cm2)	
								
	tha  =  -30	(mV)		: v 1/2 for act	
	qa   = 7.2	(mV)		: act slope (4.5)		
	Ra   = 0.4	(/ms)		: open (v)		
	Rb   = 0.124 	(/ms)		: close (v)		

	thi1  = -45	(mV)		: v 1/2 for inact 	
	thi2  = -45 	(mV)		: v 1/2 for inact 	
	qd   = 1.5	(mV)	        : inact tau slope
	qg   = 1.5      (mV)
	mmin=0.02	
	hmin=0.5			
	q10=2
	Rg   = 0.01 	(/ms)		: inact recov (v) 	
	Rd   = .03 	(/ms)		: inact (v)	
	qq   = 10        (mV)
	tq   = -55      (mV)

	thinf  = -50 	(mV)		: inact inf slope	
	qinf  = 4 	(mV)		: inact inf slope 

        vhalfs=-60	(mV)		: slow inact.
        a0s=0.0003	(ms)		: a0s=b0s
        zetas=12	(1)
        gms=0.2		(1)
        smax=10		(ms)
        vvh=-58		(mV) 
        vvs=2		(mV)
        celsius         (degC)
        ar2=1		(1)		: 1=no inact., 0=max inact.
	ena		(mV)            : must be explicitly def. in hoc
	v 		(mV)
}


UNITS {
	(mA) = (milliamp)
	(mV) = (millivolt)
	(pS) = (picosiemens)
	(um) = (micron)
} 

ASSIGNED {
	ina 		(mA/cm2)
	thegna		(mho/cm2)
	minf 		hinf 		
	mtau (ms)	htau (ms) 	
	sinf (ms)	taus (ms)
}
 

STATE { m h s}

BREAKPOINT {
        SOLVE states METHOD cnexp
        thegna = gbar*m*m*m*h*s
	ina = thegna * (v - ena)
} 

INITIAL {
	trates(v,ar2)
	m=minf  
	h=hinf
	s=sinf
}


FUNCTION alpv(v(mV)) {
         alpv = 1/(1+exp((v-vvh)/vvs))
}
        
FUNCTION alps(v(mV)) {  
  alps = exp(1.e-3*zetas*(v-vhalfs)*9.648e4/(8.315*(273.16+celsius)))
}

FUNCTION bets(v(mV)) {
  bets = exp(1.e-3*zetas*gms*(v-vhalfs)*9.648e4/(8.315*(273.16+celsius)))
}

LOCAL mexp, hexp, sexp

DERIVATIVE states {   
        trates(v,ar2)      
        m' = (minf-m)/mtau
        h' = (hinf-h)/htau
        s' = (sinf - s)/taus
}

PROCEDURE trates(vm,a2) {  
        LOCAL  a, b, c, qt
        qt=q10^((celsius-24(degC))/(10(degC))
	a = trap0(vm,tha,Ra,qa)
	b = trap0(-vm,-tha,Rb,qa)
	mtau = 1/(a+b)/qt
        if (mtau<mmin) {mtau=mmin}
	minf = a/(a+b)

	a = trap0(vm,thi1,Rd,qd)
	b = trap0(-vm,-thi2,Rg,qg)
	htau =  1/(a+b)/qt
        if (htau<hmin) {htau=hmin}
	hinf = 1/(1+exp((vm-thinf)/qinf))
	c=alpv(vm)
        sinf = c+a2*(1-c)
        taus = bets(vm)/(a0s*(1+alps(vm)))
        if (taus<smax) {taus=smax}
}

FUNCTION trap0(v,th,a,q) {
	if (fabs(v-th) > 1e-6) {
	        trap0 = a * (v - th) / (1 - exp(-(v - th)/q))
	} else {
	        trap0 = a * q
 	}
}	


I am pretty clueless about some things and am trying to learn quickly on a need to know basis. I would really appreciate any help to guide my learning in the right direction. I apologise for the length of this.

Thank you!
Last edited by fvmillevoi on Thu Mar 04, 2021 10:49 am, edited 1 time in total.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Help with fixing errors to run modeldb neurons

Post by ted »

When trying to see if somebody else's code executes, the first thing to do is try executing the code. Don't start tinkering with it or you may break something that didn't need fixing--or worse, destroy a clue to a problem that rendered the original code's results invalid.

The first message "One point section . . . " isn't an error message per se. Instead, it's just Import3d reporting what it did to rectify some iffy stuff in a morphometric data file. Bloss et al. probably felt that this was OK, but I for one would want to check out the original morphometric data to see if these fixes were appropriate.

The first real error message in the program's output, and the only important one, is

Code: Select all

/Applications/NEURON-7.8//bin/nrniv: id is not a MECHANISM
 in idMorph.hoc near line 5
 	insert id
          ^
        xopen("idMorph.hoc")
means that idMorph.hoc expected the existence of a density mechanism (AKA "distributed mechanism") called id. You might already know that a density mechanism (or distributed mechanism) can be defined by a Channel Builder or by code in a mod file. The source code directory contains no ses files, so there are no Channel Builders. But there is a file called id.mod, and its NEURON block starts with the statement
SUFFIX id
so this is the mod file that defines the properties of the distributed mechanism called id. And NEURON won't know anything about id until after id.mod has been compiled with nrnivmodl (or mknrndll).

Advice: start over with the authors' original code, run nrnivmodl (or mknrndll) in the directory that contains all the hoc and mod files, and try executing

nrngui start.hoc

When I did that, all of the "not a MECHANISM" messages vanished, and the program executed without further ado, producing a figure exactly like the one shown in the model entry's readme.html file.

See if compiling the mechanisms of the other model entry allow it to execute properly.


An aside: The model authors seem to be using id to store information about the attributes of whatever section in which it has been inserted. In Python this could be done with a dict, obviating the need for a special distributed mechanism, but that's a different story.


WRT checking user-written mod files with modlunit--

There's a lot of slop in user-written mod files. Much of it is benign, like failure to declare units. Some is not benign, such as failing to include scale factors when parameter and variable units are such that formulas contain real inconsistencies (e.g. in this ODE

y' = (yinf - y)/ytau

where ytau is in seconds (NEURON requires y' to be in units_of_y per ms, not units_of_y per second). Rate functions can become practically unreadable if units assertions are incorporated into them, so users often wrap such functions inside
UNITSOFF . . . UNITSOFF to make modlunit ignore such things, e.g.

UNITSOFF
FUNCTION . . .
FUNCTION . . .
FUNCTION . . .
UNITSON

Otherwise modlunit will stop at the first (often just apparent) unit inconsistency it finds, and you'll never discover the really important error that happens somewhere else.
fvmillevoi
Posts: 4
Joined: Wed Feb 24, 2021 3:49 pm

Re: Help with fixing errors to run modeldb neurons

Post by fvmillevoi »

Hi Ted

Firstly thank you so much! These explanations are very useful and I will address the points you make once I can.

But first, I am unable to compile mod files in mknrndll ... I tried with a few more models and there is a problem I am unable to understand. I was able to successfully compile before, but maybe because I was on a windows 10 system and am now using macOS bigsur?

Code: Select all

/usr/bin/xcrun
/Users/flavia/Desktop/arrayTomography
-n Mod files:
-n  "./dists.mod"
-n  "./eff.mod"
-n  "./exc.mod"
-n  "./id.mod"
-n  "./inh.mod"
-n  "./kad.mod"
-n  "./kap.mod"
-n  "./kdr.mod"
-n  "./na3.mod"
-n  "./nmdaSyn.mod"
-n  "./syns.mod"


COBJS=''
 -> Compiling mod_func.c
x86_64-apple-darwin13.4.0-clang -g  -O2   -I.   -I/Applications/NEURON-7.8//include  -I/usr/local/Cellar/open-mpi/4.0.5/include -fPIC -c mod_func.c -o mod_func.o
 => LINKING shared library ./libnrnmech.dylib
x86_64-apple-darwin13.4.0-clang++ -g  -O2  -std=c++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -fPIC  -I /Applications/NEURON-7.8//include -o ./libnrnmech.dylib -Wl,-install_name,@rpath/libnrnmech.dylib \
	  ./mod_func.o ./dists.o ./eff.o ./exc.o ./id.o ./inh.o ./kad.o ./kap.o ./kdr.o ./na3.o ./nmdaSyn.o ./syns.o  -L/Applications/NEURON-7.8//lib -lnrniv -Wl,-rpath,/Applications/NEURON-7.8//lib    -lreadline
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mech_lib_shared] Error 1
Press 'return' key to close

The same error appears in each case. I am sure this is fairly trivial and I am sorry that I am asking you this!

Thank you again.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Help with fixing errors to run modeldb neurons

Post by ted »

First thing I would do--if I was moving code from a windows box to a mac, I'd get rid of all nrnmech.dll, .o, and .c files that were generated on the PC. Then I'd try nrnivmodl on the Mac. Maybe that doesn't apply to you (maybe you did a fresh download from ModelDB).
fvmillevoi
Posts: 4
Joined: Wed Feb 24, 2021 3:49 pm

Re: Help with fixing errors to run modeldb neurons

Post by fvmillevoi »

Yes so I reinstalled code from modeldb before trying to run it on my mac!
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Help with fixing errors to run modeldb neurons

Post by ramcdougal »

From StackOverflow, it looks like that error could occur from XCode not matching the system version. Try the instructions in the first answer there to see if updating XCode resolves the issue.

(The discussion at the link was for Catalina not Big Sur, but presumably the update Xcode advice should still work.)

For what it's worth, I run 7.8.2 on Big Sur and the ModelDB entries both compile just fine for me. I doubt it matters, but I compile using nrnivmodl from the command line.
fvmillevoi
Posts: 4
Joined: Wed Feb 24, 2021 3:49 pm

Re: Help with fixing errors to run modeldb neurons

Post by fvmillevoi »

I have now removed and reinstalled Xcode and CLTs but nothing has changed. I have also made sure all other prerequisites updated and still no change to the original error when compiling in mknrndll...

Code: Select all

ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mech_lib_shared] Error 1
Not sure if anyone can help on this one ? It seems that other people are having issues with CLTs not being compatible with latest OSX update
Post Reply