Code running differently (...) [SOLVED]

Post Reply
guillaume

Code running differently (...) [SOLVED]

Post by guillaume »

Hello everyone,
I have just begun working with NEURON, and I have been studying the book and looking at examples of code from people at my lab

one of these examples, however, fails to run on my computer (which is on windows vista), though it works on the ubuntu computer on which it was written



if (xopen("PARAM.hoc")) {}

begintemplate simpleIAFneuron

public soma
public IAF

create soma

objref IAF

proc init() {
soma {
IAF = new Gmodel(0.5)
IAF.Qe = IAF_QE
IAF.Qi = IAF_QI
IAF.tauE = IAF_TAUE
IAF.tauI = IAF_TAUI
IAF.Gl = IAF_GL
IAF.C = IAF_C
IAF.Vthre = IAF_VTHRE
IAF.Vreset = IAF_VRESET
IAF.Ei = IAF_EI
IAF.Ee = IAF_EE
IAF.El = IAF_EL
IAF.refrac = IAF_REFRAC
IAF.start = TSTART

}
}

endtemplate simpleIAFneuron


faulty part is bolded and italicised

capsed variables are actually defined in a parameter file (PARAM.hoc) which is loaded at the beginning of the program via xopen("param.hoc")
but, nrngui says:
nrniv: undefined variable IAF_QE, etc ...

what I really don't understand is that variables defined in PARAM.hoc are accessible pretty much anywhere in my programs except in templates, and that seems to be the case only in windows !

I hope my problem is clear enough: I can provide clarifications if need be

thank you very much for your time !


edit: SOLVED
Last edited by guillaume on Thu Apr 14, 2011 10:41 am, edited 1 time in total.
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Code running differently in Linux and in windows (vista)

Post by ted »

Have you compiled the mod files that your model needs, and are the mechanisms from those mod files being loaded when NEURON starts?
guillaume

Re: Code running differently in Linux and in windows (vista)

Post by guillaume »

Yes

Apparently, the problem is the variables defined in the PARAM.hoc file are not readable from inside a "begintemplate // endtemplate" block though they can be read from anywhere else in the code

I made a clearer example: this creates a test template with 3 fields a, b, c whose values are set by test.init() to be equal to values A, B, C defined in test_param.hoc

test.hoc

Code: Select all

load_file("test_param.hoc")

begintemplate test
	public a, b, c
	
	proc init(){
		a = A
		b = B
		c = C
	}

endtemplate test

objref myTest

myTest = new test()
test_param.hoc

Code: Select all

A = 1
B = 2
C = 3

print "param loaded"
this gives:

NEURON -- Release 7.1 (359:7f113b76a94b) 2009-10-26
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2008
See http://www.neuron.yale.edu/credits.html

param loaded
1
nrniv: undefined variable A
in ~~/test.hoc near line 16
myTest = new test()
^
test[0].init( )

when loaded on my computer
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Code running differently in Linux and in windows (vista)

Post by ted »

In order for code inside a template to access anything that was declared outside a template, you must use an external statement. You'll find more about external and object oriented programming in hoc in the Programmer's Reference
http://www.neuron.yale.edu/neuron/stati ... rogramming
guillaume

Re: Code running differently in Linux and in windows (vista)

Post by guillaume »

This worked, thank you very much

after checking, the code I was given was not the code that worked on the linux computer. Sorry about that.
Post Reply