IGOR Rat SA Code

This is the code written for the IGOR macros used to model self-administration in rats. (Cadle, 2010)

Last updated 4/5/2010.

Written by Don Cooper and Brian Cadle.

Code
(#)pragma rtGlobals=1 // Use modern global access method.

macro cocaine(dose) variable dose, infusions,interval,i,x,stop,interval2,x2,random,seed variable/g count duplicate/o fit_wave0, BE_scaled_0 duplicate/o fit_wave2, COC_scaled_2 dose/=2 BE_scaled_0*=dose COC_scaled_2*=dose duplicate/o BE_scaled_0,BE_total duplicate/o COC_scaled_2,coc_total duplicate/o BE_scaled_0, first duplicate/o COC_scaled_2, coc duplicate/o COC_scaled_2, detect_coc_2 detect_coc_2/=250 duplicate/o detect_coc_2, coc_be_rates

COC_BE_rates+=BE_Scaled_0 duplicate/o coc_be_rates,total duplicate/o coc_be_rates, COC_BE_total

x=0 x2=0 count=0 stop=240 seed=abs(gnoise(2))+.2 do

if(coc_total[x]&gt;=1.5) random=round(abs(enoise(40)*(seed))) else doupdate random=round(abs(enoise(4)*(seed)))

endif insertpoints x,random,first insertpoints x,random,coc insertpoints x,random,total BE_total+=first COC_total+=coc COC_BE_total+=total

x+=random count+=1

while(x&lt;=stop-interval)

end

macro hecaton(dosex) variable dosex, counter, c, changer, blah, countaverage, t, q string masterlist="BE_" string/g beholder="beholder" string coc_masterlist="COC_" string/g coc_holder="cocholder" string coc_be_masterlist="COC_BE_" string/g coc_be_holder="cocbeholder"

//variables counter=0 c=0 changer=0 blah=1 countaverage=0 t=0 q=0

//make windows and waves dowindow/r/k BEmastergraph dowindow/r/k COCmastergraph dowindow/r/k COCBEmastergraph

make/O/N=240 masterlistx make/O/N=240 COCmasterlistx make/O/N=240 COCBEmasterlistx display/N=BEmastergraph masterlistx display/N=COCmastergraph masterlistx display/N=COCBEmastergraph masterlistx modifygraph/W=BEmastergraph rgb(masterlistx)=(0,0,0) modifygraph/W=COCmastergraph rgb(masterlistx)=(0,0,0) modifygraph/W=COCBEmastergraph rgb(masterlistx)=(0,0,0) autopositionwindow/M=0/R=BEmastergraph COCmastergraph autopositionwindow/M=0/R=COCmastergraph COCBEmastergraph make/O/N=240 BEfinalaverage make/O/N=240 COCfinalaverage make/O/N=240 COCBEfinalaverage make/O/N=240 BE_X make/O/N=240 COC_X make/O/N=240 COCBE_X make/O/N=240 BEtotalx make/O/N=240 COCtotalx make/O/N=240 COCBEtotalx make/O/N=100 countwave make/O/N=100 maxBEwave make/O/N=100 maxCOCwave make/O/N=100 maxCOCBEwave

//do loop to paste each BE/COC curve into a graph do cocaine(dosex) sprintf masterlist "%s%d", "BE_", c sprintf coc_masterlist "%s%d", "COC_", c sprintf coc_be_masterlist "%s%d", "COC_BE_", c duplicate/O BE_total, $masterlist duplicate/O COC_total, $coc_masterlist duplicate/O COC_BE_total, $coc_be_masterlist appendtograph/W=BEmastergraph $masterlist appendtograph/W=COCmastergraph $coc_masterlist appendtograph/W=COCBEmastergraph $coc_be_masterlist modifygraph/W=BEmastergraph rgb($masterlist)=(50000,50000,50000) modifygraph/W=COCmastergraph rgb($coc_masterlist)=(50000,50000,50000) modifygraph/W=COCBEmastergraph rgb($coc_be_masterlist)=(50000,50000,50000)

counter+=1 c+=1 countaverage=countaverage+count countwave[t]=count

t+=1 while(counter&lt;=99)

//between area BEtotalx=BE_0 maxBEwave[q]=BE_0[240] COCtotalx=COC_0 maxCOCwave[q]=COC_0[240] COCBEtotalx=COC_BE_0 maxCOCBEwave[q]=COC_BE_0[240]

//do loop to take the average of each BE/COC curve do sprintf beholder "%s%d", "BE_", blah duplicate/O $beholder, BE_X BEtotalx=BEtotalx+$beholder sprintf coc_holder "%s%d", "COC_", blah duplicate/O $coc_holder, COC_X COCtotalx=COCtotalx+$coc_holder sprintf coc_be_holder "%s%d", "COC_BE_", blah duplicate/O $coc_be_holder, COCBE_X COCBEtotalx=COCBEtotalx+$coc_be_holder

q+=1

maxBEwave[q]=$beholder[240] maxCOCwave[q]=$coc_holder[240] maxCOCBEwave[q]=$coc_be_holder[240]

changer+=1 blah+=1

while(changer&lt;=98)

//Dividing for averages, printing outputs, graphics changes countaverage=countaverage/blah print "infusions average=", countaverage BEfinalaverage=BEtotalx/blah COCfinalaverage=COCtotalx/blah COCBEfinalaverage=COCBEtotalx/blah appendtograph/W=BEmastergraph BEfinalaverage appendtograph/W=COCmastergraph COCfinalaverage appendtograph/W=COCBEmastergraph COCBEfinalaverage modifygraph/W=BEmastergraph rgb(BEfinalaverage)=(0,0,0) modifygraph/W=BEmastergraph lsize(BEfinalaverage)=2 wavestats/Q/R=[0,changer] countwave print "infusions stdev=", v_sdev wavestats/Q/R=[0,changer] maxBEwave print "BE max avg=", v_avg print "BE max stdev=", v_sdev modifygraph/W=COCmastergraph rgb(COCfinalaverage)=(0,0,0) modifygraph/W=COCmastergraph lsize(COCfinalaverage)=2 wavestats/Q/R=[0,changer] maxCOCwave print "COC max avg=", v_avg print "COC max stdev=", v_sdev modifygraph/W=COCBEmastergraph rgb(COCBEfinalaverage)=(0,0,0) modifygraph/W=COCBEmastergraph lsize(COCBEfinalaverage)=2 wavestats/Q/R=[0,changer] maxCOCBEwave print "COC/BE max avg=", v_avg print "COC/BE max stdev=", v_sdev

removefromgraph/W=BEmastergraph masterlistx removefromgraph/W=COCmastergraph masterlistx removefromgraph/W=COCBEmastergraph masterlistx end