REM >AdjDelay REM ======================================================================== REM Delay of reinforcement: Mazur/Bradshaw task (updated version). REM Adjusting delay. REM Free to adjust delay on any choice trial. REM THIS IS THE ONE IN USE. REM Note - this bears little resemblance to either Mazur's or Bradshaw's REM actual task; it's a version designed to use the adjusting-delay REM principle, but resemble the Evenden or Richards procedures more closely. REM (The !Bradshaw program is a more faithful copy of Bradshaw's task.) REM REM By Rudolf Cardinal. REM First written 17 Oct 98. REM ======================================================================== progname$="AdjDelay" version_date$="1 Dec 98" debug%=0 simple%=0 :REM Simplifies configuration as much as poss. REM ======================================================================== REM Revision History REM ======================================================================== REM 17 Oct 98 - written. REM 18 Oct 98 - uses DelayLib. REM 13 Nov 98 - mucked around with following TWR/YPL meeting. REM (actually did v. little as it's all in DELAYLIB.) 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 ======================================================================== min_delaystep% = 1: max_delaystep%=18 DIM delay_values%(18) :REM steps numbered 1-18 FOR dummy%=1 TO 18:READ delay_values%(dummy%):NEXT DATA 200, 240, 288, 346, 415, 498, 597, 717, 860 DATA 1032,1238,1468,1783,2140,2568,3081,3698,4437 global_unadj_delay% = 200 :REM 2s delay on the unadjusted lever unadj_nreinf% = 1 :REM 1 pellet on the unadjusted lever adj_nreinf% = 4 :REM 4 pellets on the adjusted lever adjusting_method% = mazur% nblocks% = 10 :REM for Mazur, number of 4-trial blocks max_consec_choice% = 2 :REM for Richards, after this many responses on a single lever, :REM a forced-choice trial is initiated. nchoicetrials% = 60 :REM gets changed later (see PROCget_parameters) pellet_gap% = 50 lights_bridge_delay%=yes% initiation_limhold% = 1000 choice_limhold% = 1000 collection_limhold%=1000 reinf_collect_period%=600 iti_time% = 10000 IF debug%=1 THEN nchoicetrials%=4 max_consec_choice%=2 :REM for Richards method nblocks%=3 :REM for Mazur method global_unadj_delay%=50 adj_nreinf%=2 max_delaystep%=5 initiation_limhold%=300 choice_limhold%=300 collection_limhold%=300 reinf_collect_period%=200 iti_time%=2000 ENDIF REM ======================================================================== REM Variables REM ======================================================================== DIM adj_delaystep%(nboxes%) :REM the *step*, not the delay REM ======================================================================== REM Main REM ======================================================================== dummy% = RND(-TIME) PROCsay_hello PROCget_parameters PROCselect_filenames PROCwarn_kickoff PROCdisplay_screen FOR i%=1 TO nboxes% PROCstart_box(i%) PROCpipe_fkey(i%,0,1,"FNabort_box(",i%,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"!AdjDelay" PRINT"______________________________________________________________________" PRINT"Delay of reinforcement: Mazur/Bradshaw task (updated version)." PRINT" Freely adjusting delay." 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 REM must not exceed this, or arrays will have been DIMmed too small global_unadj_delay%=FNget_num_param("Unadjusted delay (cs)",global_unadj_delay%,0,500) unadj_nreinf%=FNget_num_param("Unadjusted #pellets",unadj_nreinf%,0,500) adj_nreinf%=FNget_num_param("Adjusted #pellets",adj_nreinf%,0,500) adjusting_method%=FNget_num_param("Adjusting method - USE MAZUR ("+STR$(mazur%)+"=Mazur, "+STR$(richards%)+"=Richards",adjusting_method%,mazur%,richards%) IF adjusting_method%=mazur% THEN nblocks%=FNget_num_param(" Number of 4-trial blocks",nblocks%,5,15) nchoicetrials%=nblocks%*2 ENDIF IF adjusting_method%=richards% THEN nchoicetrials%=FNget_num_param(" Number of choice trials",nchoicetrials%,5,nchoicetrials%) max_consec_choice%=FNget_num_param(" Trigger forced choice after how many repetitions (0=never,1=stupid)",max_consec_choice%,0,30) ENDIF 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%) 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 odd-numbered boxes have L=unadj, R=adj REM even-numbered boxes have the reverse IF (box% MOD 2)=0 THEN defside%=left% ELSE defside%=right% IF simple%=1 THEN adj_side%(box%) = defside% ELSE PRINT"Adjusted lever [";sidename$(defside%);"]: "; INPUT""lever$ CASE lever$ OF WHEN "L","l": adj_side%(box%) = left% WHEN "R","r": adj_side%(box%) = right% OTHERWISE: REM leave it as it is, then! adj_side%(box%) = defside% ENDCASE ENDIF REM now ask for the starting delay in cs and convert it to a step satisfied%=0 REPEAT delaytemp%=FNget_num_param("Adjusted delay (cs)",delay_values%(min_delaystep%),delay_values%(min_delaystep%),delay_values%(max_delaystep%)) FOR i%=min_delaystep% TO max_delaystep% IF delay_values%(i%)=delaytemp% THEN adj_delaystep%(box%)=i%:satisfied%=1 NEXT IF satisfied%=0 THEN PRINT"-- Not valid, try again." UNTIL satisfied%=1 NEXT COLOUR3 PRINT''"3. CHECK THEM." PRINT "--------------":COLOUR7 FOR box%=1 TO nboxes% PRINT" Box ";box%;" (";subject$(box%);") - session ";session_number%(box%); PRINT" - adjusting delay is ";delay_values%(adj_delaystep%(box%)) 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%) LOCAL dummy% CASE adjusting_method% OF WHEN mazur%: PROCschedule_mazur(box%) WHEN richards%: PROCschedule_richards(box%) ENDCASE ENDPROC DEF PROCtrial_setup(box%) adj_delay%(box%,trial%(box%)) = delay_values%(adj_delaystep%(box%)) unadj_delay%(box%,trial%(box%)) = global_unadj_delay% adj_pellets%(box%,trial%(box%)) = adj_nreinf% unadj_pellets%(box%,trial%(box%)) = unadj_nreinf% ENDPROC DEF PROCtrial_adjustingpoint(box%) CASE adjusting_method% OF WHEN mazur%: PROCadjust_mazur(box%) WHEN richards%: PROCadjust_richards(box%) ENDCASE ENDPROC DEF PROCadjust_mazur(box%) LOCAL r% IF trial%(box%)<2 THEN ENDPROC IF stimulus%(box%,trial%(box%))<>choice% OR stimulus%(box%,trial%(box%)-1)<>choice% THEN ENDPROC r% = response%(box%,trial%(box%)) IF r%<>response%(box%,trial%(box%)-1) THEN ENDPROC IF r%=adj% THEN adj_delaystep%(box%)=FNlengthen_delay(adj_delaystep%(box%)) IF r%=unadj% THEN adj_delaystep%(box%)=FNshorten_delay(adj_delaystep%(box%)) REM if omission, ignore ENDPROC DEF PROCadjust_richards(box%) IF stimulus%(box%,trial%(box%)) <> choice% THEN ENDPROC IF response%(box%,trial%(box%)) = adj% THEN adj_delaystep%(box%)=FNlengthen_delay(adj_delaystep%(box%)) IF response%(box%,trial%(box%)) = unadj% THEN adj_delaystep%(box%)=FNshorten_delay(adj_delaystep%(box%)) ENDPROC DEF FNlengthen_delay(delaystep%) IF delaystep%min_delaystep% THEN =delaystep%-1 ELSE =delaystep% REM ======================================================================== REM Display/clock functions REM ======================================================================== DEF PROCdisplay_screen LOCAL i% PROCsay_hello PRINT"Target is ";nchoicetrials%;" choice trials." IF adjusting_method%=mazur% THEN PRINT"Mazur technique. There are ";nblocks%;" blocks of four trials." ELSE PRINT"Richards technique. Forced trial triggered after ";max_consec_choice%;" consecutive choices." ENDIF PRINT"Press F1-";nboxes%;" to abort individual boxes." PRINT"Elapsed time: ";:clockx%=POS:clocky%=VPOS:PRINT'' REM 012345678901234567890123456789012345678901234567890123456789012345678901234567890 PRINT"Box In? AdjLv Trial ChTr Blk/Tr AdjDelay 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(8,y%);sidename$(adj_side%(box%)); PRINTTAB(15,y%);trial%(box%); PRINTTAB(21,y%);choicetrial%(box%); IF adjusting_method%=mazur% THEN PRINTTAB(28,y%);(trial%(box%)-1)DIV4 + 1;"/";(trial%(box%)-1)MOD4 + 1; PRINTTAB(36,y%);delay_values%(adj_delaystep%(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"!AdjDelay adjusting delay, 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 choice trials = ";nchoicetrials% IF adjusting_method%=mazur% THEN PRINT" Mazur technique. There are ";nblocks%;" blocks." ELSE PRINT" Richards technique. Forced trial triggered after ";max_consec_choice%;" consecutive choices." ENDIF PRINT" Unadjusting delay = ";global_unadj_delay%;" cs" PRINT" Unadjusting reinforcer = ";unadj_nreinf%;" pellets" PRINT" Adjusting delay = ";delay_values%(min_delaystep%);" to ";delay_values%(max_delaystep%);" cs" PRINT" Adjusting reinforcer = ";adj_nreinf%;" pellets" PRINT" Gap between pellets = ";pellet_gap%;" cs" PRINT" Lights on during delay = ";lights_bridge_delay%;" (";yes%;"=yes, ";no%;"=no)" PRINT" 'ITI' time (choice->new trial) = ";iti_time%;" cs" PRINT ENDPROC DEF PROCprint_data LOCAL box%, t% FOR box%=1 TO nboxes% PRINT"BOX ";box% PRINT"----------------------------------------------------------------------" PRINT"Rat ID: ";subject$(box%) PRINT"Adjusted lever: ";sidename$(adj_side%(box%)) PRINT"Session: ";session_number%(box%) PRINT"----------------------------------------------------------------------" PRINT"Trial Choicetrial InitLat Stimulus Response ChoiceLat AdjDelay Collected? ColLat" REM01234567890123456789012345678901234567890123456789012345678901234567890123456789 FOR t%=1 TO trial%(box%) PRINTTAB(0);t%; PRINTTAB(6);choicetrial_num%(box%,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(54);adj_delay%(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 ChoiceTrials Adj# Unadj# Om# Pellets consumed Subject ID" PRINT"--------------------------------------------------------------------------" REM 01234567890123456789012345678901234567890123456789012345678901234567890123456789 FOR box%=1 TO nboxes% PRINTTAB(0);box%; PRINTTAB(5);trial%(box%); PRINTTAB(13);choicetrial%(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 COLOUR 3 PRINT"DELAYS FOR NEXT TIME:" PRINT"---------------------" COLOUR 7 FOR box%=1 TO nboxes% PRINT"Box ";box%;" (";subject$(box%);") - ";delay_values%(adj_delaystep%(box%)) NEXT PRINT ENDPROC