Author Topic: Recording Events Into Arrays  (Read 34 times)

milliel

  • Newbie
  • *
  • Posts: 9
    • View Profile
Recording Events Into Arrays
« on: May 26, 2017, 02:55:49 pm »
I have several arrays set up to record various events in this program however it does not appear that the data is actually being collected in a trial by trail basis as I need. Specifically, I do not see anything being recorded for my A or D arrays, and see only a few events in my B array. I am not sure what the code needs to be to record these different elements. Any help would be appreciated as I have looked at the programers manual and I am still at a loss.



\\ ******************************************************************************************
\\ This is Attentional Set to Visual Cue (active lever is indicated by the cue light)
\\  60 minutes
\\ ******************************************************************************************




\Inputs
^LeftLever  = 1
^RightLever = 2
^NosePoke   = 4


\Outputs
^LeftLever  = 1
^RightLever = 2
^Sipper     = 3
^NosePoke   = 4
^LLight     = 5
^RLight     = 6


\Defined Variables
\A()  =
\A(1) = Total # Rewards
\A(2) = Total Active NP
\A(3) = Total NP Omissions (Type 1)
\A(4) = Total Lever Omissions (Type 2)
\A(5) = Time
\A(6) = LLever ON (1) or OFF (0)
\A(7) = RLever ON (1) or OFF (0)


\B()    = Trial by Trial Data
\B(1)   = Trial #
\B(C+1) = Omission Type (1 or 2)
\B(Z+1) = Trial Completed Successfully (1 = yes, 2 = no)
\B(2)   = Total Incorrect Left Lever Press
\B(3)   = Total Incorrect Right Lever Press
\B(4)   = Percent Correct Entire Session


\D()    = Latency Array
\D(1)   = NP Latency
\D(2)   = Lever Latency


\Working Variables
\ E = NP Latency Timer
\ F = NP Latency Timer ON (0) OFF (1)
\ G = Lever Latency Timer
\ H = Lever Latency Timer ON (0) OFF (1)
\ I = # of Rewards to deliver
\ J = New Trial (1) Continue Trial (0)
\ K = Incorrect Left Lever Press
\ L = Incorrect Right Lever Press
\ M,N = List Variables for probability of cue above lever (1 = Left, 2 = Right)
\ S = NP Lat counter
\ V = Lever Lat counter
\ O = Trial #


LIST M = 1,2 \ Light position variable


DIM A = 7
DIM B = 6
DIM D = 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_SipperEnd   = 5   \\\\ Signal End of Sipper Deliveries
^Z_NewTrial    = 6   \\\\ Signal New Trial
^Z_NPLatEnd    = 7   \\\\ Signal End of NP Latency Counter
^Z_LLatEnd     = 8   \\\\ Signal End of L Latency Counter
^Z_NewTrialL   = 9   \\\\ Signal New Trial After Lever Omission


DISKCOLUMNS = 7     \ # of Columns
DISKVARS    = A, B, D  \ arrays to be saved


\\\\***************************************************
\\\\                   Schedule         
\\\\
\\\\   Session Length                        (60mins)
\\\\   New Trial Interval                    (4s)
\\\\   Response Time                         (10 sec)
\\\\   


\\\\***************************************************


