acquisition and reversal

MEDState Notation Repository Forums Coding Help Archive acquisition and reversal

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15446

    I am starting a new task wherein a rat has to make a correct choice based on where the cue light is; however, the sound (click or tone) is randomized. Then the next day, the rat must pay attention to which lever a sound is associated with while not paying attention to the location of light cue. At the moment, I think I have all (or at least most) of the state sets, but I cannot correctly link them together. I’m also not sure how to say to end the program with 10 consecutive correct choices, as opposed to 10 correct choices throughout. Any help is appreciated!!

    Here’s the code:

    \ Written by Carol Dannenhoffer 04/29/2019
    \Acquisition
    \ Very comment heavy; first time programmer
    \
    \Day 6: Animal makes decision of which lever to press based on cue light.
    \FR1 schedule for correct lever.
    \Animal must reach 10 correct in a row.
    \Session is 100 trials max. Stop if 10 consecutive correct.
    \Correct lever is directly beneath cue light on.
    \Random intertrial interval.

    \*******************************
    \ CONSTANTS
    \*******************************

    \Threshold receptacle entry or exit time before an entry or exit is registered (in ms)
    ^ReceptacleThreshold = 10

    \*******************************
    \ VARIABLE NAMES
    \*******************************

    \ A = Counter for left lever extension – lever #1
    \ B = Counter for right lever extension – lever #2
    \ C = Counter for left pump delivery \not needed since it’s not connected in these boxes
    \ D = Counter for right pump delivery
    DIM F = 2
    \ F(1) = Counter for left lever pressed
    \ F(2) = Counter for right lever pressed

    \ M = Array G stores timestamp of each receptacle entry
    DIM M=10000
    \ N = Array H stores timestamp of each receptacle exit
    DIM N=10000
    \ Q = ON/OFF switch for LEFT lever
    \ S = ON/OFF switch for RIGHT lever

    \ W = List W deals with receptacle information
    DIM W = 5
    \ W(1) = Increments with each receptacle entry
    \ W(2) = Increments with each receptacle exit
    \ W(3) = Number of clock ticks receptacle beam is broken
    \ W(4) = Threshold number of clock ticks for detecting receptacle entries/exits (as defined in constants)
    \ W(5) = BTIME at start of experiment
    \ J = Array for random intertrial interval (10-20 seconds)
    LIST J=10,11,12,13,14,15,16,17,18,19,20
    \ I = Element in the J array

    \*******************************
    \ Z PULSES
    \*******************************

    \Z1 = initiates trial
    \Z2 = counts RPUMP deliveries
    \Z4 = initiate left lever sequence
    \Z5 = initiate right lever sequence

    \*******************************
    \ TTL PULSES
    \*******************************

    ^LLEVTTL =19
    ^RLEVTTL =20
    ^STARTANTTTL =21
    ^ENDANTTTL =22
    ^LEVOUTTTL =23

    \*******************************
    \ TIME STAMPS
    \*******************************

    LIST R=1
    DIM E=4900 \E is a list of timestamps of reward deliveries from which cue onset can be inferred (30 s prior to rew delivery)
    DIM G=4900 \measuring both lever responses
    DIM H=4900 \H is a list of timestamps of lever presses

    \ **********************************************
    \ DEFINE INPUT/OUTPUT CONSTANTS
    \ **********************************************

    \Inputs
    ^LLEV=1
    ^RLEV=3
    ^Receptacle = 5
    ^ReceptacleEntry = 9
    ^ReceptacleExit = 10

    \Outputs
    ^LLIGHT =4
    ^RLIGHT =5
    ^CLICKER =8
    ^TONE =9
    ^NOISE =6
    ^HOUSE =7
    ^LPUMP =10
    ^RPUMP =11
    ^FAN =3
    ^OPLLEV =1
    ^OPRLEV =2

    \ *********************************************
    \ TEST CHAMBERS PRIOR TO RUN:
    \ PRESS LEFT LEVER (1) THEN RIGHT LEVER (2)
    \ *********************************************

    S.S.1,
    S1,
    .1″:SET W(4) = (^ReceptacleThreshold/1000)*1″;
    ON^HOUSE,^FAN,^NOISE,^OPLLEV,^OPRLEV—>S2
    S2,
    #R^LLEV:ON^LPUMP,^LLIGHT,^TONE;OFF^OPLLEV—>S3
    S3,
    3.5″:OFF^LPUMP—>S4
    S4,
    .1″:OFF^LLIGHT,^TONE —>S5
    S5,
    #R^RLEV:ON^RPUMP,^RLIGHT;OFF^OPRLEV —>S6
    S6,
    3.5″:OFF^RPUMP—>S7
    S7,
    #Z^ReceptacleEntry:—>S8
    S8,
    .1″:OFF^RLIGHT,^HOUSE—>S9
    S9,
    300′:—>SX

    \ HOUSE LIGHT IS OFF, FAN IS ON

    \ **************************************************
    \ DETECT RECEPTACLE ENTRIES AND EXITS
    \ -photobeam must be broken for a threshold amount of time before being registered as an entry (threshold time = Q(7))
    \ -only works if the jumper corresponding to this input on the smartctrl card is set as a “level” input (see smartctrl card manual)
    \ **************************************************

    S.S.3,
    S1,
    .1″:—>S2
    S2,
    #R^Receptacle:ADD W(3);IF W(3)>W(4) [@YesBeamBreak,@NoBeamBreak]
    @YesBeamBreak:SET W(3)=0;Z^ReceptacleEntry—>S3
    @NoBeamBreak:—>SX
    W(4)#T:SET W(3)=0—>S2
    S3,
    #R^Receptacle:—>S3
    W(4)#T:Z^ReceptacleExit—>S2

    \ **************************************************
    \ RECORDS TIME OF EACH RECEPTACLE ENTRY AND EXIT
    \ **************************************************

    S.S.4,
    S1,
    .1″:—>S2
    S2,
    #Z^ReceptacleEntry:ADD W(1);SET M(W(1)-1)=(BTIME-W(5))/^1″;IF W(1)>=10000 [@Stop,@SealArray]
    @Stop:—>STOPABORTFLUSH
    @SealArray:SET M(W(1))=-987.987—>S3
    #Z^ReceptacleExit:ADD W(2);SET N(W(2)-1)=(BTIME-W(5))/^1″;ADD W(1);SET M(W(1)-1)=0;SET M(W(1))=-987.987;IF W(2)>=10000 [@Stop,@SealArray]
    @Stop:—>STOPABORTFLUSH
    @SealArray:SET N(W(2))=-987.987—>SX
    S3,
    #Z^ReceptacleExit:ADD W(2);SET N(W(2)-1)=(BTIME-W(5))/^1″;IF W(2)>=10000 [@Stop,@SealArray]
    @Stop:—>STOPABORTFLUSH
    @SealArray:SET N(W(2))=-987.987—>S2
    #Z^ReceptacleEntry:ADD W(1);SET M(W(1)-1)=(BTIME-W(5))/^1″;ADD W(2);SET N(W(2)-1)=0;SET N(W(2))=-987.987;IF W(1)>=10000 [@Stop,@SealArray]
    @Stop:—>STOPABORTFLUSH
    @SealArray:SET M(W(1))=-987.987—>SX

    \ *********************************************
    \ BEGIN SESSION – ACQUISITION: LIGHT CUE
    \ *********************************************

    S.S.2,
    S1,
    .1″:—>S2
    S2,
    #START:SET W(5)=BTIME;SET W(1)=0;ON^HOUSE—>S3
    S3,
    .1″:—>SX

    S.S.3, \LEFT lever process – lever 1
    S1,
    #Z7:—>S2
    S2,
    10″:ON^OPLLEV;SET K=0;SET K=K+.01;ADD A—>S3
    S3,
    .1″:—>S4
    S4,
    .1″:IF Q=1 [@TRUELP,@FALSELNP] \LP=LEFT PRESSED;LNP=LEFT NOT PRESSED
    @TRUELP:OFF^OPLLEV;ON^LPUMP;ADD F(1)—>S5
    @FALSELNP:—>S7
    S5,
    3.5″:OFF^LPUMP;ADD D—>S6
    S6,
    6.5″:—>S1
    S7,
    .1″:IF K=10 [@TrueLOmis,@FalseLKeeplooking]
    @TrueLOmis:Z8—>SX
    @FalseLKeepLooking:—>SX

    S.S.4, \if no response in 10 seconds, count as omission
    S1,
    #START:—>S2
    S2,
    #Z8:—>S3
    S3,
    .1″:OFF^OPLLEV,^OPRLEV,ADD O—>S2

    S.S.5, \RIGHT lever process – lever 2
    S1,
    #Z7:—>S2
    S2,
    10″:ON^OPRLEV;SET K=0;SET K=K+.01;ADD B—>S3
    S3,
    .1″:—>S4
    S4,
    .1″:IF S=1 [@TRUERP,@FALSERNP] \RP=RIGHT PRESSED;RNP=RIGHT NOT PRESSED
    @TRUERP:OFF^OPRLEV;ON^RPUMP;ADD F(2)—>S5
    @FALSERNP:—>S7
    S5,
    3.5″:OFF^RPUMP;ADD D—>S6
    S6,
    6.5″:—>S1
    S7,
    .1″:IF K=10 [@TrueROmis,@FalseRKeepLooking]
    @TrueROmis:Z8—>SX
    @FalseRKeepLooking:—>SX

    S.S.6, \if no response in 10 seconds, count as omission
    S1,
    #START:—>S2
    S2,
    #Z8:—>S3
    S3,
    .1″:OFF^OPLLEV,^OPRLEV,ADD O—>S2

    S.S.7, \counts every receptacle entry – maybe add time stamp? – NEED LATENCIES
    S1,
    #START:—>S2
    S2,
    .1″:—>S3
    S3,
    #R^ReceptacleEntry:ADD V—>SX

    \ ****************************
    \ SINGLE TONES AND CLICKERS
    \ ****************************

    S.S.11, \plays one TONE if LEFT lever extends
    S1,
    #START:—>S2
    S2,
    #ON^OPLLEV—>S3
    S3,
    .1″:ON^TONE:—>S4
    S4,
    3″:OFF^TONE:—>S2

    S.S.12, \plays one CLICK if LEFT lever extends
    S1,
    #START:—>S2
    S2,
    #ON^OPLLEV—>S3
    S3,
    .1″:ON^CLICKER:—>S4
    S4,
    3″:OFF^CLICKER:—>S2

    S.S.14, \plays one TONE if RIGHT lever extends
    S1,
    #START:—>S2
    S2,
    #ON^OPRLEV—>S3
    S3,
    .1″:ON^TONE—>S4
    S4,
    3″:OFF^TONE—>S2

    S.S.15, \plays one CLICK if RIGHT lever extends
    S1,
    #START:—>S2
    S2,
    #ON^OPRLEV—>S3
    S3,
    .1″:ON^CLICKER:—>S4
    S4,
    3″:OFF^CLICKER:—>S2

    S.S.13, \left lever on/off switch
    S1,
    #START:—>S2
    S2,
    #R^LLEV:SET Q=1—>S3
    S3,
    .5″:SET Q=0—>S2

    S.S.14, \right lever on/off switch
    S1,
    #START:—>S2
    S2,
    #R^RLEV:SET S=1—>S3
    S3,
    .5″:SET S=0—>S2

    \ *********************************************
    \ SETTING RANDOM INTERTRIAL INTERVAL
    \ *********************************************

    S.S.8,
    S1,
    #Z3:—>S2
    S2,
    .1″:RANDI I=J;SHOW 6,ITI,I;Z7—>SX

    \ *********************************************
    \ z pulses for sounds
    \ *********************************************

    S.S.10,
    S1,
    #Z1:—>S2
    S2,
    .1″:ON^TONE—>S3
    S3,
    3″:OFF^TONE—>S1

    S.S.11,
    S1,
    #Z2:—>S2
    S2,
    .1″:ON^CLICKER—>S3
    S3,
    3″:OFF^CLICKER—>S1

    \ *********************************************
    \ SHOW COUNTS ON SCREEN
    \ *********************************************

    S.S.8,
    S1,
    .1″:—>S2
    S2,
    #START:—>S3
    S3,
    1″:SHOW 1,SessionTime,(BTIME-W(5))/^1″,2,LLEVEXT,A,3,RLEVEXT,B,4,RPUMP,D,5,LLEVPRESS,F(1),6,RLEVPRESS,F(2),7,OMISSION,O,8,TotalTrials,J,9,ReceptacleEntry,V,10,Correct,H,11,Incorrect,I—>SX

    \ *********************************************
    \ END SESSION; 10 CONSECUTIVE CORRECT OR 150 TRIALS
    \ *********************************************

    S.S.9,
    S1,
    .1″:—>S2
    S2,
    #START:—>S3
    S3,
    #Z3:ADD H;IF H=10[TRUEFINISH,@FALSECONTINUE] \\\\\\\\\CHANGE TO MAKE SURE IT’S 10 IN A ROW, NOT JUST 10 CORRECT
    @TRUEFINISH:—>S4
    @FALSECONTINUE:—>SX
    S4,
    .1″:IF A and B = 150 [@YesEnd,@NoContinue]
    @YesEnd:OFF^OPLLEV,^OPRLEV,^HOUSE,^NOISE,^FAN —>STOPABORTFLUSH \\\\\END AT 150 LEVER PRESSES
    @NoContinue:—>SX

    #15448
    Med_Support
    Moderator
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.