\ Copyright (c) 2011 MEDState Notation Repository, All rights reserved.
\ Delayed Reward_v2.mpc
\
\ After ITI the House Light and Stim Light are turned on. Animal is given a
\ specified amount of time to respond with a nose poke. If no response, a Type
\ 1 Omission is recorded.
\
\ If there is a response, then for the forced trials either the Immediate or the
\ Delayed lever is presented alternatingly and the Stim Light is turned off.
\ If this is a free choice trial, then both levers are presented. If there is
\ no lever press within the specified time, then a Type 2 Omission is recorded.
\
\ If the Delayed lever is chosen then the lever(s) are retracted, the House
\ Light is turned off, the large reward is given and the Stim Light is turned on
\ after the delay. If there is no nose poke in the pellet tray within the
\ specified time, then a Type 3 Omission is recorded.
\
\ If the Immediate lever is chosen then the lever(s) are retracted, the Stim
\ Light is turned on, House Light is turned off, and 1 pellet is given. There
\ is no delay before the reward when the Immediate lever is chosen. If there is
\ no nose poke in the pellet tray within the specified time, then a Type 4
\ Omission is recorded.
\
\ The program will start with the specified number of forced trials and then the
\ rest of the trials in the block will be free choice trials. When the number
\ of trials per block have been reached the program will draw a new delay to the
\ large reward from LIST N. When all trial blocks have been completed the
\ program will end.
\
\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution.
\ Inputs
^LeftLever = 1
^RightLever = 2
^Nosepoke = 3 \ Level Mode
\ Outputs
^LeftLever = 1
^RightLever = 2
^Pellet = 3
^StimLight = 4
^HouseLight = 8
\ A() = Control Variables with Assigned Aliases as Defined
Var_Alias New Trial Interval (sec) = A(0) \ Default = 100 seconds
Var_Alias Response Time (sec) = A(1) \ Default = 10 seconds
Var_Alias Immediate Reward Lever (1=Left 2=Right) = A(2) \ Default = 1-Left
Var_Alias Delayed Reward Lever (1=Left 2=Right) = A(3) \ Default = 2-Right
Var_Alias Number of Pellets for Delayed Rewards = A(4) \ Default = 4
Var_Alias Number of Blocks to Run = A(5) \ Default = 5
Var_Alias Number of Forced Trials (Should be an Even #) = A(6) \ Default = 2
Var_Alias Number of Trials per Block = A(7) \ Default = 12
Var_Alias SoftCR Data Array (1=Yes 0=No) = A(8) \ Default = 1
^NTI = 0
^ResponseTime = 1
^ImmediateLever = 2
^DelayedLever = 3
^LargeReward = 4
^NumBlocks = 5
^ForcedTrials = 6
^TrialsPerBlock = 7
^SoftCR = 8
^NTITicks = 9
^ResponseTicks = 10
\ List Data Variables Here
\ B() = Experiment Totals
\ B(0) = Not Used
\ B(1) = Total Pellets Delivered
\ B(2) = Total Immediate Lever Responses
\ B(3) = Total Delayed Lever Responses
\ B(4) = Total Successful Trials
\ B(5) = Total Nose Poke Omissions (Type 1)
\ B(6) = Total Lever Omissions (Type 2)
\ B(7) = Total Delayed Reward Omissions (Type 3)
\ B(8) = Total Immediate Reward Omissions (Type 4)
\
\ C() = SoftCR Array
\
\ D() = Trial by Trial Data
\ D(J) = Trial Number in this Block
\ D(J+1) = Number of Pellets Delivered this Trial
\ D(J+2) = Lever Chosen (1=Immediate, 2=Delayed)
\ D(J+3) = Omission Type (1, 2, 3, or 4)
\ D(J+4) = Trial Completed Successfully (1=Yes, 0=No)
\ D(J+5) = Latency to Initial Nose Poke
\ D(J+6) = Latency to Lever Press
\ D(J+7) = Latency to Final Nose Poke
\ D(J+8) = Delay Time to Reward
\
\ E() = Block by Block Data
\ E(K) = Block Number
\ E(K+1) = Number of Pellets Delivered this Block
\ E(K+2) = Number of Immediate Lever Responses this Block
\ E(K+3) = Number of Delayed Lever Responses this Block
\ E(K+4) = Number of Successful Trials this Block
\ E(K+5) = Number of Nose Poke Omissions (Type 1) this Block
\ E(K+6) = Number of Lever Omissions (Type 2) this Block
\ E(K+7) = Number of Delayed Reward Omissions (Type 3) this Block
\ E(K+8) = Number of Immediate Reward Omissions (Type 4) this Block
\ List Working Variables Here
\ F = Counter for Nose Poke Level Inputs
\ G = List for selecting the Forced Trial Type
\ H = Forced Trial Type (Immediate or Delayed) drawn from List G
\ I = Subscript for the SoftCR Array C
\ J = Subscript into the Trial Array D
\ K = Subscript into the Block Array E
\ L = Block Number
\ M = Trial Number this Block
\ N = List of Delay Times
\ O = Nose Poke Latency Timer
\ P = Lever Latency Timer
\ Q = Number of Pellets to Deliver
\ R = Number of Rewards Delivered
\ S = Subscript into List N
\ T = Elapsed Time in 0.01 sec increments for SoftCR Data
\ U = Delay Time that was drawn from List N
LIST G = 1, 2 \ Forced Trial Type
LIST N = 0", 10", 20", 40", 60" \ List of Delay Times
DIM A = 10
DIM B = 8
DIM C = 100000 \ Dimension Array C for 100,001 data points.
\ Under MED-PC Version IV, this array may be
\ enlarged up to 1 million elements; however,
\ 100,001 was felt to be adequate for this application.
\ An end of array seal -987.987 will limit the saved
\ file to only those elements used during the running
\ of the procedure.
DIM D = 50000
DIM E = 1000
\ Z-Pulses Used in this Program
^Z_Pellet = 1 \ Signal Pellet Delivery
^Z_NPLat = 2 \ Signal Start of Nose Poke Latency Counter
^Z_LeverLat = 3 \ Signal Start of Lever Latency Counter
^Z_LatEnd = 4 \ Signal End of Latency Counters
^Z_PelletEnd = 5 \ Signal End of Pellet Deliveries
^Z_NewTrial = 6 \ Signal New Trial
^Z_CorrectResp = 7 \ Signal a Step or Correct Response
^Z_Reward = 8 \ Signal a Pip or Reward Issued
^Z_Type1 = 9 \ Signal a Event 0 or Type 1 Omission
^Z_Type2 = 10 \ Signal a Event 1 or Type 2 Omission
^Z_Type3 = 11 \ Signal a Event 2 or Type 3 Omission
^Z_Type4 = 12 \ Signal a Event 3 or Type 4 Omission
^Z_NPBreak = 13 \ Signal Completed Nose Poke Break
^Z_NPRelease = 14 \ Signal Nose Poke Withdrawal
DISKCOLUMNS = 9
DISKFORMAT = 10.2
DISKVARS = A, B, C, D, E
\***************************************************
\ DELAYED REWARD_V2 SCHEDULE
\ S1 - Set Default Values
\ New Trial Interval (100 sec)
\ Response Time (10 sec)
\ Immediate Reward Lever (1-Left)
\ Delayed Reward Lever (2-Right)
\ Number of Pellets for Delayed Rewards (4)
\ Number of Blocks to Run (5)
\ Number of Forced Trials (2)
\ Number of Trials per Block (12)
\ SoftCR Data Array (1-Yes)
\***************************************************
S.S.1,
S1,
0.01": SET A(^NTI) = 100, A(^ResponseTime) = 10, A(^ImmediateLever) = 1;
SET A(^DelayedLever) = 2, A(^LargeReward) = 4, A(^NumBlocks) = 5;
SET A(^ForcedTrials) = 2, A(^TrialsPerBlock) = 12, A(^SoftCR) = 1 ---> S2
S2, \ First Statement: Wait for START signal, initialize the Trial
\ number and the Block number, and transition to ITI.
\
\ Second Statement: Update screen display with default values
\ for control variables. This will show any changes made via
\ the Configure | Change Variables window prior to START.
#START: CLEAR 1,60; SET L = 1, M = 1;
RANDD H = G; LIST U = N(S);
SET D(J+9) = -987.987, E(K+9) = -987.987;
SET A(^NTITicks) = A(^NTI) * 1";
SET A(^ResponseTicks) = A(^ResponseTime) * 1" ---> S3
1": SHOW 1,New Trial Int,A(^NTI), 2,Response Time,A(^ResponseTime), 3,Immediate Lever,A(^ImmediateLever);
SHOW 4,Delayed Lever,A(^DelayedLever), 5,# of Pellets,A(^LargeReward), 6,# of Blocks,A(^NumBlocks);
SHOW 7,Forced Trials,A(^ForcedTrials), 8,Trials/Block,A(^TrialsPerBlock), 9,SoftCR Code,A(^SoftCR) ---> SX
S3, \ Time Initial ITI. Signal start of Nose Poke Latency counter.
#Z^Z_NewTrial: ON ^HouseLight, ^StimLight;
SET E(K) = L, D(J) = M;
Z^Z_NPLat ---> S4
S4, \ If Nose Poke is made within allotted time, turn off
\ the Stim Light and extend only one lever if a
\ forced trial or both levers if a free choice trial.
\ Signal start of Lever Latency counter.
\
\ If Timeout, record Type 1 Omission.
#Z^Z_NPBreak: OFF ^StimLight; SET D(J+5) = O;
Z^Z_LeverLat; Z^Z_LatEnd; Z^Z_CorrectResp;
IF M > A(^ForcedTrials) [@Free, @Forced]
@Free: ON ^LeftLever, ^RightLever ---> S5
@Forced: IF H = 1 [@Immediate, @Delayed]
@Immediate: ON A(^ImmediateLever) ---> S5
@Delayed: ON A(^DelayedLever) ---> S5
A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
ADD B(5), E(K+5);
SET D(J+3) = 1, D(J+5) = O;
Z^Z_LatEnd; Z^Z_Type1 ---> S10
S5, \ If Lever response is made within allotted time, turn off
\ the House Light, retracts the levers. Signal to issue
\ immediate rewards.
\
\ If Timeout, record Type 2 Omission.
#RA(^ImmediateLever): ADD B(2), E(K+2); ON ^StimLight;
OFF ^HouseLight, ^LeftLever, ^RightLever;
SET D(J+2) = 1, D(J+6) = P, Q = 1;
Z^Z_Pellet; Z^Z_NPLat;
Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
#RA(^DelayedLever): ADD B(3), E(K+3);
OFF ^HouseLight, ^LeftLever, ^RightLever;
SET D(J+2) = 2, D(J+6) = P, Q = A(^LargeReward);
Z^Z_LatEnd; Z^Z_CorrectResp ---> S7
A(^ResponseTicks)#T: OFF ^HouseLight, ^LeftLever, ^RightLever;
ADD B(6), E(K+6);
SET D(J+3) = 2, D(J+6) = P;
Z^Z_LatEnd; Z^Z_Type2 ---> S10
S6, \ Immediate Reward Lever chosen. If Nose Poke detected
\ record latency.
\
\ If timeout record Type 4 Omission.
#Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
ADD B(4), D(J+4), E(K+4);
SET D(J+7) = O;
Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
ADD B(8), E(K+8);
SET D(J+3) = 4, D(J+7) = O;
Z^Z_LatEnd; Z^Z_Type4 ---> S10
S7, \ Delayed Reward Lever chosen. Wait until delay time
\ has elapsed, signal for the large reward to be
\ issued, and turn on the Stim Light.
U#T: ON ^StimLight; SET D(J+8) = U;
Z^Z_Pellet; Z^Z_NPLat ---> S8
S8, \ If Nose Poke detected record latency. If Z^Z_PelletEnd
\ pulse arrives, last pellet has been issued, begin timer.
#Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
ADD B(4), D(J+4), E(K+4);
SET D(J+7) = O;
Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
#Z^Z_PelletEnd: ---> S9
S9, \ If Nose Poke detected record latency.
\
\ If timeout record Type 3 Omission.
#Z^Z_NPBreak: OFF ^HouseLight, ^StimLight;
ADD B(4), D(J+4), E(K+4);
SET D(J+7) = O;
Z^Z_LatEnd; Z^Z_CorrectResp ---> S10
A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
ADD B(7), E(K+7);
SET D(J+3) = 3, D(J+7) = O;
Z^Z_LatEnd; Z^Z_Type3 ---> S10
S10, \ Wait for New Trial Signal. Increment trial number.
\ Select next lever for forced trials. If this is the
\ 12th trial in this block, increment the block number,
\ select new Delay value, and reset trial number to 1.
\ Signal start of Nose Poke Latency counter.
#Z^Z_NewTrial: ADD M; RANDD H = G;
IF M > A(^TrialsPerBlock) [@NewBlock, @Cont]
@New: LIST U = N(S); ADD L;
IF L > A(^NumBlocks) [@End, @Cont]
@End: ---> S11
@Cont: SET K = K + 9, E(K+9) = -987.987;
SET M = 1, J = J + 9, D(J+9) = -987.987;
ON ^HouseLight, ^StimLight;
SET E(K) = L, D(J) = M; Z^Z_NPLat ---> S4
@Cont: SET J = J + 9, D(J+9) = -987.987;
ON ^HouseLight, ^StimLight;
SET D(J) = M; Z^Z_NPLat ---> S4
S11, \ Wait for Screen Update and end with
\ STOPABORTFLUSH for Automatic Data Saving
2": ---> STOPABORTFLUSH
\***************************************************
\ REWARD CONTROL TIMER
\***************************************************
S.S.2,
S1,
#Z^Z_Pellet: ON ^Pellet; ADD B(1), D(J+1), E(K+1);
Z^Z_Reward ---> S2
S2, \ Time Reward Device for 0.05 seconds
0.05": OFF ^Pellet; ADD R;
IF R >= Q [@Done, @Cont]
@Done: SET R = 0; Z^Z_PelletEnd ---> S1
@Cont: ---> S3
S3,
0.45": ON ^Pellet; ADD B(1), D(J+1), E(K+1);
Z^Z_Reward ---> S2
\***************************************************
\ INCREMENT TIME T FOR IRT AND EVENT ARRAY
\***************************************************
S.S.3, \ 10ms Resolution. Every 10ms = 1 Tick
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
0.01": ADD T ---> SX
\*********************************************************
\ ADD A STEP ELEMENT TO ARRAY C FOR EACH CORRECT RESPONSE
\*********************************************************
S.S.4, \ Enter each Response into Array C.
\ This code is for Relative or Incremental
\ values. If Absolute or Cumulative values are
\ desired, delete the code ", T = 0" in S2.
S1,
#START: IF A(^SoftCR) > 0 [@ActivateSoftCR, @NoSoftCR]
@ActSoftCR: SET C(I) = 0.50, I = I + 1, C(I) = -987.987 ---> S2
@NoSoftCR: SET C(0) = -987.987 ---> SX \ Seal Array
S2,
#Z^Z_CorrectResp: SET C(I) = T + 0.10, T = 0; ADD I;
IF I = 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\***************************************************
\ ADD A PIP ELEMENT TO ARRAY C FOR EACH REWARD
\***************************************************
S.S.5, \ Enter each Reward into Array C.
\ This code is for Relative or Incremental
\ values. If Absolute or Cumulative values are
\ desired, delete the code ", T = 0" in S2.
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
#Z^Z_Reward: SET C(I) = T + 0.20, T = 0; ADD I;
IF I = 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\************************************************************
\ ADD AN EVENT 0 ELEMENT TO ARRAY C FOR EACH TYPE 1 OMISSION
\************************************************************
S.S.6, \ Enter each Type 1 Omission into Array C.
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
#Z^Z_Type1: SET C(I) = T + 0.60, C(I+1) = 0.50, T = 0, I = I + 2;
IF I >= 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\************************************************************
\ ADD AN EVENT 1 ELEMENT TO ARRAY C FOR EACH TYPE 2 OMISSION
\************************************************************
S.S.7, \ Enter each Type 2 Omission into Array C.
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
#Z^Z_Type2: SET C(I) = T + 0.61, C(I+1) = 0.51, T = 0, I = I + 2;
IF I >= 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\************************************************************
\ ADD AN EVENT 2 ELEMENT TO ARRAY C FOR EACH TYPE 3 OMISSION
\************************************************************
S.S.8, \ Enter each Type 3 Omission into Array C.
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
#Z^Z_Type3: SET C(I) = T + 0.62, C(I+1) = 0.52, T = 0, I = I + 2;
IF I >= 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\************************************************************
\ ADD AN EVENT 3 ELEMENT TO ARRAY C FOR EACH TYPE 4 OMISSION
\************************************************************
S.S.9, \ Enter each Type 4 Omission into Array C.
S1,
#START: IF A(^SoftCR) > 0 [] ---> S2
S2,
#Z^Z_Type4: SET C(I) = T + 0.63, C(I+1) = 0.53, T = 0, I = I + 2;
IF I >= 100000 [@True, @False]
@True: ---> S1
@False: SET C(I) = -987.987 ---> SX
\***************************************************
\ NOSE POKE LATENCY COUNTER
\***************************************************
S.S.10, \ 10ms Resolution
S1,
#Z^Z_NPLat: SET O = 0.01 ---> S2
S2,
0.01": SET O = O + 0.01 ---> SX
#Z^Z_LatEnd: ---> S1
\***************************************************
\ LEVER LATENCY COUNTER
\***************************************************
S.S.11, \ 10ms Resolution
S1,
#Z^Z_LeverLat: SET P = 0.01 ---> S2
S2,
0.01": SET P = P + 0.01 ---> SX
#Z^Z_LatEnd: ---> S1
\***************************************************
\ TIME NEW TRIAL INTERVAL
\***************************************************
S.S.12, \ Times the New Trial Interval. A new trial
\ is started every A(^NTI) seconds regardless
\ of the responses that the animal has done.
S1,
#START: ---> S2
S2,
A(^NTITicks)#T: Z^Z_NewTrial ---> S2
\***************************************************
\ NOSE POKES DEFINED - 20ms BREAK, 20ms RELEASE
\***************************************************
S.S.13, \ Nose Poke Defined - 20ms Break, 20ms Release.
S1,
#Z^Z_NPLat: ---> S2
S2, \ Inputs in Level Mode generate an input "count" on each
\ interrupt. With a 10 ms system resolution 2 counts
\ will be reached in 20 ms. The Z^Z_NPBreak pulse is used to
\ signal a completed Beam Break. The second statement resets
\ the counter every 20 ms so that a partial Beam Break of
\ less than 20 ms will not constitute a Response.
#R^NosePoke: ADD F; IF F >= 2 [@BeamBreak, @NoBeamBreak]
@Break: SET F = 0; Z^Z_NPBreak ---> S3
@NoBreak: ---> SX
0.02": SET F = 0 ---> S2
S3, \ As long as the Beam is broken the second statement
\ causes a re-entry to this State. This resets the
\ the internal 20 ms timer so it never times out. When
\ the Beam is released for 20 ms the timer times out
\ and a Z^Z_NPRelease pulse signals the release.
0.02": Z^Z_NPRelease ---> S1
#R^NosePoke: ---> S3
\***************************************************
\ UPDATE DISPLAY
\***************************************************
S.S.14,
S1,
#START: SHOW 1,Tot Pellets,B(1), 2,Immed Lvr Presses,B(2), 3,Delay Lvr Presses,B(3);
SHOW 4,Completed Trials,B(4), 5,Tot Type 1,B(5), 6,Tot Type 2,B(6);
SHOW 7,Tot Type 3,B(7), 8,Tot Type 4,B(8);
SHOW 11,Block #,L, 12,Trial #,M, 13,Delay,U/1" ---> S2
S2,
1": SHOW 1,Tot Pellets,B(1), 2,Immed Lvr Presses,B(2), 3,Delay Lvr Presses,B(3);
SHOW 4,Completed Trials,B(4), 5,Tot Type 1,B(5), 6,Tot Type 2,B(6);
SHOW 7,Tot Type 3,B(7), 8,Tot Type 4,B(8);
SHOW 11,Block #,L, 12,Trial #,M, 13,Delay,U/1" ---> S2
|