Differential Reinforcement of Low-rate Responding species: any
Maintainer Gary Bamberger Current version 0.1 View the changelog
Original Author Gary Bamberger Date last modified Jul-06-2005
License BSD MED-PC version 4
In the differential reinforcement of low-rate responding procedure, animals are rewarded for pressing a lever, but only if the previous lever-press was at least a predefined number of seconds before. Responses before that period has passed result in a reset of the counter.
No references given. Click to e-mail a reference to the maintainer.
Code
How to use this code Download the code No macro available No profile available
 
\ DRL.MPC


\ Inputs
^LeftLever  = 1
^RightLever = 2  

\ Outputs
^Pellet     = 3  \ If both Pellet and Dipper are being used
^Dipper     = 3  \ It will be necessary to change one of these
^LeftLight  = 4
^RightLight = 5
^HouseLight = 7
^Pump       = 8


\ Constants
^Left      = 1
^Right     = 2
^PrevTrial = -5
^NextTrial = 5


\ A() = Control Variables with Assigned Aliases as defined
Var_Alias Correct Lever (L=1  R=2)            = A(0)
Var_Alias Reward (Pellet=1  Dipper=2  Drug=3) = A(1)
Var_Alias Reward Time (sec)                   = A(2)
Var_Alias Time Out following Reward           = A(3)
Var_Alias Session Time (Min)                  = A(4)
Var_Alias Inter-Response Time (Sec)           = A(5)
Var_Alias Maximum Reinforcers                 = A(6)
Var_Alias SoftCR Data Array (Yes=1  No=0)     = A(7)

\ Constants for Control Variables Array
^CorLever     = 0
^Reward       = 1
^RewTime      = 2
^TimeOut      = 3
^SessTime     = 4
^IRT          = 5
^MaxReinf     = 6
^SoftCR       = 7
^RewTimeTicks = 8
^TimeOutTicks = 9
^IRTTicks     = 10


\ List Data Variables Here
\  B() = Trial Data
\  B(0) = Total Responses
\  B(1) = Correct Response Count
\  B(2) = Incorrect Response Count
\  B(3) = % Correct
\  B(4) = % Incorrect
\  B(J)   = Trial Number
\  B(J+1) = Correct Responses
\  B(J+2) = Incorrect Responses
\  B(J+3) = Pause (sec)
\  B(J+4) = Run Time (sec)

\  Constants for Trial Data Array
^Total     = 0
^Correct   = 3
^Incorrect = 4
^Trial     = 0
^CorResp   = 1
^IncorResp = 2
^Pause     = 3
^RunTime   = 4

\ C() = IRT Array and Event Pen Code for Soft Cum. Recorder
\ F = Total Rewards


\ List Working Variables Here
\  I = Subscript for the IRT Array C
\  J = Subscript for the Trial Array B
\  K = Elapsed Time in Session
\  L = Ratio Count
\  T = Elapsed Time in 0.1 sec increments for SoftCR Data


DIM A = 10
DIM B = 205
DIM C = 10000  \ Dimension Array C for 10001 data points.
               \ Under MED-PC Version IV, this array may be
               \ enlarged up to 1 million elements; however,
               \ 10,000 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.


\ Z-PULSES USED IN THIS PROGRAM
\  Z1 = Pellet Reinforcement Signal
\  Z2 = Dipper Reinforcement Signal
\  Z3 = Pump Reinforcement Signal
\  Z5 = End of Session Signal

^End = 5


DISKCOLUMNS = 5


\***************************************************
\                IRT LESS SCHEDULE
\  S1 - Set Default Values
\       Left Lever Correct         (1)
\       Reward Device Pellet       (1)
\       Reward Time                (0.05 seconds)
\       Time Out following Reward  (0 seconds)
\       Session Time               (60 minutes)
\       Inter-Response Time        (5 seconds)
\       Maximum Reinforcers        (50)
\       SoftCR Activation          (1-Yes)
\***************************************************
S.S.1,
S1,      
  0.001": SET A(^CorLever) = 1,  A(^Reward)   = 1,  A(^RewTime) = 0.05;
          SET A(^TimeOut)  = 0,  A(^SessTime) = 60, A(^IRT) = 5;
          SET A(^MaxReinf) = 50, A(^SoftCR)   = 1, J = 5, B(J) = -987.987 ---> S2

