Delayed Match To Sample species: rat, mouse
Maintainer Gary Bamberger Current version 1.0 View the changelog
Original Author Gary Bamberger Date last modified Dec-20-2011
License BSD MED-PC version 4
No description given
Dunnett, S. (1993). Operant delayed matching and non-matching to position in rats. In A. Sahgal (Vol. Ed.), Behavioral Neuroscience: Vol. 1. A Practical Approach (pp. 123-136). New York: Oxford University Press.
Code
How to use this code Download the code Download an example macro Download the profile
 
\ Copyright (c) 2011 MEDState Notation Repository, All rights reserved.

\ DMTS.MPC - Delayed Match to Sample
\
\ The program first presents the sample lever with the stimulus light.  The
\ Animal must press the sample lever.  If there is no press, then an Omission is
\ recorded, the HouseLight is turned off and the program goes to the ITI.
\
\ After the Animal presses the sample lever it must poke its head into the food
\ magazine.  If the Animal does not poke its head into the food magazine, then
\ an Omission is recorded, the HouseLight is turned off and the program goes to
\ the ITI.
\
\ After the Animal has poked its head into the food magazine the program waits
\ for a the delay time that was randomly chosen from list W.  After the delay is
\ over the program presents both levers and both stimulus lights.  The Animal
\ must then select the same lever as the sample lever.
\
\ If there is no press, then an Omission is recorded, the House Light is turned
\ off and the program goes to the ITI.
\
\ If the wrong lever is chosen, then an Incorrect Lever is recorded, the
\ House Light is turned off and the program goes to the ITI.
\
\ If the correct lever is chosen, then the Reward is presented for a specified
\ amount of time.  When the Reward Time runs out the program goes to the ITI
\ state and starts the next trial.


\ Inputs
^LeftLever  = 1
^RightLever = 2
^HeadEntry  = 3

\ Outputs
^LeftLever       = 1
^RightLever      = 2
^Pellet          = 3
^LeftLight       = 4
^RightLight      = 5
^ReceptacleLight = 6
^HouseLight      = 7
^Pump            = 8


\ A() = Control Variable with Assigned Aliases as Defined
Var_Alias Number of Trials                 = A(0)  \ Default = 100
Var_Alias Response Time (sec)              = A(1)  \ Default = 20 seconds
Var_Alias Reward Time (sec)                = A(2)  \ Default = 5 seconds
Var_Alias Inter-Trial Interval (sec)       = A(3)  \ Default = 5 seconds

^Trials      = 0
^RespTime    = 1
^RewardTime  = 2
^ITI         = 3
^RewardTicks = 4
^ITITicks    = 5


\ List Data Variables Here
\  B() = Trial by Trial Data
\  B(I)   = Trial Number
\  B(I+1) = Left or Right Lever (1=Left  2=Right)
\  B(I+2) = Delay Length
\  B(I+3) = Latency to Sample Lever
\  B(I+4) = Latency to Head Entry
\  B(I+5) = Latency to Choice Lever
\  B(I+6) = Correct, Incorrect, or Omission Response (1=Correct  2=Incorrect  3=Omission)

\  D() = Experiment Totals
\  D(0) = Percent Correct, 1st Delay
\  D(1) = Percent Correct, 2nd Delay
\  D(2) = Percent Correct, 3rd Delay
\  D(3) = Percent Correct, 4th Delay
\  D(4) = Percent Correct, 5th Delay
\  D(5) = Percent Correct, 6th Delay
\  D(6) = Percent Correct, Entire Session
\  D(7) = Total Number of Correct Responses
\  D(8) = Total Number of Incorrect Responses
\  D(9) = Total Number of Omissions


\ List Working Variables Here
\  G() = List that is Used for Deciding the Next Lever
\  I   = Subscript for the Trial Data Array B
\  L   = Used to Time Latency to Lever Responses and Head Entries
\  N   = Value Drawn from List G
\  O   = Value Drawn from List W
\  P   = Omission Time Out  = ITI - 5"
\  Q   = ITI Between Trials = ITI - 5" - Reward Time
\  R() = Total Number of Times each Delay has been Used
\  S   = Elapsed Time in Session
\  T   = Trial Number
\  W() = List of 6 Different Delay Times


DIM A = 5
DIM B = 10000
DIM D = 9
DIM R = 5

LIST G = 1, 2
LIST W = 1", 2", 4", 8", 16", 24"  \ Initialize List with 6 Different Delay Times


\ Z-Pulses Used in this Program
^Z_Reward     = 1   \ Z1  = Signal Reward
^Z_DelayDrawn = 2   \ Z2  = Signal that Delay type has been Drawn
^Z_End        = 32  \ Z32 = Signal End of Session


