Chaining Response/Outcome Issues

MEDState Notation Repository › Forums › Coding Help Archive › Chaining Response/Outcome Issues

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #12640
    Med_Support
    Moderator
    milliel

    Hey Everyone,

     

    I’ve been working on this code and I am having some issues

     

    Mainly in S.S.1
    The transition from S3 to S4 is not fully working. The nose poke turns on but does not turn off after a response is made, and the lever light does not turn on after a nose poke is made but a response on the correct lever results in sipper descent. However, the sipper remains descended for longer than the 2 seconds for which it is programmed. Both omission types appear to functioning and being recorded correctly so I am confused as to how some but not all aspects of these statements are functioning.
    
     
    
    Any thoughts?
    
     
    
     
    
    S.S.1,
    S1,
    0.01": SET A(^ResponseTime) = 10, A(^CorrectLever) = 1;
    SET A(^NumBlocks) = 6, A(^NTI) = 4;
    SET A(^TrialsPerBlock) = 15, 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 J = 1, K = 1;
    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,Correct Lever,A(^CorrectLever);
    SHOW 4,# of Blocks,A(^NumBlocks), 5,Trials Per Block,A(^TrialsPerBlock), 6,SoftCR Code,A(^SoftCR) ---> SX
    
     
    
    S3, \\\\ Time Initial ITI. Signal start of Nose Poke Latency counter.
    #Z^Z_NewTrial : ON ^CenterNPLight;
    SET E(K) = J, D(J) = K;
    Z^Z_NPLat ---> S4
    
     
    
    S4, \\\\ If Nose Poke is made within allotted time, turn off
    \\\\ the NP Light and turn on lever light
    \\\\ Signal start of Lever Latency counter.
    \\\\
    \\\\ If Timeout, record Type 1 Omission.
    
    #R^Nosepoke : IF L < 10" [@TrueRun, @ FalseTimeout]
    @TrueRun: OFF ^CenterNPLight; SET D(J+3) = O;
    Z^Z_LeverLat; Z^Z_LatEnd; Z^Z_CorrectResp;
    ON ^LLeverLIGHT ---> S5
    
    @FalseTimeout: OFF ^CenterNPLight;
    ADD B(4), E(K+4);
    SET D(J+1) = 1, D(J+3) = O;
    Z^Z_LatEnd; Z^Z_Type1 ---> S5
    
     
    
     
    
    S5, \\\\ If Lever response is made within allotted time, turn off
    \\\\ the LeverLight, Signal to issue immediate reward.
    \\\\ If Timeout, record Type 2 Omission.
    
    #RA(^CorrectLever): IF M < 10" [@TrueRun, @ FalseTimeout]
    @TrueRun: ADD B(2), E(K+2);
    OFF ^LLeverLight;
    SET D(J+6) = M, N = 1;
    Z^Z_Sipper; Z^Z_NPLat;
    Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
    @ FalseTimeout: OFF ^LLeverLight;
    ADD B(5), E(K+5);
    SET D(J+1) = 2, D(J+4) = M;
    Z^Z_LatEnd; Z^Z_Type2 ---> S3
    
     
    
    S6, \\\\ Wait for New Trial Signal. Increment trial number.
    \\\\ Signal start of Nose Poke Latency counter.
    
    #Z^Z_NewTrial: ADD K;
    IF K > A(^TrialsPerBlock) [@NewBlock, @Cont]
    @New: ADD J;
    IF J > A(^NumBlocks) [@End, @Cont]
    @End: ---> S7
    @Cont: SET I = I + 6, E(K+6) = -987.987;
    SET K = 1, H = H + 5, D(J+5) = -987.987;
    ON ^CenterNPLight;
    SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4
    @Cont: SET H = H + 5, D(J+5) = -987.987;
    ON ^CenterNPLight;
    SET D(J) = K; Z^Z_NPLat ---> S4
    
     
    
    S7, \\\\ Wait for Screen Update and end with
    \\\\ STOPABORTFLUSH for Automatic Data Saving
    
    2": ---> STOPABORTFLUSH
    

     

    #12641
    Med_Support
    Moderator
    Gary Bamberger

    Hello,

    I don’t think I have enough information to answer your question. You only posted S.S.1 so I don’t know what is going on in the rest of the program. The only thing that I can do is tell you what the State Set you posted will do.

    S1, Initializes your variables. —> S2

    S2, Waits for the START command, seals the arrays, and converts seconds to MED Ticks. —> S3

    S3, Waits for a #Z^Z_NewTrial, turns on Center NP Light, sets E(K) = J and D(J) = K (NOTE: K and J look like they are pulling double duty) —> S4

    S4, Waits for a NP. It will wait forever for a NP. L looks like it is used as a timer somewhere.
    If L < 1000, turn off Center NP Light, on Left Lever Light, set D(J+3) = O —> S5
    If L >= 1000, turn off Center NP Light, add B(4), add E(K+4), set D(J+1) = 1, set D(J+3) = O —> S5
    NOTE: Both true and false go to S5
    NOTE: The false statement does not turn on the Left Lever Light

    S5, Waits for a response on the Correct Lever. It will wait forever for a response. M looks like it is used as a timer somewhere.
    If M < 1000, turn off Left Lever Light, add B(2), E(K+2), set D(J+6) = M, set N = 1 —> S6
    If M >= 1000, turn off Left Lever Light, add B(5), E(K+5), set D(J+1) = 2, set D(J+4) = N —> S3

    S6, Waits for a #Z^Z_NewTrial, adds K and/or J if new trial block
    State looks like it sets up the next trial and/or next block, then turns on Center NP Light —> S4
    If Number of Trials and Number of Blocks are finished —> S7

    S7, Waits 2″ then ends with STOPABORTFLUSH

    I don’t know if elsewhere in the program the Center NP Light is turned on or off, but S4 will turn it off no matter when the response happened.

    The sipper is controlled somewhere else in the program. I can only see a Z^Z_Sipper in S5 telling the sipper to activate.

     

    I hope that this helps.
    Gary

    #12644
    Med_Support
    Moderator
    milliel

    Hey Gary,
    Thanks for your help. I have gone through and made significant changes to the code which I am hopeful will fix the problems I was having however, I’ve now run into PASCAL errors when trying to translate and compile into Med-PC.

     

    The errors say “constant expression violates subrange bounds” , “$C Fixed Preload Permanent”, “Fatal:Could not compile used unit DF041033625.pas” but does not give any specific state, state sets, or code lines associated with these errors.

     

    The following is my code in its entirety, if you have any thoughts as to what might be causing these errors your help would be greatly appreciated.

     

    – Lauren

     

    \\After ITI the NosePoke light is turned on. Animal is given 10s to respond with a nose poke. If no response, a Type
    \\ 1 Omission is recorded.
    
     
    
    \\If there is a response, then the left lever light is turned on. If there is
    \\no lever press within 10s, then a Type 2 Omission is recorded.
    \\\
    \\ If the Correct lever is chosen then the lever
    \\ Light is turned off, and 2s reward is given. With an ITI of 4s
    \\ before the start of a new trial indicated by the illumination of the NosePoke.
    \\\\***********************************************************************************************************************************************************
    \\\
    \\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution.
    
     
    
     
    
    \Inputs
    ^LeftLever = 1
    ^RightLever = 2
    ^Nosepoke = 4
    
     
    
    \Outputs
    ^LeftLever = 1
    ^RightLever = 2
    ^Sipper = 3
    ^NosePoke = 4
    ^LLeverLight = 5
    ^RLeverLight = 6
    
     
    
    \ A() = Control Variables with Assigned Aliases as Defined
    Var_Alias Response Time (sec) = A(1) Default = 10 seconds
    Var_Alias Correct Lever (1=Left) = A(2) Default = 1-Left
    Var_Alias SoftCR Data Array (1=Yes 0=No) = A(3) Default = 1
    Var_Alias Number of Blocks to Run = A(4) Default = 23
    Var_Alias Number of Trials per Block = A(5) Default = 4
    
     
    
     
    
     
    
    ^NTI = 0
    ^ResponseTime = 1
    ^CorrectLever = 2
    ^SoftCR = 3
    ^NumBlocks = 4
    ^TrialsPerBlock = 5
    ^ResponseTicks = 6
    ^NTITicks = 7
    
     
    
    \List Data Variables Here
    \ B() = Experiment Totals
    \ B(0) = Not Used
    \ B(1) = Total Rewards Delivered
    \ B(2) = Total Correct Lever Responses
    \ B(3) = Total Successful Trials
    \ B(4) = Total NosePoke Omissions (Type 1)
    \ B(5) = Total Lever Omissions (Type 2)
    \ B(6) = Total NosePokes
    
     
    
    \ C() = SoftCR Array
    
     
    
    \ D() = Trial by Trial Data
    \ D(J) = Trial Number in this Block
    \ D(J+1) = Omission Type (1, or 2)
    \ D(J+2) = Trial Completed Successfully (1=Yes, 0=No)
    \ D(J+3) = Latency to Initial Nose Poke
    \ D(J+4) = Latency to Lever Press
    
     
    
     
    
    \ E() = Block by Block Data
    \ E(K) = Block Number
    \ E(K+1) = Number of Rewards Delivered this Block
    \ E(K+2) = Number of Correct Lever Responses this Block
    \ E(K+3) = Number of Successful Trials this Block
    \ E(K+4) = Number of NosePoke Omissions (Type 1) this Block
    \ E(K+5) = Number of Lever Omissions (Type 2) this Block
    \ E(K+6) = Number of NosePokes
    
     
    
    \ List Working Variables Here
    \ F = Counter for Nose Poke Level Inputs
    \ G = Subscript for the SoftCR Array C
    \ H = Subscript into the Trial Array D
    \ I = Subscript into the Block Array E
    \ J = Block Number
    \ K = Trial Number this Block
    \ L = Nose Poke Latency Timer
    \ M = Lever Latency Timer
    \ N = Number of Rewards to Deliver
    \ O = Number of Rewards Delivered
    \ P = Elapsed Time in 0.01 sec increments for SoftCR Data
    
     
    
     
    
    DIM A = 6
    DIM B = 7
    DIM C = 100000
    DIM D = 500000
    DIM E = 100000
    
     
    
     
    
    \ Z-Pulses Used in this Program
    ^Z_Sipper = 1 \\\\ Signal Sipper 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_SipperEnd = 5 \\\\ Signal End of Sipper 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
    
     
    
     
    
    DISKCOLUMNS = 9
    DISKFORMAT = 10.2
    DISKVARS = A, B, C, D, E
    
     
    
    \\\\***************************************************
    \\\\ DELAYED REWARD_V2 SCHEDULE\
    \\\\ S1 - Set Default Values\
    \\\\ New Trial Interval (4s)
    \\\\ Response Time (10 sec)
    \\\\ Correct Reward Lever (1-Left)
    \\\\ Number of Blocks to Run (6)
    \\\\ Number of Trials per Block (15)
    \\\\ SoftCR Data Array (1-Yes)
    \\\\***************************************************
    S.S.1,
    S1,
    0.01": SET A(^ResponseTime) = 10", A(^CorrectLever) = 1;
    SET A(^NumBlocks) = 23, A(^NTI) = 4";
    SET A(^TrialsPerBlock) = 4, 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 J = 1, K = 1;
    SET D(J+5) = -987.987, E(K+7) = -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,Correct Lever,A(^CorrectLever);
    SHOW 4,# of Blocks,A(^NumBlocks), 5,Trials Per Block,A(^TrialsPerBlock), 6,SoftCR Code,A(^SoftCR) ---> SX
    
     
    
    S3, \\\\ Time Initial ITI. Signal start of Nose Poke Latency counter.
    #Z^Z_NewTrial: ON ^NosePoke;
    SET E(K) = J, D(J) = K;
    Z^Z_NPLat ---> S4
    
     
    
    S4, \\\\ If NosePoke is made within allotted time, turn off
    \\\\ the NP Light and turn on lever light
    \\\\ Signal start of Lever Latency counter.
    \\\\
    \\\\ If Timeout, record Type 1 Omission.
    
     
    
    #R^Nosepoke : IF L < 10" [@TrueRun, @ FalseTimeout]
    @TrueRun: OFF ^NosePoke; SET D(J+3) = L;
    ADD B(6), E(K+6);
    Z^Z_LeverLat; Z^Z_LatEnd; Z^Z_CorrectResp;
    ON ^LLeverLIGHT ---> S5
    
     
    
    @FalseTimeout: OFF ^NosePoke;
    ADD B(4), E(K+4);
    SET D(J+1) = 1, D(J+3) = L;
    Z^Z_LatEnd; Z^Z_Type1 ---> S5
    
     
    
     
    
    S5, \\\\ If Lever response is made within allotted time, turn off
    \\\\ the LeverLight, Signal to issue immediate reward.
    \\\\ If Timeout, record Type 2 Omission.
    
     
    
    #RA(^CorrectLever): IF M < 10" [@TrueRun, @ FalseTimeout]
    @TrueRun: ADD B(2), E(K+2);
    OFF ^LLeverLight;
    SET D(J+4) = M, N = 1;
    Z^Z_Sipper; Z^Z_NPLat;
    Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
    @ FalseTimeout: OFF ^LLeverLight;
    ADD B(5), E(K+5);
    SET D(J+1) = 2, D(J+4) = M;
    Z^Z_LatEnd; Z^Z_Type2 ---> S3
    
     
    
    S6, \\\\ Wait for New Trial Signal. Increment trial number.
    \\\\ Signal start of Nose Poke Latency counter.
    
     
    
    #Z^Z_NewTrial : ADD K;
    IF K > A(^TrialsPerBlock) [@NewBlock, @Cont]
    @New: ADD J;
    IF J > A(^NumBlocks) [@End, @Cont]
    @End: ---> S7
    @Cont: SET I = I + 6, E(K+5) = -987.987;
    SET K = 1, D(J+3) = -987.987;
    ON ^NosePoke;
    SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4
    @Cont: SET D(J+3) = -987.987;
    ON ^NosePoke;
    SET D(J) = K; Z^Z_NPLat ---> S4
    
     
    
    S7, \\\\ Wait for Screen Update and end with
    \\\\ STOPABORTFLUSH for Automatic Data Saving
    
     
    
    2": ---> STOPABORTFLUSH
    
     
    
     
    
    \\\\***************************************************
    \\\\ REWARD CONTROL TIMER
    \\\\***************************************************
    S.S.2,
    S1,
    #Z^Z_Sipper: ON ^Sipper; ADD B(1), D(J+1), E(K+1);
    Z^Z_Reward ---> S2
    
     
    
    S2, \\\\ Time Reward Device for 2 seconds
    2": OFF ^Sipper; ADD R;
    IF R >= Q [@Done, @Cont]
    @Done: SET R = 0; Z^Z_SipperEnd ---> S1
    @Cont: ---> S3
    
     
    
    S3,
    2": ON ^Sipper; 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; 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; 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) > O [] ---> 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
    
     
    
    \\\\***************************************************
    \\\\ NOSE POKE LATENCY COUNTER
    \\\\***************************************************
    S.S.8, \\\\ 10ms Resolution\\\
    S1,
    #Z^Z_NPLat: SET L = 0.01 ---> S2
    
     
    
    S2,
    0.01": SET L = L + 0.01 ---> SX
    #Z^Z_LatEnd: ---> S1
    
     
    
     
    
    \\\\***************************************************
    \\\\ LEVER LATENCY COUNTER
    \\\\***************************************************
    S.S.9, \\\\ 10ms Resolution
    S1,
    #Z^Z_LeverLat: SET M = 0.01 ---> S2
    
     
    
    S2,
    0.01": SET M = M + 0.01 ---> SX
    #Z^Z_LatEnd: ---> S1
    
     
    
    \\\\***************************************************
    \\\\ UPDATE DISPLAY\\\
    \\\\***************************************************
    S.S.10,
    S1,
    #START: SHOW 1,Tot Rewards,B(1), 6,Tot NosePokes,B(6);
    SHOW 3,Completed Trials,B(3), 4,Tot Type 1,B(4), 5,Tot Type 2,B(5) ---> S2
    
     
    
     
    
    S2,
    1": SHOW 1,Tot Rewards,B(1), 6,Tot NosePokes,B(6);
    SHOW 3,Completed Trials,B(3), 4,Tot Type 1,B(4), 5,Tot Type 2,B(5) ---> S2
    
     
    
     
    
    \\\\***************************************************
    \\\\ Time New Trial
    \\\\***************************************************
    S.S.11,
    S1,
    #START: ---> S2
    S2,
    A(^NTITicks) #T: Z^Z_NewTrial ---> S2
    
    

    AttSSL copy

    #12646
    Med_Support
    Moderator
    Gary Bamberger

    Hi Lauren,

    Let’s take a look at the error message:

     

    “constant expression violates subrange bounds” , “$C Fixed Preload Permanent”, “Fatal:Could not compile used unit DF041033625.pas”

     

    Most Pascal error messages are useless.  They do not tell you what the problem was with the code.  The above error message is one of the few that actually contains some useful information about the problem.  Specifically the statement:

     

    Error: Constant expression violates subrange bounds

     

    What this means is that an array was declared with the DIM statement and you are trying to access an array element beyond the declared size.

    It looks like you have tried to expand the size of the A Array by adding one element:

    ^NTITicks = 7
    
    S2,
    #START: CLEAR 1,60; SET J = 1, K = 1;
    SET D(J+5) = -987.987, E(K+7) = -987.987;
    SET A(^NTITicks)      = A(^NTI)          * 1";
    SET A(^ResponseTicks) = A(^ResponseTime) * 1" ---> S3
    

    But the A Array is still set to DIM A = 6.  When I expand the size of the A Array:

    DIM A = 7

    to include the new element the program compiles as expected.

     

    I hope that this information helps.
    Gary

    #12648
    Med_Support
    Moderator
    milliel

    Hey Gary,
    Thanks for your help with the error message. Unfortunately I am still having issues with my latencies and my omissions being recorded correctly. I’ve looked over several codes using latencies and can not seem to parse out what my issue is.

     

    Again any thoughts you have would be greatly appreciated.

     

    \\\\*****************************************************************************************************************************
    \\After ITI the Center NosePoke light is turned on.  Animal is given 10s to respond with a nose poke.  If no response, a Type
    \\ 1 Omission is recorded.
    
     
    
    \\If there is a response, then the left lever light is turned on.  If there is
    \\no lever press within 10s, then a Type 2 Omission is recorded.
    \\\
    \\ If the Correct lever is chosen then the lever
    \\ Light is turned off, and 2s reward is given.
    \\\\*****************************************************************************************************************************
    \\\
    \\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution.
    
     
    
     
    
    \Inputs
    ^LeftLever  = 1
    ^RightLever = 2
    ^Nosepoke   = 4
    
     
    
    \Outputs
    ^LeftLever  = 1
    ^RightLever = 2
    ^Sipper     = 3
    ^NosePoke   = 4
    ^LLeverLight  = 5
    ^RLeverLight = 6
    
     
    
    \ A() = Control Variables with Assigned Aliases as Defined
    Var_Alias Response Time (sec)                           = A(1)  Default = 10 seconds
    Var_Alias Correct Lever (1=Left)                        = A(2)  Default = 1-Left
    Var_Alias SoftCR Data Array (1=Yes  0=No)         = A(3)  Default = 1
    Var_Alias Number of Blocks to Run                       = A(4)  Default = 23
    Var_Alias Number of Trials per Block                    = A(5)  Default = 4
    
     
    
     
    
     
    
    ^NTI            = 0
    ^ResponseTime   = 1
    ^CorrectLever   = 2
    ^SoftCR         = 3
    ^NumBlocks      = 4
    ^TrialsPerBlock = 5
    ^ResponseTicks  = 6
    ^NTITicks       = 7
    
     
    
    \List Data Variables Here
    \ B() = Experiment Totals
    \ B(0) = Not Used
    \ B(1) = Total Rewards Delivered
    \ B(2) = Total Correct Lever Responses
    \ B(3) = Total Successful Trials
    \ B(4) = Total NosePoke Omissions        (Type 1)
    \ B(5) = Total Lever Omissions           (Type 2)
    \ B(6) = Total NosePokes
    
     
    
    \ C() = SoftCR Array
    
     
    
    \  D() = Trial by Trial Data
    \  D(J)   = Trial Number in this Block
    \  D(J+1) = Omission Type (1, or 2)
    \  D(J+2) = Trial Completed Successfully (1=Yes, 0=No)
    \  D(J+3) = Latency to Initial Nose Poke
    \  D(J+4) = Latency to Lever Press
    
     
    
     
    
    \  E() = Block by Block Data
    \  E(K)   = Block Number
    \  E(K+1) = Number of Rewards Delivered this Block
    \  E(K+2) = Number of Correct Lever Responses this Block
    \  E(K+3) = Number of Successful Trials this Block
    \  E(K+4) = Number of NosePoke Omissions         (Type 1) this Block
    \  E(K+5) = Number of Lever Omissions            (Type 2) this Block
    \  E(K+6) = Number of NosePokes
    
     
    
    \ List Working Variables Here
    \  F = Counter for Nose Poke Level Inputs
    \  G = Subscript for the SoftCR Array C
    \  H = Subscript into the Trial Array D
    \  I = Subscript into the Block Array E
    \  J = Block Number
    \  K = Trial Number this Block
    \  L = Nose Poke Latency Timer
    \  M = Lever Latency Timer
    \  N = Number of Rewards to Deliver
    \  O = Number of Rewards Delivered
    \  P = Elapsed Time in 0.01 sec increments for SoftCR Data
    
     
    
     
    
    DIM A = 8
    DIM B = 7
    DIM C = 100000
    DIM D = 50000
    DIM E = 10000
    
     
    
     
    
    \ Z-Pulses Used in this Program
    ^Z_Sipper      = 1   \\\\ Signal Sipper 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_SipperEnd   = 5   \\\\ Signal End of Sipper 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
    
     
    
     
    
    DISKCOLUMNS = 9
    DISKFORMAT  = 10.2
    DISKVARS    = A, B, C, D, E
    
     
    
    \\\\***************************************************
    \\\\            DELAYED REWARD_V2 SCHEDULE\
    \\\\ S1 - Set Default Values\
    \\\\   New Trial Interval                    (4s)
    \\\\   Response Time                         (10 sec)
    \\\\   Correct Reward Lever                  (1-Left)
    \\\\   Number of Blocks to Run               (6)
    \\\\   Number of Trials per Block            (15)
    \\\\   SoftCR Data Array                     (1-Yes)
    \\\\***************************************************
    S.S.1,
    S1,
    0.01": SET A(^ResponseTime) = 10,   A(^CorrectLever)   = 1;
    SET A(^NumBlocks)    = 23,    A(^NTI)            = 4;
    SET A(^TrialsPerBlock) = 4, 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 J = 1, K = 1;
    SET D(J+5) = -987.987, E(K+7) = -987.987;
    SET A(^NTITicks)= A(^NTI)  * 1";
    SET A(^ResponseTicks) = A(^ResponseTime) * 1"; Z^Z_NewTrial ---> S3
    1": SHOW 1,New Trial Int,A(^NTI),         2, Response Time,A(^ResponseTime),      3,Correct Lever,A(^CorrectLever);
    SHOW 4,# of Blocks,A(^NumBlocks),         5,Trials Per Block,A(^TrialsPerBlock),  6,SoftCR Code,A(^SoftCR) ---> SX
    
     
    
    S3,     \\\\ Time Initial ITI.  Signal start of Nose Poke Latency counter.
    4" : ON ^NosePoke ;
    SET E(K) = J, D(J) = K;
    Z^Z_NPLat ---> S4
    
     
    
    S4,     \\\\ If Nose Poke is made within allotted time, turn off
    \\\\ the NP Light and turn on lever light
    \\\\ Signal start of Lever Latency counter.
    \\\\
    \\\\ If Timeout, record Type 1 Omission.
    
     
    
    #R^Nosepoke       : IF L <=10 [@TrueRun, @ FalseTimeout]
    @TrueRun: OFF ^NosePoke; ON ^LLeverLIGHT;
    SET D(J+3) = L;
    ADD B(6), E(K+6);Z^Z_LatEnd;
    Z^Z_LeverLat; Z^Z_CorrectResp ---> S5
    
     
    
    @FalseTimeout:  OFF ^NosePoke;
    ADD B(4), E(K+4);
    SET D(J+1) = 1;
    Z^Z_Type1 ---> S3
    
     
    
     
    
    S5,     \\\\ If Lever response is made within allotted time, turn off
    \\\\ the LeverLight, Signal to issue immediate reward.
    \\\\  If Timeout, record Type 2 Omission.
    
     
    
    #RA(^CorrectLever): IF M <=10 [@TrueRun, @ FalseTimeout]
    @TrueRun: ADD B(2), E(K+2);
    OFF ^LLeverLight;
    SET D(J+4) = M, N = 1;
    Z^Z_Sipper;Z^Z_LatEnd;
    Z^Z_CorrectResp ---> S6
    @ FalseTimeout: OFF ^LLeverLight;
    ADD B(5), E(K+5);
    SET D(J+1) = 2;
    Z^Z_Type2 ---> S3
    
     
    
    S6,    \\\\ Wait for New Trial Signal.  Increment trial number.
    \\\\ Signal start of Nose Poke Latency counter.
    
     
    
    #Z^Z_NewTrial : ADD K;
    IF K > A(^TrialsPerBlock) [@NewBlock, @Cont]
    @New: ADD J;
    IF J > A(^NumBlocks) [@End, @Cont]
    @End: ---> S7
    @Cont: SET I = I + 6, E(K+5) = -987.987;
    SET K = 1, D(J+3) = -987.987;
    ON ^NosePoke;
    SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4
    @Cont: SET D(J+3) = -987.987;
    ON ^NosePoke;
    SET D(J) = K; Z^Z_NPLat ---> S4
    
     
    
    S7,    \\\\ Wait for Screen Update and end with
    \\\\ STOPABORTFLUSH for Automatic Data Saving
    
     
    
    2": ---> STOPABORTFLUSH
    
     
    
     
    
    \\\\***************************************************
    \\\\               REWARD CONTROL TIMER
    \\\\***************************************************
    S.S.2,
    S1,
    #Z^Z_Sipper: ON ^Sipper; ADD B(1), D(J+1), E(K+1);
    Z^Z_Reward ---> S2
    
     
    
    S2,     \\\\ Time Reward Device for 2 seconds
    2": OFF ^Sipper; ADD R;
    IF R >= Q [@Done, @Cont]
    @Done: SET R = 0; Z^Z_SipperEnd ---> S1
    @Cont: ---> S3
    
     
    
    S3,
    2":  ON ^Sipper; 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; ADD I; ADD B(3);
    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; 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) > O [] ---> 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
    
     
    
    \\\\***************************************************
    \\\\             NOSE POKE LATENCY COUNTER
    \\\\***************************************************
    S.S.8, \\\\ 10ms Resolution\\\
    S1,
    #Z^Z_NPLat: SET L = 0.01 ---> S2
    
     
    
    S2,
    0.01": SET L = L + 0.01 ---> SX
    #Z^Z_LatEnd: ---> S1
    
     
    
     
    
    \\\\***************************************************
    \\\\               LEVER LATENCY COUNTER
    \\\\***************************************************
    S.S.9, \\\\ 10ms Resolution
    S1,
    #Z^Z_LeverLat: SET M = 0.01 ---> S2
    
     
    
    S2,
    0.01": SET M = M + 0.01 ---> SX
    #Z^Z_LatEnd: ---> S1
    
     
    
    \\\\***************************************************
    \\\\                  UPDATE DISPLAY\\\
    \\\\***************************************************
    S.S.10,
    S1,
    #START: SHOW 1,Tot Rewards,B(1),   2,Tot Type 1,B(4),  3,Tot Type 2,B(5) ---> S2
    
     
    
     
    
    S2,
    1": SHOW 1,Tot Rewards,B(1),       2,Tot Type 1,B(4),   3,Tot Type 2,B(5) ---> S2
    
    #12650
    Med_Support
    Moderator
    Gary Bamberger

    Hi Lauren,

    So when an omission happens you don’t turn off the latency counter with a Z^Z_LatEnd. The latency counter keeps running into the next trial.

    Also when an omission happens you send the program back to S3 and not S6. I think that when an omission happens that it is supposed to end the trial. The code in S6 handles all of the setup for the next trial.

    I hope that this helps.
    Gary

    #12652
    Med_Support
    Moderator
    milliel

    Hey Gary,
    So I tried to simplify this code as much as possible to just what I absolutely need and I’m still having issues. Mainly after the initial trial, I can not get a new trial to start (it appears my z-pulse for my new trial will not fire) so that I never get past the first trial and after the initial omission my omissions are being recorded every second instead of only when the IF statement is true.

     

    Hey Gary, I’m not sure why it keeps cutting the code off, but I’ve attached it in a file as well.

    \\After ITI the NosePoke light is turned on. Animal is given 10s to respond with a nose poke. If no response, a Type
    \\ 1 Omission is recorded.
    
    \\If there is a response, then the left lever light is turned on.
    \\\
    \\ If the Correct lever is chosen then the lever
    \\ Light is turned off, and 2s reward is given.
    \\\\*****************************************************************************************************************************
    
    \Inputs
    ^LeftLever = 1
    ^RightLever = 2
    ^NosePoke = 4
    
    \Outputs
    ^LeftLever = 1
    ^RightLever = 2
    ^Sipper = 3
    ^NosePoke = 4
    ^LLeverLight = 5
    ^RLeverLight = 6
    
    \ A() = Control Variables with Assigned Aliases as Defined
    Var_Alias Response Time (sec) = A(1) Default = 10 seconds
    Var_Alias Correct Lever (1=Left) = A(2) Default = 1-Left
    Var_Alias Number of Trials to Run = A(3) Default = 180
    
    ^ResponseTime = 1
    ^CorrectLever = 2
    
    \List Data Variables Here
    \ B() = Experiment Totals
    \ B(0) = Not Used
    \ B(1) = Total Rewards Delivered
    \ B(2) = Total Correct Lever Responses
    \ B(3) = Total Successful Trials
    \ B(4) = Total NosePoke Omissions (Type 1)
    \ B(5) = Total Lever Omissions (Type 2)
    \ B(6) = Total NosePokes
    
    \ D() = Trial by Trial Data
    \ D(J) = Trial Number
    \ D(J+1) = Omission Type (1, or 2)
    \ D(J+2) = Trial Completed Successfully (1=Yes, 0=No)
    \ D(J+3) = Latency to Initial Nose Poke
    \ D(J+4) = Latency to Lever Press
    
    \ List Working Variables Here
    \ H = Subscript into the Trial Array D
    \ L = Nose Poke Latency Timer
    \ M = Lever Latency Timer
    \ N = Number of Rewards to Deliver
    \ O = Number of Rewards Delivered
    \ S = Session Time
    
    DIM A = 4
    DIM B = 7
    DIM C = 100000
    DIM D = 50000
    
    \ Z-Pulses Used in this Program
    ^Z_Sipper = 1 \\\\ Signal Sipper 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_SipperEnd = 5 \\\\ Signal End of Sipper 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
    
    DISKCOLUMNS = 9
    DISKFORMAT = 10.2
    DISKVARS = A, B, C, D, E
    
    \\\\***************************************************
    \\\\ DELAYED REWARD_V2 SCHEDULE\
    \\\\ S1 - Set Default Values\
    \\\\ Session Length (60mins)
    \\\\ New Trial Interval (4s)
    \\\\ Response Time (10 sec)
    \\\\ Correct Reward Lever (1-Left)
    \\\\ Number of Trials to run (180)
    
    \\\\***************************************************
    S.S.1,
    S1,
    #START: SET A(^ResponseTime) = 10, A(^CorrectLever) = 1;
    SET D(J) = 0 ---> S2[size=78%]S2, [/size]
    4
    
    #12655
    Med_Support
    Moderator
    Gary Bamberger

    Hi Lauren,

    I believe the problem is in S.S.1 and S.S.3.

    In S.S.1, S2 you issue a Z^Z_NPLat.
    S.S.3 responds to the Z-pulse —> S2
    1″ later it checks IF E = 1 (false)
    Program then checks IF L >= A(^ResponseTime)

    Now if the animal takes longer than 10s to respond to the Nose Poke an Omission is recorded and a Z^Z_NewTrial is issued, but S.S.1, S3 is still looking for a response on the Nose Poke and the Z^Z_NewTrial is ignored. The program will continue doing this every 1s until the animal responds on the Nose Poke.

    Once the animal responds on the Nose Poke the program SETs E = 1 and S.S.3, S2 SETs L = 0 and goes back to S1 and stops issuing the Z^Z_NewTrial.

    S.S.1, now goes to S4, then S5, and finally S6 where it waits for a Z^Z_NewTrial, but now S.S.3 is in S1 and not issuing anymore Z-pulses.

     

    Even if the animal responds to the Nose Poke in less than the Response Time:

    S.S.1, S3 SETs E = 1
    S.S.3, S2 now SETs L = 0 and goes to S1
    S.S.1, now goes to S4, then S5, and finally S6 where it waits for a Z^Z_NewTrial, but now S.S.3 is in S1 and not issuing anymore Z-pulses.

     

    Gary

    #12657
    Med_Support
    Moderator
    milliel

    Hey Gary,
    Do you have any suggestions as to how I can fix this? It seems that if I’m understanding correctly, I should also have a z-pulse issued in S.S.3 before returning to S1 however, I don’t know how how to address S.S.1, S3 issue for the z-pulse being ignored.

     

    -Lauren

    #12660
    Med_Support
    Moderator
    Gary Bamberger

    Hi Lauren,

    The following might work:

     

    S.S.1,
    S1,
    #START: SET A(^ResponseTime) = 10, A(^CorrectLever) = 1;
    SET D(J) = 0, X = 0 ---> S5
    
    S2,     \ Time Initial ITI.  Signal start of Nose Poke Latency counter.
    4": ADD J;
    ON ^NosePoke;
    SET X = 1, E = 0;
    Z^Z_NPLat ---> S3
    
    S3,     \ Wait for NP response
    #R^NosePoke: OFF ^NosePoke;
    ON ^LLeverLIGHT;
    SET E = 1 ---> S4
    #Z^Z_NewTrial: SET E = 1, X = 0;
    OFF ^NosePoke ---> S5
    
    S4,     \ When Lever response is made turn off the LeverLight, Signal to issue immediate reward.
    #RA(^CorrectLever): OFF ^LLeverLight;
    SET N = 1, D(J+2) = 1;
    ADD B(2), B(3);
    Z^Z_Sipper ---> S5
    
    S5,
    0.01": IF X = 0 [@GO, @STOP]
    @GO:   ---> S2
    @STOP: ---> S5
    

     

    Gary

    #12662
    Med_Support
    Moderator
    milliel

    You are the best Gary! That worked, thanks so much for all your help and patience!

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.