REM >DTrain REM ======================================================================== REM Delay of reinforcement: TRAINING PROGRAM. REM REM Nosepoke initiates single-lever trials. REM Levers come out in randomised pair order (i.e. each pair is AB or BA). REM #Pellets and delays are fixed and specifiable. REM Can specify max number of trials and max total time. REM "Another satisfied DelayLib Client(tm)". REM REM By Rudolf Cardinal. REM First written 17 Oct 98. REM ======================================================================== progname$="DTrain" version_date$="7 Dec 98" debug%=0 simple%=0 :REM Simplifies configuration as much as poss. REM ======================================================================== REM Method / data output - see DELAYLIB and methods document REM ======================================================================== REM All trials are forced-choice trials, counterbalanced in pairs. REM Both levers have zero delay and one pellet. REM REM ======================================================================== REM Revision History REM ======================================================================== REM 21 Oct 98 - written. REM 13 Nov 98 - mucked around with following TWR/YPL meeting. REM (actually did v. little as it's all in DELAYLIB.) REM 7 Dec 98 - houselights_bridge_delay% supported REM REM ======================================================================== REM Libraries REM ======================================================================== PROCinit :REM Arachnid init PROCkill_all :REM Arachnid init LIBRARY ".ProgLibs.Ascii" LIBRARY ".ProgLibs.UI" LIBRARY ".ProgLibs.DateTime" LIBRARY ".ProgLibs.Filename" date_time$ = FNdate_time_code LIBRARY ".ProgLibs.Arachnid" LIBRARY ".ProgLibs.BoxConst" PROCcombined_boxes LIBRARY ".ProgLibs.DelayLib" maxnchoicetrials%=100:PROCdelay_lib_init REM ======================================================================== REM Constants REM ======================================================================== global_delay% = 0 :REM delay on the levers global_maxdelay% = 1000 global_nreinf% = 1 :REM #pellets global_maxtime% = 60*60*100 :REM default 1 hour... nforcedtrials% = 60 :REM ... or 60 trials. nchoicetrials% = 60 :REM ignore - delaylib needs this, but never gets incremented pellet_gap% = 50 :REM ignore - only one pellet! lights_bridge_delay%=yes% initiation_limhold% = 1000 choice_limhold% = 1000 collection_limhold%=1000 reinf_collect_period%=600 iti_time% = 4000 IF debug%=1 THEN nforcedtrials%=2 initiation_limhold%=300 choice_limhold%=300 collection_limhold%=300 reinf_collect_period%=200 iti_time%=1500 global_maxtime%=120*100 ENDIF REM ======================================================================== REM Variables REM ======================================================================== DIM expired%(nboxes%) :REM has it finished its time? DIM pairtype%(nboxes%) :REM AB or BA? REM ======================================================================== REM Main REM ======================================================================== dummy% = RND(-TIME) PROCsay_hello PROCget_parameters PROCselect_filenames PROCwarn_kickoff PROCdisplay_screen FOR box%=1 TO nboxes% expired%(box%)=no% PROCstart_box(box%) PROCpipe_fkey(box%,0,1,"FNabort_box(",box%,E%) PROCpipe_timer(session_timer%+box%,global_maxtime%,0,"FNtimeout_box(",box%,E%) NEXT start_time% = TIME PROCpipe_timer(clock_timer%, 100, 100, "FNclock_tick(",0,E%) PROCwait(E%): *AE END REM ======================================================================== REM Startup functions REM ======================================================================== DEF PROCsay_hello MODE 12 PRINT"!DTrain" PRINT"______________________________________________________________________" PRINT"Delay of reinforcement: Training program." PRINT" Nosepoke -> forced trial." PRINT"By Rudolf Cardinal. Version date ";version_date$ IF debug%=1 COLOUR3:PRINT"*** DEBUGGING!!! ***":COLOUR7 PRINT' ENDPROC DEF PROCget_parameters COLOUR1 PRINT "1. CHOOSE OVERALL PARAMETERS" PRINT "----------------------------":COLOUR7 IF simple%=0 THEN PRINT"Program will terminate when it reaches a maximum number of trials" PRINT"or a maximum time, whichever comes first." nforcedtrials%=FNget_num_param("Maximum number of (forced) trials",nforcedtrials%,5,maxnchoicetrials%*2) REM must not exceed this, or arrays will have been DIMmed too small global_maxtime%=60*100*FNget_num_param("Maximum time, in MINUTES",global_maxtime%/(60*100),5,180) global_delay%=FNget_num_param("Delay on each lever (cs)",global_delay%,0,5000) global_nreinf%=FNget_num_param("Pellets on each lever",global_nreinf%,1,10) pellet_gap%=FNget_num_param("Time between individual pellets (cs)",pellet_gap%,10,100) lights_bridge_delay%=FNget_num_param("CS light on during delay ("+STR$(no%)+"=no, "+STR$(yes%)+"=yes)",lights_bridge_delay%,no%,yes%) houselights_bridge_delay%=FNget_num_param("Houselight on during delay/feeding period ("+STR$(no%)+"=no, "+STR$(yes%)+"=yes)",houselights_bridge_delay%,no%,yes%) PRINT"... and you're not allowed to muck around with the ITI times." ELSE PRINT"In simple mode. Skipped." ENDIF COLOUR1:PRINT ' PRINT "2. PARAMETERS FOR EACH BOX" PRINT "--------------------------":COLOUR7 LOCAL box%, defside%,lever$,satisfied%,delaytemp%,i% FOR box%=1 TO nboxes% COLOUR3:PRINT'"______________________________ BOX ";box%':COLOUR7 subject$(box%) = FNget_str_param(" Rat name: ","???") INPUT " Session: " session_number%(box%) REM both levers are the same, so this doesn't matter at all. adj_side%(box%) = left% NEXT COLOUR3 PRINT'"Press a key if you're happy. We won't start quite yet.";:COLOUR7:IFGET ENDPROC REM ======================================================================== REM Box control/calculation functions REM ======================================================================== DEF PROCschedule_next_trial(box%) REM 1. regardless of FNstart_trial/FNtrial_finished, next trial is forced. REM Randomise in pairs. IF (trial%(box%) MOD 2)=1 THEN next_trial_type%(box%) = FNrandom_stim ELSE next_trial_type%(box%) = FNother_than(stimulus%(box%,trial%(box%)-1)) ENDIF ENDPROC DEF PROCtrial_setup(box%) adj_delay%(box%,trial%(box%)) = global_delay% unadj_delay%(box%,trial%(box%)) = global_delay% adj_pellets%(box%,trial%(box%)) = global_nreinf% unadj_pellets%(box%,trial%(box%)) = global_nreinf% ENDPROC DEF PROCtrial_adjustingpoint(box%) REM use trial%(), not choicetrial%(), to finish. REM calling function looks for finished%(). IF expired%(box%)=yes% OR trial%(box%)>=nforcedtrials% THEN finished%(box%)=yes% ENDPROC DEF FNtimeout_box(box%,R%) IF R%=0 =0 expired%(box%)=yes% :REM next time it gets to PROCtrial_setup it will finish. :REM We don't want to interrupt a trial half-way. =0 REM ======================================================================== REM Display/clock functions REM ======================================================================== DEF PROCdisplay_screen LOCAL i% PROCsay_hello PRINT"Maximum #trials = ";nforcedtrials%;"; maximum time (min) = ";global_maxtime%/6000 PRINT"Delay is ";global_delay%;" cs; delivering ";global_nreinf%;" pellet(s) on each lever." PRINT"'Adjusted' lever always refers to the left." PRINT"Press F1-";nboxes%;" to abort individual boxes." PRINT"Elapsed time: ";:clockx%=POS:clocky%=VPOS:PRINT'' REM 012345678901234567890123456789012345678901234567890123456789012345678901234567890 PRINT"Box In? Trial State Stimulus Response Pellets" PRINT"______________________________________________________________________________" display_firstline%=VPOS FOR i%=1 TO nboxes%:PROCupdate_box(i%):NEXT ENDPROC DEF PROCupdate_box(box%) LOCAL y% y% = FNdisplay_line(box%) PRINTTAB(0,y%);box%; PRINTTAB(15,y%);trial%(box%); PROCupdate_box_pellets(box%," ") PROCupdate_box_stimulus(box%," ") PROCupdate_box_response(box%," ") PROCupdate_box_nosepoke(box%) ENDPROC DEF PROCupdate_box_nosepoke(box%) PRINTTAB(5,FNdisplay_line(box%)); IF FNswitch(nosepoke%(box%),E%)=On THEN PRINT"*"; ELSE PRINT" "; ENDPROC DEF PROCupdate_box_state(box%,state$) COLOUR3:PRINTTAB(44,FNdisplay_line(box%));state$;:COLOUR7 ENDPROC DEF PROCupdate_box_stimulus(box%,stim$) COLOUR3:PRINTTAB(52,FNdisplay_line(box%));stim$;:COLOUR7 ENDPROC DEF PROCupdate_box_response(box%,resp$) COLOUR3:PRINTTAB(62,FNdisplay_line(box%));resp$;:COLOUR7 ENDPROC DEF PROCupdate_box_pellets(box%,pel$) COLOUR5:PRINTTAB(73,FNdisplay_line(box%));pel$;" ";:COLOUR7 ENDPROC REM ======================================================================== REM Results/output functions REM ======================================================================== DEF PROCprint_config CLS PRINT"=====================================================================" PRINT"!DTrain nosepoke/delay training program, by Rudolf Cardinal, ";version_date$ PRINT"Finished at ";TIME$ PRINT"Date/time code: ";date_time$ IF debug%=1 COLOUR3:PRINT"*** DEBUGGING!!! ***":COLOUR7 PRINT"=====================================================================" PRINT" Number of forced trials = ";nforcedtrials% PRINT" Maximum session time (min) = ";global_maxtime%/6000 PRINT" Delay (cs) = ";global_delay% PRINT" #Pellets = ";global_nreinf% PRINT" Gap between pellets = ";pellet_gap%;" cs" PRINT" Lights on during delay = ";lights_bridge_delay%;" (";yes%;"=yes, ";no%;"=no)" PRINT" Houselights on during delay/feeding = ";houselights_bridge_delay%;" (";yes%;"=yes, ";no%;"=no)" PRINT" 'ITI' time (leverpress->new trial) = ";iti_time%;" cs" PRINT" 'Adjusted' lever always refers to the left." PRINT ENDPROC DEF PROCprint_data LOCAL box%, t% FOR box%=1 TO nboxes% PRINT"BOX ";box% PRINT"----------------------------------------------------------------------" PRINT"Rat ID: ";subject$(box%) PRINT"Session: ";session_number%(box%) PRINT"----------------------------------------------------------------------" PRINT"Trial InitLat Stimulus Response ChoiceLat Collected? ColLat" REM01234567890123456789012345678901234567890123456789012345678901234567890123456789 FOR t%=1 TO trial%(box%) PRINTTAB(0);t%; PRINTTAB(18);initiation_lat%(box%,t%); PRINTTAB(26);desc$(stimulus%(box%,t%)); PRINTTAB(35);desc$(response%(box%,t%)); PRINTTAB(44);choice_lat%(box%,t%); PRINTTAB(63);yesno$(reward_collected%(box%,t%)); PRINTTAB(74);collect_latency%(box%,t%) NEXT PRINT NEXT ENDPROC DEF PROCprint_summaries LOCAL box% COLOUR 3 PRINT'"* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"' PRINT"SUMMARIES (lever totals refer to choice trials only)" COLOUR 7 PRINT PRINT"Box Trials Adj# Unadj# Om# Pellets consumed Subject ID" PRINT"--------------------------------------------------------------------------" REM 01234567890123456789012345678901234567890123456789012345678901234567890123456789 FOR box%=1 TO nboxes% PRINTTAB(0);box%; PRINTTAB(5);trial%(box%); PRINTTAB(27);adjtotal%(box%); PRINTTAB(33);unadjtotal%(box%); PRINTTAB(41);omissiontotal%(box%); PRINTTAB(46);pelletcount%(box%);" (";FNfood_mass(pelletcount%(box%));"g)"; PRINTTAB(64);subject$(box%) NEXT PRINT ENDPROC