Delay Reward Help

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14421
    gutierad
    Participant

    I am trying to figure out how to modify the DelayedReward_v2 program from the repository. I basically just want to remove the nose poke element from the code so that the rather than starting when a nose poke is detected, the program starts after an interval (something like 10 seconds after manually starting the program). Similarly, I am trying to remove the nose poke elements that produce Type 3 and 4 omissions (we currently have no nose-poke capability in this set-up).

    I am still very new to this type of coding, so any help would greatly be appreciated.

    Thank you very much for your time!

    #14422
    Gary Bamberger
    Moderator

    Hello,

    The first thing would be changing how the program starts:

    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

    becomes:

    S3,     \ Time Initial ITI
      #Z^Z_NewTrial: ON ^HouseLight, ^StimLight;
                     SET E(K) = L, D(J) = M ---> S4
    
    S4,     \ Wait Response 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.
      A(^ResponseTicks)#T: 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

    I chose the response time as the Initial ITI, but you could hard code a different number if you so desired.

    Without a nose poke the program has no way of knowing if the animal got the reinforcement so again I just chose the response time and if the animal doesn’t get the reinforcement in that amount of time, too bad the next trial is going to start:

    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 ---> S4
                        @Cont: SET J = J + 9, D(J+9) = -987.987;
                               ON ^HouseLight, ^StimLight;
                               SET D(J) = M ---> S4

    becomes:

    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_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.  Wait Response Time
      A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
                           ADD B(4), D(J+4), E(K+4);
                           SET D(J+7) = O;
                           Z^Z_LatEnd; Z^Z_CorrectResp ---> 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 ---> S8
    
    S8,     \ Wait for Z^Z_PelletEnd
            \ pulse to arrives, last pellet has been issued, begin timer.
      #Z^Z_PelletEnd: ---> S9
    
    S9,     \ Wait Response Time
      A(^ResponseTicks)#T: OFF ^HouseLight, ^StimLight;
                           ADD B(4), D(J+4), E(K+4);
                           SET D(J+7) = O;
                           Z^Z_LatEnd; Z^Z_CorrectResp ---> 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.
      #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 ---> S4
                        @Cont: SET J = J + 9, D(J+9) = -987.987;
                               ON ^HouseLight, ^StimLight;
                               SET D(J) = M ---> S4

    You will also want to comment out S.S.10 and S.S.13.

    While that should compile you will be missing a lot of information that the original program collected with the nose poke.

    Also I have not tested these changes so it is possible that there might be a flow control issue that I have not accounted for, but I think it will work.

    I always recommend running a test trial before running a full experiment with your animals.

    Gary

    #14433
    gutierad
    Participant

    Thanks, Gary! The program works great!

    One more question. How can I separate the one pellet dispenser into two pellet dispensers, one for the immediate reward and one for the delayed reward?

    Again, thank you so much for your help!

    #14435
    Gary Bamberger
    Moderator

    What you are going to need is to issue one Z-pulse for the immediate reward (Z^Z_Pellet1) and one for the delayed reward (Z^Z_Pellet2):

    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_Pellet1; 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
    
    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_Pellet2; Z^Z_NPLat ---> S8

    You will then need to modify the reward control for each output:

    S.S.2,
    S1,
      #Z^Z_Pellet1: ON ^Pellet1; ADD B(1), D(J+1), E(K+1);
                    Z^Z_Reward ---> S2
      #Z^Z_Pellet2: ON ^Pellet2; ADD B(1), D(J+1), E(K+1);
                    Z^Z_Reward ---> S3
    
    S2,     \ Time Reward Device for 0.05 seconds
      0.05": OFF ^Pellet1; Z^Z_PelletEnd ---> S1
    
    S3,     \ Time Reward Device for 0.05 seconds
      0.05": OFF ^Pellet2; ADD R;
             IF R >= Q [@Done, @Cont]
                @Done: SET R = 0; Z^Z_PelletEnd ---> S1
                @Cont: ---> S4
    
    S4,
      0.45": ON ^Pellet2; ADD B(1), D(J+1), E(K+1);
             Z^Z_Reward ---> S3

    I hope that this helps.

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