\ This code trains the mice to nose poke in response to a pure tone cue \ and withhold nosepoking behavior in response to a white-noise cue. \ There are 5 distinct periods: \ITI Period - Z1: 10", house light off, responses recorded but not rewarded \Pre-Cue Period - Z2: random interval 9"-24", house light on, laser on for Pre-cue period only, \responses recorded but not rewarded, responses in the last 3" of this period result in \immediate termination of the trial and jump to ITI \Go Cue Period - Z3: 0"-30", house light on, pure 2.9 kHz Tone at 70-75 dB, and laser triggered, first head-entry \immediately terminates the phase and initiates the Reward Delivery Period, after 30" no head-entry results \in termination of the trial and jumps straight to the ITI. \No-Go Cue Period - Z4: 0"-30", house light on, white noise at 0.5" pulses at 70-75 dB, and laser triggered, \first head-entry immediately terminates the phase and initiates the ITI Period, no head-entry results \in termination of the Cue period and initiates the Reward Period. \Reward Delivery Period - Z5:3", house light on, initiates reward delivery, paired with a click \and LED light in the dispenser \Session lasts for 60 trials or 40' \ Filename, Go/No-Go-(Tone/Noise)-with-Laser_2017-04-24.mpc \ Date: July 17, 2017 \*********************************************************** \ Inputs (up to 4) \*********************************************************** ^HeadEntry = 1 \*********************************************************** \ Outputs (up to 8) \*********************************************************** ^House = 1 ^Reward = 2 ^Light = 3 ^Click = 4 ^Tone = 5 ^WhiteNoise = 6 ^Laser = 7 \*********************************************************** \ Variables \*********************************************************** \ A() = Control Variables with Assigned Aliases as Defined Var_Alias Max Trial Number = A(1) Default = 61 Var_Alias Max Duration (mins) = A(2) Default = 40 ^MaxTrials = 1 ^MaxDuration = 2 \Data Variables \B() = Total periods (ITI+PreCue+GoCue+NoGoCue+Reward) \B(0) = Total number of Trials (determined by how many ITIs have been) \B(1) = Total number of nosepokes \B(2) = Total number of Rewards \B(3) = Total number of Go Trials \B(4) = Total number of No-Go Trials \B(5) = Total number of Premature Responses \B(6) = Total number of Go CORRECT \B(7) = Total number of Go FALSE \B(8) = Total number of No-Go FALSE \B(9) = Total number of No-Go CORRECT \B(10) = Total session duration \C() = SoftCR Array \D() = Trial by trial data (DIM D = 61* \D(J) = Trial # \D(J+1) = ITI Nosepokes \D(J+2) = PreCue Nosepokes \D(J+3) = Pre-Cue Success? (Y/N = 1/0) \D(J+4) = Go Cue Nosepokes \D(J+5) = Go Cue Success? (Y/N = 1/0) \D(J+6) = No Go Cue Nosepokes \D(J+7) = No Go Cue Success? (Y/N = 1/0) \D(J+8) = Reward Nosepokes \E() = Time bin data (DIM E = 40*60*5* #variables \E(K) = T (timepoint) \E(K+1) = #R^NosePoke \E(K+2) = #Z^Z_ITI \E(K+3) = #Z^Z_PreCue \E(K+4) = #Z^Z_GoCue \E(K+5) = #Z^Z_NoGoCue \E(K+6) = #Z^Z_Reward \E(K+7) = #Z^Z_Premature \E(K+8) = #Z^Z_GoCorrect \E(K+9) = #Z^Z_GoFail \E(K+10) = #Z^Z_NoGoCorrect \E(K+11) = #Z^Z_NoGoFail \F(G) = Latency & Duration Data \F(G+1) = ITI latency to first nosepoke \F(G+2) = ITI Duration \F(G+3) = Pre Cue latency to first nosepoke \F(G+4) = Pre Cue Duration \F(G+5) = Go Cue latency to first nosepoke \F(G+6) = Go Cue Duration \F(G+7) = No Go Cue latency to first nosepoke \F(G+8) = No Go Cue Duration \F(G+9) = Reward Period latency to first nosepoke \F(G+10) = Reward Period Duration \ A = \ A(0) = Not used \ A(1) = A(^MaxTrials) = Maximum number of trials counted by number of ITI periods (61) \ A(2) = A(^MaxDuration) = Maximum session duration (40 mins) \ B = Array to count totals \ C = \ D = Array for Trial by Trial Data Collection \ E = Array for Time Bin Data collection \ F = Array for Latency and Period Duration Data Collection \ G = Subscript for Array F - Latency and Period Duration Data Collection \ H = \ I = \ J = Subscript for Array D - Trial by Trial Data Collection \ K = Subscript for Array E - Time Bin Data Collection \ L = List - Random Trial Generator \ M = List - Random Time Generator \ N = Premature response count and show \ O = GoCorrect response count and show \ P = GoFail response count and show \ Q = NoGoCorrect response count and show \ R = NoGoFail response count and show \ S = Total Nosepoke count and show \ T = Session Timer \ U = Number of Trials \ V = Latency & period duration timer \ W = \ X = Random Time Intervals Generation 60"-90" \ Y = Random Trial Generation List L = 1, 2, 1, 2, 1, 2 List M = 6", 7", 8", 9", 10", 11", 12", 13", 14", 15", 16", 17", 18", 19", 20", 21" \*********************************************************** \ Z-pulses (up to 32 allowed) \*********************************************************** ^Z_ITI = 1 \ITI Period initiation ^Z_PreCue = 2 \Pre-Cue Period initiation ^Z_GoCue = 3 \Go Cue Period initiation ^Z_NoGoCue = 4 \No-Go Cue Period initiation ^Z_Reward = 5 \Reward Delivery Period initiation ^Z_GoCorrect = 6 \Go Trial: Success ^Z_GoFail = 7 \Go Trial: Failure ^Z_NoGoFail = 8 \No-Go Trial: Failure ^Z_NoGoCorrect = 9 \No-Go Trial: Success ^Z_ITINosePoke = 10 \NosePokes during ITI ^Z_PreCueNosePoke = 11 \NosePokes during Pre-Cue Period ^Z_RewardNosePoke = 12 \NosePokes during Reward Period ^Z_TotalNosePokes = 13 \Total # NosePokes ^Z_PreCueSuccess = 14 \Total # successful Pre-Cue Periods ^Z_PreCueFail = 15 \Total # unsuccessful Pre-Cue Periods \^Z_ = 16 \^Z_ = 17 \^Z_ = 18 \^Z_ = 19 \^Z_ = 20 \^Z_ = 21 \^Z_ = 22 \^Z_ = 23 \^Z_ = 24 \^Z_ = 25 \^Z_ = 26 \^Z_ = 27 \^Z_ = 28 \^Z_ = 29 \^Z_ = 30 \^Z_ = 31 \^Z_ = 32 \*********************************************************** \ Trial Logic \*********************************************************** S.S.1, \*********************************************************** \ ITI 10 seconds, house lights off \*********************************************************** S1, \Turn on house light and issue Z^Z_ITI pulse to initiate the first ITI #START : ON ^House ; Z^Z_ITI ---> S2 S2, \Turn house light off, move to S3 0.001" : OFF ^House ---> S3 S3, \Count NosePokes and trigger NosePoke counting Z-pulses #R^NosePoke : Z^Z_ITINosePoke ; Z^Z_TotalNosePokes ---> S3 \after 10" of house light off turn them back on \initiate a new Pre-Cue Period and move to S4 10" : ON ^House ; Z^Z_PreCue ---> S4 \*********************************************************** \ Pre-Cue Period & premature response logic \*********************************************************** S4, \Turn on opto Laser and move to S6 0.001" : ON ^Laser ---> S6 S6, \Initiate random time selected from List M (6-21") move on to S7 0.001" : RANDD X = M ---> S7 S7, \Count NosePokes - register both Pre-Cue NosePokes and for total #NosePokes #R^NosePoke : Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes --> S8 S8, \If the animal responds in the last three seconds trigger ITI and move to S2, \if not initiate trial randomisation #R^NosePoke : OFF ^Laser ; Z^Z_ITI ; Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes ; Z^Z_PreCueFail ----> S2 3" : OFF ^Laser ; Z^Z_PreCueSuccess ---> S9 \*********************************************************** \ Randomly generate trial order (Go v. No-Go) \*********************************************************** S9, \Randomly select a number from List L 0.001" : RANDD Y = L ---> S10 S10, \If the number was 1 then trigger Go Cue, else trigger No- Go Cue and wait for the next Z-Pulse 0.001" : IF Y = 1 [@GO, @NOGO] @GO : Z^Z_GoCue ---> S11 @NOGO : Z^Z_NoGoCue ---> S13 \*********************************************************** \ Go Cue Period, 0-30" no response triggers ITI, \ response triggers Reward Delivery Period \*********************************************************** S11, \Trigger Tone then move to S12 0.001" : ON ^Tone, ^Laser ---> S12 S12, \If response trigger Reward Delivery Period and move to S15 \If no response count omission, trigger ITI, and move to S2 #R^NosePoke : OFF ^Tone, ^Laser ; Z^Z_GoCorrect ; Z^Z_Reward ; Z^Z_TotalNosePokes ---> S15 30" : OFF ^Tone, ^Laser ; Z^Z_GoFail ; Z^Z_ITI ---> S2 \ No-Go Cue Period, 0-30" no response triggers Reward Period, \ response triggers ITI \*********************************************************** S13, \Trigger White Noise then move to S14 0.001" : ON ^Noise, ^Laser ---> S14 S14, \If response trigger ITI, count False Alarm, and move to S2 \If no response count Omission, trigger Reward Period, and move to S15 #R^NosePoke : OFF ^Tone, ^Laser ; Z^Z_NoGoFail ; Z^Z_TotalNosePokes ; Z^Z_ITI ---> S1 30" : OFF ^Tone, ^Laser ; Z^Z_NoGoCorrect ; Z^Z_Reward ---> S15 \*********************************************************** \ Reward Delivery Period Logic \*********************************************************** S15, \deliver reward paired with a click and LED light 0.001" : ON ^Reward, ^Click, ^Light ---> S16 S16, \Count NosePokes #R^NosePoke : Z^Z_RewardNosePoke ; Z^Z_TotalNosePokes ---> S17 S17, \turn off reward and click 0.001" : OFF ^Reward, ^Click ---> S18 S18, \turn off LED Light, trigger ITI, and return to S1 3" : OFF ^Light ; ^Z_ITI ---> S2 \*********************************************************** \ Latency to First Response & Period Duration Logic \*********************************************************** S.S.2, \HeadEntry Latency Counter: Set array, wait for Z pulses, set timer to zero S1, 0.01" : SET F(G) = -987.987 ---> S2 S2, #Z^Z_ITI : SET V = 0 ---> S3 #Z^Z_PreCue : SET V = 0 ---> S4 #Z^Z_GoCue : SET V = 0 ---> S5 #Z^Z_NoGoCue : SET V = 0 ---> S6 #Z^Z_Reward : SET V = 0 ---> S7 S3, \********* ITI Period ********* 0.01" : SET V = V + 0.01 ---> S3 #R^NosePoke : SET F(G+1) = V ; ADD G+1 ; \ITI Latency SET F(G+1) = -987.987 ---> S4 #Z^Z_PreCue : SET F(G+2) = V ; ADD G+2 ; \ITI Duration if no Nosepoke SET F(G+2) = -987.987 ; SET V = 0 ---> S5 S4, 0.01" : SET V = V + 0.01 ---> S4 #Z^Z_PreCue : SET F(G+2) = V ; ADD G+2 ; \ITI Duration SET F(G+2) = -987.987 ; SET V = 0 ---> S5 \********* Pre Cue Period ********* S5,\ PreCue NosePoke Latency and Duration Timer 0.01" : SET V = V + 0.01 ---> S5 #R^NosePoke : SET F(G+3) = V ; ADD G+3 ; \Pre Cue Latency SET F(G+3) = -987.987 ---> S6 #Z^Z_ITI : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration if no NosePoke SET F(G+4) = -987.987 ; SET V = 0 ---> S3 #Z^Z_GoCue : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration if no NosePoke SET F(G+4) = -987.987 ; SET V = 0 ---> S8 #Z^Z_NoGoCue : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration if no NosePoke SET F(G+4) = -987.987 ; SET V = 0 ---> S10 S6, 0.01" : SET V = V + 0.01 ---> S6 #Z^Z_ITI : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration SET F(G+4) = -987.987 ; SET V = 0 ---> S3 #Z^Z_GoCue : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration SET F(G+4) = -987.987 ; SET V = 0 ---> S8 #Z^Z_NoGoCue : SET F(G+4) = V ; ADD G+4 ; \Pre Cue Duration SET F(G+4) = -987.987 ; SET V = 0 ---> S10 \********* Go Cue Period ********* S7,\ Go Cue NosePoke Latency and Duration Timer 0.01" : SET V = V + 0.01 ---> S7 #R^NosePoke : SET F(G+5) = V ; ADD G+5 ; \Go Cue Latency SET F(G+5) = -987.987 ---> S8 #Z^Z_Reward : SET F(G+6) = V ; ADD G+6 ; \Go Cue Duration if no nosepoke SET F(G+6) = -987.987 ; SET V = 0 ---> S11 #Z^Z_ITI : SET F(G+6) = V ; ADD G+6 ; \Go Cue Duration if no nosepoke SET F(G+6) = -987.987 ; SET V = 0 ---> S3 S8, 0.01" : SET V = V + 0.01 ---> S8 #Z^Z_Reward : SET F(G+6) = V ; ADD G+6 ; \Go Cue Duration SET F(G+6) = -987.987 ; SET V = 0 ---> S11 #Z^Z_ITI : SET F(G+6) = V ; ADD G+6 ; \Go Cue Duration SET F(G+6) = -987.987 ; SET V = 0 ---> S3 \********* No Go Cue Period ********* S9,\ No Go Cue NosePoke Latency and Duration Timer 0.01" : SET V = V + 0.01 ---> S9 #R^NosePoke : SET F(G+7) = V ; ADD G+7 ; \No Go Cue Latency SET F(G+7) = -987.987 ---> S10 #Z^Z_Reward : SET F(G+8) = V ; ADD G+8 ; \No Go Cue Duration if no nosepoke SET F(G+8) = -987.987 ; SET V = 0 ---> S11 #Z^Z_ITI : SET F(G+8) = V ; ADD G+8 ; \No Go Cue Duration if no nosepoke SET F(G+8) = -987.987 ; SET V = 0 ---> S3 S10, 0.01" : SET V = V + 0.01 ---> S10 #Z^Z_Reward : SET F(G+8) = V ; ADD G+8 ; \No Go Cue Duration SET F(G+8) = -987.987 ; SET V = 0 ---> S11 #Z^Z_ITI : SET F(G+8) = V ; ADD G+8 ; \No Go Cue Duration SET F(G+8) = -987.987 ; SET V = 0 ---> S3 \********* Reward Period ********* S11,\ Reward NosePoke Latency and Duration Timer 0.01" : SET V = V + 0.01 ---> S11 #R^NosePoke : SET F(G+9) = V ; ADD G+9 ; \Reward Latency SET F(G+9) = -987.987 ---> S12 #Z^Z_ITI : SET F(G+10) = V ; ADD G+10 ; \Reward Duration if no nosepoke SET F(G+10) = -987.987 ; SET V = 0 ---> S3 S12, 0.01" : SET V = V + 0.01 ---> S12 #Z^Z_ITI : SET F(G+10) = V ; ADD G+10 ; \Reward Duration SET F(G+10) = -987.987 ; SET V = 0 ---> S3 \*********************************************************** \ Incremental Increases \*********************************************************** S.S.3, \Set Time Bin Timer to increment with each 0.02" for timebin data collection S1, 0.2" : SET K = K+12 ---> SX S.S.4, \Set Latency/Duration Timer to increment with each PreCue Z-pulse as a marker of a new trial S1, #Z^Z_PreCue : SET G = G+11 ---> SX S.S.5, \Set set Trial by Trial counter to increment with each PreCue Z-pulse as a marker of a new trial S1, #Z^Z_PreCue : SET J = J+9 ---> SX \*********************************************************** \ Data Collection: Logging Z pulses and #Rs into Arrays \*********************************************************** S.S.6, S1, \ Wait for ITI Cue #Z^Z_ITI : ADD E(K+2) ---> S2 S2, \ ITI Period #R^NosePoke : ADD E(K+1) ---> S2 #Z^Z_ITINosePoke : ADD D(J+1) ---> S2 #Z^Z_TotalNosePokes : ---> S2 #Z^Z_PreCue : E(K+3) ---> S3 S3, \ Pre Cue Period #R^NosePoke : ADD E(K+1) ---> S3 #Z^Z_PreCueNosePoke : ADD D(J+2) ---> S3 #Z^Z_TotalNosePokes : ADD B(1) ---> S3 #Z^Z_PreCueSuccess : SET D(J+3) = 1 ; ADD J+3 ; SET D(J+3) = -987.987 ---> S3 #Z^Z_PreCueFail : SET D(J+3) = 0 ; ADD J+3, E(K+7), B(5); SET D(J+3) = -987.987 ---> S3 #Z^Z_GoCue : ADD E(K+4), B(3) ---> S4 #Z^Z_NoGoCue : ADD E(K+5), B(4) ---> S4 S4, \ Go Cue Period #R^NosePoke : ADD E(K+1), D(J+4) ---> S4 #Z^Z_GoCorrect : SET D(J+5) = 1 ; ADD J+5, E(K+8), B(6) ; SET D(J+5) = -987.987 ---> S4 #Z^Z_GoFail : SET D(J+5) = 0 ; ADD J+5, E(K+9), B(7) ; SET D(J+5) = -987.987 ---> S4 #Z^Z_TotalNosePokes : ADD B(1) #Z^Z_Reward : ADD E(K+6), B(2) ---> S6 #Z^Z_ITI : ADD E(K+2) ---> S2 S5, \ No Go Cue Period #R^NosePoke : ADD E(K+1), D(J+6) ---> S5 #Z^Z_NoGoCorrect : SET D(J+7) = 1 ; ADD J+7, E(K+10), B(8) ; SET D(J+7) = -987.987 ---> S5 #Z^Z_NoGoFail : SET D(J+7) = 0 ; ADD J+7, E(K+11), B(9) ; SET D(J+7) = -987.987 ---> S5 #Z^Z_TotalNosePokes : ADD B(1) #Z^Z_Reward : ADD E(K+6), B(2) ---> S6 #Z^Z_ITI : ADD E(K+2) ---> S2 S6, \ Reward Period #R^NosePoke : ADD E(K+1) ---> S6 #Z^Z_RewardNosePoke : ADD D(J+8) #Z^Z_TotalNosePokes : ADD B(1) #Z^Z_ITI : ADD E(K+2) ---> S2 \*********************************************************** \ Count & Display Logic \*********************************************************** S.S.7, \Count and display: # response types and total nosepokes S1, 0.001" : SHOW 3, premature, ; SHOW 4, gocorrect, ; SHOW 5, gofail, ; SHOW 6, nogocorrect, ; SHOW 7, nogofail, ; SHOW 8, totalnosepokes, ---> S2 S2, #Z^Z_Premature : ADD N; SHOW 3, premature, N ; #Z^Z_GoCorrect : ADD O; SHOW 4, gocorrect, O ; #Z^Z_GoFail : ADD P; SHOW 5, gofail, P ; #Z^Z_NoGoCorrect : ADD Q; SHOW 6, nogocorrect, Q ; #Z^Z_NoGoFail : ADD R; SHOW 7, nogofail, R ; #Z^Z_TotalNosePokes : ADD S; SHOW 8, totalnosepokes, S ---> SX \*********************************************************** \ Session Timer & # of Trials Logic \*********************************************************** S.S.8, \Count and display: Total # Trials (by counting number of ITI Periods initiated with Z-pulse) S1, \Set Max number of trials @ START command #START: SET A (^MaxTrials) = 61 SHOW 2, trials, U ---> S2 S2, \Wait for Z^ITI Pulse, on Z-Pulse move to S3 increase the trial count by 1 with each Z^Z_ITI pulse issued #Z^Z_ITI : ADD U; SHOW 2,trials,O; \at Z_ITI-Pulse add 1 to trial number IF U >= 61 [@True, @False] \If trial number >= Max trial number @True: ---> S3 \End session via S3 @False: ---> SX \If not - await next ITI Z-Pulse S3, \ 1" : SET B(10) = A (^MaxDuration) ; ADD B(10) ; SET B(10) = -987.987 ; SET B(0) = A (^MaxTrials) ; ADD B(0) ; SET B(0) = -987.987 ---> STOPABORTFLUSH S.S.9, \Session Timer S1, \start session timer @ START command #START: SET A (^MaxDuration) = 40; SHOW 1,Session,T ---> S2 S2, \increment every second; once minutes = 40 then stop abort 1" : ADD T; SHOW 1,Session,T; IF T/60 >= A (^MaxDuration) [@True, @False] @True: ---> S3 @False: ---> SX S3, 3" : SET B(10) = A (^MaxDuration) ; ADD B(10) ; SET B(10) = -987.987 ; SET B(0) = A (^MaxTrials) ; ADD B(0) ; SET B(0) = -987.987 ---> STOPABORTFLUSH \That's all, folks! \S.M.Tyree \***********************************************************