flag=0 proc err () { xpanel("**** ERROR ****") xlabel($s1) xpanel() } strdef tstr if (unix_mac_pc() == 3) { chdir(neuronhome()) if (chdir("fctb")==0) flag=1 if (chdir("..\fctb")==0) flag=1 if (flag==0) { sprint(tstr,"ERROR: FCTB directory not found; should be in %s or %s/..\n",neuronhome(),neuronhome()) err(tstr) } else if (default_dll_loaded_== 0) { flag = nrn_load_dll("nrnmech.dll") if (flag==1) { default_dll_loaded_ = 1 } else { sprint(tstr,"ERROR loading %s/nrnmech.dll; remake with mknrndll.\n",getcwd()) err(tstr) } } } objref helpbox, helpdeck proc help_list() { helpbox=new HBox(2) helpbox.intercept(1) xpanel("") xbutton("General","helpdeck.flip_to(0)") xbutton("InterViews (the Neuron Graphical User Interface)","helpdeck.flip_to(1)") xbutton("Handling buttons","helpdeck.flip_to(2)") xbutton("Action on the graph","helpdeck.flip_to(3)") xbutton("Graph pull-down menu","helpdeck.flip_to(4)") xbutton("Printing and saving graphics","helpdeck.flip_to(5)") xbutton("Model GUI","helpdeck.flip_to(6)") xbutton("definitions","helpdeck.flip_to(7)") xbutton("GUI Exercises","helpdeck.flip_to(8)") xbutton("Model Exercises","helpdeck.flip_to(9)") xpanel() helpdeck=new Deck() helpdeck.intercept(1) xpanel("") xlabel("This is an interactive version of Fig. 3.2. Since this is the first") xlabel("exercise, I will use it to present the general Graphical User") xlabel("Interface (GUI, pronounced gooey) used by Neuron as well as to") xlabel("present some neurophysiology.") xlabel("") xlabel("The model illustrates inhibitory (IPSP) and excitatory (EPSP)") xlabel("potentials in a neural model. The voltage trace is shown") xlabel("deviating downward with the inhibition and upward with") xlabel("excitations. EPSP#3 produces an action potential (AP, spike).") xlabel("") xpanel() xpanel("") xlabel("The following information is abstracted from the Neuron") xlabel("documentation, which gives a much more detailed treatment of the") xlabel("features of this interactive graphical system. The GUI is based on") xlabel("InterViews, a system developed by Silicon Graphics Inc. and Stanford") xlabel("University. It's great strength is that it allows rapid, complex") xlabel("manipulations of graphs, including multiple views into a single") xlabel("graph. It's greatest weakness is that it can quickly fill up your") xlabel("screen with too many windows. Every window has buttons to \"Close\"") xlabel("or \"Hide\" (iconify) which should be used freely to avoid window") xlabel("overload.") xlabel("") xpanel() xpanel("") xlabel("As seen here, some buttons are associated with numbers and others") xlabel("are not. All of the exercises in this book will have a \"Quit\"") xlabel("button and a \"Help\" button. The \"Help\" button brings up a document") xlabel("like this one which itself has buttons on the left to display") xlabel("various topics. \"General\" will be the first and \"Exercises\" the") xlabel("last help topic for each exercise.") xlabel("") xlabel("The buttons with numbers are a little more complex. In this case,") xlabel("pressing one of the 4 buttons will rerun and redraw the simulation.") xlabel("On most machines, this will happen so fast that you won't see it.") xlabel("") xlabel("Now change the value next to IPSP time from \"2\" to \"10\" (ten). You") xlabel("will need to use the mouse to activate the cursor in this field and") xlabel("then use the delete button to erase the \"2\" before typing in the") xlabel("\"10.\" When you type in the \"10\" nothing will happen. You will need") xlabel("to hit \"RETURN\" or \"ENTER\" or hit the button for the change to take") xlabel("effect. Once this is done, three things happen: 1) a parameter") xlabel("changes for the simulation (in this case the time of the IPSP), 2)") xlabel("the checkbox will have a check which shows that the value has been") xlabel("changed, 3) the simulation will be rerun and the graph redrawn. You") xlabel("will see that the IPSP (the downward lump) will move to the right and") xlabel("be placed just before EPSP#1. The \"IPSP\" label will also move to") xlabel("accompany the lump.") xlabel("") xlabel("Now click on the check mark in the checkbox. This will restore the") xlabel("simulation parameter to it original value (2). The simulation will") xlabel("rerun and the graph will redraw. This brings the simulation back to") xlabel("where we started. Note that the \"Reset\" button will change back all") xlabel("of the parameters while the checkbox will only change back the") xlabel("single parameter. Now, try hitting the checkbox again. This will") xlabel("toggle the parameter back and forth.") xlabel("") xlabel("To the right of each parameter is a little up-arrow and little") xlabel("down-arrow. Pressing the arrow will move the associated parameter") xlabel("up or down, usually (but now always) by one. Starting at the") xlabel("default value (\"Reset\"), change the IPSP to 10 by clicking on the") xlabel("up-arrow 8 times. Watch the IPSP creep across the screen as you do") xlabel("this. ") xlabel("") xlabel("The lowest button on the control panel illustrates the other two") xlabel("types of controls. The button labeled \"Line color\" brings up a") xlabel("pull-down menu. Choosing one of the colors changes the color of the") xlabel("line in the graph and also sets a toggle indicating that this color") xlabel("has been chosen (try it). This is just one style of toggle switch") xlabel("for turning things on and off.") xlabel("") xpanel() xpanel("") xlabel("The mouse can play complicated games on the graph itself, some of") xlabel("which I will detail here. More details are available in Neuron") xlabel("documentation. ") xlabel("") xlabel("In this simulation, the graph is on the left. An x-axis for time") xlabel("(in milliseconds) and a y-axis for voltage (in millivolts) are") xlabel("shown. The curving line is the voltage trace. Put the mouse over") xlabel("this line and click the left mouse button. A crosshair will come up and") xlabel("show the x,y values at that point (if you are too far from the line") xlabel("nothing will happen). This graph is a little busy so you may not be") xlabel("able to see the numbers. If you resize the window by using the") xlabel("tools of your window system (usually dragging on a corner), you may") xlabel("be able to see things more easily. You can follow the values by") xlabel("holding down the left mouse button and running the cursor along the curve.") xlabel("") xlabel("Now go anywhere on the graph and hold down the middle mouse button. By") xlabel("dragging the middle mouse button around the graph will move. Now try the") xlabel("right mouse button. Pushing and holding the right mouse button brings up a very") xlabel("large menu with lots of choices. You can pull the mouse to the") xlabel("right where it says \"View ...\" and get another large menu. Under") xlabel("\"Graph pull-down\", I describe some of them more useful choices. ") xlabel("") xpanel() xpanel("") xlabel("Pushing and holding the right mouse button brings up a menu. Pull right") xlabel("where it says \"View ...\" and there's another menu. Here are some of") xlabel("the more useful choices.") xlabel("") xlabel("Main menu:") xlabel("\"Crosshair\" -- reinstate the crosshair after selecting something else ") xlabel("\"Erase\" -- will erase the curves but not the axes or labels") xlabel("\"Change text\" -- allows you to change a label you click on or place a") xlabel(" new label by clicking on an empty spot") xlabel("Right menu:") xlabel("\"View=plot\" -- brings the curve back into view if it's moved away") xlabel(" (move the graph to the side with middle mouse button and then do \"View=plot\"") xlabel("\"Set view\" -- type in limits for x and y axis") xlabel("\"New view\" -- changes left mouse button to tool for grabbing a piece of graph") xlabel(" (select and then drag left mouse button over the IPSP; when new window") xlabel(" pops up enlarge it [drag on corner] to get a blow-up view)") xlabel("\"Zoom in/out\" -- changes left mouse button to tool for zooming") xlabel("") xlabel("Suggestion: set the choice back to cursor when you're done with") xlabel("using the left mouse button for \"New view\" or for \"Zoom in/out.\"") xlabel("") xpanel() xpanel("") xlabel("A \"Print panel\" button is available under the \"Help\" button. This") xlabel("brings up a printing window. It gives a lot of options. The basics") xlabel("are as follows. The view on the left shows Neuron windows that are") xlabel("available on your screen. If you move a Neuron window in the root") xlabel("window it will move on this left-hand frame. To print something use") xlabel("the left mouse button to select a window you want to print. This") xlabel("window will now show up on the right-hand frame. At this point you") xlabel("can pull-down the menu under \"Print\" (upper left of the window).") xlabel("This gives you a variety of options including \"To printer\" (to") xlabel("printer) and \"PostScript\" (to file). Another useful option is") xlabel("\"Idraw\" which saves in a graphical format that can be edited by a") xlabel("drawing program called \"idraw\" which comes with Neuron.") xlabel("") xpanel() xpanel("") xlabel("The numbers shown in the panel are the times of the IPSPs") xlabel("and EPSPs. Change values by entering numbers or by hitting") xlabel("the arrows to the right of numbers. Remember to hit return or click") xlabel("on the button after changing a numerical value. ") xlabel("") xlabel("The simulation begins with the neuron potential at -70 mV. This is") xlabel("a typical resting potential. The IPSP drives the membrane to a more") xlabel("negative potential of about -73.7 mV (3.7 mV below rest). EPSP#1") xlabel("moves the potential to a less negative potential of about -65.8 mV") xlabel("(4.2 mV above rest). EPSP#2 is bigger -- it bringers the membrane") xlabel("potential up to about -60.7 mV. EPSP#3 is big enough that it") xlabel("exceeds the threshold for firing the neuron and causes an action") xlabel("potential of the cell.") xlabel("") xlabel("Moving the 4 PSPs around") xlabel("") xpanel() xpanel("") xlabel("AP = action potential") xlabel(" Spike in membrane voltage conducted down an axon to transmit") xlabel(" information to other neurons. Also called spike.") xlabel("IPSP = inhibitory postsynaptic potential") xlabel(" A change in membrane voltage due to synaptic activation") xlabel(" that tends to reduce the activity of a postsynaptic neuron.") xlabel(" Usually hyperpolarizing.") xlabel("EPSP = excitatory postsynaptic potential") xlabel(" Depolarization of the postsynaptic membrane potential due") xlabel(" to synaptic action.") xlabel("PSP = postsynaptic potential") xlabel(" Any change in neuron potential caused by synaptic activation.") xlabel("") xpanel() xpanel("") xlabel("1. Use the middle mouse button to center the IPSP on the graph. Now use") xlabel("the right mouse button to reset to \"View ...\" -> \"Zoom in/out.\" Press the") xlabel("left mouse button and move the cursor up and down to make magnify in y or") xlabel("left and right to magnify in x. Recenter (middle mouse button).") xlabel("Reset (button on right panel). Use right mouse button to put menu choice") xlabel("back on \"Crosshair.\" Measure the amplitude of the IPSP (used in") xlabel("exercise below).") xlabel("") xlabel("2. Use right mouse button to select \"View...\"->\"New view.\" Now use left mouse") xlabel("button (down and move) to put a square around EPSP#1. Release to") xlabel("get a new window. Make this window bigger to look closely at") xlabel("EPSP#1. Use right mouse button to select \"View...\"->\"View = plot\" instead") xlabel("of \"Reset\" to get back to previous view. Use right mouse button to put") xlabel("menu choice back on \"Crosshair.\"") xlabel("") xlabel("3. Use right button to select \"View...\"->\"Set view.\" For \"x values,\" enter ") xlabel("\"47 55\" and for \"y values\" \"-70 40.\"") xlabel("") xlabel("4. Use right mouse button to select \"Change text.\" Click on \"time (ms).\"") xlabel("Change the text. Click on a blank spot. Write something profound.") xlabel("") xlabel("5. Erase the curve (right mouse button).") xlabel("") xlabel("6. Click on \"Print panel.\" Print out the graph (it will print out") xlabel("with the buttons on it). Directions for printing are given under") xlabel("Help button \"Printing and saving graphics.\"") xlabel("") xpanel() xpanel("") xlabel("1. Use the cursor to measure the size of the IPSP and of each of the") xlabel("two subthreshold EPSPs (both in absolute magnitude and magnitude") xlabel("relative to rest). Select a half-height location to measure the") xlabel("approximate duration of each signal. (You may find it easier to") xlabel("resize the window or use \"New view\" to make extra windows to measure") xlabel("the sizes. Remember to reselect \"Crosshair\" after making new") xlabel("windows or blowing up the picture.)") xlabel("") xlabel("2. What is the approximate amplitude of EPSP#3. Determine this by") xlabel("finding the point of inflection where the EPSP seems to be") xlabel("flattening out just before the action potential (spike) occurs and") xlabel("produces a rapid voltage change. Firing threshold is somewhere") xlabel("between the amplitude of EPSP#2 and EPSP#3.") xlabel("") xlabel("3. What is the approximate amplitude and duration of the action") xlabel("potential (AP)? What happens after the action potential. What is") xlabel("the approximate amplitude and duration of this potential?") xlabel("") xlabel("4. Reset and move the IPSP to later times. What happens when it") xlabel("overlaps EPSP#1? EPSP#2? EPSP#3?") xlabel("") xlabel("5. Reset and move EPSP#2 to later times. What happens when it") xlabel("overlaps EPSP#2? What does this tell you about the firing") xlabel("threshold?") xlabel("") xlabel("6. Reset and move EPSP#3 to later times. Note the behavior of the") xlabel("spike (action potential) as the time changes. This illustrates a") xlabel("surprising inhibitory effect of a stimulus that is usually") xlabel("excitatory. This phenomenon will be explained in a later chapter.") xlabel("") xlabel("7. Set EPSP#2 to 39. This will switch off the spike since the") xlabel("EPSP#2 near-threshold excitation leaves the membrane \"exhausted\" and") xlabel("unable to respond to EPSP#3. Now move EPSP#2 forward. What happens?") xlabel("Isn't that weird? It shows that the neuron membrane can hold a \"memory\" for") xlabel("preceding events for a relatively long time.") xpanel() helpdeck.intercept(0) helpdeck.map() helpdeck.flip_to(0) helpbox.intercept(0) helpbox.map() } // Created 07/24/09 17:50:27 by "/usr/site/scripts/loadfiles -q -a BR1_psp.hoc" //================================================================ // INSERTED BR1_psp.hoc // =Id= BR1_psp.hoc,v 1.23 2002/10/11 18:23:47 ben Exp // load_file("BR1_psp_.hoc") //================================================================ // INSERTED string2.hoc // =Id= string2.hoc,v 1.1 2002/09/07 12:55:06 billl Exp //*String2 template begintemplate String2 public s,t strdef s,t proc init() { if (numarg() == 1) { s=$s1 } if (numarg() == 2) { s=$s1 t=$s2 } } endtemplate String2 // END string2.hoc //================================================================ //================================================================ // INSERTED bkutils.hoc // =Id= bkutils.hoc,v 1.73 2004/04/30 15:35:32 billl Exp // load_file("stdgui.hoc") // load_file("setup.hoc") load_file("stdrun.hoc") if (name_declared("install_matrix")) execute("install_matrix()") if (name_declared("install_vecst")) execute("install_vecst()") //* objects objref g[4], stim[2], nc, gp, sns, ind, vec0, vec[2], rdm[2], XO, YO, cvode objref st,wt,scr,smat,box[4],insr,nil,sref,tmpfile,tmpobj,tmpvec,tmplist,sfunc,deck strdef mesg,tstr,tstr2,temp_string_,filename,section tmpfile = new File() tmplist = new List() fchooser_flag = 0 graph_flag = 1 double x[4],y[4] rdm = new Random() cvode = new CVode() sfunc = new StringFunctions() { ind=new Vector() vec[0]=ind.c vec[1]=ind.c vec0=ind.c} //* iterators and templates //** string iterator iterator case() { local i i1 = 0 for i = 2, numarg() { $&1 = $i iterator_statement i1+=1 } } iterator scase() { local i i1 = 0 for i = 1, numarg() { temp_string_ = $si iterator_statement i1+=1 } } // eg for scase2("a","b","c","d","e","f") print temp_string_,temp_string2_ iterator scase2() { local i i1 = 0 if (numarg()%2==1) {print "ERROR: scase2 needs even number of args" return } for i = 1, numarg() { tmpobj=new String2() tmpobj.s=$si i+=1 tmpobj.t=$si iterator_statement i1+=1 } } // like perl chop -- removes the last character proc chop () { sfunc.left($s1,sfunc.len($s1)-1) } //** list iterator ltr // usage 'for ltr(XO, tmplist) { print XO }' iterator ltr() { local i if (numarg()==3) {$&3=0} else {i1 = 0} for i = 0, $o2.count() - 1 { $o1 = $o2.object(i) iterator_statement if (numarg()==3) { $&3+=1 } else { i1+=1 } } $o1 = nil } //** list pairwise iterator ltrp // usage 'for ltrp(XO, YO, list) { print XO,YO }' takes them pairwise iterator ltrp() { local i if (numarg()==4) {$&4=0} else {i1 = 0} for (i=0;i<$o3.count()-1;i+=2) { $o1 = $o3.object(i) $o2 = $o3.object(i+1) iterator_statement if (numarg()==4) { $&4+=1 } else { i1+=1 } } $o1=nil $o2=nil } //** vector iterator vtr // usage 'for vtr(&x, vec) { print x }' iterator vtr() { local i if (numarg()==3) {$&3=0} else {i1 = 0} for i = 0, $o2.size() - 1 { $&1 = $o2.x[i] iterator_statement if (numarg()==3) { $&3+=1 } else { i1+=1 } } } //* vlk(vec) -- display vector slice -- more flexible than vec.printf // vlk(vec,max) // vlk(vec,min,max) // prints out a segment of a vector vlk_width=20 proc vlk () { local i,j,min,max,dual,wdh,nonl,nl j=dual=0 nl=1 wdh=vlk_width if (numarg()==1) { min=0 max=$o1.size-1 } if (numarg()==2) if ($2==0) { nl=min=0 max=$o1.size-1 // vlk(vec,0) flag to suppress new lines } else if ($2>0) { min=0 max=$2-1 } else { min=$o1.size+$2 max=$o1.size-1 } if (numarg()==3) if ($3>-1) { min=$2 max=$3 } else { min=0 max=$o1.size-1 dual=1 } if (numarg()==4) { min=$3 max=$4 dual=1 } if (min<0) min=0 if (max>$o1.size-1) max=$o1.size-1 if (dual) if (max>$o2.size-1) max=$o2.size-1 for i=min,max { if (dual) printf("%g:%g ",$o1.x[i],$o2.x[i]) else printf("%g ",$o1.x[i]) if ((j=j+1)%vlk_width==0 && nl) { print "" } } if (nl) print "" } //** savevec([list,]vec1[,vec2,...]) add vector onto veclist or other list if given as 1st arg objref veclist veclist = new List() proc savevec () { local i,flag,beg if (isobj($o1,"List")) beg=2 else beg=1 for i=beg, numarg() { tmpvec = new Vector($oi.size) tmpvec.copy($oi) if (beg==2) $o1.append(tmpvec) else veclist.append(tmpvec) tmpvec = nil } } //* graphics; symbols and colors {symnum = 7 colnum = 9} objectvar cl[colnum], sym[symnum] for ii=0,colnum-1 cl[ii]=new String() { cl[0].s ="white" cl[1].s ="black" cl[2].s ="red" cl[3].s ="blue" cl[4].s ="green" cl[5].s ="orange" cl[6].s ="brown" cl[7].s ="violet" cl[8].s ="yellow" } for ii=0,symnum-1 sym[ii]=new String() { sym[0].s = "o" sym[1].s = "t" sym[2].s = "s" sym[3].s = "O" sym[4].s = "T" sym[5].s = "S" sym[6].s = "+"} gcl=0 // graph color func color () { gcl = (gcl+1)%colnum if (gcl==0) gcl=1 // throw out white if (numarg()==1) $o1.color(gcl) return gcl } //** qhp() basic buttons proc qhp () { if (numarg()==1) xpanel("CONTROLS",1) xbutton("Quit","quit()") xbutton("Help","help_list()") xbutton("Print panel","pwman_place(50,50)") xbutton("Reset","reset()") if (numarg()==1) xvarlabel(mesg) if (numarg()==1) xpanel(0,0) mesg="" } //** allgraphs() proc remgrs () { local ii for ii=0,3 graphList[ii].remove_all() objref graphItem } proc allgraphs () { for ii=0,3 for ltr(XO,graphList[ii]) XO.exec_menu($s1) } proc vp() { allgraphs("View = plot") } proc allgrop () { for ii=0,3 for ltr(XO,graphList[ii]) { sprint(tstr,"%s.%s",XO,$s1) execute(tstr) } } //** grrtsize() use view=plot and then pad a little proc grrtsize () { local h,w,frac if (numarg()>=1) tmpobj=$o1 else tmpobj=graphItem if (numarg()>=2) frac = $2 else frac=.05 tmpobj.exec_menu("View = plot") tmpobj.size(&x) w=frac*(x[1]-x[0]) h=frac*(x[3]-x[2]) x[0]-=2*w x[1]+=w x[2]-=4*h x[3]+=h // need extra padding on bottom tmpobj.size(x[0],x[1],x[2],x[3]) } //** isobj(o1,s2) checks whether object $o1 is of type $s2 func isobj () { sprint(temp_string_,"%s",$o1) if (sfunc.substr(temp_string_,$s2)==0) { return 1 } else { return 0 } } // cbin(min,max): binary colormap proc cbin () { $o1.colormap(2) $o1.colormap(0, 255, 0, 0) $o1.colormap(1, 255, 255, 0) $o1.scale($2, $3) } // my version of newPlotV() leaves off the label proc newplotv () { newplot() graphItem.addvar("","v(.5)",1,3) } proc redraw0 () { plrdrf=0 } // stub with flag proc plcback () { } // callback objref oxv,oyv // coordinates: 0,1 line start; 2,3 last loc oxv=new Vector(2) oyv=new Vector(2) plrdrf=1 // flag will be unset if using redraw stub plhorz=0 // 1 for horizontal, 2 for verticle lines proc pl () { if ($1==2) { // mouse down -- new line redraw0() // unset plrdrf if redraw0() not overwritten oxv.x[0]=oxv.x[1]=$2 oyv.x[0]=oyv.x[1]=$3 } else { if (plrdrf) graphItem.erase_all oyv.line(graphItem,oxv,0,2) oxv.x[1]=$2 oyv.x[1]=$3 if (plhorz==1) oyv.x[1]=oyv.x[0] if (plhorz==2) oxv.x[1]=oxv.x[0] oyv.line(graphItem,oxv,2,2) redraw0() // will redraw if defined if ($1==3) plcback(oxv,oyv) } } // newplot([width,height,pointer]) OR newplot([pointer]) proc newplot () { local wd,ht graphItem = new Graph(0) if (numarg()==1) $o1=graphItem // make a pointer if (numarg()==3) $o3=graphItem if (numarg()>1) { wd=$1 ht=$2 } else { wd=500 ht=300 } graphItem.save_name("graphList[0].") graphList[0].append(graphItem) graphItem.view(0,-90,tstop,150,600,200,wd,ht) } //* cbw(min,max): b/w binary colormap proc cbw () { $o1.colormap(2) $o1.colormap(0, 0, 0, 0) $o1.colormap(1, 255, 255, 255) $o1.scale($2, $3) } //* I/O //** svrd(0/1,name,file_ext[,fflag]) save-0 and read-1 // eg svrd(1,"Image","img") will look for file.img files to read // fflag -- return filename only -- don't call parser proc svrd () { local ii,num,cnt,fflag rdflag=$1 if (numarg()==4) fflag=$4 else fflag=0 sprint(tstr2,"*.%s",$s3) if (rdflag==0) { // write sprint(tstr,"Write %s",$s2) tmpfile.chooser("w",tstr,tstr2,"WRITE","","") if (tmpfile.chooser()==1) { tmpfile.getname(filename) if (!fflag) parsr(rdflag) } } else if (rdflag==1) { // read sprint(tstr,"Read %s",$s2) tmpfile.chooser("r",tstr,tstr2,"READ","","") if (tmpfile.chooser()==1) { tmpfile.getname(filename) if (!fflag) parsr(rdflag) } } mesg=filename tmpfile.close } //* xgetargs, d2b //** range(val,min,max) -- return val only if in proper range // eg stim.noise=range(stim.noise,0,1) func range () { if ($1<$2) return $2 if ($1>$3) return $3 return $1 } //** err() proc err () { if (numarg()==1) mesg=$s1 print mesg } //** xvarstr(): display a list of strings in an xpanel using xvarlabel proc xvarstr () { local ii,cnt // ivoc_style("*font", "fixed") if (unix_mac_pc() == 1) { ivoc_style("*font", "*helvetica-bold-r-normal*--14*") } xpanel($s1) for ltr(XO,$o2) xvarlabel(XO.s) xpanel() } //** xgetargs(panel_name,command,arg1[,arg2,...],defaults) // xgetargs("Random session","newrand","# of patts","patt size ","overlap ","5,33,7") objref argv argv = new Vector() proc xgetargs () { local i,args args=numarg()-3 i=numarg() argv.resize(0) sprint(temp_string_,"argv.append(%s)",$si) execute(temp_string_) if (argv.size!=args) argv.resize(args) xpanel($s1) mesg=$s1 xvarlabel(mesg) for i=3,numarg()-1 { sprint(temp_string_,"argv.x[%d]",i-3) xvalue($si,temp_string_) } sprint(temp_string_,"xgetexec(\"%s\",%d)",$s2,args) xbutton("Execute",temp_string_) xpanel() } proc xgetexec () { local i,args args = $2 if (argv.size!=args) { mesg="Error-close & relaunch panel" return } sprint(temp_string_,"%s(",$s1) for i=0,args-2 sprint(temp_string_,"%s%g,",temp_string_,argv.x[i]) sprint(temp_string_,"%s%g)",temp_string_,argv.x[i]) print temp_string_ execute(temp_string_) } //** d2b(): decimal to binary, gives a binary appearing number for showing // eg for ii=0,100 printf("%010d\n",d2b(ii)) func d2b () { local num,ii,rem,res num=$1 ii=0 res=0 while (num>0) { rem = int(2*(num/2-int(num/2))) // right digit num=int(num/2) // remove right digit res+=rem*10^ii ii+=1 } return res } //* matrix stuff //** cvec(),rvec() put out col bzw row vecs in latex format proc cvec () { local i printf("\\bpm ") for vtr(&x,$o1) if (i1<$o1.size-1) printf("%g \\\\ ",x) printf("%g \\epm\n",x) } proc rvec () { local i printf("\\bpm ") for vtr(&x,$o1) if (i1<$o1.size-1) printf("%g & ",x) printf("%g \\epm\n",x) } //** matp(mat,rows,cols) prints out matrix in latex format proc matp () { local i,j,rows,cols rows=$2 cols=$3 if ($o1.size!=rows*cols) {print "ERR: matp - mat.size != rows*cols" return} printf("\\bpm\n") for (i=0;irows) for i=rows,cols-1 printf("%70.04g \n",$o2.x[i]) } //** mmlt(mdest,m1,m2,r2) matrix mult between 2 mats // r2==c1 gives shared dimension proc mmlt () { local i,j,r1,c1,r2,c2 c1 = r2 = $4 // shared dimension (cols of 1st/rows of second) r1=$o2.size/c1 c2=$o3.size/r2 printf("%dx%d * %dx%d = %dx%d\n",r1,c1,r2,c2,r1,c2) $o1.resize(r1*c2) vec[0].resize(c1) // length of a row of mat A vec[1].resize(r2) // length of a col of mat B for i=0,r1-1 for j=0,c2-1 { vec[0].mrow($o2,i,c1) vec[1].mcol($o3,j,c2) $o1.x[i*c2+j]=vec[0].dot(vec[1]) } $o1.mprintf(r1,c2) dealloc(a) } //* membrane and pp's //** runbutton running_ = 1 proc runbutton () { if (running_ == 0) { stoprun = 1 return } if (t>0 && t2) stim.start= $3 if (numarg()>3) stim.noise= $4 } } endtemplate SNS //* geom create soma access soma soma area(0.5) // force calculation of diams //* syns SN=3 objref sns[SN+1] for ii=0,SN sns[ii] = new SNS() //* params //** declare params tstop=70 v_init=-70 soma { L=100 diam=100 insert hh gnabar_hh = .1 gkbar_hh = .02 gl_hh = 5e-4 } //** syn params for ii=0,SN { sns[ii].setstim(1,1e4,ii*15+2,0) sns[ii].nmda.atau1=.1 sns[ii].nmda.atau2=1 sns[ii].nmda.ae=0 } sns[0].wt(7e-2,0) sns[1].wt(3e-2,0) sns[2].wt(6e-2,0) sns[3].wt(8e-2,0) NMDA[0].ae = -100 //* run cvode_active(1) cvode.atol(1e-3) proc init () { finitialize(v_init) fcurrent() forall el_hh = (ina+ik+gl_hh*v_init)/gl_hh } colr = 1 proc draw_plot () { graphItem.erase_all graphItem.addvar("","soma.v(0.5)",colr,2) sns[0].setstim(1,1e4,a,0) sns[1].setstim(1,1e4,b,0) sns[2].setstim(1,1e4,c,0) sns[3].setstim(1,1e4,d,0) graphItem.label(5,47,"Voltage (mV)",1,1,0.5,0.5,1) graphItem.label(65,6,"time (ms)",1,1,0.5,0.5,1) graphItem.label(a+2.5,-85,"IPSP",1,1,0.5,0.5,2) graphItem.label(b+5,-55,"EPSP #1",1,1,0.5,0.5,2) graphItem.label(c+8,-50,"EPSP #2",1,1,0.5,0.5,2) graphItem.label(d+6,-40,"EPSP #3",1,1,0.5,0.5,2) graphItem.label(d+7,40,"AP",1,1,0.5,0.5,2) run() } {a=2 b=17 c=32 d=47} proc reset () { a=2 b=17 c=32 d=47 draw_plot() graphItem.exec_menu("View = plot") } objref fhbox1,fvbox1 proc trpanel () { local ii fhbox1=new HBox(3) fhbox1.intercept(1) newplotv() xpanel("EPSP or IPSP") qhp() xvalue("IPSP time","a",1,"draw_plot()") xvalue("EPSP#1 time","b",1,"draw_plot()") xvalue("EPSP#2 time","c",1,"draw_plot()") xvalue("EPSP#3 time","d",1,"draw_plot()") xmenu("Line Color") for ii = 1,3 { sprint(tstr,"colr=%d draw_plot()",ii) xradiobutton(cl[ii].s,tstr) } xmenu() xpanel() fhbox1.intercept(0) fhbox1.map("Postsynaptic potentials") } //------------call trpanel()----------- trpanel() reset() // END BR1_psp.hoc //================================================================