S2,     \ First Statement: Wait for START signal, turn houselight ON,
        \ test for correct lever and turn associated stimulus ON.
        \    
        \ Second Statement: Update screen display with default values
        \ for control variables.  This will show any change made
        \ via the "Configure | Change Variables" Window prior to START.    
  #START: CLEAR 1,60; SET A(^RewTimeTicks) = A(^RewTime) * 1", A(^TimeOutTicks) = A(^TimeOut) * 1";
          SET A(^IRTTicks) = A(^IRT) * 1", B(J+^Trial) = 1, B(J+^NextTrial) = -987.987;
          SHOW 2,Tot Cor Rsp,B(^CorResp), 3,Tot Incor Rsp,B(^IncorResp), 4,Reward,F;
          SHOW 6,Trial #,B(J+^Trial),     7,Cor Rsp,B(J+^CorResp),       8,Incor Rsp,B(J+^IncorResp);
          ON ^HouseLight, ^LeftLight, ^Rightlight ---> S3
  1": SHOW 1,Lever Code,A(^CorLever),      2,Reward,A(^Reward),         3,Reward Time,A(^RewTime);
      SHOW 4,Timeout,A(^TimeOut),          5,Session Time,A(^SessTime), 6,Inter-Response Time,A(^IRT);
      SHOW 7,Max Reinforcers,A(^MaxReinf), 8,SoftCR Code,A(^SoftCR) ---> SX

S3,     \ Look for First Lever Press
  #RA(^CorLever): ADD B(^Total), B(^CorResp), B(J+^CorResp); 
                  SHOW 2,Tot Cor Rsp,B(^CorResp), 7,Cor Rsp,B(J+^CorResp) ---> S4
  #R^RightLever: ADD B(^Total), B(^IncorResp), B(J+^IncorResp); 
                 SHOW 3,Tot Incor Rsp,B(^IncorResp), 8,Incor Rsp,B(J+^IncorResp) ---> SX
  #Z^End: ---> S10

S4,     \ Wait A(^IRT) Time, Reset if Lever Press Occurs
  A(^IRTTicks)#T: ---> S5
  #RA(^CorLever): ADD B(^Total), B(^CorResp), B(J+^CorResp); 
                  SHOW 2,Tot Cor Rsp,B(^CorResp), 7,Cor Rsp,B(J+^CorResp) ---> S4
  #R^RightLever: ADD B(^Total), B(^IncorResp), B(J+^IncorResp); 
                 SHOW 3,Tot Incor Rsp,B(^IncorResp), 8,Incor Rsp,B(J+^IncorResp) ---> SX
  #Z^End: ---> S10

S5,     \ Wait for Correct Lever Press
  #RA(^CorLever): ADD B(^Total), B(^CorResp), B(J+^CorResp); 
                  SHOW 2,Tot Cor Rsp,B(^CorResp), 7,Cor Rsp,B(J+^CorResp);
                  ADD F; SHOW 4,Reward,F; ZA(^Reward) ---> S6
  #R^RightLever: ADD B(^Total), B(^IncorResp), B(J+^IncorResp); 
                 SHOW 3,Tot Incor Rsp,B(^IncorResp), 8,Incor Rsp,B(J+^IncorResp) ---> SX
  #Z^End: ---> S10

S6,     \ Time out Interval Following Reward
  A(^TimeOutTicks)#T: IF F >= A(^MaxReinf) [@End, @cont]
                         @End: Z^End; SET B(J) = -987.987 ---> S10
                         @Cont: SET B(J+^Trial) = B(J+^PrevTrial) + 1;
                                SHOW 6,Trial #,B(J+^Trial) ---> S4
  #Z^End: ---> S10

S10,    \ End of Session - Turn lights off
        \ Calculate % Correct and % Incorrect.
  0.01": OFF ^HouseLight, ^LeftLight, ^RightLight;
         IF B(^Total) = 0 [@Nocalc, @Calculate]
            @NoCalc: ---> S11
            @Calculate: SET B(^Correct)   = B(^CorResp)   / B(^Total) * 100;
                        SET B(^Incorrect) = B(^IncorResp) / B(^Total) * 100 ---> S11

S11,    \ Holding state at end of session.
  1': ---> SX


\*********************************************
\            REWARD CONTROL TIMER
\*********************************************
S.S.3,  
S1,
  #Z1: ON ^Pellet ---> S2
  #Z2: ON ^Dipper ---> S2           
  #Z3: ON ^Pump ---> S2

S2,     \ Time Reward Device for A(^RewTime) seconds
        \ Default value set in S.S.1, S1 & S2.
  A(^RewTimeTicks)#T: OFF ^Pellet, ^Dipper, ^Pump ---> S1


\***********************************************
\           PAUSE AND RUN TIME TIMING
\***********************************************
S.S.10,
S1,
  #START: ---> S2

S2,
  #RA(^CorLever): ---> S3

