Error: kCGErrorInvalidConnection

Discussions of particular models.

Moderator: tom_morse

Post Reply
tseredynski

Error: kCGErrorInvalidConnection

Post by tseredynski » Tue Jun 26, 2012 11:21 am

Hello,

I am attempting to run the model Meuth et al 2005 (https://senselab.med.yale.edu/ModelDB/S ... 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:
load_file("nrngui.hoc")
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}

pk_leak=8e-6
gkbar_iA=0.0055
gkbar_iC=0.00018
ghbar_iH=0.0006
eh= -40
pcabar_iT=0.00045
g_iNaP=17e-5


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

psection()

tom_morse
Posts: 40
Joined: Wed May 18, 2005 10:23 pm
Location: Yale University School of Medicine
Contact:

Re: Error: kCGErrorInvalidConnection

Post by tom_morse » Tue Jun 26, 2012 1:53 pm

Hi,

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):
: INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)}
...
: 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

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

: table macros commented out to see if helps with nan error - TM Morse
:INDEPENDENT {t FROM 0 TO 1 WITH 1 (ms)}

UNITS {
        (mA) = (milliamp)
        (mV) = (millivolt)
}
 
NEURON {
        SUFFIX HH
        USEION na READ ena WRITE ina
        USEION k READ ek WRITE ik
        NONSPECIFIC_CURRENT il
        RANGE gnabar,gkbar,gl,el,m_inf,h_inf,n_inf,tau_m,tau_n,tau_h,ina,ik 
}
 
PARAMETER {
        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)
}
 
STATE {
        m h n
}
 
ASSIGNED {
        ina	(mA/cm2)
        ik	(mA/cm2)
        il	(mA/cm2)
        m_inf h_inf n_inf tau_m tau_h tau_n
	tadj
}
 
BREAKPOINT {
        SOLVE states
        ina = gnabar * m*m*m*h * (v - ena)
        ik = gkbar * n*n*n*n * (v - ek)      
        il = gl * (v-el)
}
 
UNITSOFF
INITIAL {
	tadj = 3.0^((celsius-23.5)/10)
	rates(v)
	m = m_inf
	h = h_inf
	n = n_inf
}

PROCEDURE states() { 
        rates(v)   
        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)) }
}
UNITSON
-Tom
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.

tseredynski

Re: Error: kCGErrorInvalidConnection

Post by tseredynski » Tue Jun 26, 2012 2:16 pm

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

tom_morse
Posts: 40
Joined: Wed May 18, 2005 10:23 pm
Location: Yale University School of Medicine
Contact:

Re: Error: kCGErrorInvalidConnection

Post by tom_morse » Tue Jun 26, 2012 2:35 pm

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:

http://lists.apple.com/archives/carbon- ... 00020.html

-Tom

tseredynski

Re: Error: kCGErrorInvalidConnection

Post by tseredynski » Tue Jun 26, 2012 3:33 pm

Alright, well that's good to know. Thanks again for all the help.

Post Reply