Page 1 of 1

Error: kCGErrorInvalidConnection

Posted: Tue Jun 26, 2012 11:21 am
by tseredynski

I am attempting to run the model Meuth et al 2005 ( ... del=121600). However, when I initially run the model (version 4 for instance) the plot only displays data for the first time step and nothing else. On the MacOS I also get the following notifications in Terminal:

Jun 26 10:04:04 dh130141./domain removed/.ca nrniv[2109] <Error>: kCGErrorInvalidConnection: CGSGetWindowTags: Invalid connection
Jun 26 10:04:04 dh130141./domain removed/.ca nrniv[2109] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.

/domain removed/ - inserted myself for privacy; my university hosting site was displayed here.

I found that I can overcome this error by running the simulation once, getting the errors, then reassigning the variable celsius in Terminal, and running the simulation again. After doing so the simulation will run completely and the errors will not occur again.

This is a fairly annoying and time consuming fix, and I feel that I must be doing something wrong or there is an error in code. Is anyone able to give me an indication on what is going on?

Thank you.

PS. To save time, here is the code I am referencing (I've added a few stimuli) from Meuth et al 2005:
v_init = -70
tstop = 1000

create soma
access soma

{L = 30 diam = 20}

insert leak
insert HH
insert iA
insert iC
insert iH
insert iT
insert iNaP
insert iL

celsius = 35

nao = 145
{ki = 135 ko = 3.1}
{cli = 7 clo = 120}

eh= -40

objref stimulus
stimulus = new IClamp(0.5)
stimulus.amp = 0.1
stimulus.del = 200
stimulus.dur = 30

objref stimulus2
stimulus2 = new IClamp(0.5)
stimulus2.amp = 0.2
stimulus2.del = 400
stimulus2.dur = 30

objref stimulus3
stimulus3 = new IClamp(0.5)
stimulus3.amp = 0.3
stimulus3.del = 600
stimulus3.dur = 30


Re: Error: kCGErrorInvalidConnection

Posted: Tue Jun 26, 2012 1:53 pm
by tom_morse

I noticed that one problem is that the variables tau_m,tau_n,tau_h in HH.mod become nan (Not A Number) signifying that something bad has happened in the first time step. I found that if the table macro commands are commented out (with the colon character):
: TABLE m_inf, tau_m, h_inf, tau_h, n_inf, tau_n DEPEND dt,
: celsius FROM -100 TO 100 WITH 200
the problem seems to go away.

Please let me know if this fixes it for you as well.
For completeness here is the updated HH.mod:

Code: Select all

TITLE Hodgkin-Huxley like sodium, potassium, and leak channels

        reference:      McCormick & Huguenard (1992) 
			J.Neurophysiology 68(4), 1384-1400
        found in:       cortical pyramidal cells
        Assembled for MyFirstNEURON by Arthur Houweling

: table macros commented out to see if helps with nan error - TM Morse

        (mA) = (milliamp)
        (mV) = (millivolt)
        SUFFIX HH
        USEION na READ ena WRITE ina
        USEION k READ ek WRITE ik
        RANGE gnabar,gkbar,gl,el,m_inf,h_inf,n_inf,tau_m,tau_n,tau_h,ina,ik 
        v		(mV)
        celsius		(degC)
        dt		(ms)
        gnabar= 0.1	(mho/cm2)
        ena		(mV)
        gkbar= 0.01	(mho/cm2)
        ek		(mV)
        gl= 0		(mho/cm2)
        el		(mV)
        m h n
        ina	(mA/cm2)
        ik	(mA/cm2)
        il	(mA/cm2)
        m_inf h_inf n_inf tau_m tau_h tau_n
        SOLVE states
        ina = gnabar * m*m*m*h * (v - ena)
        ik = gkbar * n*n*n*n * (v - ek)      
        il = gl * (v-el)
	tadj = 3.0^((celsius-23.5)/10)
	m = m_inf
	h = h_inf
	n = n_inf

PROCEDURE states() { 
        m = m + (1-exp(-dt/tau_m)) * (m_inf-m)
        h = h + (1-exp(-dt/tau_h)) * (h_inf-h)
        n = n + (1-exp(-dt/tau_n)) * (n_inf-n)
PROCEDURE rates(v) { LOCAL alpha, beta, q10, tinc
:        TABLE m_inf, tau_m, h_inf, tau_h, n_inf, tau_n DEPEND dt, 
:	      celsius FROM -100 TO 100 WITH 200
	:"m" sodium activation system
          alpha = .091 * vtrap(v+38,5)
          beta =  .062 * vtrap(-(v+38),5) 
       	  tau_m = 1 / (alpha+beta) / tadj
       	  m_inf = alpha/(alpha+beta)
	:"h" sodium inactivation system
       	  alpha = .016 * exp(-(v+55)/15)
       	  beta = 2.07 / (1+exp((17-v)/21))
       	  tau_h = 1 / (alpha+beta) / tadj
       	  h_inf = alpha/(alpha+beta)
	:"n" potassium activation system
       	  alpha = .01*vtrap(v+45,5) 
       	  beta = .17*exp(-(v+50)/40)
       	  tau_n = 1 / (alpha+beta) / tadj
       	  n_inf = alpha/(alpha+beta)
FUNCTION vtrap( x, b) {
	: Traps for 0 in denominator of rate equations
	if (fabs(x/b) < 1e-6) {
	  vtrap = b+x/2 }
	else {
	  vtrap = x / (1-exp(-x/b)) }
PS I found the nan values by starting with a file called added_stimulation.hoc that contained the code you provided above,
clicking on the NEURON main menu:
Tools -> Distributed Mechanisms -> Viewers -> Name Values
and then selecting the additional check boxes: States, Assigned
and then finally double clicking on soma.
A few dialogue boxes appear that then allow the monitoring of many variables.
I also started a Tools -> RunControl and clicked Init and then Single Step.

Re: Error: kCGErrorInvalidConnection

Posted: Tue Jun 26, 2012 2:16 pm
by tseredynski
Hi Tom,

Thank you very much for the help, and for explaining how you trouble shot it! I copied your changes into HH.mod and it does seem to have solved my simulation problem. Oddly those error messages still appear in my Terminal window... but everything seems to be working, so I'm not sure whether to still be concerned or not.

Do you have any inkling why the table macro is problematic? I am fairly new to NEURON and am curious.

- Tyler

Re: Error: kCGErrorInvalidConnection

Posted: Tue Jun 26, 2012 2:35 pm
by tom_morse
Hi Tyler,

You are very welcome. I do not know yet why the TABLE macros were causing trouble. When I googled the Mac error message, for what it's worth, a reply to a request for help at an apple web site stated they were harmless: ... 00020.html


Re: Error: kCGErrorInvalidConnection

Posted: Tue Jun 26, 2012 3:33 pm
by tseredynski
Alright, well that's good to know. Thanks again for all the help.