DISKCOLUMNS = 7


\***************************************************
\                   DMTS Schedule
\  S1 - Set default values
\       Number of Trials               (100)
\       Response Time                  (20 seconds)
\       Reward Time                    (5 seconds)
\       Inter-Trial Interval           (5 seconds)
\***************************************************
S.S.1,
S1,
  0.001": SET A(^Trials)     = 100, A(^RespTime) = 20;
          SET A(^RewardTime) = 5,   A(^ITI)      = 5 ---> S2

S2,     \ First Statement: Wait for START signal, turn HouseLight ON
        \
        \ 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 T = 1; ON ^HouseLight;
          SET A(^RewardTicks) = A(^RewardTime) * 1";
          SET A(^ITITicks)    = A(^ITI)        * 1";
          SET P               = A(^ITITicks)   - 5";
          SET Q               = A(^ITITicks)   - 5" - A(^RewardTicks) ---> S3
  1": SHOW 1,# of Trials,A(^Trials),     2,Resp Time,A(^RespTime);
      SHOW 3,Reward Time,A(^RewardTime), 4,ITI,A(^ITI) ---> SX

S3,     \ Time Acclimation Period.
        \ Choose Left or Right Lever and Delay Length.
  A(^ITITicks)#T: RANDD N = G, O = W;
                  SET B(I)   = T,      B(I+1) = N;
                  SET B(I+2) = O / 1", B(I+7) = -987.987;
                  Z^Z_DelayDrawn;
                  IF N = 1 [@Left, @Right]
                     @Left:  ON ^LeftLight,  ^LeftLever  ---> S5
                     @Right: ON ^RightLight, ^RightLever ---> S6

\---------------------------------------------------
S5,     \ Left Lever Sample.
        \ Time Latency.  If >= A(^RespTime), record as Omission
        \ and go to ITI.  If chosen, turn on FoodLight.
  #R^LeftLever: SET B(I+3) = L, L = 0;
                OFF ^LeftLight, ^LeftLever;
                ON ^ReceptacleLight ---> S7
  0.01": SET L = L + 0.01;
         IF L >= A(^RespTime) [@Omission, @Cont]
            @Omission: SET B(I+3) = L, B(I+6) = 3, L = 0; ADD D(9);
                       OFF ^LeftLight, ^LeftLever ---> S13
            @Cont: ---> SX

S6,     \ Right Lever Sample.
        \ Time Latency.  If >= A(^RespTime), record as Omission
        \ and go to ITI.  If chosen, turn on FoodLight.
  #R^RightLever: SET B(I+3) = L, L = 0;
                 OFF ^RightLight, ^RightLever;
                 ON ^ReceptacleLight ---> S7
  0.01": SET L = L + 0.01;
         IF L >= A(^RespTime) [@Omission, @Cont]
            @Omission: SET B(I+3) = L, B(I+6) = 3, L = 0; ADD D(9);
                       OFF ^RightLight, ^RightLever ---> S13
            @Cont: ---> SX

\---------------------------------------------------
S7,     \ Wait for Head Entry.
        \ If >= A(^RespTime)s, record as Omission and go to ITI.
  #R^HeadEntry: SET B(I+4) = L, L = 0;
                OFF ^ReceptacleLight ---> S8
  0.01": SET L = L + 0.01;
         IF L >= A(^RespTime) [@Omission, @Cont]
            @Omission: SET B(I+4) = L, B(I+6) = 3, L = 0;
                       ADD D(9); OFF ^ReceptacleLight ---> S13
            @Cont: ---> SX

S8,     \ Delay before lever presentation.
        \ Delay is chosen from List W.
  O#T: ON ^LeftLight, ^LeftLever, ^RightLight, ^RightLever;
       IF N = 1 [@Left, @Right]
          @Left:  ---> S9
          @Right: ---> S10

\---------------------------------------------------
S9,     \ Left Lever Choice.
        \ Time Latency.  If >= A(^RespTime), record as Omission
        \ and go to ITI.  If wrong lever is chosen, record as
        \ Incorrect and go to ITI.
  #R^LeftLever: SET B(I+5) = L, B(I+6) = 1, L = 0;                   \ Correct Lever
                OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever;
                ADD D(7); ON ^ReceptacleLight; Z^Z_Reward ---> S11
  #R^RightLever: SET B(I+5) = L, B(I+6) = 2, L = 0; ADD D(8);        \ Incorrect Lever
                 OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever, ^HouseLight ---> S14
  0.01": SET L = L + 0.01;
         IF L >= A(^RespTime) [@Omission, @Cont]
            @Omission: SET B(I+5) = L, B(I+6) = 3, L = 0; ADD D(9);  \ Omission
                       OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever ---> S13
            @Cont: ---> SX