S.S.1,
  S1,
    #START :  SET O = 0, J = 0, D(1) = 0, D(2) = 0 ---> S2
 
  S2,
    .01" : IF J = 0 [@GO, @STOP]
      @GO : ---> S3
      @STOP : ---> S2
  S3,
    4" : ON^NosePoke ; SET J = 1 , F = 0, A(6) = 0, A(7) = 0;
                       ADD O; Z^Z_NPLat ---> S4
  S4,
    #R^NosePoke : OFF^NosePoke; SET D(1) = S, F = 1; RANDD N = M;
                  SET H = 0; Z^Z_LeverLat; Z^Z_NPLatEnd; ADD A(2);
                  IF N = 1 [@CL, @CR]
         @CL : ON^LLight; SET A(6) = 1 ---> S5
         @CR : ON^RLight; SET A(7) = 1 ---> S5
   
    #Z^Z_NewTrial : SET J = 0, E = 0 ; OFF^NosePoke ---> S2


  S5,
    #R^LeftLever : IF A(6) = 1 [@Truepress, @Falsepress]
         @Truepress: OFF^LLight; OFF^RLight; SET D(2) = V, A(6) = 0 , I = 1, H = 1;
                                 SET B(Z+1) = 1;
                                 Z^Z_Sipper;Z^Z_LLatEnd ---> S2
                     @Falsepress: OFF^RLight; OFF^LLight; SET B(Z+1) = 0,J = 0, H = 1, D(2) = V;
                                  SET A(6) = 0;
                                   ADD K;Z^Z_LLatEnd ---> S2
   
   #R^RightLever : IF A(7) = 1 [@Truepress, @Falsepress]
           @Truepress: OFF^RLight; OFF^LLight; SET D(2) = V, A(7) = 0 , I = 1, H = 1;                                                                             
                                  SET B(Z+1) = 1, G = 0;
                                 Z^Z_Sipper; Z^Z_LLatEnd ---> S2
                     @Falsepress: OFF^LLight; OFF^RLight; SET B(Z+1) = 0, J = 0, H = 1, G = 0,
                                  D(2) = V; SET A(7) = 0;
                                  ADD L;Z^Z_LLatEnd ---> S2
     
   #Z^Z_NewTrialL : SET J = 0, A(6) = 0, A(7) = 0, G = 0 ; OFF^LLight; OFF^RLight ---> S2
 
 


\\\\***************************************************
\\\\               REWARD CONTROL TIMER
\\\\***************************************************
S.S.2,
S1,
  #Z^Z_Sipper: ON ^Sipper; ADD A(1), ---> S2


S2,     \\\\ Time Reward Device for 2 seconds
  2": OFF ^Sipper; SET J = 0 ---> S1




\\\\***************************************************
\\\\             NOSE POKE OMISSION COUNTER
\\\\***************************************************
S.S.3, \\\\ 10ms Resolution\\\
S1,
  #Z^Z_NPLat:  ---> S2


S2,
  1": ADD E; IF F = 1 [@NPLatend, @NPON]
                   @NPLatend : SET E = 0; Z^Z_NewTrial ---> S1
                   @NPON: IF E >= 10 [@ Omission, @Cont]
                             @Omission:  OFF ^NosePoke;
                  ADD A(3); SET F = 1;
                              SET B(C+1) = 1; Z^Z_NewTrial ---> SX
                   @Cont: ---> S2
\\\\***************************************************
\\\\             LEVER OMISSION COUNTER
\\\\***************************************************
S.S.4, \\\\ 10ms Resolution\\\
S1,
  #Z^Z_LeverLat:  ---> S2


S2,
 1": ADD G; IF H = 1 [@LLatend, @LON]
                   @LLatend : SET G = 0; Z^Z_NewTrialL ---> S1
                   @LON: IF G >= 10 [@ Omission, @Cont]
                        @Omission:  OFF ^LLight; OFF^RLight;
                          ADD A(4); SET  H =1, A(6) = 0, A(7) = 0;
                                  SET B(C+1) = 2; Z^Z_NewTrialL ---> SX
                   @Cont: ---> S2
\\\\***************************************************
\\\\                  UPDATE DISPLAY\\\
\\\\***************************************************
S.S.5,
S1,
  #START: SHOW 1,Tot Rewards,A(1),   2,NP Omissions ,A(3),  3,L Omissions ,A(4),    4,Trial #,O ---> S2




S2,
  1": SHOW 1,Tot Rewards,A(1),   2,NP Omissions ,A(3),  3,L Omissions ,A(4),    4,Trial #,O ---> S2


