REM *** data output needs some tweaking (doesn't record all probabilities, etc.) REM >Gamble REM version29/08/02- set to run R69 progname$ = "gamble" version_date$ = "25-Mar-2003" debug% = 0 :REM in debugging mode? printing% = 0 :REM controls whether log is sent to printout (0=no, 1=yes) REM Description of task: REM Rat must make choice between different holes associated with different REM levels of reward (1-4 pellets) and different levels of punishment (time REM out from reward) REM PROCs for flashing lights defined in ARACHNID library. F**k knows what I'm REM doing trying to play this game.... REM ======================================================================== REM ======================================================================== PROCinit :REM Arachnid init PROCkill_all :REM Arachnid init LIBRARY ".ProgLibs.Ascii" LIBRARY ".ProgLibs.UI": PROCdefine_colours LIBRARY ".ProgLibs.DateTime": date_time$ = FNdate_time_code LIBRARY ".ProgLibs.Filename" LIBRARY ".ProgLibs.Arachnid" LIBRARY ".ProgLibs.BoxConst": PROCfive_hole_boxes LIBRARY ".ProgLibs.Random" MODE 12 dummy% = RND(-TIME) PROCbox_set_up PROCget_parameters PROCdisplay_startup FOR box% = 1 TO nboxes% IF using_the_box%(box%)=yes% THEN PROCstart_the_box(box%) PROCpipe_fkey(box%,1,0,"FNabort_box(",box%,E%) ENDIF NEXT PROCwait(E%):*AE PROCkill_all END DEF PROCbox_set_up maxtrials% = 100 :REM this is the _maximum_ possible number of trials (arrays dimensioned according to this) ndelay_options% = 4 :REM how many possible delays? nnoise_options% = 4 :REM how many possible noise onsets? iti_timer% = 0 * nboxes% timeout_timer% = 1 * nboxes% stim_on_timer% = 2 * nboxes% :REM I know that I don't need to define so many, but it doesn't hurt and reads more clearly. pellet_dispenser_timer% = 4 * nboxes% timeout_timer% = 5 * nboxes% noise1_timer% = 6 * nboxes% :REM used for time-to-noise noise2_timer% = 7 * nboxes% :REM used for noise-duration flash_timer1% = 8 * nboxes% :REM need both flash_line timers for cunning flash_timer2% = 9 * nboxes% :REM flash code in Arachnid (RNC) REM global parameters: some are defaults only, superseded by per-box parameters (below) pulse% = 50 :REM pellet dispenser pulse on-time pellet_gap% = 60 :REM gap between subsequent pellets numpellets% = 1 :REM the reward size session_limit% = 30 :REM the default session length, in minutes REM _____________________________________ per session (in) DIM rat_id$(nboxes%) DIM using_the_box%(nboxes%) DIM confirm%(nboxes%) :REM used after parameters fro each box are entered (or if box is not used) DIM session_number%(nboxes%) DIM treatment$(nboxes%) DIM numtrials%(nboxes%) DIM session_length%(nboxes%) DIM delay_option%(nboxes%,ndelay_options%) :REM not usre if we need this either DIM stimulus_duration%(nboxes%) DIM timeout_duration%(nboxes%) DIM traylight_used%(nboxes%) REM _____________________________________ per session (out) DIM total_pellets%(nboxes%) DIM total_omissions%(nboxes%) DIM total_incorrect%(nboxes%) :REM responses to untli holes, unpunished DIM total_correct%(nboxes%) :REM - CW change. We'll now use this to mean 'number of valid choices' REM________________________________________ per trial DIM perseverative_nosepokes_to_same_hole%(nboxes%,maxtrials%) DIM perseverative_nosepokes_to_other_holes%(nboxes%,maxtrials%) DIM iti_duration%(nboxes%,maxtrials%) :REM how long the initial ITI was DIM chosen_hole%(nboxes%,maxtrials%) :REM which hole was first chosen (0=omission) DIM latency_to_respond%(nboxes%,maxtrials%) :REM time from stim. onset to first nosepoke DIM timeout_experienced%(nboxes%,maxtrials%) :REM the length of timeout it actually got (can exceed programmed timeout) DIM latency_to_collect_reward%(nboxes%,maxtrials%) :REM time from pellet delivery to collection DIM perseverative_nosepokes%(nboxes%,maxtrials%) :REM nosepokes in awaiting_collect / please_push. DIM premature_nosepokes%(nboxes%,maxtrials%) :REM dunno what it does, put back by CAW/RNC 17/3/3 DIM perseverative_panelpushes%(nboxes%,maxtrials%) DIM trial_duration%(nboxes%,maxtrials%) :REM how long did that trial last? DIM trial_start_time%(nboxes%,maxtrials%) :REM trial start time, relative to session start time REM *** Note REM This is the only place that I code boxes from 0-3, rather than 1-4. REM It's harder to read, but saves 25% on memory; this is the only place where such REM a saving is significant. Only referred to in PROCrecord_response and the final output code. REM Responses are still coded 1-max, though. max_responses% = 4000 :REM How many (interesting) responses to record. Have to try it and see - memory-dependent. DIM recorded_responses%(nboxes%) :REM how many individual responses have we recorded for this box? DIM response_trial%(nboxes%-1, max_responses%) :REM which trial was it on? DIM response_phase%(nboxes%-1, max_responses%) :REM e.g. ITI, timeout, ... DIM response_location%(nboxes%-1, max_responses%) panel_code% = 99 :REM the location code for panel-pushes DIM response_time%(nboxes%-1, max_responses%) :REM the time (relative to something interesting) that the response occurred DIM response_time_in_trial%(nboxes%-1, max_responses%) :REM absolute time (meaning relative to session start) REM _________________________________________ flags and internal variables DIM finished%(nboxes%) :REM finished or not DIM trial%(nboxes%) :REM current trial number DIM nosepoke_state%(nboxes%) :REM which State is the box in? DIM iti_began_at%(nboxes%) :REM time the "ITI" began DIM please_push_began_at%(nboxes%) :REM *** don't know if I need this; is to record latency of perseverative NPs in this phase DIM stim_on_at%(nboxes%) :REM stimulus onset (absolute time) DIM timeout_began_at%(nboxes%) :REM start of timeout (absolute time) DIM rewarded_at%(nboxes%) :REM time reward was given DIM session_began_at%(nboxes%) :REM session start time, to limit session length with DIM trial_began_at%(nboxes%) :REM this trial's start time REM _____________________________________ The all-important STATES OF THE BOX, see top. dont_care% = 0 please_push% = 1 intertrial_interval% = 2 stim_on% = 3 gambling_lost% = 4 awaiting_collect% = 5 timeout% = 6 finished_state% = 7 aborted_state% = 8 REM _____________________________________ other internal constants yes% = 1 no% = 0 DIM yesno$(1): yesno$(yes%)="Y": yesno$(no%)="N" REM _____________________________________ Added by CW nholes% = 5 DIM number_of_choice_holes%(nboxes%) :REM the number of choice holes avail / trial DIM hole_pellets%(nholes%,nboxes%) :REM reward available for each hole DIM hole_timeout%(nholes%,nboxes%) :REM timeout length for each hole DIM hole_probtimeout(nholes%,nboxes%):REM timeout prob for each hole DIM hole_offered%(nholes%,nboxes%,maxtrials%) :REM is this hole presented on this trial? DIM total_hole%(nholes%,nboxes%):REM number of choices made to each hole ENDPROC DEF PROCget_parameters LOCAL box%, d%, noisetemp%, i% CLS COLOUR yellow% PRINT progname$;" by Catharine Winstanley, Mike Aitken and Rudolf Cardinal, ";version_date$ PRINT "Output by Yogita, 04-April-00" PRINT "Gambling for rats." PRINT "________________________________________________________________________" COLOUR white% PRINT "Date/Time: ";date_time$ PRINT FOR box% =1 TO nboxes% REPEAT COLOUR yellow%:PRINT ''"Box number ";box%:COLOUR white% using_the_box%(box%) = FNget_num_param("Use the box? "+STR$(yes%)+"=yes, "+STR$(no%)+"=no",yes%,0,1) IF using_the_box%(box%) = yes% THEN rat_id$(box%) = FNget_str_param("Enter rat ID (NO COMMAS):", "???") session_number%(box%) = FNget_num_param("Enter session number", 1, 1, 1000) treatment$(box%) = FNget_str_param("Treatment (NO COMMAS):", "Training") numtrials%(box%) = FNget_num_param("Number of trials",100,1,maxtrials%) session_length%(box%) = 60 * 100 * FNget_num_param("Session length limit (in MINUTES)",30,1,120) traylight_used%(box%) = FNget_num_param("Use traylight? "+STR$(yes%)+"=yes, "+STR$(no%)+"=no",yes%,0,1) brightness_level%(box%) = FNget_num_param("Enter level of brightness (1 to 6)", 6, 1, 6) REM here goes nothing- attempt to get some gambling parameters in here... number_of_choice_holes%(box%) = FNget_num_param("Enter number of choices available (1, 2 or 4)", 2, 1, 4) FOR h% = 1 TO nholes% REM get the values for each hole in turn IF h% = 3 THEN NEXT :REM don't care about hole 3 - not used. IF h% < 3 THEN def_pellets% = h% ELSE def_pellets% = h%-1 hole_pellets%(h%,box%) = FNget_num_param("Enter pellets reward for hole "+STR$(h%)+" ",def_pellets%,0,10) hole_timeout%(h%,box%) = FNget_num_param("Enter timeout length for hole "+STR$(h%)+" (csec)", 500, 0, 10000) hole_probtimeout(h%,box%) = FNget_num_param("Enter probability of timeout for hole "+STR$(h%)+" (0-1)",0.1,0,1) NEXT FOR d% = 1 TO ndelay_options% delay_option%(box%,d%) = FNget_num_param("Enter ITI delay option "+STR$(d%)+" of "+STR$(ndelay_options%)+" (csec)", 500, 0, 1000) NEXT stimulus_duration%(box%) = FNget_num_param("Enter stimulus duration (csec)", 1000, 0, 6000) timeout_duration%(box%) = FNget_num_param("Enter minimum timeout (darkness) interval (csec)", 500, 500, 6000) ENDIF UNTIL FNget_letter_param("Please confirm...", "YN", "") = "Y" NEXT PRINT' COLOUR red% OSCLI("CAT") REPEAT PRINT datafile$ = FNget_filename("DATA FILE - Filename for output") responsefile$ = FNget_filename("RESPONSE FILE - Filename for output") IF (datafile$=responsefile$) THEN PRINT"--- Unacceptable, can't have the same name for two." UNTIL NOT (datafile$=responsefile$) COLOUR yellow% PRINT''"KICKOFF." PRINT "------------" PRINT'"Ensure rats in boxes. Press a key to start.";:COLOUR white%:IFGET ENDPROC DEF PROCstart_the_box(box%) LOCAL hole% trial%(box%) = 0 :REM FNstart_trial increments it to 1 for the first trial finished%(box%) = no% nosepoke_state%(box%) = dont_care% FOR hole% = 1 TO nholes% PROCpipe_switch(nosepoke%(box%,hole%), On, 1, "FNnosepoke("+STR$(hole%)+",",box%,E%) NEXT PROCpipe_switch(panelpush%(box%), On, 1, "FNpanelpush(", box%, E%) PROCstart_session(box%) ENDPROC DEF PROCstart_session(box%) LOCAL dummy% PROCsingle_pellet(pellet_dispenser%(box%)) total_pellets%(box%) += 1 session_began_at%(box%) = TIME PROCrequire_a_poke(box%) ENDPROC DEF PROCrequire_a_poke(box%) PROCswitch_on(houselight%(box%),E%) IF traylight_used%(box%)=yes% THEN PROCswitch_on(traylight%(box%),E%) PROCset_np_state(box%, please_push%) please_push_began_at%(box%) = TIME PROCdisplay_box(box%) ENDPROC DEF PROCstart_trial_with_iti(box%) IF total_correct%(box%)+ total_omissions%(box%) >= numtrials%(box%) OR trial%(box%) >= maxtrials% OR (TIME-session_began_at%(box%))>session_length%(box%) THEN REM ... until we (1) reach the trial criterion; (2) hit the memory limit; (3) run out of time. PROCset_np_state(box%,finished_state%) PROCfinished(box%) ELSE trial_duration%(box%, trial%(box%)) = TIME - trial_began_at%(box%) :REM one trial finishes, the next begins trial%(box%) += 1 trial_began_at%(box%) = TIME - session_began_at%(box%) trial_start_time%(box%, trial%(box%)) = trial_began_at%(box%) PROCswitch_on(houselight%(box%),E%) PROCswitch_off(traylight%(box%),E%) PROCset_np_state(box%, intertrial_interval%) iti_began_at%(box%) = TIME iti_duration%(box%,trial%(box%)) = FNget_programmed_delay(box%) IF iti_duration%(box%,trial%(box%))>0 THEN PROCpipe_timer(iti_timer%+box%, iti_duration%(box%,trial%(box%)), 0, "FNoffer_stimulus(", box%, E%) ELSE dummy% = FNoffer_stimulus(box%,1) ENDIF PROCdisplay_box(box%) ENDPROC DEF FNoffer_stimulus(box%, bogus%) IF bogus% = 0 THEN = 0 LOCAL loop%, dummy% PROCset_np_state(box%, dont_care%) FOR h% = 1 TO nholes% hole_offered%(h%,box%,trial%(box%)) = FALSE REM One or more of these will be changed to TRUE below. NEXT CASE number_of_choice_holes%(box%) OF REM call procedures to choose which holes to offer WHEN 1: PROCforced_choice(box%) WHEN 2: PROCchoice_of_two(box%) WHEN 4: PROCchoice_of_four(box%) OTHERWISE: ERROR 0, "Internal error - invalid number_of_choice_holes% in FNoffer_stimulus" ENDCASE FOR h% = 1 TO nholes% IF hole_offered%(h%,box%,trial%(box%)) THEN PROCswitch_on(aperturelight%(box%,h%), E%) NEXT PROCpipe_timer(box% + stim_on_timer%,stimulus_duration%(box%), 0, "FNstimulus_over(" , box%, E%) stim_on_at%(box%) = TIME :REM time when light comes on PROCset_np_state(box%, stim_on%) :REM deals with all nosepoking! =0 DEF PROCforced_choice(box%) REM only one light comes on at a time, but the light changes from trial to trial (like v. easy 5 REM CSRT) REM we want a number from 1-5 that isn't 3 h% = FNrandom_integer(1,4) IF h%>=3 THEN h%=h%+1 hole_offered%(h%,box%,trial%(box%)) = TRUE ENDPROC DEF PROCchoice_of_two(box%) REM two lights come on during each trial, but these two change on every trial FOR loop% = 1 TO number_of_choice_holes%(box%) :REM should this be nholes%? REPEAT REM pick a hole... h% = FNrandom_integer(1,5) REM make usre it's not hole 3 and we haven't already picked it UNTIL h% <> 3 AND hole_offered%(h%,box%,trial%(box%)) = FALSE REM use the hole hole_offered%(h%,box%,trial%(box%)) = TRUE NEXT ENDPROC DEFPROCchoice_of_four(box%) FOR h% = 1 TO nholes% IF h% = 3 THEN NEXT hole_offered%(h%,box%,trial%(box%)) = TRUE NEXT ENDPROC REM if two stimuli are needed, I haven't writtne anything that means "if you don't poke where the REM light is, you'll get punished/nothing will happen etc. Need to put that in nosepoke code latREM er? REM CW: not using limited hold in this version DEF FNstimulus_over(box%, bogus%) IF bogus% = 0 THEN = 0 PROCswitch_off_all_holes(box%) total_omissions%(box%) += 1 PROCrequire_a_poke(box%) :REM- NO TIMEOUT PUNISHMENT REM chosen_hole% will remain at zero, which flags this trial as an omission, but in this task, will incorrect trials also be counted as omissions? = 0 DEF PROCswitch_off_all_holes(box%) LOCAL h% FOR h%=1 TO nholes% PROCswitch_off(aperturelight%(box%, h%), E%) NEXT ENDPROC DEF PROCset_timeout(box%) PROCswitch_off_all_holes(box%) PROCswitch_off(houselight%(box%), E%) PROCswitch_off(traylight%(box%), E%) timeout_began_at%(box%) = TIME PROCset_np_state(box%, timeout%) PROCpipe_timer(timeout_timer% + box%, timeout_duration%(box%), 0, "FNtimeout_finished(", box%, E%) ENDPROC DEF FNtimeout_finished(box%, bogus%) IF bogus%=0 =0 PROCswitch_off_all_holes(box%) :REM need to switch off flashing light after gambling timeout, OR DO WE? timeout_experienced%(box%, trial%(box%)) = TIME - timeout_began_at%(box%) PROCrequire_a_poke(box%) =0 DEFPROCtimeout_chance(box%,chosen_hole%) REM chance of getting a time out REM when any hole is chosen... IF RND(1) < hole_probtimeout(chosen_hole%,box%) THEN PROCswitch_off_all_holes(box%) PROCswitch_off(houselight%(box%), E%) PROCswitch_off(traylight%(box%), E%) REM: turn on chosen hole% and make it flash to make timeouts for different choices discriminable timeout_began_at%(box%) = TIME PROCset_np_state(box%, gambling_lost%) REM We enter the "gambling, lost" state... this is different from a punishment timeout, REM so we label it with a different state, but it does end in the same way as a punishment REM timeout, so we go to FNtimeout_finished in both cases. PROCpipe_timer(timeout_timer% + box%, hole_timeout%(chosen_hole%,box%), 0, "FNtimeout_finished(", box%, E%) PROCflash_line_time(aperturelight%(box%,chosen_hole%), flash_timer1%+box%, flash_timer2%+box%, 25, 25, hole_timeout%(chosen_hole%,box%)) ELSE PROCgive_reward(box%,chosen_hole%) ENDIF ENDPROC DEF PROCgive_reward(box%,chosen_hole%) PROCset_np_state(box%, dont_care%) PROCswitch_off_all_holes(box%) IF traylight_used%(box%)=yes% THEN PROCswitch_on(traylight%(box%), E%) numpellets% = hole_pellets%(chosen_hole%,box%) PROCspaced_pellet(pellet_dispenser%(box%), numpellets%, pellet_dispenser_timer%+box%,pellet_gap%) total_pellets%(box%) += numpellets% rewarded_at%(box%) = TIME PROCset_np_state(box%, awaiting_collect%) ENDPROC DEF FNget_programmed_delay(box%) = delay_option%(box%,FNrandom_integer(1,ndelay_options%)) REM ======================================================================== REM Nosepoke and panel-push code REM Nosepoke *duration* is ignored. REM ======================================================================== DEF PROCset_np_state(box%, state%) nosepoke_state%(box%) = state% REM PROCcheck_np(box%) PROCdisplay_state(box%) ENDPROC DEF FNnosepoke(hole%,box%,bogus%) IF bogus%=0 =0 REM In this program, we're not interested in NP duration, so never look at leaving the magazine. CASE nosepoke_state%(box%) OF WHEN dont_care%: REM not interested in NP REM NOTHING. WHEN please_push%: REM Perseverative nosepoke. PROCrecord_response(box%, hole%, TIME - please_push_began_at%(box%)) perseverative_nosepokes%(box%, trial%(box%)) += 1 WHEN intertrial_interval%: REM Premature response. PROCrecord_response(box%, hole%, TIME - iti_began_at%(box%)) premature_nosepokes%(box%, trial%(box%)) += 1 PROCkill_timer(box% + iti_timer%, E%) REM The ITI timer is stopped so there is no stimulus ON after this ITI. REM PROCkill_timer(box% + noise1_timer%, E%) REM If there is noise scheduled, it is now cancelled. PROCset_timeout(box%) WHEN stim_on%: REM Correct/incorrect response- which we don't really have here PROCkill_timer(box% + stim_on_timer%, E%) latency_to_respond%(box%, trial%(box%)) = TIME - stim_on_at%(box%) PROCrecord_response(box%, hole%, TIME - stim_on_at%(box%)) chosen_hole%(box%, trial%(box%)) = hole% IF hole_offered%(hole%,box%,trial%(box%)) = TRUE THEN REM useful or correct response PROCtimeout_chance(box%,hole%) total_hole%(hole%,box%) += 1 ELSE REM response to unlit hole = incorrect total_incorrect%(box%) += 1 REM nothing happens until end of stimulus REM this isn't where omissions come; this is where you deal with incorrect responses (responses to a hole that wasn't offered) ENDIF WHEN awaiting_collect%, gambling_lost%: REM Perseverative nosepoke. PROCrecord_response(box%, hole%, TIME - stim_on_at%(box%)) perseverative_nosepokes%(box%, trial%(box%)) += 1 WHEN timeout%: REM NOTHING - don't prolong a timeout. WHEN finished_state%: REM NOTHING. WHEN aborted_state%: REM NOTHING. OTHERWISE: VDU7:COLOUR magenta%:PRINTTAB(0,0);"--- Invalid case to FNnosepoke ---"; ENDCASE =0 DEF FNpanelpush(box%, bogus%) IF bogus%=0 =0 CASE nosepoke_state%(box%) OF WHEN dont_care%: REM not interested in NP REM NOTHING. WHEN please_push%: REM Begin a new trial, which begins with the "ITI". PROCstart_trial_with_iti(box%) WHEN intertrial_interval%: REM Perseverative panel-push. PROCrecord_response(box%, panel_code%, TIME - iti_began_at%(box%)) perseverative_panelpushes%(box%, trial%(box%)) += 1 WHEN stim_on%: REM Perseverative panel-push. PROCrecord_response(box%, panel_code%, TIME - stim_on_at%(box%)) REM perseverative_panelpushes%(box%, trial%(box%)) += 1 WHEN awaiting_collect%: REM Successful collection, record latency and begin a new trial with an ITI. latency_to_collect_reward%(box%, trial%(box%)) = TIME - rewarded_at%(box%) PROCstart_trial_with_iti(box%) WHEN gambling_lost%: REM NOTHING. WHEN timeout%: REM NOTHING. WHEN finished_state%: REM NOTHING. WHEN aborted_state%: REM NOTHING. OTHERWISE: VDU7:COLOUR magenta%:PRINTTAB(0,0);"--- Invalid case to FNpanelpush ---"; ENDCASE =0 DEF PROCrecord_response(box%, location%, time%) LOCAL r% IF recorded_responses%(box%) = max_responses% THEN COLOUR white% PRINTTAB(0,0);"--- Exceeded maximum number of recorded responses for box ";box%;" ---"; ENDPROC ELSE recorded_responses%(box%) += 1 r% = recorded_responses%(box%) response_time_in_trial%(box%-1, r%) = TIME - trial_began_at%(box%) response_trial%(box%-1, r%) = trial%(box%) response_phase%(box%-1, r%) = nosepoke_state%(box%) response_location%(box%-1, r%) = location% response_time%(box%-1, r%) = time% ENDIF ENDPROC REM ======================================================================== REM Displays during execution REM ======================================================================== DEF PROCdisplay_startup MODE 12 COLOUR yellow% PRINT "Gambling Task" PRINT progname$;" by CAW/RNC/MAF. Version of ";version_date$ PRINT "Date/Time: ";date_time$ PRINT "___________________________________________________________________________" COLOUR white% PRINT' PRINT"Box Trial State #Hole1 #Hole2 #Hole3 #Hole4 " PRINT"-----------------------------------------------------------------------------" REM 0123456789012345678901234567890123456789012345678901234567890123456789 display_firstline%=VPOS ENDPROC DEF FNdisplay_line(box%) = display_firstline% + (box%-1)*3 DEF PROCdisplay_box(box%) line% = FNdisplay_line(box%) COLOUR white% PRINTTAB(0,line%);box%; PRINTTAB(5,line%);trial%(box%); PROCdisplay_state(box%) COLOUR white% PRINTTAB(40,line%);total_hole%(1,box%); PRINTTAB(46,line%);total_hole%(2,box%); PRINTTAB(57,line%);total_hole%(4,box%); PRINTTAB(69,line%);total_hole%(5,box%); ENDPROC DEF PROCdisplay_state(box%) line% = FNdisplay_line(box%) COLOUR yellow% PRINTTAB(12,line%); CASE nosepoke_state%(box%) OF WHEN dont_care%: PRINT "Nothing much "; WHEN please_push%: PRINT "Awaiting panel push. "; WHEN intertrial_interval%: PRINT "Trial started, in 'ITI'. "; WHEN stim_on%: PRINT "Stimulus on... "; WHEN gambling_lost%: PRINT "Bad luck. Return to Vegas"; WHEN awaiting_collect%: PRINT "You won. Eat up. "; WHEN timeout%: PRINT "You've been a naughty rat"; WHEN finished_state%: PRINT "--- FINISHED --- "; WHEN aborted_state%: PRINT "--- ABORTED --- "; OTHERWISE: VDU7:COLOUR magenta%:PRINTTAB(0,0);"--- Invalid case to PROCdisplay_state ---"; ENDCASE COLOUR white% ENDPROC REM ======================================================================== REM Finishing up REM ======================================================================== DEF FNabort_box(box%,bogus%) :REM checked for AC IF bogus%=0 =0 PROCset_np_state(box%,aborted_state%) PROCfinished(box%) =0 DEF PROCfinished(box%) LOCAL hole%, i% PROCswitch_off_all_holes(box%) PROCswitch_off(houselight%(box%), E%) PROCswitch_off(traylight%(box%), E%) FOR hole% = 1 TO nholes% PROCkill_switch(nosepoke%(box%,hole%), E%) NEXT PROCkill_switch(panelpush%(box%), E%) REM ... any timers outstanding? Shouldn't be. finished%(box%) = yes% FOR i%=1 TO nboxes% IF using_the_box%(i%)=yes% AND finished%(i%)<>yes% THEN ENDPROC NEXT REM Now all boxes have finished. PROCkill_all REM Output. REM ----------------------------------------------------------------- LOCAL ch%,t%,r%,d$,score, pers_np%, prem_np%, pers_pp% ch% = OPENOUT(datafile$) REM Don't have lines longer than about 160 chars; BASIC can't load it ("Bad program"). PROCprint_string(ch%,"PROGNAME,DATE_TIME,RAT,BOX,SESSION,STIM_DUR,TIMEOUT_DUR,TREATMENT,NUMCHOICE") PROCprint_string(ch%,"TRIAL,ITI_TIME,PPP,PREM_NP,OFFERED_1,OFFERED_2,OFFERED_4,OFFERED_5,NUM_OFFERED,CHOSEN,RESPONSE_LATENCY,") PROCprint_line(ch%,"PERSEV_RESPONSES,COLLECT_LATENCY,EXPERIENCED_TIMEOUT,TOTALH1,TOTALH2,TOTALH4,TOTALH5") FOR box% = 1 TO nboxes% IF using_the_box%(box%)=yes% THEN FOR t% = 1 TO trial%(box%) PROCprint_string(ch%, progname$+"("+version_date$+"),"+date_time$+","+rat_id$(box%)+","+STR$(box%)) PROCprint_string(ch%, ","+STR$(session_number%(box%))+","+STR$(stimulus_duration%(box%))) PROCprint_string(ch%, ","+STR$(timeout_duration%(box%))+","+treatment$(box%)) PROCprint_string(ch%, ","+STR$(number_of_choice_holes%(box%))) REM how am I going to record responses here? PROCprint_string(ch%, ","+STR$(t%)) PROCprint_string(ch%, ","+STR$(iti_duration%(box%,t%))) PROCprint_string(ch%, ","+STR$(perseverative_panelpushes%(box%,t%))) PROCprint_string(ch%, ","+STR$(premature_nosepokes%(box%,t%))) PROCprint_string(ch%, ","+STR$(FNtrue1(hole_offered%(1,box%,t%)))) PROCprint_string(ch%, ","+STR$(FNtrue1(hole_offered%(2,box%,t%)))) PROCprint_string(ch%, ","+STR$(FNtrue1(hole_offered%(4,box%,t%)))) PROCprint_string(ch%, ","+STR$(FNtrue1(hole_offered%(5,box%,t%)))) PROCprint_string(ch%, ","+STR$(FNtrue1(hole_offered%(1,box%,t%))+FNtrue1(hole_offered%(2,box%,t%))+FNtrue1(hole_offered%(4,box%,t%))+FNtrue1(hole_offered%(5,box%,t%)))) PROCprint_string(ch%, ","+STR$(chosen_hole%(box%,t%))) PROCprint_string(ch%, ","+STR$(latency_to_respond%(box%,t%))) PROCprint_string(ch%, ","+STR$(perseverative_nosepokes%(box%,t%))) PROCprint_string(ch%, ","+STR$(latency_to_collect_reward%(box%,t%))) PROCprint_line(ch%, ","+STR$(timeout_experienced%(box%,t%))) NEXT ENDIF NEXT CLOSE#ch% ch% = OPENOUT(responsefile$) PROCprint_string(ch%,"PROGNAME,DATE_TIME,RAT,BOX,") PROCprint_line(ch%,"TRIAL,PHASE,LOCATION,TIME") FOR box% = 1 TO nboxes% IF using_the_box%(box%)=yes% THEN d$ = progname$ + "," + date_time$ + "," + rat_id$(box%) + "," + STR$(box%) + "," FOR r% = 1 TO recorded_responses%(box%) PROCprint_string(ch%, d$ + STR$(response_trial%(box%-1,r%)) + "," + STR$(response_phase%(box%-1,r%))) PROCprint_line(ch%, "," + STR$(response_location%(box%-1,r%)) + "," + STR$(response_time%(box%-1,r%))) PROCprint_line(ch%, "," + STR$(response_time_in_trial%(box%-1,r%))) NEXT ENDIF NEXT CLOSE#ch% PRINT COLOUR magenta% PRINT"Session Complete" PRINT PRINT"Total food:"' FOR box%=1 TO nboxes% PRINT "Box ";box%;": ";total_pellets%(box%);" pellets (";FNfood_mass(total_pellets%(box%));" g)" NEXT =0 DEF FNtrue1(bool%) IF bool% THEN =1 =0