S10,    \ Right Lever Choice.
        \ Time Latency.  If >= A(^RespTime), record as Omission
        \ and go to ITI.  If wrong lever is chosen, record as
        \ Incorrect and go to ITI.
  #R^RightLever: SET B(I+5) = L, B(I+6) = 1, L = 0;                  \ Correct Lever
                 OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever;
                 ADD D(7); ON ^ReceptacleLight; Z^Z_Reward ---> S11
  #R^LeftLever: SET B(I+5) = L, B(I+6) = 2, L = 0; ADD D(8);         \ Incorrect Lever
                OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever, ^HouseLight ---> S14
  0.01": SET L = L + 0.01;
         IF L >= A(^RespTime) [@Omission, @Cont]
            @Omission: SET B(I+5) = L, B(I+6) = 3, L = 0; ADD D(9);  \ Omission
                       OFF ^LeftLight, ^LeftLever, ^RightLight, ^RightLever ---> S13
            @Cont: ---> SX

\---------------------------------------------------
S11,    \ Time Reward.  Check if end of Trials.
  A(^RewardTicks)#T: OFF ^ReceptacleLight;
                     IF T >= A(^Trials) [@End, @Cont]
                        @End: Z^Z_End ---> S31
                        @Cont: ---> S12
  #R^HeadEntry: OFF ^ReceptacleLight ---> SX

S12,    \ After the reward has been issued, time the rest of the
        \ ITI minus 5" for S15.
        \
        \ Check if the Reward Time A(^RewardTime) equals the
        \ ITI Time A(^ITI).  If they are equal, then Choose next
        \ Lever and next Delay.  Increment Trial counter and
        \ index into the B Array.  Record Trial values and turn
        \ on the correct sample lever.
  Q#T: IF A(^ITI) = A(^RewardTime) [@Equal, @NotEqual]
          @Equal: RANDD N = G, O = W;
                  SET I = I + 7; ADD T;
                  SET B(I)   = T,      B(I+1) = N;
                  SET B(I+2) = O / 1", B(I+7) = -987.987;
                  Z^Z_DelayDrawn;
                  IF N = 1 [@Left, @Right]
                     @Left:  ON ^LeftLight,  ^LeftLever  ---> S5
                     @Right: ON ^RightLight, ^RightLever ---> S6
          @NotEqual: ---> S15

S13,    \ Time Omission ITI minus 5" for S15.  Check if end of Trials.
  P#T: IF T >= A(^Trials) [@End, @Cont]
          @End: Z^Z_End ---> S31
          @Cont: ---> S15

S14,    \ Time Incorrect Choice ITI minus 5" for HouseLight signal
        \ (S15) of next Trial.  Check if end of Trials.
  25": IF T >= A(^Trials) [@End, @Cont]
          @End: Z^Z_End ---> S31
          @Cont: ON ^HouseLight ---> S15

S15,    \ Choose next Lever and next Delay.  Increment Trial
        \ counter and index into the B Array.  Record Trial
        \ values and turn on the correct sample lever.
  5": RANDD N = G, O = W;
      SET I = I + 7; ADD T;
      SET B(I)   = T,      B(I+1) = N;
      SET B(I+2) = O / 1", B(I+7) = -987.987;
      Z^Z_DelayDrawn;
      IF N = 1 [@Left, @Right]
         @Left:  ON ^LeftLight,  ^LeftLever  ---> S5
         @Right: ON ^RightLight, ^RightLever ---> S6

\---------------------------------------------------
S31,    \ Calculate the Final Percent Correct.
  0.01": SET D(0) = D(0) / R(0) * 100;
         SET D(1) = D(1) / R(1) * 100;
         SET D(2) = D(2) / R(2) * 100;
         SET D(3) = D(3) / R(3) * 100;
         SET D(4) = D(4) / R(4) * 100;
         SET D(5) = D(5) / R(5) * 100;
         SET D(6) = D(6) / T    * 100 ---> S32

S32,    \ Wait for Screen Update and end with
        \ STOPABORTFLUSH for Automatic Data Saving
  2": OFF ^HouseLight ---> STOPABORTFLUSH