\\\\***************************************************
\\\\                  Session Clock\\\
\\\\***************************************************
S.S.6,


\   This is the clock and the max time of the session
S1,
    #START: SET T=0 ---> S2
S2,
    1":ADD T; SHOW 5, SesTim, (T/60); IF (T = 3600) [@TrueEnd, @FalseRun]   \  After 1 sec. this sets time in position 5 (with the                                                       \ label SesTim to the left) the session is set to 60 min.                                     
                     @TrueEnd: SET B(2) = K, B(3) = L, B(1) = O,
                               B(4) = A(1) / B(C) * 100;
                     SHOW 6, Percent Correct, B(4) ---> STOPABORTFLUSH     \ Session ends after 60 min
                     @FalseRun: ---> S2                        \ when an hour has passed, the                                                                \program transitions                                     
                                                \ to S2
\\\\***************************************************
\\\\             NOSE POKE LATENCY COUNTER
\\\\***************************************************
S.S.7, \\\\ 10ms Resolution\\\
S1,
  #Z^Z_NPLat: SET S = .01 ---> S2


S2,
 .01": SET S = S + .01 ---> SX
 #Z^Z_NPLatEnd ---> S1
\\\\***************************************************
\\\\             LEVER LATENCY COUNTER
\\\\***************************************************
S.S.8, \\\\ 10ms Resolution\\\
S1,
  #Z^Z_LeverLat: SET V = .01 ---> S2


S2,
 .01": SET V = V + .01 ---> SX
  #Z^Z_LLatEnd ---> S1

Gary Bamberger

  • Administrator
  • Hero Member
  • *****
  • Posts: 640
    • View Profile
    • MED Associates, Inc.
Re: Recording Events Into Arrays
« Reply #1 on: May 30, 2017, 09:38:16 am »
Hi Lauren,

It looks like you are trying to record two pieces of information in the D Array:

\D()    = Latency Array
\D(1)   = NP Latency
\D(2)   = Lever Latency

But when you look in your code for S.S.1, S4 & S5 you have hard coded the array indexes to be 1 and 2.  So every time the trial runs it is going to overwrite the value that was recorded from the last trial.

The way to fix this is to have an index variable into array D that gets incremented every time a new trial starts:

  S4,
    #R^NosePoke : OFF^NosePoke; SET D(P) = S, F = 1; RANDD N = M;
                  SET H = 0; Z^Z_LeverLat; Z^Z_NPLatEnd; ADD A(2);
                  IF N = 1 [@CL, @CR]
         @CL : ON^LLight; SET A(6) = 1 ---> S5
         @CR : ON^RLight; SET A(7) = 1 ---> S5
   
    #Z^Z_NewTrial : SET J = 0, E = 0 ; OFF^NosePoke ---> S6


  S5,
    #R^LeftLever : IF A(6) = 1 [@Truepress, @Falsepress]
         @Truepress: OFF^LLight; OFF^RLight; SET D(P+1) = V, A(6) = 0 , I = 1, H = 1;
                                 SET B(Z+1) = 1;
                                 Z^Z_Sipper;Z^Z_LLatEnd ---> S6
                     @Falsepress: OFF^RLight; OFF^LLight; SET B(Z+1) = 0,J = 0, H = 1, D(P+1) = V;
                                  SET A(6) = 0;
                                   ADD K;Z^Z_LLatEnd ---> S6
   
   #R^RightLever : IF A(7) = 1 [@Truepress, @Falsepress]
           @Truepress: OFF^RLight; OFF^LLight; SET D(P+1) = V, A(7) = 0 , I = 1, H = 1;
                                  SET B(Z+1) = 1, G = 0;
                                 Z^Z_Sipper; Z^Z_LLatEnd ---> S6
                     @Falsepress: OFF^LLight; OFF^RLight; SET B(Z+1) = 0, J = 0, H = 1, G = 0,
                                  D(P+1) = V; SET A(7) = 0;
                                  ADD L;Z^Z_LLatEnd ---> S6
     
   #Z^Z_NewTrialL : SET J = 0, A(6) = 0, A(7) = 0, G = 0 ; OFF^LLight; OFF^RLight ---> S6

  S6,
    0.01": SET P = P + 2 ---> S2