S3,
  1": ADD B(J+^RunTime) ---> S3
  #ZA(^Reward): SHOW 10,Run Time,B(J+^RunTime);
                SET J = J + 5, B(J+^NextTrial) = -987.987 ---> S4

S4,
  #RA(^CorLever): SHOW 9,Pause,B(J+^Pause) ---> S3
  1": ADD B(J+^Pause) ---> S4


\***********************************************
\   INCREMENT TIME T FOR IRT AND EVENT ARRAY
\***********************************************
S.S.15,
S1,
  #START: IF A(^SoftCr) > 0 [] ---> S2

S2,
  0.1": ADD T ---> SX
  #Z^End: ---> S1

    
\*********************************************************
\ ADD A STEP ELEMENT TO ARRAY C FOR EACH CORRECT RESPONSE
\*********************************************************
S.S.17,
S1,
  #START: IF A(^SoftCR) = 1 [@ActivateSoftCR, @NoSoftCR]
             @ActSoftCR: IF A(^CorLever) = 1 [@LeftLeverCorrect, @RightLeverCorrect]
                            @LeftCorrect: ---> S2
                            @RightCorrect: ---> S3
             @NoSoftCR: ---> SX

S2,     \ Left Lever Correct
  #R^LeftLever: SET C(I) = T + 0.1, T = 0; ADD I;
                IF I = 10000 [@True, @False]
                   @True: ---> S1
                   @False: SET C(I) = -987.987 --->SX
  #Z^End: ---> S1

S3,     \ Right Lever Correct
  #R^RightLever: SET C(I) = T + 0.1, T = 0; ADD I;
                 IF I = 10000 [@True, @False]
                    @True: ---> S1
                    @False: SET C(I) = -987.987 ---> SX
  #Z^End: ---> S1


\*****************************************************
\    ADD A PIP ELEMENT TO ARRAY C FOR EACH REWARD
\*****************************************************
S.S.19,   
S1,
  #START: IF A(^SoftCR) = 1 [@ActivateSoftCR, @NoSoftCR]
             @ActSoftCR: ---> S2
             @NoSoftCR: ---> SX

S2,
  #Z1 ! #Z2 ! #Z3: SET C(I) = T + 0.2, T = 0; ADD I;
                   IF I = 10000 [@True, @False]
                      @True: ---> S1
                      @False: SET C(I) = -987.987 ---> SX
  #Z^End: SET C(I) = T + 0.31, T = 0, I = I + 1, C(I) = -987.987 ---> S1


\**************************************************************
\  ADD AN EVENT ELEMENT TO ARRAY C FOR EACH INCORRECT RESPONSE
\       ADDITIONAL EVENT ELEMENTS MAY BE ADDED AS NEEDED
\           FOR EXAMPLE TO MARK TIME OUT INTERVALS.
\**************************************************************
S.S.21,
S1,
  #START: IF A(^SoftCR) = 1 [@ActivateSoftCR, @NoSoftCR]
             @ActSoftCR: SET C(I) = 0.50, I = I + 1, C(I) = -987.987;
                         IF A(^CorLever) = ^Right [@LeftLeverIncorrect, @RightLeverIncorrect]
                            @LeftIncorrect: ---> S2
                            @RightIncorrect: ---> S3
             @NoSoftCR: SET C(0) = -987.987 ---> SX  \ Seal Array

S2,     \ Left Lever Incorrect
  #R^LeftLever: SET C(I) = T + 0.60, C(I+1) = 0.50, T = 0, I = I + 2;
                IF I >= 10000 [@True, @False]
                   @True: ---> S1
                   @False: SET C(I) = -987.987 ---> SX
  #Z^End: ---> S1

S3,     \ Right Lever Incorrect
  #R^RightLever: SET C(I) = T + 0.60, C(I+1) = 0.50, T = 0, I = I + 2;
                 IF I >= 10000 [@True, @False]
                    @True: ---> S1
                    @False: SET C(I) = -987.987 ---> SX
  #Z^End: ---> S1


\*********************************************
\               SESSION CLOCK
\*********************************************
S.S.23,
S1,
  #START: SHOW 1,Session,K ---> S2

S2,
  1": ADD K; SHOW 1,Session,K/60;
      IF K/60 >= A(^SessTime) [@EndSession, @ContinueTiming]
         @END: Z^End ---> S3
         @Cont: ---> SX
  #Z^End: ---> S3

S3,     \ Wait for screen update and end with
        \ STOPABORTFLUSH for automatic data saving.
  A(^RewTimeTicks)#T: ---> STOPABORTFLUSH

              
Related programs Other versions
No training programs submitted/required

No older versions available
No experimental versions available