\***************************************************
\  ADD THE CORRECT RESPONSE TO THE RUNNING TOTALS
\***************************************************
S.S.2,
S1,
  #Z^Z_Reward: IF O = W(0) [@Delay1, @Next]
                  @Delay1: ADD D(0), D(6) ---> S1
                  @Next: IF O = W(1) [@Delay2, @Next]
                            @Delay2: ADD D(1), D(6) ---> S1
                            @Next: IF O = W(2) [@Delay3, @Next]
                                      @Delay3: ADD D(2), D(6) ---> S1
                                      @Next: IF O = W(3) [@Delay4, @Next]
                                                @Delay4: ADD D(3), D(6) ---> S1
                                                @Next: IF O = W(4) [@Delay5, @Delay6]
                                                          @Delay5: ADD D(4), D(6) ---> S1
                                                          @Delay6: ADD D(5), D(6) ---> S1


\********************************************************
\ ADD THE TOTAL NUMBER OF TIMES EACH DELAY HAS BEEN USED
\********************************************************
S.S.3,
S1,
  #Z^Z_DelayDrawn: IF O = W(0) [@Delay1, @Next]
                      @Delay1: ADD R(0) ---> S1
                      @Next: IF O = W(1) [@Delay2, @Next]
                                @Delay2: ADD R(1) ---> S1
                                @Next: IF O = W(2) [@Delay3, @Next]
                                          @Delay3: ADD R(2) ---> S1
                                          @Next: IF O = W(3) [@Delay4, @Next]
                                                    @Delay4: ADD R(3) ---> S1
                                                    @Next: IF O = W(4) [@Delay5, @Delay6]
                                                              @Delay5: ADD R(4) ---> S1
                                                              @Delay6: ADD R(5) ---> S1


\***************************************************
\                   PELLET TIMER
\***************************************************
S.S.4,
S1,
  #Z^Z_Reward: ON ^Pellet ---> S2

S2,
  0.05": OFF ^Pellet ---> S1


\***************************************************
\                   SESSION CLOCK
\***************************************************
S.S.5,
S1,
  #START: SHOW 1,Session,S/60 ---> S2

S2,
  0.01": SET S = S + 0.01;
         SHOW 1,Session,S/60 ---> SX
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE OVERALL DISPLAY
\***************************************************
S.S.6,
S1,
  #START: ---> S2

S2,
  1": SHOW 2,Trial #,B(I);
      IF T <> 0 [@True, @False]
         @True:  SHOW 3,Overall PC,D(6)/T*100 ---> S2
         @False: SHOW 3,Overall PC,D(6)       ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 1 DISPLAY
\***************************************************
S.S.7,
S1,
  #START: ---> S2

S2,
  1": IF R(0) <> 0 [@True, @False]
         @True:  SHOW 4,Delay 1 PC,D(0)/R(0)*100 ---> S2
         @False: SHOW 4,Delay 1 PC,D(0)          ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 2 DISPLAY
\***************************************************
S.S.8,
S1,
  #START: ---> S2

S2,
  1": IF R(1) <> 0 [@True, @False]
         @True:  SHOW 5,Delay 2 PC,D(1)/R(1)*100 ---> S2
         @False: SHOW 5,Delay 2 PC,D(1)          ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 3 DISPLAY
\***************************************************
S.S.9,
S1,
  #START: ---> S2

S2,
  1": IF R(2) <> 0 [@True, @False]
         @True:  SHOW 6,Delay 3 PC,D(2)/R(2)*100 ---> S2
         @False: SHOW 6,Delay 3 PC,D(2)          ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 4 DISPLAY
\***************************************************
S.S.10,
S1,
  #START: ---> S2

S2,
  1": IF R(3) <> 0 [@True, @False]
         @True:  SHOW 7,Delay 4 PC,D(3)/R(3)*100 ---> S2
         @False: SHOW 7,Delay 4 PC,D(3)          ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 5 DISPLAY
\***************************************************
S.S.11,
S1,
  #START: ---> S2

S2,
  1": IF R(4) <> 0 [@True, @False]
         @True:  SHOW 8,Delay 5 PC,D(4)/R(4)*100 ---> S2
         @False: SHOW 8,Delay 5 PC,D(4)          ---> S2
  #Z^Z_End: ---> S1


\***************************************************
\              UPDATE DELAY 6 DISPLAY
\***************************************************
S.S.12,
S1,
  #START: ---> S2

S2,
  1": IF R(5) <> 0 [@True, @False]
         @True:  SHOW 9,Delay 6 PC,D(5)/R(5)*100 ---> S2
         @False: SHOW 9,Delay 6 PC,D(5)          ---> S2
  #Z^Z_End: ---> S1
Related programs Other versions
No training programs submitted/required

Version 0.1