Now
  D(0) = NP Latency Trial 1
  D(1) = Lever Latency Trial 1
  D(2) = NP Latency Trial 2
  D(3) = Lever Latency Trial 2
  D(4) = NP Latency Trial 3
  D(5) = Lever Latency Trial 4
etc.

I hope that this information helps.

Gary

milliel

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Recording Events Into Arrays
« Reply #2 on: June 14, 2017, 11:23:22 am »
Hey Gary, so your suggestion fixed one of my array problems but I was still having issues with several others so I decided to try and adapt the Delayed Reward code that you have up for my task. Everything appears to function properly including the array recordings except the nose poke and lever latencies are suppose to be 10 seconds as in the original code and yet they are firing and turning off the cue lights after about 2 seconds.


Any thoughts as to where I've gone wrong? As always I appreciate all the help.


\\***************************************************\

\\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution.\
\
\
\\ Inputs\
^LeftLever  = 1\
^RightLever = 2\
^Nosepoke   = 4  \\ Level Mode\
\
\\ Outputs\
^LeftLever  = 1\
^RightLever = 2\
^Sipper     = 3\
^Nosepoke   = 4\
^LLight     = 5
^RLight     = 6\
\
\
\\ A() = Control Variables with Assigned Aliases as Defined\
Var_Alias New Trial Interval (sec)                      = A(0)  \\ Default = 4 seconds
Var_Alias Response Time (sec)                           = A(1)  \\ Default = 10 seconds
Var_Alias Number of Rewards                             = A(2)  \\ Default = 1
Var_Alias Number of Blocks to Run                       = A(3)  \\ Default = 40
Var_Alias Number of Forced Trials                       = A(4)  \\ Default = 2
Var_Alias Number of Trials per Block                    = A(5)  \\ Default = 8
Var_Alias SoftCR Data Array (1=Yes  0=No)               = A(6)  \\ Default = 1
\
^NTI            = 0
^ResponseTime   = 1
^NumBlocks      = 2
^ForcedTrials   = 3
^TrialsPerBlock = 4
^SoftCR         = 5
^NTITicks       = 6
^ResponseTicks  = 7
^NumRewards     = 8


\\ List Data Variables Here
\\  B() = Experiment Totals
\\  B(0) = Not Used
\\  B(1) = Total Rewards Delivered
\\  B(2) = Total Successful Trials
\\  B(3) = Total Nose Poke Omissions        (Type 1)
\\  B(4) = Total Lever Omissions            (Type 2)
\
\\\
\\  C() = SoftCR Array
\\\
\\  D() = Trial by Trial Data
\\  D(J)   = Trial Number in this Block
\\  D(J+1) = Number of Rewards Delivered this Trial
\\  D(J+2) = Lever Chosen (1=Left, 2=Right)
\\  D(J+3) = Omission Type (1, or 2)
\\  D(J+4) = Trial Completed Successfully (1=Yes, 0=No)
\\  D(J+5) = Latency to Nose Poke
\\  D(J+6) = Latency to Lever Press
\
\\\
\\  E() = Block by Block Data
\\  E(K)   = Block Number
\\  E(K+1) = Number of Pellets Delivered this Block
\\  E(K+2) = Number of Left Lever Responses this Block
\\  E(K+3) = Number of Right 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


\
\
\\ List Working Variables Here
\\  F = Counter for Nose Poke Level Inputs
\\  G = List for selecting the Cue Light
\\  H = Trial Type (Left or Right) 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
\\  O = Nose Poke Latency Timer
\\  P = Lever Latency Timer
\\  R = Number of Rewards Delivered
\\  T = Elapsed Time in 0.01 sec increments for SoftCR Data
\\  S = Session Clock, limit 60 minutes
\
\
LIST G = 1, 2                    \\ Light Position Variable




