Delayed reward task

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #12487
    Med_Support
    Moderator
    Aude

    I try to make the delayed reward task you posted on the repository working in our lab.
    I switched the nose poke input in level mode on the smart control card (not the ones for the levers), changed all the code for the inputs/outputs according to our plugging configuration, and allocated the lever output number to the control variables (if I well understood…) in the section S1, of S.S.1.
    The task is starting as it is supposed to, with a forced choice: ITI then illumination of houselight and stimulus light, the nose poke is detected and the first lever inserted. And after that, the task is blocked. I mean the lever press is not detected, no reward is delivered and the lever is not retracted. then the second forced trial starts and everything comes as the first one with the other lever..
    I know that I am missing something in the variables in your code but I can’t figure it out…
    thanks for your helps

     

    in case it helps here is our configuration:

     

    Inputs:
    ^leftlever = 1
    ^rightlever = 2
    ^Nosepoke = 3

     

    outputs:
    ^Leftlever = 15
    ^Rightlever = 13
    ^pellet = 8
    ^stimlight = 4
    ^houselight = 7

    #12489
    Med_Support
    Moderator
    Gary Bamberger

    Hi Aude,

    I think that you are running into a problem in S.S.1, S5

    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

    The code is looking for an input on the A(^ImmediateLever) and A(^DelayedLever) which you have now assigned to be 13 and 15.  But your lever inputs are connected to 1 and 2.  The code is really expecting the inputs and outputs to be the same.

    You need to create another variable to be used for the inputs:

    DIM V = 1
    
    #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";
     IF A(^ImmediateLever) = 13 [@Left, @Right]
     @Left:  SET V(0) = 1, V(1) = 2 ---> S3
     @Right: SET V(0) = 2, V(1) = 1 ---> S3
    
    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.
     #RV(0): 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
     #RV(1): 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

     

    I hope that this information helps.

    Gary

    #12491
    Med_Support
    Moderator
    Aude

    Dear Gary

     

    Thanks a lot,
    I tryed the code you sent me, and this time the reward is given for each of the levrs however the levers are not retracted after the lever press…
    it looks like i need once again your help…

     

    Thanks a lot

     

    Aude

    #12493
    Med_Support
    Moderator
    Gary Bamberger

    Hi Aude,

    Search the code and everywhere you find ON or OFF ^LeftLever, ^RightLever replace it with ON or OFF A(^ImmediateLever), A(^DelayedLever). That should do it.

    Gary

     

    #12495
    Med_Support
    Moderator
    Aude

    Dear Gary!!!

     

    Fantastic it works fine! Thank you sooooo much!!!
    You saved me!

     

    Best

     

    Aude

    #12497
    Med_Support
    Moderator
    Gary Bamberger

    Glad to hear that it is now working.

    #12499
    Med_Support
    Moderator
    Aude

    Hi Gary,

     

    Me again!
    While checking if all the variable were well recorded, I noticed something weird about the table for variable A. A(0) is well recorded as the ITI time however, I noticed a left shift in the recorded table : A(1) which is supposed to be the response time (and I set it as default 10sec in the S.S.1, S.1 part of the program) is recorded as A(2) = 13 ^immediatelever, A(2) is recorded as A(3)=15 ^delayedlever, then A(3) is 0 and then the other variables are recorded as expected.
    when loading the program on medPC, on the screen, the same error is here. This is not the case with your unmodified program. I tried to understand but I am stuck…

     

    I also noticed that if the rat fails to respond during the allocated time 10 s time at the first trial (before the forced choice), this does not lead back to the 100s ITI time but to a 5 sec timeout (this also true in your unmodified program…) and it counts as a trial and record the omission. it is not the case after the first forced choice if I well remember… I am just wondering if it is normal…

     

    looking forward to being in touch!
    aude

    #12501
    Med_Support
    Moderator
    Gary Bamberger

    Hi Aude,

    For your first question here is the code in question:

    \ 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
    
    S.S.1,
     S1,
     0.01": SET A(^NTI)          = 100, A(^ResponseTime)   = 10, A(^ImmediateLever) = 13;
     SET A(^DelayedLever) = 15,  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

     

    This will result in A(0) = 100, A(1) = 10, A(2) = 13, A(3) = 15

    I downloaded and ran the program from the repository and it is working this way.  The only way this would change is if the named constants for the A array were changed from:

    ^ResponseTime   = 1
    ^ImmediateLever = 2
    ^DelayedLever   = 3

     

    For your second question here is the code for the initial nose poke:

    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 A(^ImmediateLever), A(^DelayedLever) ---> 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
    
    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
    
    \***************************************************
     \              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

     

    So if the animal fails to Nose Poke then the program will record an omission, end the trial, and go to S10 where it waits for the signal for a New Trial.  The program does not time a Inter-Trial Interval.  A “New Trial” starts every 100s.  Since we already waited 10s for the Response Time the next trial should start 90s later.  I just downloaded the program from the repository and that is exactly what it does.

     

    I hope that this information helps.
    Gary

    #12503
    Med_Support
    Moderator
    Aude

    thanks Gary,

     

    I did not change the variable, juste the setting in the first paragraph… but I have this super weird problem A(1) = 13, A(2) = 15 and A(3) = 0
    The task is functioning perfectly, with the good delay for the response time, and the lever are inserted and retracted and counted as expected…
    I really don’t know… I will look into it…
    thanks again!
    Aude

    #12505
    Med_Support
    Moderator
    If you post the entire code with the changes that we have made recently I would be happy to take a look at it.

    Gary

    #12507
    Med_Support
    Moderator
    Aude

    Dear Gary,

     

    Here is the entire code, with the changes I made following your recommendations.
    I left the the ^nosepoke input in level mode finally

     

    \ Inputs
    ^ImmediateLever  = 1 \Left lever                                                                                    
    ^DelayedLever = 2 \Right lever       
    ^Nosepoke   = 3  \ Level Mode
    
    
    
    \ Outputs                               
    ^ImmediateLever  = 13  \ left lever
    ^DelayedLever = 15 \ Right lever 
    ^Pellet     = 3
    ^StimLight  = 4
    ^HouseLight = 7
    ^fan = 1             
    
    
    
    \ 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 (15=Left  13=Right)      = A(2)  \ Default = 15-Left
    Var_Alias Delayed Reward Lever (15=Left  13=Right)        = A(3)  \ Default = 13-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( \ 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( = 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           
    DIM V = 1
               
    \ 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) = 13;
             SET A(^DelayedLever) = 15,   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";
              if A(^ImmediateLever)= 13 [@Left, @Right]
                  @Left: set v(0)=1, v(1)=2 ---> S3
                  @Right: set v(0)=2, v(1)=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 A(^ImmediateLever), A(^DelayedLever) ---> 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.
      #Rv(0): ADD B(2), E(K+2); ON ^StimLight;
                            OFF ^HouseLight, A(^ImmediateLever), A(^DelayedLever);                                                 
                            SET D(J+2) = 1, D(J+6) = P, Q = 1;
                            Z^Z_Pellet; Z^Z_NPLat;                                
                            Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
      #Rv(1): ADD B(3), E(K+3);                                                         
                          OFF ^HouseLight,  A(^ImmediateLever), A(^DelayedLever);
                          SET D(J+2) = 2, D(J+6) = P, Q = A(^LargeReward);
                          Z^Z_LatEnd; Z^Z_CorrectResp ---> S7
      A(^ResponseTicks)#T: OFF ^HouseLight, A(^ImmediateLever), A(^DelayedLever);
                           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( , 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": OFF ^fan ---> 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( ;
              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( ;
          SHOW 11,Block #,L,            12,Trial #,M,             13,Delay,U/1" ---> S2
    
    
    
    \***************************************************
    \                  START FAN
    \***************************************************
    S.S.15,
    S1,
      #START: ON ^fan ---> SX
    #12510
    Med_Support
    Moderator
    Aude

    I also copy here the data file by just running the task for couple of sec (not even start a trial). It was just for you to see the Array A:

     

    File: C:\MED-PC IV\DATA\!2017-07-20
    
    
    
    
    
    
    
    Start Date: 07/20/17
    End Date: 07/20/17
    Subject: 0
    Experiment: 0
    Group: 0
    Box: 1
    Start Time: 10:22:29
    End Time: 10:22:46
    MSN: Delay discounting
    A:
     0: 10.00 15.00 13.00 0.00 4.00 5.00 2.00 12.00 1.00
     9: 1000.00 1500.00
    B:
     0: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
    C:
     0: 0.50
    D:
     0: 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
    E:
     0: 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

     

     

    Thank you very much for your help,

     

    best
    aude

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