Med_Support
Forum Replies Created
-
AuthorPosts
-
Med_Support
ModeratorIf you post the entire code with the changes that we have made recently I would be happy to take a look at it.Gary
Med_Support
ModeratorAude
thanks Gary,
I did not change the variable, juste the setting in the first paragraph… but I have this super weird problem A(1) = 13, A(2) = 15 and A(3) = 0
The task is functioning perfectly, with the good delay for the response time, and the lever are inserted and retracted and counted as expected…
I really don’t know… I will look into it…
thanks again!
AudeMed_Support
ModeratorGary Bamberger
Hello Suszie,
I think this might do what you want:
\*********************************************************** \ Variables \*********************************************************** \ M = List - Random Time Generator \ Y = Random Trial Generation List M = 6", 7", 8", 9", 10", 11", 12", 13", 14", 15", 16", 17", 18", 19", 20", 21" \*********************************************************** \ Pre-Cue Period & premature response logic \*********************************************************** S4, \Turn on opto Laser and move to S6 0.001": ON ^Laser ---> S6 S6, \Initiate random time selected from List M (6-21") move on to S7 0.001": RANDD X = M ---> S7 S7, \Count NosePokes - register both for Pre-Cue NosePokes and for total #NosePokes M#T: ---> S8 #R^NosePoke: Z^Z_PreCueNosePoke; Z^Z_TotalNosePokes ---> SX S8, \If the animal responds in the last three seconds trigger ITI and move to S2 (ITI logic), \if not initiate trial randomisation #R^NosePoke: OFF ^Laser; Z^Z_PreCueNosePoke; Z^Z_TotalNosePokes; Z^Z_ITI; Z^Z_PreCueFail ----> S2 \S2 is the ITI logic 3": OFF ^Laser; Z^Z_PreCueSuccess ---> S9 \if not, initiate trial randomisation in S9
Please let me know if I can help you in any other way.
GaryMed_Support
ModeratorGary Bamberger
Hi Aude,
For your first question here is the code in question:
\ A() = Control Variables with Assigned Aliases as Defined Var_Alias New Trial Interval (sec) = A(0) \ Default = 100 seconds Var_Alias Response Time (sec) = A(1) \ Default = 10 seconds Var_Alias Immediate Reward Lever (1=Left 2=Right) = A(2) \ Default = 1-Left Var_Alias Delayed Reward Lever (1=Left 2=Right) = A(3) \ Default = 2-Right Var_Alias Number of Pellets for Delayed Rewards = A(4) \ Default = 4 Var_Alias Number of Blocks to Run = A(5) \ Default = 5 Var_Alias Number of Forced Trials (Should be an Even #) = A(6) \ Default = 2 Var_Alias Number of Trials per Block = A(7) \ Default = 12 Var_Alias SoftCR Data Array (1=Yes 0=No) = A(8 ) \ Default = 1 ^NTI = 0 ^ResponseTime = 1 ^ImmediateLever = 2 ^DelayedLever = 3 ^LargeReward = 4 ^NumBlocks = 5 ^ForcedTrials = 6 ^TrialsPerBlock = 7 ^SoftCR = 8 ^NTITicks = 9 ^ResponseTicks = 10 S.S.1, S1, 0.01": SET A(^NTI) = 100, A(^ResponseTime) = 10, A(^ImmediateLever) = 13; SET A(^DelayedLever) = 15, A(^LargeReward) = 4, A(^NumBlocks) = 5; SET A(^ForcedTrials) = 2, A(^TrialsPerBlock) = 12, 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; LIST U = N(S); SET D(J+9) = -987.987, E(K+9) = -987.987; SET A(^NTITicks) = A(^NTI) * 1"; SET A(^ResponseTicks) = A(^ResponseTime) * 1" ---> S3 1": SHOW 1,New Trial Int,A(^NTI), 2,Response Time,A(^ResponseTime), 3,Immediate Lever,A(^ImmediateLever); SHOW 4,Delayed Lever,A(^DelayedLever), 5,# of Pellets,A(^LargeReward), 6,# of Blocks,A(^NumBlocks); SHOW 7,Forced Trials,A(^ForcedTrials), 8,Trials/Block,A(^TrialsPerBlock), 9,SoftCR Code,A(^SoftCR) ---> SX
This will result in A(0) = 100, A(1) = 10, A(2) = 13, A(3) = 15
I downloaded and ran the program from the repository and it is working this way. The only way this would change is if the named constants for the A array were changed from:
^ResponseTime = 1
^ImmediateLever = 2
^DelayedLever = 3For your second question here is the code for the initial nose poke:
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 A(^ImmediateLever), A(^DelayedLever) ---> 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 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; Z^Z_NPLat ---> S4 @Cont: SET J = J + 9, D(J+9) = -987.987; ON ^HouseLight, ^StimLight; SET D(J) = M; Z^Z_NPLat ---> S4 \*************************************************** \ TIME NEW TRIAL INTERVAL \*************************************************** S.S.12, \ 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
So if the animal fails to Nose Poke then the program will record an omission, end the trial, and go to S10 where it waits for the signal for a New Trial. The program does not time a Inter-Trial Interval. A “New Trial” starts every 100s. Since we already waited 10s for the Response Time the next trial should start 90s later. I just downloaded the program from the repository and that is exactly what it does.
I hope that this information helps.
GaryMed_Support
ModeratorAude
Hi Gary,
Me again!
While checking if all the variable were well recorded, I noticed something weird about the table for variable A. A(0) is well recorded as the ITI time however, I noticed a left shift in the recorded table : A(1) which is supposed to be the response time (and I set it as default 10sec in the S.S.1, S.1 part of the program) is recorded as A(2) = 13 ^immediatelever, A(2) is recorded as A(3)=15 ^delayedlever, then A(3) is 0 and then the other variables are recorded as expected.
when loading the program on medPC, on the screen, the same error is here. This is not the case with your unmodified program. I tried to understand but I am stuck…I also noticed that if the rat fails to respond during the allocated time 10 s time at the first trial (before the forced choice), this does not lead back to the 100s ITI time but to a 5 sec timeout (this also true in your unmodified program…) and it counts as a trial and record the omission. it is not the case after the first forced choice if I well remember… I am just wondering if it is normal…
looking forward to being in touch!
audeMed_Support
ModeratorGary Bamberger
Glad to hear that it is now working.
Med_Support
ModeratorAude
Dear Gary!!!
Fantastic it works fine! Thank you sooooo much!!!
You saved me!Best
Aude
Med_Support
ModeratorGary Bamberger
Hi Aude,
Search the code and everywhere you find ON or OFF ^LeftLever, ^RightLever replace it with ON or OFF A(^ImmediateLever), A(^DelayedLever). That should do it.
Gary
Med_Support
ModeratorAude
Dear Gary
Thanks a lot,
I tryed the code you sent me, and this time the reward is given for each of the levrs however the levers are not retracted after the lever press…
it looks like i need once again your help…Thanks a lot
Aude
Med_Support
ModeratorGary Bamberger
Hi Aude,
I think that you are running into a problem in S.S.1, S5
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
The code is looking for an input on the A(^ImmediateLever) and A(^DelayedLever) which you have now assigned to be 13 and 15. But your lever inputs are connected to 1 and 2. The code is really expecting the inputs and outputs to be the same.
You need to create another variable to be used for the inputs:
DIM V = 1 #START: CLEAR 1,60; SET L = 1, M = 1; RANDD H = G; LIST U = N(S); SET D(J+9) = -987.987, E(K+9) = -987.987; SET A(^NTITicks) = A(^NTI) * 1"; SET A(^ResponseTicks) = A(^ResponseTime) * 1"; IF A(^ImmediateLever) = 13 [@Left, @Right] @Left: SET V(0) = 1, V(1) = 2 ---> S3 @Right: SET V(0) = 2, V(1) = 1 ---> S3 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. #RV(0): 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 #RV(1): 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
I hope that this information helps.
Gary
Med_Support
ModeratorGary Bamberger
Hi Aude,
To change to the code so that it works with a Nose Poke in Transition Mode is fortunately rather small. All you need to do is look for everywhere that it says
#Z^Z_NPBreak:
and replace it with
#R^NosePoke:
I hope that this helps.
Gary
Med_Support
ModeratorGary Bamberger
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
Med_Support
Moderatormilliel
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 ( \\ 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
Med_Support
ModeratorGary Bamberger
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
April 21, 2017 at 5:01 am in reply to: Houselight not turning on when given command in middle of session #12638Med_Support
ModeratorMed
Doh! I knew it would be something simple. Thanks for your help, I will go try it out.
April 20, 2017 at 12:51 pm in reply to: Houselight not turning on when given command in middle of session #12635Med_Support
ModeratorHello,
Here is S.S.10 from your code:
S.S.10 S1, #START: --->S2 S2, 10": ON^HOUSELIGHT --->S3 S3, 10": OFF^HOUSELIGHT --->SxWhat this State Set does is after the START command the State Set waits 10 seconds and then turns on the House Light. The State Set then waits for 10 seconds and turns off the House Light.
A double quote is for seconds.
A single quote is for minutes.So a simple change should do what you want:
S.S.10 S1, #START: --->S2 S2, 10': ON^HOUSELIGHT --->S3 S3, 10': OFF^HOUSELIGHT --->SxPlease let me know if this helps.
GaryP.S. I’ve discovered that the forum editor does not like curly or smart quotes. That is why your previous posts wouldn’t display. If you only use straight quotes, then it works.
Med_Support
Moderatormilliel
You are the best Gary! That worked, thanks so much for all your help and patience!
Med_Support
ModeratorGary Bamberger
Hi Lauren,
The following might work:
S.S.1, S1, #START: SET A(^ResponseTime) = 10, A(^CorrectLever) = 1; SET D(J) = 0, X = 0 ---> S5 S2, \ Time Initial ITI. Signal start of Nose Poke Latency counter. 4": ADD J; ON ^NosePoke; SET X = 1, E = 0; Z^Z_NPLat ---> S3 S3, \ Wait for NP response #R^NosePoke: OFF ^NosePoke; ON ^LLeverLIGHT; SET E = 1 ---> S4 #Z^Z_NewTrial: SET E = 1, X = 0; OFF ^NosePoke ---> S5 S4, \ When Lever response is made turn off the LeverLight, Signal to issue immediate reward. #RA(^CorrectLever): OFF ^LLeverLight; SET N = 1, D(J+2) = 1; ADD B(2), B(3); Z^Z_Sipper ---> S5 S5, 0.01": IF X = 0 [@GO, @STOP] @GO: ---> S2 @STOP: ---> S5
Gary
Med_Support
Moderatormilliel
Hey Gary,
Do you have any suggestions as to how I can fix this? It seems that if I’m understanding correctly, I should also have a z-pulse issued in S.S.3 before returning to S1 however, I don’t know how how to address S.S.1, S3 issue for the z-pulse being ignored.-Lauren
Med_Support
ModeratorGary Bamberger
In S.S.4, S1 when a response happens on the ControlKey the program issues a Z2 pulse and then —> S5.
The Z2 pulse is responded to in S.S.3, S2 which issues a Z1 pulse.
S.S.1 would now be in S5 so it responds to the Z1 pulse and —> S1 and the 3″ timer never happens.To fix this don’t issue a Z1 pulse in S.S.3, S2.
One other thing that I noticed is that you are not calling the InitANL926 command until S.S.3, but in S.S.1 you are issuing a ToneOn command. This may work under most circumstances, but you will eventually run into a time when the program doesn’t work properly.
You should move S.S.3 to be above S.S.1.
Gary
Med_Support
ModeratorEtaire
THANK YOU SO MUCH!!
…
I have one more question: My code here doesn’t seem to work .. I want my no go cue to reset when PeckKey is pressed during the 3 seconds of the no go cue. When I added “ #Z1: OFF ^Light1g; ON ^Light1r —> S1″ to S5, my code stopped working completely.
\ Inputs ^PeckKey = 3 ^ControlKey = 2 \ Outputs ^Pellet = 2 \light colours g = green r = red w = white ^Light1g = 6 \controlKey light ^Light1w = 5 ^Light1r = 4 ^Light2r = 7 \PeckingKey light ^Light2g = 9 ^Light2w = 8 ^Door = 1 ^No =10 LIST A = 1, 2, 3, 4 S.S.1, S1, 0.01": ~ToneOFF(MG,1);~; RANDI B = A; SHOW 1, GO/NOGO, B; OFF ^Pellet; OFF ^Light1w; OFF ^Light2W; OFF ^Light1r; OFF ^Light2r; OFF ^Light1g; OFF ^Light2g; SET X =0 --->S2 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S2, 5": ON^Light1w; ON^Light2w ---> S3 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S3, 0.01": IF (B = 2) OR (B = 4) [@True, @False] @True: ON ^Light1g --->S4 \no go @False: ON^ Light1r--->S6 \go #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S4, #R^ControlKey: OFF ^Light1w; OFF ^Light2w; ON ^Light1r; ON ^Light2r; Z2 ---> S5 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S5, 3": ~ToneOFF(MG,1);~;OFF ^Light1r; OFF ^Light2r --->S8 S6, #R^ControlKey: OFF ^Light1w; OFF ^Light2w; ON ^Light1g; ON ^Light2g; SET X = 1 ---> S7 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S7, 10":SET X = 0--->S1 S8, 0.01": ON ^Pellet--->S1 S.S.2, S1, #R^PeckKey: ---> S2 S2, 0.01": IF X = 1 [@True, @False] @True: SET X = 1 --->S3 @False: Z1 --->S1 S3, 0.01":ON ^Pellet; OFF ^Light1g; OFF ^Light2g; Z1 --->S1 S.S.3, S1, 0.01": ~SetRack(MG,1) ;~; ~InitANL926;~; --->S2 S2, #Z2: ~ToneOn(MG,1);~; Z1 ---> S2
Med_Support
ModeratorGary Bamberger
Hello,
In S.S.2 you are checking IF X = 1. The only time X = 1 is when the program is in S.S.1, S5. When the program is in S.S.1, S5 that is when you want a reward to be issued. When the program is in S.S.1, S1 – S4 you don’t want a reward to be issued.
The only place that you are looking for a Z1 pulse is in S.S.1, S5 and that is the only place it is not needed. The following change should work for you:
\ Inputs ^PeckKey = 3 ^ControlKey = 2 \ Outputs ^Pellet = 2 \light colours g = green r = red w = white ^Light1g = 6 \controlKey light ^Light1w = 5 ^Light1r = 4 ^Light2r = 7 \PeckingKey light ^Light2g = 9 ^Light2w = 8 ^Door = 1 ^No =10 \Variables \X = 1 (pecks that occur during go signal) , 0 (pecks that occur NOT at go signal) S.S.1, S1, 0.01":OFF ^Pellet; OFF ^Light1w; OFF ^Light2W; OFF ^Light1r; OFF ^Light2r; OFF ^Light1g; OFF ^Light2g; SET X =0 --->S2 #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S2, 3": ---> S3 #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S3, #R^ControlKey: ON^Light1w ---> S4 \start of pre cue period #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S4, 2#R^ControlKey: OFF ^Light1w; OFF ^Light2r; ON ^Light1g; ON ^Light2g; SET X = 1 ---> S5 \end of precue period and start of go cue period #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S5, 10":SET X = 0; OFF ^Light2g; ON^Light2r --->S1 \10s go cue period duration S.S.2, S1, #R^PeckKey: ---> S2 S2, 0.01": IF X = 1 [@True, @False] @True: --->S3 \if pecks occur at go signal, reward with pellet @False: Z1 --->S1 \if pecks occur anytime else, reset program with Z pulse S3, 0.01":ON ^Pellet; OFF ^Light1g; OFF ^Light2g --->S1
Now when the program is not in the cue period any pecks will reset the program.
Gary
Med_Support
ModeratorGary Bamberger
Hi Lauren,
I believe the problem is in S.S.1 and S.S.3.
In S.S.1, S2 you issue a Z^Z_NPLat.
S.S.3 responds to the Z-pulse —> S2
1″ later it checks IF E = 1 (false)
Program then checks IF L >= A(^ResponseTime)Now if the animal takes longer than 10s to respond to the Nose Poke an Omission is recorded and a Z^Z_NewTrial is issued, but S.S.1, S3 is still looking for a response on the Nose Poke and the Z^Z_NewTrial is ignored. The program will continue doing this every 1s until the animal responds on the Nose Poke.
Once the animal responds on the Nose Poke the program SETs E = 1 and S.S.3, S2 SETs L = 0 and goes back to S1 and stops issuing the Z^Z_NewTrial.
S.S.1, now goes to S4, then S5, and finally S6 where it waits for a Z^Z_NewTrial, but now S.S.3 is in S1 and not issuing anymore Z-pulses.
Even if the animal responds to the Nose Poke in less than the Response Time:
S.S.1, S3 SETs E = 1
S.S.3, S2 now SETs L = 0 and goes to S1
S.S.1, now goes to S4, then S5, and finally S6 where it waits for a Z^Z_NewTrial, but now S.S.3 is in S1 and not issuing anymore Z-pulses.Gary
Med_Support
Moderatormilliel
Hey Gary,
So I tried to simplify this code as much as possible to just what I absolutely need and I’m still having issues. Mainly after the initial trial, I can not get a new trial to start (it appears my z-pulse for my new trial will not fire) so that I never get past the first trial and after the initial omission my omissions are being recorded every second instead of only when the IF statement is true.Hey Gary, I’m not sure why it keeps cutting the code off, but I’ve attached it in a file as well.
\\After ITI the NosePoke light is turned on. Animal is given 10s to respond with a nose poke. If no response, a Type \\ 1 Omission is recorded. \\If there is a response, then the left lever light is turned on. \\\ \\ If the Correct lever is chosen then the lever \\ Light is turned off, and 2s reward is given. \\\\***************************************************************************************************************************** \Inputs ^LeftLever = 1 ^RightLever = 2 ^NosePoke = 4 \Outputs ^LeftLever = 1 ^RightLever = 2 ^Sipper = 3 ^NosePoke = 4 ^LLeverLight = 5 ^RLeverLight = 6 \ A() = Control Variables with Assigned Aliases as Defined Var_Alias Response Time (sec) = A(1) Default = 10 seconds Var_Alias Correct Lever (1=Left) = A(2) Default = 1-Left Var_Alias Number of Trials to Run = A(3) Default = 180 ^ResponseTime = 1 ^CorrectLever = 2 \List Data Variables Here \ B() = Experiment Totals \ B(0) = Not Used \ B(1) = Total Rewards Delivered \ B(2) = Total Correct Lever Responses \ B(3) = Total Successful Trials \ B(4) = Total NosePoke Omissions (Type 1) \ B(5) = Total Lever Omissions (Type 2) \ B(6) = Total NosePokes \ D() = Trial by Trial Data \ D(J) = Trial Number \ D(J+1) = Omission Type (1, or 2) \ D(J+2) = Trial Completed Successfully (1=Yes, 0=No) \ D(J+3) = Latency to Initial Nose Poke \ D(J+4) = Latency to Lever Press \ List Working Variables Here \ H = Subscript into the Trial Array D \ L = Nose Poke Latency Timer \ M = Lever Latency Timer \ N = Number of Rewards to Deliver \ O = Number of Rewards Delivered \ S = Session Time DIM A = 4 DIM B = 7 DIM C = 100000 DIM D = 50000 \ 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_LatEnd = 4 \\\\ Signal End of Latency Counters ^Z_SipperEnd = 5 \\\\ Signal End of Sipper 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\ \\\\ Session Length (60mins) \\\\ New Trial Interval (4s) \\\\ Response Time (10 sec) \\\\ Correct Reward Lever (1-Left) \\\\ Number of Trials to run (180) \\\\*************************************************** S.S.1, S1, #START: SET A(^ResponseTime) = 10, A(^CorrectLever) = 1; SET D(J) = 0 ---> S2[size=78%]S2, [/size] 4
Med_Support
ModeratorGary Bamberger
Hi Lauren,
So when an omission happens you don’t turn off the latency counter with a Z^Z_LatEnd. The latency counter keeps running into the next trial.
Also when an omission happens you send the program back to S3 and not S6. I think that when an omission happens that it is supposed to end the trial. The code in S6 handles all of the setup for the next trial.
I hope that this helps.
GaryMed_Support
Moderatormilliel
Hey Gary,
Thanks for your help with the error message. Unfortunately I am still having issues with my latencies and my omissions being recorded correctly. I’ve looked over several codes using latencies and can not seem to parse out what my issue is.Again any thoughts you have would be greatly appreciated.
\\\\***************************************************************************************************************************** \\After ITI the Center NosePoke light is turned on. Animal is given 10s to respond with a nose poke. If no response, a Type \\ 1 Omission is recorded. \\If there is a response, then the left lever light is turned on. If there is \\no lever press within 10s, then a Type 2 Omission is recorded. \\\ \\ If the Correct lever is chosen then the lever \\ Light is turned off, and 2s reward is given. \\\\***************************************************************************************************************************** \\\ \\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution. \Inputs ^LeftLever = 1 ^RightLever = 2 ^Nosepoke = 4 \Outputs ^LeftLever = 1 ^RightLever = 2 ^Sipper = 3 ^NosePoke = 4 ^LLeverLight = 5 ^RLeverLight = 6 \ A() = Control Variables with Assigned Aliases as Defined Var_Alias Response Time (sec) = A(1) Default = 10 seconds Var_Alias Correct Lever (1=Left) = A(2) Default = 1-Left Var_Alias SoftCR Data Array (1=Yes 0=No) = A(3) Default = 1 Var_Alias Number of Blocks to Run = A(4) Default = 23 Var_Alias Number of Trials per Block = A(5) Default = 4 ^NTI = 0 ^ResponseTime = 1 ^CorrectLever = 2 ^SoftCR = 3 ^NumBlocks = 4 ^TrialsPerBlock = 5 ^ResponseTicks = 6 ^NTITicks = 7 \List Data Variables Here \ B() = Experiment Totals \ B(0) = Not Used \ B(1) = Total Rewards Delivered \ B(2) = Total Correct Lever Responses \ B(3) = Total Successful Trials \ B(4) = Total NosePoke Omissions (Type 1) \ B(5) = Total Lever Omissions (Type 2) \ B(6) = Total NosePokes \ C() = SoftCR Array \ D() = Trial by Trial Data \ D(J) = Trial Number in this Block \ D(J+1) = Omission Type (1, or 2) \ D(J+2) = Trial Completed Successfully (1=Yes, 0=No) \ D(J+3) = Latency to Initial Nose Poke \ D(J+4) = Latency to Lever Press \ E() = Block by Block Data \ E(K) = Block Number \ E(K+1) = Number of Rewards Delivered this Block \ E(K+2) = Number of Correct Lever Responses this Block \ E(K+3) = Number of Successful Trials this Block \ E(K+4) = Number of NosePoke Omissions (Type 1) this Block \ E(K+5) = Number of Lever Omissions (Type 2) this Block \ E(K+6) = Number of NosePokes \ List Working Variables Here \ F = Counter for Nose Poke Level Inputs \ G = Subscript for the SoftCR Array C \ H = Subscript into the Trial Array D \ I = Subscript into the Block Array E \ J = Block Number \ K = Trial Number this Block \ L = Nose Poke Latency Timer \ M = Lever Latency Timer \ N = Number of Rewards to Deliver \ O = Number of Rewards Delivered \ P = Elapsed Time in 0.01 sec increments for SoftCR Data DIM A = 8 DIM B = 7 DIM C = 100000 DIM D = 50000 DIM E = 10000 \ 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_LatEnd = 4 \\\\ Signal End of Latency Counters ^Z_SipperEnd = 5 \\\\ Signal End of Sipper 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 (4s) \\\\ Response Time (10 sec) \\\\ Correct Reward Lever (1-Left) \\\\ Number of Blocks to Run (6) \\\\ Number of Trials per Block (15) \\\\ SoftCR Data Array (1-Yes) \\\\*************************************************** S.S.1, S1, 0.01": SET A(^ResponseTime) = 10, A(^CorrectLever) = 1; SET A(^NumBlocks) = 23, A(^NTI) = 4; SET A(^TrialsPerBlock) = 4, 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 J = 1, K = 1; SET D(J+5) = -987.987, E(K+7) = -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,Correct Lever,A(^CorrectLever); SHOW 4,# of Blocks,A(^NumBlocks), 5,Trials Per Block,A(^TrialsPerBlock), 6,SoftCR Code,A(^SoftCR) ---> SX S3, \\\\ Time Initial ITI. Signal start of Nose Poke Latency counter. 4" : ON ^NosePoke ; SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4 S4, \\\\ If Nose Poke is made within allotted time, turn off \\\\ the NP Light and turn on lever light \\\\ Signal start of Lever Latency counter. \\\\ \\\\ If Timeout, record Type 1 Omission. #R^Nosepoke : IF L <=10 [@TrueRun, @ FalseTimeout] @TrueRun: OFF ^NosePoke; ON ^LLeverLIGHT; SET D(J+3) = L; ADD B(6), E(K+6);Z^Z_LatEnd; Z^Z_LeverLat; Z^Z_CorrectResp ---> S5 @FalseTimeout: OFF ^NosePoke; ADD B(4), E(K+4); SET D(J+1) = 1; Z^Z_Type1 ---> S3 S5, \\\\ If Lever response is made within allotted time, turn off \\\\ the LeverLight, Signal to issue immediate reward. \\\\ If Timeout, record Type 2 Omission. #RA(^CorrectLever): IF M <=10 [@TrueRun, @ FalseTimeout] @TrueRun: ADD B(2), E(K+2); OFF ^LLeverLight; SET D(J+4) = M, N = 1; Z^Z_Sipper;Z^Z_LatEnd; Z^Z_CorrectResp ---> S6 @ FalseTimeout: OFF ^LLeverLight; ADD B(5), E(K+5); SET D(J+1) = 2; Z^Z_Type2 ---> S3 S6, \\\\ Wait for New Trial Signal. Increment trial number. \\\\ Signal start of Nose Poke Latency counter. #Z^Z_NewTrial : ADD K; IF K > A(^TrialsPerBlock) [@NewBlock, @Cont] @New: ADD J; IF J > A(^NumBlocks) [@End, @Cont] @End: ---> S7 @Cont: SET I = I + 6, E(K+5) = -987.987; SET K = 1, D(J+3) = -987.987; ON ^NosePoke; SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4 @Cont: SET D(J+3) = -987.987; ON ^NosePoke; SET D(J) = K; Z^Z_NPLat ---> S4 S7, \\\\ Wait for Screen Update and end with \\\\ STOPABORTFLUSH for Automatic Data Saving 2": ---> STOPABORTFLUSH \\\\*************************************************** \\\\ 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; IF R >= Q [@Done, @Cont] @Done: SET R = 0; Z^Z_SipperEnd ---> S1 @Cont: ---> S3 S3, 2": ON ^Sipper; ADD B(1), D(J+1), E(K+1); Z^Z_Reward ---> S2 \\\\*************************************************** \\\\ 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; ADD I; ADD B(3); 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; 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) > O [] ---> 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 L = 0.01 ---> S2 S2, 0.01": SET L = L + 0.01 ---> SX #Z^Z_LatEnd: ---> S1 \\\\*************************************************** \\\\ LEVER LATENCY COUNTER \\\\*************************************************** S.S.9, \\\\ 10ms Resolution S1, #Z^Z_LeverLat: SET M = 0.01 ---> S2 S2, 0.01": SET M = M + 0.01 ---> SX #Z^Z_LatEnd: ---> S1 \\\\*************************************************** \\\\ UPDATE DISPLAY\\\ \\\\*************************************************** S.S.10, S1, #START: SHOW 1,Tot Rewards,B(1), 2,Tot Type 1,B(4), 3,Tot Type 2,B(5) ---> S2 S2, 1": SHOW 1,Tot Rewards,B(1), 2,Tot Type 1,B(4), 3,Tot Type 2,B(5) ---> S2
Med_Support
ModeratorGary Bamberger
Hi Lauren,
Let’s take a look at the error message:
“constant expression violates subrange bounds” , “$C Fixed Preload Permanent”, “Fatal:Could not compile used unit DF041033625.pas”
Most Pascal error messages are useless. They do not tell you what the problem was with the code. The above error message is one of the few that actually contains some useful information about the problem. Specifically the statement:
Error: Constant expression violates subrange bounds
What this means is that an array was declared with the DIM statement and you are trying to access an array element beyond the declared size.
It looks like you have tried to expand the size of the A Array by adding one element:
^NTITicks = 7 S2, #START: CLEAR 1,60; SET J = 1, K = 1; SET D(J+5) = -987.987, E(K+7) = -987.987; SET A(^NTITicks) = A(^NTI) * 1"; SET A(^ResponseTicks) = A(^ResponseTime) * 1" ---> S3
But the A Array is still set to DIM A = 6. When I expand the size of the A Array:
DIM A = 7
to include the new element the program compiles as expected.
I hope that this information helps.
GaryMed_Support
Moderatormilliel
Hey Gary,
Thanks for your help. I have gone through and made significant changes to the code which I am hopeful will fix the problems I was having however, I’ve now run into PASCAL errors when trying to translate and compile into Med-PC.The errors say “constant expression violates subrange bounds” , “$C Fixed Preload Permanent”, “Fatal:Could not compile used unit DF041033625.pas” but does not give any specific state, state sets, or code lines associated with these errors.
The following is my code in its entirety, if you have any thoughts as to what might be causing these errors your help would be greatly appreciated.
– Lauren
\\After ITI the NosePoke light is turned on. Animal is given 10s to respond with a nose poke. If no response, a Type \\ 1 Omission is recorded. \\If there is a response, then the left lever light is turned on. If there is \\no lever press within 10s, then a Type 2 Omission is recorded. \\\ \\ If the Correct lever is chosen then the lever \\ Light is turned off, and 2s reward is given. With an ITI of 4s \\ before the start of a new trial indicated by the illumination of the NosePoke. \\\\*********************************************************************************************************************************************************** \\\ \\ SoftCR data is saved in Array C in Relative Mode with a 10ms Resolution. \Inputs ^LeftLever = 1 ^RightLever = 2 ^Nosepoke = 4 \Outputs ^LeftLever = 1 ^RightLever = 2 ^Sipper = 3 ^NosePoke = 4 ^LLeverLight = 5 ^RLeverLight = 6 \ A() = Control Variables with Assigned Aliases as Defined Var_Alias Response Time (sec) = A(1) Default = 10 seconds Var_Alias Correct Lever (1=Left) = A(2) Default = 1-Left Var_Alias SoftCR Data Array (1=Yes 0=No) = A(3) Default = 1 Var_Alias Number of Blocks to Run = A(4) Default = 23 Var_Alias Number of Trials per Block = A(5) Default = 4 ^NTI = 0 ^ResponseTime = 1 ^CorrectLever = 2 ^SoftCR = 3 ^NumBlocks = 4 ^TrialsPerBlock = 5 ^ResponseTicks = 6 ^NTITicks = 7 \List Data Variables Here \ B() = Experiment Totals \ B(0) = Not Used \ B(1) = Total Rewards Delivered \ B(2) = Total Correct Lever Responses \ B(3) = Total Successful Trials \ B(4) = Total NosePoke Omissions (Type 1) \ B(5) = Total Lever Omissions (Type 2) \ B(6) = Total NosePokes \ C() = SoftCR Array \ D() = Trial by Trial Data \ D(J) = Trial Number in this Block \ D(J+1) = Omission Type (1, or 2) \ D(J+2) = Trial Completed Successfully (1=Yes, 0=No) \ D(J+3) = Latency to Initial Nose Poke \ D(J+4) = Latency to Lever Press \ E() = Block by Block Data \ E(K) = Block Number \ E(K+1) = Number of Rewards Delivered this Block \ E(K+2) = Number of Correct Lever Responses this Block \ E(K+3) = Number of Successful Trials this Block \ E(K+4) = Number of NosePoke Omissions (Type 1) this Block \ E(K+5) = Number of Lever Omissions (Type 2) this Block \ E(K+6) = Number of NosePokes \ List Working Variables Here \ F = Counter for Nose Poke Level Inputs \ G = Subscript for the SoftCR Array C \ H = Subscript into the Trial Array D \ I = Subscript into the Block Array E \ J = Block Number \ K = Trial Number this Block \ L = Nose Poke Latency Timer \ M = Lever Latency Timer \ N = Number of Rewards to Deliver \ O = Number of Rewards Delivered \ P = Elapsed Time in 0.01 sec increments for SoftCR Data DIM A = 6 DIM B = 7 DIM C = 100000 DIM D = 500000 DIM E = 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_LatEnd = 4 \\\\ Signal End of Latency Counters ^Z_SipperEnd = 5 \\\\ Signal End of Sipper 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 (4s) \\\\ Response Time (10 sec) \\\\ Correct Reward Lever (1-Left) \\\\ Number of Blocks to Run (6) \\\\ Number of Trials per Block (15) \\\\ SoftCR Data Array (1-Yes) \\\\*************************************************** S.S.1, S1, 0.01": SET A(^ResponseTime) = 10", A(^CorrectLever) = 1; SET A(^NumBlocks) = 23, A(^NTI) = 4"; SET A(^TrialsPerBlock) = 4, 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 J = 1, K = 1; SET D(J+5) = -987.987, E(K+7) = -987.987; SET A(^NTITicks) = A(^NTI) * 1"; SET A(^ResponseTicks) = A(^ResponseTime) * 1" ---> S3 1": SHOW 1,New Trial Int,A(^NTI), 2, Response Time,A(^ResponseTime), 3,Correct Lever,A(^CorrectLever); SHOW 4,# of Blocks,A(^NumBlocks), 5,Trials Per Block,A(^TrialsPerBlock), 6,SoftCR Code,A(^SoftCR) ---> SX S3, \\\\ Time Initial ITI. Signal start of Nose Poke Latency counter. #Z^Z_NewTrial: ON ^NosePoke; SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4 S4, \\\\ If NosePoke is made within allotted time, turn off \\\\ the NP Light and turn on lever light \\\\ Signal start of Lever Latency counter. \\\\ \\\\ If Timeout, record Type 1 Omission. #R^Nosepoke : IF L < 10" [@TrueRun, @ FalseTimeout] @TrueRun: OFF ^NosePoke; SET D(J+3) = L; ADD B(6), E(K+6); Z^Z_LeverLat; Z^Z_LatEnd; Z^Z_CorrectResp; ON ^LLeverLIGHT ---> S5 @FalseTimeout: OFF ^NosePoke; ADD B(4), E(K+4); SET D(J+1) = 1, D(J+3) = L; Z^Z_LatEnd; Z^Z_Type1 ---> S5 S5, \\\\ If Lever response is made within allotted time, turn off \\\\ the LeverLight, Signal to issue immediate reward. \\\\ If Timeout, record Type 2 Omission. #RA(^CorrectLever): IF M < 10" [@TrueRun, @ FalseTimeout] @TrueRun: ADD B(2), E(K+2); OFF ^LLeverLight; SET D(J+4) = M, N = 1; Z^Z_Sipper; Z^Z_NPLat; Z^Z_LatEnd; Z^Z_CorrectResp ---> S6 @ FalseTimeout: OFF ^LLeverLight; ADD B(5), E(K+5); SET D(J+1) = 2, D(J+4) = M; Z^Z_LatEnd; Z^Z_Type2 ---> S3 S6, \\\\ Wait for New Trial Signal. Increment trial number. \\\\ Signal start of Nose Poke Latency counter. #Z^Z_NewTrial : ADD K; IF K > A(^TrialsPerBlock) [@NewBlock, @Cont] @New: ADD J; IF J > A(^NumBlocks) [@End, @Cont] @End: ---> S7 @Cont: SET I = I + 6, E(K+5) = -987.987; SET K = 1, D(J+3) = -987.987; ON ^NosePoke; SET E(K) = J, D(J) = K; Z^Z_NPLat ---> S4 @Cont: SET D(J+3) = -987.987; ON ^NosePoke; SET D(J) = K; Z^Z_NPLat ---> S4 S7, \\\\ Wait for Screen Update and end with \\\\ STOPABORTFLUSH for Automatic Data Saving 2": ---> STOPABORTFLUSH \\\\*************************************************** \\\\ 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; IF R >= Q [@Done, @Cont] @Done: SET R = 0; Z^Z_SipperEnd ---> S1 @Cont: ---> S3 S3, 2": ON ^Sipper; ADD B(1), D(J+1), E(K+1); Z^Z_Reward ---> S2 \\\\*************************************************** \\\\ 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; 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; 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) > O [] ---> 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 L = 0.01 ---> S2 S2, 0.01": SET L = L + 0.01 ---> SX #Z^Z_LatEnd: ---> S1 \\\\*************************************************** \\\\ LEVER LATENCY COUNTER \\\\*************************************************** S.S.9, \\\\ 10ms Resolution S1, #Z^Z_LeverLat: SET M = 0.01 ---> S2 S2, 0.01": SET M = M + 0.01 ---> SX #Z^Z_LatEnd: ---> S1 \\\\*************************************************** \\\\ UPDATE DISPLAY\\\ \\\\*************************************************** S.S.10, S1, #START: SHOW 1,Tot Rewards,B(1), 6,Tot NosePokes,B(6); SHOW 3,Completed Trials,B(3), 4,Tot Type 1,B(4), 5,Tot Type 2,B(5) ---> S2 S2, 1": SHOW 1,Tot Rewards,B(1), 6,Tot NosePokes,B(6); SHOW 3,Completed Trials,B(3), 4,Tot Type 1,B(4), 5,Tot Type 2,B(5) ---> S2 \\\\*************************************************** \\\\ Time New Trial \\\\*************************************************** S.S.11, S1, #START: ---> S2 S2, A(^NTITicks) #T: Z^Z_NewTrial ---> S2
Med_Support
ModeratorGary Bamberger
Hello,
I don’t think I have enough information to answer your question. You only posted S.S.1 so I don’t know what is going on in the rest of the program. The only thing that I can do is tell you what the State Set you posted will do.
S1, Initializes your variables. —> S2
S2, Waits for the START command, seals the arrays, and converts seconds to MED Ticks. —> S3
S3, Waits for a #Z^Z_NewTrial, turns on Center NP Light, sets E(K) = J and D(J) = K (NOTE: K and J look like they are pulling double duty) —> S4
S4, Waits for a NP. It will wait forever for a NP. L looks like it is used as a timer somewhere.
If L < 1000, turn off Center NP Light, on Left Lever Light, set D(J+3) = O —> S5
If L >= 1000, turn off Center NP Light, add B(4), add E(K+4), set D(J+1) = 1, set D(J+3) = O —> S5
NOTE: Both true and false go to S5
NOTE: The false statement does not turn on the Left Lever LightS5, Waits for a response on the Correct Lever. It will wait forever for a response. M looks like it is used as a timer somewhere.
If M < 1000, turn off Left Lever Light, add B(2), E(K+2), set D(J+6) = M, set N = 1 —> S6
If M >= 1000, turn off Left Lever Light, add B(5), E(K+5), set D(J+1) = 2, set D(J+4) = N —> S3S6, Waits for a #Z^Z_NewTrial, adds K and/or J if new trial block
State looks like it sets up the next trial and/or next block, then turns on Center NP Light —> S4
If Number of Trials and Number of Blocks are finished —> S7S7, Waits 2″ then ends with STOPABORTFLUSH
I don’t know if elsewhere in the program the Center NP Light is turned on or off, but S4 will turn it off no matter when the response happened.
The sipper is controlled somewhere else in the program. I can only see a Z^Z_Sipper in S5 telling the sipper to activate.
I hope that this helps.
GaryMed_Support
Moderatorneur0mancer
Wonderful, this is exactly what we needed.
Thank you so much for your help here.
Med_Support
Moderatorneur0mancer
Hi, this does help to an extent, but I should have clarified: the reward outcome frequency should not be random (as in 5 pellets should be dispensed exactly 6/10 times in 10 trials, 2 pellets exactly 3/10 times, and 1 pellet exactly 1/10 times, etc)…however, the order that the reward outcomes appear in should be randomized. Is this still possible?
Thank you for your help thus far.
Med_Support
ModeratorHello,
The way that I would do it is to create a list with the number of pellets.
LIST Z = 5,5,3,5,3,5,1,3,5,5
When the lever is pressed draw a value from the list randomly and then issue a Z-pulse to start the pellet dispenser.
S5,
#RLever: RANDD R = Z; Z^Reward —> S6The following code can be used to dispense multiple pellets
\ Outputs ^Pellet = 3 \ Z-Pulses Used in this Program ^Z_Reward = 1 \ Z1 = Signal Reinforcement \*************************************************** \ PELLET DISPENSER CONTROL \*************************************************** S.S.2, S1, \ Wait for Reinforcement Signal #Z^Z_Reward: ON ^Pellet; ADD P ---> S2 S2, \ Check if delivered desired Number of Pellets 0.05": OFF ^Pellet; IF P >= R [@Done, @More] @Done: SET P = 0 ---> S1 @More: ---> S3 S3, \ Must wait a certain amount of time before \ trying to dispense the next pellet. This \ delay can be shortened for some Pellet \ Dispensers. 0.5": ON ^Pellet; ADD P ---> S2I hope that this helps.
GaryMed_Support
ModeratorGary Bamberger
So I had a bug in my list statement. It should have been:
LIST Z = 5,5,2,5,2,5,1,2,5,5So the number 5 is listed 6 times, 2 is listed 3 times, and 1 is listed 1 time.
When the lever is pressed we are drawing from the list randomly with the RANDD command.
S5, #RLever: RANDD R = Z; Z^Reward ---> S6I don’t know what number will be drawn, but after it has been drawn the number is removed from the list and can’t be drawn again until every number has been drawn at least once at which point the list is refreshed for the next 10 trials. That is what the RANDD command does.
So for every 10 trials the frequency of 6,3,1 is guaranteed, but the order will be random.
Gary
-
AuthorPosts