DIM A = 8
DIM B = 4
DIM C = 300000  \\ 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 = 100000
\
\
\\ Z-Pulses Used in this Program\
^Z_Sipper      = 1   \\ Signal Reward 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 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\
\
\
\
DISKCOLUMNS = 9
DISKFORMAT  = 10.2
DISKVARS    = A, B, C, D, E
\
\
\\***************************************************\
\\            DELAYED REWARD_V2 SCHEDULE\
\\ S1 - Set Default Values\
\\   New Trial Interval                     (4 sec)
\\   Response Time                         (10 sec)
\\   Number of Blocks to Run           (40)
\\   Number of Forced Trials             (2)
\\   Number of Trials per Block         (8)
\\   SoftCR Data Array                     (1-Yes)
\\***************************************************\
S.S.1,
S1,
  0.01": SET A(^NTI)          = 4,   A(^ResponseTime)   = 10, A(^LeftLever) = 1;
         SET A(^RightLever)   = 2,   A(^NumBlocks)      = 40, A(^NumRewards)  = 1;
         SET A(^ForcedTrials) = 2,   A(^TrialsPerBlock) = 8, 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;
          SET D(J+8) = -987.987, E(K+8) = -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,Left Lever,A(^LeftLever);
      SHOW 4,Right Lever,A(^RightLever),     5,# of Rewards,A(^NumRewards),     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 ^Nosepoke;
                 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 turn on lever cue light.
        \\ Signal start of Lever Latency counter.
        \\
        \\ If Timeout, record Type 1 Omission.
  #R^Nosepoke: OFF ^Nosepoke; SET D(J+5) = O; RANDD H = G;
                Z^Z_LeverLat; Z^Z_LatEnd;
                IF H = 1 [@CL, @CR]
                   @@CL: ON^LLight; SET D(J+2) = 1 ---> S5
                   @@CR: ON^RLight; SET D(J+2) = 2 ---> S5
                               \
  A(^ResponseTicks)#T: OFF ^Nosepoke, ^LLight, ^RLight; [size=78%] [/size]
                       ADD B(3), E(K+5);
                       SET D(J+3) = 1, D(J+4) = 0, D(J+5) = O;
                       Z^Z_LatEnd; Z^Z_Type1 ---> S6
                 


S5,     \\ If Lever response is made within allotted time, turn off\
        \\ the Lever Light.  Signal to issue\
        \\ reward.\
        \\\
        \\ If Timeout, record Type 2 Omission.\
  #RA(^LeftLever): IF D(J+2) = 1 [@Truepress, @Falsepress]
             @Truepress: ADD E(K+2), E(K+4);                         
         OFF ^LLight, ^LeftLever, ^RightLever;
                        SET D(J+6) = P;
                        Z^Z_Sipper;
                        Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
        @Falsepress : OFF ^LLight, ^RLight, ^LeftLever, ^RightLever;
          SET D(J+4) = 0;
          Z^Z_LatEnd ---> S6
  #RA(^RightLever):  IF D(J+2) = 2 [@Truepress, @Falsepress]
      @Truepress : ADD E(K+3), E(K+4);
                      OFF ^RLight, ^LeftLever, ^RightLever;
                      SET D(J+6) = P; Z^Z_Sipper;
                      Z^Z_LatEnd; Z^Z_CorrectResp ---> S6
        @Falsepress : OFF ^LLight, ^RLight, ^LeftLever, ^RightLever;
              SET D(J+4) = 0;
              Z^Z_LatEnd ---> S6


  A(^ResponseTicks)#T: OFF ^LLight, ^RLight, ^LeftLever, RightLever;
                       ADD B(4), E(K+6);
                       SET D(J+3) = 2, D(J+6) = P;
                       Z^Z_LatEnd; Z^Z_Type2 ---> S6
                 


S6,    \\ Wait for New Trial Signal.  Increment trial number.
        \\ Select next  cue light over lever.  If this is the
        \\ 8th trial in this block, increment the block number,\
        \\ 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: ADD L;
                          IF L > A(^NumBlocks) [@End, @Cont]
                             @End: ---> STOPABORTFLUSH
                             @Cont: SET K = K + 7, E(K+7) = -987.987;
                                    SET M = 1, J = J + 7, D(J+7) = -987.987;
                                    ON ^NosePoke;
                                    SET E(K) = L, D(J) = M; Z^Z_NPLat ---> S4
                    @Cont: SET J = J + 7, D(J+7) = -987.987;
                           ON ^NosePoke;
                           SET D(J) = M; Z^Z_NPLat ---> S4




\\***************************************************\
\\               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 ---> S1




\\***************************************************\
\\     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




\\***************************************************\
\\             NOSE POKE LATENCY COUNTER\
\\***************************************************\
S.S.8, \\ 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.9, \\ 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.10, \\ 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


\\***************************************************\
\\                  UPDATE DISPLAY\
\\***************************************************\
S.S.11,
S1,
  #START: SHOW 1,Tot Rewards,B(1),      2,Left Lvr Presses,E(K+2),       3,Right Lvr Presses,E(K+3);
      SHOW 4,Completed Trials,B(2), 5,Tot Type 1,B(3),        6,Tot Type 2,B(4);
      SHOW 7,Block #,L,             8,Trial #,M  ---> S2
           
S2,
  1": SHOW 1,Tot Rewards,B(1),      2,Left Lvr Presses,E(K+2) ,      3,Right Lvr Presses,E(K+3);
      SHOW 4,Completed Trials,B(2), 6,Tot Type 1,B(3),        7,Tot Type 2,B(4);
      SHOW 8,Block #,L,             9,Trial #,M  ---> S2
           


\\\\\\\\***************************************************
\
\\\\\\\\                  Session Clock\\\\\\
\
\\\\\\\\***************************************************
\
S.S.12,


\\   This is the clock and the max time of the session


S1,


    #START: SET S = 0 ---> S2


S2,


    1":ADD S; SHOW 5, SesTim,(S/60); IF S = 3600 [@TrueEnd, @FalseRun]   \\  After 1 sec. this sets time in position 5 (with the                                                         \\ label SesTim to the left) the session is set to 60 min                  
                     @TrueEnd:  ---> STOPABORTFLUSH                            \\ Session ends after 60 min
                     @FalseRun: ---> S2      

Gary Bamberger

  • Administrator
  • Hero Member
  • *****
  • Posts: 640
    • View Profile
    • MED Associates, Inc.
Re: Recording Events Into Arrays
« Reply #3 on: June 14, 2017, 11:56:46 am »
Hi Lauren,

It looks like the problem is in S.S.1, S1:

S.S.1,
S1,
  0.01": SET A(^NTI)          = 4, A(^ResponseTime)   = 10, A(^LeftLever)  = 1;
         SET A(^RightLever)   = 2, A(^NumBlocks)      = 40, A(^NumRewards) = 1;
         SET A(^ForcedTrials) = 2, A(^TrialsPerBlock) = 8,  A(^SoftCR)     = 1 ---> S2


When I take out the named constants this code becomes:

S.S.1,
S1,
  0.01": SET A(0) = 4, A(1) = 10, A(1) = 1;
         SET A(2) = 2, A(2) = 40, A(8 ) = 1;
         SET A(3) = 2, A(4) = 8,  A(5) = 1 ---> S2


That means that:

     A(^ResponseTime) = A(^LeftLever)
     A(^NumBlocks)      = A(^RightLever)

So the Response Time ends up being 1".

I believe that if you fix the above problem it should start working for you.

Gary