Med_Support
Forum Replies Created
-
AuthorPosts
-
Med_Support
ModeratorGary Bamberger
I just ran the program and it works perfectly on my computer. The only unusual thing that I notice is that you have the inputs defined as follows:
^LeftLever = 1 ^RightLever = 4
The RightLever is on input 4. So if you have nothing connected to input 4, then when the program starts you could possibly receive an input immediately and if the RightLever is **not** connected to input 4, then when that lever is pressed nothing will happen.
Gary
Med_Support
Moderatorandersem
That makes sense. I altered that and it is still doing the same thing though. It increases the incorrect lever response by one right when you turn the session on but not when you press the lever.
\This is a Fixed Ratio-1 \Filename, FixedRatio.mpc \Written by Maartje Rijkens \Date March 7, 2005 \ Inputs ^LeftLever = 1 ^RightLever = 4 \ Outputs ^Pellet = 3 ^LeftLight = 4 ^LeftLeverOperate= 1 ^HouseLight = 7 ^Fan = 9 ^RightLight = 5 ^RightLeverOperate = 2 \DEFINED VARIABLES \A = NUMBER OF RESPONSES \B = NUMBER OF REWARDS \E = DATA ARRAY LEFTLEVER \F = DATA ARRAY RIGHTlEVER \G = DATA ARRAY REWARD \M = MINUTES \X = FIXED RATIO \N = SESSION TIMER \Q = MAXIMUM REWARD VAR_ALIAS Fixed ratio = X VAR_ALIAS Maximum reward = Q VAR_ALIAS duration session (min) = M DIM E = 30 DIM F = 30 DIM G = 30 DIM J = 150 S.S.1, \Main control logic for "FR" S1, 0.001": SET X = 3; SET Q = 25; SET M = 60 ---> S2 S2, 0.001": ON ^Fan ---> S3 S3, #START: ON ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight ---> S4 S4, 1#R^LeftLever: OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight; ON ^Pellet; Z1 ---> S5 #Z2:--->S1 S5, 20": ---> S4 #Z2: ---> S1 S.S.2, \This is the state set that contains the response count and display of the active lever S1, #Start: SHOW 2,ACTIVE,A---> S2 S2, 1#R^LeftLever: ADD A; SET E(A) = n ;SHOW 2,ACTIVE,A ---> SX #Z2:--->S1 S.S.3, \ This is the state set that contains the response count and display of the inactive lever S1, #START: SHOW 3,INACTIVE,B ---> S2 S2, #R^RightLever: ADD B; SET F(B) = N; SHOW 3,INACTIVE,B ---> SX #Z2: ---> S1 S.S.4, \ Reward counter and Timer S1, #Z1: ADD C; SET G(C) = N; SHOW 4,REWARD,C ---> S2 S2, 0.001": OFF ^Pellet ---> S3 #Z2: ---> S1 S3, 20": ON ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight ---> S1 #Z2: ---> S1 S.S.5, \Session Timer S1, #START: SHOW 1,Sess_n,N ---> S2 S2, 1.0": ADD N; SHOW 1, Sess_n,N; IF (N/60 >= M) OR (B >= Q) [@True, @False] \As long as session time < M we will continue @True: Z2 ---> S3 @False: ---> SX S3, 19.0": OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight---> STOPABORTFLUSH
Med_Support
ModeratorGary Bamberger
Hi Eden,
The problem is that the variable B is pulling double duty:
S.S.3, \ This is the state set that contains the response count and display of the inactive lever S1, #START: SHOW 3,INACTIVE,B ---> S2 S2, #R^RightLever: ADD B; SET F(B) = N; SHOW 3,INACTIVE,B ---> SX #Z2: ---> S1 S.S.4, \ Reward counter and Timer S1, #Z1: ADD B; SET G(B) = N; SHOW 4,REWARD,B ---> S2 S2, 0.001": OFF ^Pellet ---> S3 #Z2: ---> S1 S3, 20": ON ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight ---> S1 #Z2: ---> S1
You a different variable for one of the counters. It looks like C is not being used.
Gary
Med_Support
Moderatorandersem
Now I have a new issue. I now want the Right inactive lever out as well. I want responses to be recorded on the right lever with no consequence. I cant figure out what is wrong with my coding. I thought a separate state set would do the trick, but the inactive lever counts at each new trial rather than responses on lever. I am having the same issues with my edited PR program. Thanks!
\This is a Fixed Ratio-1 \Filename, FixedRatio.mpc \Written by Maartje Rijkens \Date March 7, 2005 \ Inputs ^LeftLever = 1 ^RightLever = 4 \ Outputs ^Pellet = 3 ^LeftLight = 4 ^LeftLeverOperate= 1 ^HouseLight = 7 ^Fan = 9 ^RightLight = 5 ^RightLeverOperate = 2 \DEFINED VARIABLES \A = NUMBER OF RESPONSES \B = NUMBER OF REWARDS \E = DATA ARRAY LEFTLEVER \F = DATA ARRAY RIGHTlEVER \G = DATA ARRAY REWARD \M = MINUTES \X = FIXED RATIO \N = SESSION TIMER \Q = MAXIMUM REWARD VAR_ALIAS Fixed ratio = X VAR_ALIAS Maximum reward = Q VAR_ALIAS duration session (min) = M DIM E = 30 DIM F = 30 DIM G = 30 DIM J = 150 S.S.1, \Main control logic for "FR" S1, 0.001": SET X = 3; SET Q = 25; SET M = 60 ---> S2 S2, 0.001": ON ^Fan ---> S3 S3, #START: ON ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight ---> S4 S4, 1#R^LeftLever: OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight; ON ^Pellet; Z1 ---> S5 #Z2:--->S1 S5, 20": ---> S4 #Z2: ---> S1 S.S.2, \This is the state set that contains the response count and display of the active lever S1, #Start: SHOW 2,ACTIVE,B ---> S2 S2, 1#R^LeftLever: ADD A; SET E(A) = n ;SHOW 2,ACTIVE,A ---> SX #Z2:--->S1 S.S.3, \This is the state set that contains the response count and display of the inactive lever S1, #Start: SHOW 3,INACTIVE,B ---> S2 S2, #R^RightLever: ADD B; SET F(B) = n; SHOW 3,INACTIVE,B---> SX #Z2:--->S1 S.S.4, \Reward counter and Timer S1, #Z1: ADD B; SET G(B) = n ; SHOW 4,REWARD,B ---> S2 S2, 0.001": OFF ^Pellet ---> S3 #Z2:--->S1 S3, 20.0": ON ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight ---> S1 #Z2:--->S1 S.S.5, \Session Timer S1, #START: SHOW 1,Sess_n,N ---> S2 S2, 1.0": ADD N; SHOW 1, Sess_n,N; IF (N/60 >= M) OR (B >= Q) [@True, @False] \As long as session time < M we will continue @True: Z2 ---> S3 @False: ---> SX S3, 19.0": OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight, ^RightLeverOperate, ^RightLight---> STOPABORTFLUSH
Med_Support
Moderatorbatters27
Thank you
Med_Support
ModeratorPossibly you can find what you are looking for here:
\Experiment 4 simple SDT with flashing stimuli \keeps the time of every event \Michael Davison \Outputs ^LeftWhite=1 \1 = Left (WHITE) ^LeftCenterS1=2 \2 = Left Centre S1 (RED) ^LeftCenterS2=3 \3 = Left Centre S2 (GREEN) ^RightWhite=4 \4 = Right Centre (WHITE) ^Magazine=5 \5 = mag ^MagazineLight=6 \6 = mag light \Inputs ^LeftKeyPeck=1 \1 = Left key peck ^LeftCentreKeyPeck=2 \2 = Left Centre key peck ^RightCentreKeyPeck=3 \3 = Right Centre key peck \4 = Right key, unused \z pulses ^ReinforcerStart=1 ^StartFlasher=2 ^StopFlasher=3 \q array is the settings for conditions \q(0),q(1) not used in this experiment \q(2) = probability of reinforcement for left correct responses (complememt is p. for right correct) \q(3) = Reinforcers per session \q(4) = Magazine duration in seconds \q(5) = blackout time in seconds \q(6) = Inter-trial interval time in seconds \q(7) & q(8) = durations of Red and Green flash times on left-centre key \Condition 1 \list q = 0,10000/30,5000,60,3,10,5,1.2,0.44\ Condition 1 1:1 reinforcer ratio on 08/02/01 \100 sessions per condition, please keep all data on directory in d:\expt4\condx dim c = 5 \overall counts: \c(0) = LeftCorrect|S1 W \c(1) = RightError|S1 X \c(2) = LeftError|S2 Y \c(3) = RightCorrect|S2 Z \c(4) = Left Rfts \c(5) = Right Rfts \detailed data collection into the x array with index t: dim x=5000 \Codes for detailed data collection: ^SessStart=10000 ^Stim1on=20000 ^Stim2on=30000 ^Bw=40000 ^Bx=50000 ^By=60000 ^Bz=70000 ^Rw=80000 ^Rz=90000 ^NRW=100000 ^NRZ=110000 ^ITIStart=120000 ^CKPeck=130000 diskvars = c,q,x s.s.1, s1, #start:set q(4)=q(4)*1",q(5)=q(5)*1",q(6)=q(6)*1",q(7)=q(7)*1",q(8)=q(8)*1"; \ set times to ticks set t=0; \ in itialize index set x(t)=btime/1"+^sessstart;--->s8 s2,\ Set up stimulus 1 #T:withpi=5000[@S1,@s2] @s1:set s=2; \ set trial type s set f=q(7); \ set durations of Red and Green set g=q(8); z^StartFlasher; \ start flasher add t; set x(t)=btime/1"+^Stim1on;--->s3 @s2:set s=3; set f=q(8); set g=q(7); z^StartFlasher; \ start flasher add t; set x(t)=btime/1"+^Stim2on;--->s3 s3,\ Stimulus presentation #R^LeftCentreKeyPeck:z^StopFlasher; \ stop flasher add t; set x(t)=btime/1"+^CKPeck; \ store time of peck off ^LeftCenterS1,^LeftCenterS2; \ turn off flasher lights -- overkill! on ^LeftWhite,^RightWhite;--->s4 \ turn on choice keys s4, \ main routine #R^LeftKeyPeck:off ^LeftWhite,^RightWhite;if s=2[@CorrectLeft,@ErrorLeft] @correctLeft:add c(0); add t; set x(t)=btime/1"+^Bw; \ store time of choice if s.s.2=3[@ReinforcerSetup,@Rnotsetup] @ReinforcerSetup:z^ReinforcerStart; add c(4); on ^Magazine,^MagazineLight; add t; set x(t)=btime/1"+^Rw;--->s5 @RNotSetup:add t; set x(t)=btime/1"+^NRW;--->s5 @errorLeft:add c(2); add t; set x(t)=btime/1"+^By;--->s6 #R^RightCentreKeyPeck:off ^LeftWhite,^RightWhite;if s=3[@CorrectRight,@ErrorRight] @CorrectRight:add c(3); add t; set x(t)=btime/1"+^Bz; if s.s.2=4[@ReinforcerSetup,@RNotSetup] @ReinforcerSetup:z^ReinforcerStart; add c(5); on ^Magazine,^MagazineLight; add t; set x(t)=btime/1"+^Rz;--->s5 @RNotSetup:add t; set x(t)=btime/1"+^NRZ;--->s5 @ErrorRight:add c(1); add t; set x(t)=btime/1"+^Bx;--->s6 s5,\ Reinforcer time q(4) #T:off ^Magazine,^MagazineLight; show 1,W,c(0),2,X,C(1),3,Y,C(2),4,Z,C(3); add t; set x(t)=btime/1"+^ITIStart;--->s7 s6,\ BO Time q(5) #T:show 1,W,c(0),2,X,C(1),3,Y,C(2),4,Z,C(3); add t; set x(t)=btime/1"+^ITIStart;--->s7 s7,\ Inter-trial interval q(6) #T:--->s2 s8,\ Waiting to be sure box has woken up - doug added this 1":--->s2 s.s.2, \scheduling dependent, overall (runs always) s1, #start:--->s2 s2, 1":withpi=q(2)[@SetupLeftReinforcer,@SetupRightReinforcer] @SetupLeftReinforcer:--->s3 @SetupRightReinforcer:--->s4 s3,\ Left rft set up #z^ReinforcerStart:--->s2 s4,\ Right rft set up #z^ReinforcerStart:--->s2 s.s.3, \data collection s1, #start:--->s2 s2, q(3)#z^ReinforcerStart!2500":--->s3 \stop session after q(3) reinforcers or after 2500 seconds s3, q(4) #T:off 1,2,3,4,5;--->stopabortflush s.s.4,\ Flasher s1, #start:--->s2 s2, #z^StartFlasher:on ^LeftCenterS1;--->s3 s3, f#T:off ^LeftCenterS1;on ^LeftCenterS2;--->s4 #z^StopFlasher:off ^LeftCenterS2;--->s2 s4, g#T:off ^LeftCenterS2;on^LeftCenterS1;--->s3 #z^StopFlasher:off ^LeftCenterS1;--->s2
Gary
Med_Support
Moderatordrothfuss
Thanks so much Gary! Works great now and I have a better understanding of how the code works. Very clear answer
September 9, 2014 at 11:25 am in reply to: Trouble with (what should be a simple) FR DD program #12983Med_Support
Moderatorbatters27
Thanks. I’ll have to recheck the wiring!September 9, 2014 at 11:23 am in reply to: Trouble with (what should be a simple) FR DD program #12980Med_Support
ModeratorGary Bamberger
I just ran your program and it seems to be working. A response on the Right Lever turned on the Pellet Feeder and the Right Light for 3s. Responses on either Lever during those 3s were counted, but had no affect. After those 3s another response on the Right Lever turned on the Pellet Feeder and Right Light for 3s again.
Make sure that your Inputs/Outputs are wired up correctly and/or that your MED-PC IV Hardware Configuration file is setup correctly.
Here is how the Inputs/Outputs are defined in your program:
\ Inputs ^LeftLever = 1 ^RightLever = 2 \ Outputs ^LeftLever = 1 ^RightLever = 2 ^Feeder = 3 ^RightLight = 4 ^LeftLight = 5 ^HouseLight = 7
Gary
Med_Support
ModeratorGary Bamberger
So here is the relevant code:
\ Random Light S.S.8, S1, #START: RANDI Q = R; IF P = F(C) / Q [@True, @False] @True: ---> S2 @False: ---> SX S2, 0.01": ON ^RandomLight ---> S3 S3, 0.5": OFF ^RandomLight ---> SX When a START command is issued you draw a value from List R and then check IF P = F(C) / Q. Since the program has just started P = 0 and C = 0 (F(C) = F(0) = 1) so the statement is: IF 0 = 1 / 3 [@True, @False] (I'm assuming 3 was drawn, but it could have been any of the four numbers) This is of course False and causes a transition back to SX or back to State 1. Since we are still in S1 nothing will happen until another START command is received. The first thing is that we need to transition to a different State when the START command is issued. \ Random Light S.S.8, S1, #START: RANDI Q = R ---> S2
Next what is the input criteria that causes us to check if the Random Light needs to turn on? The equation is checking if the number of responses equals the Progressive Ratio divided by a random number. So we could use the response on the Left Lever as the input criteria.
S2, #R^LeftLever: IF P >= F(C) / Q [@True, @False] @True: ---> S3 @False: ---> SX
Notice that I changed the = to >=. IF 1 >= 1 / 3, then the equation will be True, but IF 1 = 1 / 3 will never be True.
One final change is needed. After the Random Light has been flashed we don’t want the Random Light to flash again until the reward has been issued so we need to wait for the reward signal:
S3, 0.01": ON ^RandomLight ---> S4 S4, 0.5": OFF ^RandomLight ---> S5 S5, #Z2: RANDI Q = R ---> S2
Once the reward signal has been received we then want to draw a new value from List R and go back to wait for the next response on the Left Lever. Give it a try and let me know if this works for you. Gary
Med_Support
Moderatorandersem
Works wonders, thanks! Someday I may fully understand how to program.
Eden
Med_Support
ModeratorGary Bamberger
That was close, but I don’t think you want the House Light and Levers coming back on until the end of the Time out. I think this will do what you want.
\*************************************************** \ MAIN PROGRAM \*************************************************** S.S.2, S1, \ Draw first Progressive Ratio from List Z #START: LIST P = Z(X) ---> S2 S2, \ Test for Correct Lever #RA(^CorrectLev): ADD B(0), B(1), R; IF R >= P [@PR_Value_Met, @False] @PR_Met: ADD B(3); SET B(6) = P, R = 0; ZA(^RewardDevice) ---> S3 @False: ---> SX #Z^Z_End: ---> S5 S3, \ Wait for End of Reward Signal #Z^Z_End: ---> S5 #Z^Z_EndReward: ---> S4 S4, \ Time Out Interval Following Reward \ Update Progressive Ratio P from LIST Z A(^TimeOutTicks)#T: ON ^HouseLight, ^LeftLight, ^LeftLever; LIST P = Z(X) ---> S2 #Z^Z_End: ---> S5 S5, \ End of Session - Turn Lights Off \ Calculate % Correct and % Incorrect 0.01": OFF ^HouseLight, ^LeftLight, ^LeftLever; IF B(0) = 0 [@NoCalc, @Calculate] @NoCalc: ---> S6 @Calculate: SET B(4) = B(1) / B(0) * 100; SET B(5) = B(2) / B(0) * 100; SHOW 7,% Correct,B(4), 8,% Incorrect,B(5), 10,Last PR Met,B(6) ---> S6 S6, \ Holding State at End of Session 1': ---> SX \*************************************************** \ REWARD CONTROL TIMER \*************************************************** S.S.3, S1, 60': Z^Z_End ---> STOPABORTFLUSH \ End if no reward received in 60 minutes #Z^Z_Pellet: ON ^Pellet; OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight ---> S2 S2, \ Time Reward Device for A(^RewardTime) seconds \ Default value set in S.S.1, S1 & S2 A(^RewardTicks)#T: OFF ^Pellet; Z^Z_EndReward ---> S1
Gary
Med_Support
Moderatorandersem
Sorry, it didnt look like that in my posted reply, I am attaching the edits. That should work?
Med_Support
Moderatorandersem
So this should work? Thanks!
\***************************************************\ MAIN PROGRAM\***************************************************S.S.2,S1, \ Draw first Progressive Ratio from List Z #START: LIST P = Z(X) ---> S2S2, \ Test for Correct Lever #RA(^CorrectLev): ADD B(0), B(1), R; IF R >= P [@PR_Value_Met, @False] @PR_Met: ADD B(3); SET B(6) = P, R = 0; ZA(^RewardDevice) ---> S3 @False: ---> SX #Z^Z_End: ---> S5S3, \ Wait for End of Reward Signal #Z^Z_End: ---> S5 #Z^Z_EndReward: ---> S4S4, \ Time Out Interval Following Reward \ Update Progressive Ratio P from LIST Z 0.001": ON ^HouseLight, ^LeftLight, ^LeftLever; A(^TimeOutTicks)#T: LIST P = Z(X) ---> S2 #Z^Z_End: ---> S5S5, \ End of Session - Turn Lights Off \ Calculate % Correct and % Incorrect 0.01": OFF ^HouseLight, ^LeftLight, ^LeftLever; IF B(0) = 0 [@NoCalc, @Calculate] @NoCalc: ---> S6 @Calculate: SET B(4) = B(1) / B(0) * 100; SET B(5) = B(2) / B(0) * 100; SHOW 7,% Correct,B(4), 8,% Incorrect,B(5), 10,Last PR Met,B(6) ---> S6S6, \ Holding State at End of Session 1': ---> SX\***************************************************\ REWARD CONTROL TIMER\***************************************************S.S.3,S1, #Z^Z_Pellet: ON ^Pellet; OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight ---> S2 60': Z^Z_End ---> STOPABORTFLUSH \end if no reward received in 60 minutesS2, \ Time Reward Device for A(^RewardTime) seconds \ Default value set in S.S.1, S1 & S2 A(^RewardTicks)#T: OFF ^Pellet
Sorry, it didnt look like that in my posted reply, I am attaching the edits. That should work?
Med_Support
ModeratorGary Bamberger
It looks like you have two timeouts in the program. S.S.3 implements a 20″ Timeout after issuing the reward and then issues a Z^Z_EndReward. S.S.2, S3 waits for that Z^Z_EndReward signal and then does another 20″ Timeout in S4.
You probably want to remove the Timeout in S.S.3 so that you can use the variable Timeout in S.S.2.
Gary
Med_Support
Moderatorandersem
Great, thanks again for your amazing help!
…
I have a new issue with this program. I want the lever, cue and house light to go in or turn off after receiving the reward for the 20 second time out. It seems that this is working as they turn back on 20 seconds after going in. However, the time out during which another pellet can be earned seems longer than 20 seconds since responses immediately after the lever comes back out are not being counted. Any ideas? Thanks, Eden
\ Copyright (c) 2013 MEDState Notation Repository, All rights reserved. \ ProgressiveRatio_v2.mpc \ \ When the program is started it will turn on the HouseLight and the lights over \ both Levers, and the current PR Value will be set to the first value drawn in \ order from List Z. The program will then wait for the Animal to respond on \ the Correct Lever enough times to meet the current PR Value. \ \ When the current PR Value has been met the program will turn on the Reward \ Device for the Reward Time. At the end of the Reward Time the program will \ time the Time Out Following Reward. \ \ When the Time Out Following Reward has been completed the program set the \ current PR Value to the next value drawn in order from List Z. \ \ The program will then once again wait for the Animal to respond on the Correct \ Lever enough times to meet the current PR Value. \ The program will end when the Session Length has been reached. \ Inputs ^LeftLever = 1 \ Outputs ^Pellet = 3 ^LeftLight = 4 ^LeftLeverOperate= 1 ^HouseLight = 7 ^Fan = 9 \ A() = Control Variables with Assigned Aliases as Defined Var_Alias Session Length (min) = A(0) \ Default = 300 minutes Var_Alias Correct Lever (1=Left 2=Right) = A(1) \ Default = 1-Left Var_Alias Reward Device (1=Pellet 2=Dipper 3=Pump) = A(2) \ Default = 1-Pellet Var_Alias Reward Time (sec) = A(3) \ Default = 0.05 seconds Var_Alias Time Out Following Reward (sec) = A(4) \ Default = 20 seconds Var_Alias SoftCR Data Array (1=Yes 0=No) = A(5) \ Default = 1-Yes ^Session = 0 ^CorrectLev = 1 ^RewardDevice = 2 ^RewardTime = 3 ^TimeOut = 4 ^SoftCR = 5 ^RewardTicks = 6 ^TimeOutTicks = 7 \ List Data Variables Here \ B() = Response Counts \ B(0) = Total Responses \ B(1) = Total Correct Response Count \ B(2) = Total Incorrect Response Count \ B(3) = Total Rewards \ B(4) = % Correct \ B(5) = % Incorrect \ B(6) = Last PR Value that was Met \ List Working Variables Here \ I = Subscript for the IRT Array C \ P = Current PR Value \ R = Ratio Response Counter \ S = Elapsed Time in Session \ X = Subscript for Progressive Ratio List Z \ Z() = Progressive Ratio Default List DIM A = 7 DIM B = 6 LIST Z = 1, 2, 4, 6, 9, 12, 15, 20, 25, 32, 40, 50, 62, 77, 95, 118, 145, 178, 219, 268, 328, 402, 492, 603, 737, 901, 1102, 1347, 1646, 2012 \ Z-Pulses Used in this Program ^Z_Pellet = 1 \ Signal Pellet Reinforcement ^Z_Dipper = 2 \ Signal Dipper Reinforcement ^Z_Pump = 3 \ Signal Pump Reinforcement ^Z_EndReward = 4 \ Signal End of Reward ^Z_End = 32 \ Signal End of Session \*************************************************** \ Progressive Ratio Schedule \ S1 - Set Default Values \ Session Length (60 minutes) \ Correct Lever (1-Left) \ Reward Device (1-Pellet) \ Reward Time (0.05 seconds) \ Time Out Following Reward (20 seconds) \ SoftCR Data Array (1-Yes) \*************************************************** S.S.1, S1, 0.01": SET A(^Session) = 300, A(^CorrectLev) = 1, A(^RewardDevice) = 1; SET A(^RewardTime) = 0.05, A(^TimeOut) = 20, A(^SoftCR) = 1 ---> S2 S2, 0.001": ON ^fan ---> S3 S3, \ First Statement: Wait for START signal, turn HouseLight ON \ and turn associated stimulus ON. \ \ Second Statement: Update screen display with default values \ for Control Variables. This will show any changes made via \ the "Configure | Change Variables" Window prior to START. #START: CLEAR 1,200; SET A(^RewardTicks) = A(^RewardTime) * 1"; SET A(^TimeOutTicks) = A(^TimeOut) * 1"; ON ^HouseLight, ^LeftLight, ^LeftLever; SHOW 1,Session,S/300 ---> S4 1": SHOW 1,Session Length,A(^Session), 2,Correct Lever,A(^CorrectLev), 3,Reward Device,A(^RewardDevice); SHOW 4,Reward Time,A(^RewardTime), 5,Time Out,A(^TimeOut), 6,SoftCR Code,A(^SoftCR) ---> SX S4, \ Time Session Length 0.01": SET S = S + 0.01; SHOW 1,Session,S/300; IF S/60 >= A(^Session) [@EndSession, @ContinueTiming] @End: Z^Z_End ---> S5 @Cont: ---> SX S5, \ Wait for Screen Update and end with \ STOPABORTFLUSH for Automatic Data Saving 2": ---> STOPABORTFLUSH \*************************************************** \ MAIN PROGRAM \*************************************************** S.S.2, S1, \ Draw first Progressive Ratio from List Z #START: LIST P = Z(X) ---> S2 S2, \ Test for Correct Lever #RA(^CorrectLev): ADD B(0), B(1), R; IF R >= P [@PR_Value_Met, @False] @PR_Met: ADD B(3); SET B(6) = P, R = 0; ZA(^RewardDevice) ---> S3 @False: ---> SX #Z^Z_End: ---> S5 S3, \ Wait for End of Reward Signal #Z^Z_End: ---> S5 #Z^Z_EndReward: ---> S4 S4, \ Time Out Interval Following Reward \ Update Progressive Ratio P from LIST Z A(^TimeOutTicks)#T: LIST P = Z(X) ---> S2 #Z^Z_End: ---> S5 S5, \ End of Session - Turn Lights Off \ Calculate % Correct and % Incorrect 0.01": OFF ^HouseLight, ^LeftLight, ^LeftLever; IF B(0) = 0 [@NoCalc, @Calculate] @NoCalc: ---> S6 @Calculate: SET B(4) = B(1) / B(0) * 100; SET B(5) = B(2) / B(0) * 100; SHOW 7,% Correct,B(4), 8,% Incorrect,B(5), 10,Last PR Met,B(6) ---> S6 S6, \ Holding State at End of Session 1': ---> SX \*************************************************** \ REWARD CONTROL TIMER \*************************************************** S.S.3, S1, #Z^Z_Pellet: ON ^Pellet; OFF ^HouseLight, ^LeftLeverOperate, ^LeftLight ---> S2 60': Z^Z_End ---> STOPABORTFLUSH \end if no reward received in 60 minutes S2, \ Time Reward Device for A(^RewardTime) seconds \ Default value set in S.S.1, S1 & S2 A(^RewardTicks)#T: OFF ^Pellet ---> S3 S3, 20": ON ^HouseLight, ^LeftLeverOperate, ^LeftLight; Z^Z_EndReward ---> S1 \*************************************************** \ UPDATE DISPLAY \*************************************************** S.S.4, S1, #START: SHOW 2,Correct Rsp,B(1), 3,Incorrect Rsp,B(2), 4,Rewards,B(3), 5,PR Value,P ---> S2 S2, 1": SHOW 2,Correct Rsp,B(1), 3,Incorrect Rsp,B(2), 4,Rewards,B(3), 5,PR Value,P ---> S2
Med_Support
ModeratorGary Bamberger
Unfortunately not. There are only 26 letters from A-Z. Each letter can be either a variable or an array. By using arrays you can have up to 1,000,000 data elements.
If that still proves to not be enough, then what I have done in the past is declare two arrays. When one array fills up or a certain amount of time has passed I use the COPYARRAY command (Ex: COPYARRAY C,D,250000). This copies the data from one array to another. I then zero out the original array (Ex: ZEROARRAY C) which allows the program to continue collecting data using the C Array. Remember to reset the index variable. Finally I execute the FLUSH command to save the data in the D Array.
When using this technique make sure to use the DISKVARS command so that only the data that you care about is saved to the disk.
Another technique for condensing variables that I have used is to turn my index variables into an array:
DIM I = 1 SET C(I(0)) = S; ADD I(0); ADD D(I(1)), I(1);
I also like to use Arrays for all of my Var_Alias commands:
DIM A = 5 Var_Alias Session Length (min) = A(0) \ Default = 60 minutes Var_Alias Correct Lever (1=Left 2=Right) = A(1) \ Default = 1-Left Var_Alias Fixed Ratio Value = A(2) \ Default = 1 Var_Alias Reward Device (1=Pellet 2=Dipper 3=Pump) = A(3) \ Default = 1-Pellet Var_Alias Reward Time (sec) = A(4) \ Default = 0.05 seconds Var_Alias Time Out Following Reward (sec) = A(5) \ Default = 0 seconds
I hope that this information helps. If you post your program or email it to me I can possibly give you more specific ways of condensing the variables in your program.
Gary
Med_Support
ModeratorGary Bamberger
It signals to the rest of the program that the experiment is ending.
S.S.4, \Session Timer S1, #START: SHOW 1,Sess_n,N ---> S2 S2, 1.0": ADD N; SHOW 1, Sess_n,N; IF (N/60 >= M) OR (B >= Q) [@True, @False] \As long as session time < M we will continue @True: Z2 ---> S3 @False: ---> SX S3, 19.0": OFF ^House, ^LeftLever---> STOPABORTFLUSHIt’s meant to stop the rest of the program.
Med_Support
Moderatorandersem
What does the #Z2 do?Thanks again for all your help, I really appreciate it.
Med_Support
ModeratorGary Bamberger
Hi Eden,
I think that the same fix can be used for both problems.
S4, 3#R^LeftLever: OFF ^House, ^LeftLever, ^Leftcue; ON ^Reward; Z1 ---> S5 #Z2:--->S1 S5, 20": ---> S4 #Z2: ---> S1
Gary
Med_Support
ModeratorGary Bamberger
You have already set the Session Time to 300 minutes so that will take care of the 5 hour time limit. For the no reward in 60 minutes criteria I believe the following change should do the trick:
\*************************************************** \ REWARD CONTROL TIMER \*************************************************** S.S.3, S1, #Z^Z_Pellet: ON ^Pellet ---> S2 60': Z^Z_End ---> STOPABORTFLUSH \ End if no reward received in 60 minutes S2, \ Time Reward Device for A(^RewardTime) seconds \ Default value set in S.S.1, S1 & S2 A(^RewardTicks)#T: OFF ^Pellet; Z^Z_EndReward ---> S1
I hope that this information helps.
…
I was just noticing that the code in S.S.1, S4 had been modified
S4, \ Time Session Length 0.01": SET S = S + 0.01; SHOW 1,Session,S/300; IF S/300 >= A(^Session) [@EndSession, @ContinueTiming] @End: Z^Z_End ---> S5 @Cont: ---> SXThe value in S is in seconds and the value in A(^Session) is in minutes. You should be dividing S by 60 to convert it into minutes for the comparison to see if the Session Time has been met.
S4, \ Time Session Length 0.01": SET S = S + 0.01; SHOW 1,Session,S/60; IF S/60 >= A(^Session) [@EndSession, @ContinueTiming] @End: Z^Z_End ---> S5 @Cont: ---> SXGary
Med_Support
ModeratorGary Bamberger
Re: MED-PC to Excel
August 18, 2014, 10:15:29 amHello,A PDF copy of the manual is normally installed with the program and you should be able to find a copy in the:
C:\Program Files\MED Associates\MED-PC to Excel
folder. If you have an older version of the program, then possibly a manual was not installed. If this is the case, then you can download one from here:
https://mednr.com/wp-content/uploads/2013/01/DOC-036-SOF-731.pdf
but you need to login into the MED Associates Customer Portal first.
Gary
Med_Support
ModeratorGary Bamberger
Re: Saving data in excel
August 12, 2014, 03:05:58 pmIt sounds like you are using the Annotated Data File (Format 1) for MED-PC IV. By default this puts 5 data elements per line with a row number:0: 5.100 7.100 10.100 5.100 7.100
5: 0.200 12.100 3.100 5.100 5.100When you open this space delimited file in Excel you end up with 5 rows of 5 numbers and are forced to move the numbers around so that you can do your calculation. There are a couple of solutions that you could try to eliminate this problem.
1) Do the calculation in MED-PC IV. This can be done with brute force {(K(0) + K(1) + … + K(24)) / 25} or by adding up the numbers as they are Recorded {SET K(I) = S, Z = Z + S;} and then dividing the value in Z by 25 before the program ends.
2) Use the Stripped with Variable Identification (Format 4). All data ends up in one vertical line. This is a little more difficult to know where the data for your K array starts and stops.
3) Use MED-PC to Excel. This program will read the data file you select and transfer it into Excel for you. If you use a Row Profile, then the data all ends up in one row, but it has labels so that you can easily find the beginning and end of your data. If you use a Table Profile, then you can have it place the data for the K array anywhere you want in the Excel spreadsheet.
I hope that this information helps.
GaryMed_Support
ModeratorGary Bamberger
Hello,
The problem with the program was in S.S.3, S4. When the trial starts one of two things can happen:
1) The animal responds (Z2)
2) The animal fails to respond (Z6)
If the animal fails to respond, then the program gets stuck because it is not looking for the Z6 pulse.A few other things that I noticed:
- You stated that premature responses are supposed to restart the ITI, but the program was not looking for a Z5 pulse in S.S.3, S3.
- S.S.6, S2 was looking for a Z2 pulse and I think that you want it to look for a Z6 pulse.
I have corrected the code below.
Best Regards,
Gary\ Inputs ^LeftPoke = 1 ^RightPoke = 2 \ Outputs ^Pellet = 3 ^LeftLight = 4 ^RightLight = 5 ^Tone = 6 ^HouseLight = 7 ^Clicker = 8 ^Shocker = 9 ^Fan = 10 \ Z-pulses \ Z1 = START 3 sec trial \ Z2 = Restart ITI after response \ Z3 = Turn off dispenser/clicker \ Z4 = START pretrial period \ Z5 = Reset ITI and count premature response \ Z6 = Restart ITI after omission LIST Y = 9.0", 12.0", 15.0", 18.0", 21.0", 24.0" \ Variables \ A = Trials \ B = Responses/Reward \ C = Omissions \ D = All nose pokes \ E = Number of pretrials \ F = Number of premature responses \ M = Minutes \ N = Session timer \ X = Pretrial time array S.S.1, \ main reward logic S1, \ (wait for Z1 pulse) at Z1 move to S2 #Z1: ---> S2 S2, \ DURING 3 SEC TRIAL: at nose poke, turn on dispenser and clicker \ go to S3 (after 3 sec return to S1) #R^LeftPoke: ON ^Pellet, ^Clicker ---> S3 3": Z6 ---> S1 S3, \ after 0.1sec turn off dispenser and clicker, issue Z2 \ move to S1 (only after response) 0.1": OFF ^Pellet, ^Clicker; Z2 ---> S1 S.S.2, \ pretrial and premature response logic S1, \ at Z4 pulse, move to S2 (start pretrial) #Z4: ---> S2 S2, \ at nose poke(premature response), turn off cue light and house light \ issue Z5 pulse (restart ITI) \ return to S1 (OR Z1 pulse ends pretrial, begins trial) #R^LeftPoke: OFF ^HouseLight; Z5 ---> S1 #Z1: ---> S1 S.S.3, \ cue lights S1, \ at START command OR Z5 pulse move to S2; begin 10 sec ITI #START ! #Z5: ---> S2 S2, \ after 10 sec ITI, turn on house light, issue Z4 pulse, move to S3 (begin pretrial) 10": ON ^HouseLight; RANDD X = Y; Z4 ---> S3 S3, \ After random time 9-24 sec end pretrial and begin trial, turn on cue light, issue Z1 pulse move to S4 X#T: ON ^LeftLight; Z1 ---> S4 #Z5: ---> S2 S4, \ turn off cue light after reward delivery; go to S5 \ At Z6 (omission) turn off house and cue lights, go to S2 to for 10 sec ITI #Z2: OFF ^LeftLight ---> S5 #Z6: OFF ^LeftLight, ^HouseLight ---> S2 S5, \ 3 seconds after cue light off, turn off house light, go to S2 for 10 sec ITI 3": OFF ^HouseLight ---> S2 S.S.4, \ trial counter and display S1, #START: SHOW 2,trials,A ---> S2 S2, #Z1: ADD A; SHOW 2,trials,A ---> SX S.S.5, \ response counter and display S1, #START: SHOW 3,responses,B ---> S2 S2, #Z2: ADD B; SHOW 3,responses,B ---> SX S.S.6, \ omission counter and display S1, #START: SHOW 4,omissions,C ---> S2 S2, #Z6: ADD C; SHOW 4,omissions,C ---> SX S.S.7, \ response counter and display S1, #START: SHOW 5,Left nose pokes,D ---> S2 S2, #R^LeftPoke: ADD D; SHOW 5,Left nose pokes,D ---> SX S.S.8, \ pretrial counter and display S1, #START: SHOW 6,pretrials,E ---> S2 S2, #Z4: ADD E; SHOW 6,pretrials,E ---> SX S.S.9, \ premature response counter and display S1, #START: SHOW 7,premature response,F ---> S2 S2, #Z5: ADD F; SHOW 7,premature response,F ---> SX S.S.10, \ session timer S1, \ start session timer @ start command #START: SET M = 40; SHOW 1,Session,N ---> S2 S2, \ increment every second; once minutes = 40 then stop abort 1" : ADD N; SHOW 1,Session,N; IF N/60 >= M [@True, @False] @True: ---> S3 @False: ---> SX S3, 3": ---> STOPABORTFLUSHMed_Support
Moderatorsdesai44
Re: MEDPC2XL
March 09, 2014, 09:58:42 amThank you very much Gary!
Med_Support
ModeratorGary Bamberger
Re: MEDPC2XL
February 25, 2014, 04:59:50 pmThe easiest way to use MPC2XL is with a Row Profile.
* After the MED-PC experiment has finished and the data has been saved start MPC2XL.
* Select the Edit Row Profiles tab and then click on the button that says Create.
* Now browse to the saved data file and select it. MPC2XL will automatically create a profile based on the data that it found in the file.
* Now edit the Column Labels to match the data. The program that was used to create the data should hopefully have a good description of the data that it is saving.
* Once done save the Row Profile with a meaningful name.To transfer the data into Excel:
* Go to the Transfer Data tab and click on the Select button in the Row Transfer section.
* Check the Column Labels check box.
* Open Excel. The transfer will only work if Excel is open to an active spreadsheet.
* Now click on the Transfer button. MPC2XL will automatically transfer the data into Excel.A Table Profile is more powerful and flexible than a Row Profile, but it is also harder to create. I personally learned by looking at existing Table Profiles. I have attached an example to this post. Just rename the file extension from TXT to MTP.
I hope that this information helps.
GaryMed_Support
Moderatorsdesai44
Re: MEDPC2XL
February 24, 2014, 02:15:21 pm
How to use medpc2excel? i tried with the procedure given in manual but when i should select data from my experiment?
regular users please help
thanksMed_Support
ModeratorGary Bamberger
Something like the following might work for you:
S.S.1, S1, #START: ---> S2 S2, #R^LeftLever: SET F = F + 4 ---> SX S.S.2, S1, #START: SET F = 10 ---> S2 S2, 0.01": SET T = T + 0.01; IF T >= F [@FIMet, @NotMet] @FIMet: ---> S3 @NotMet: ---> SX S3, #R^RightLever: ON ^Pellet ---> S4 S4, 0.05": OFF ^Pellet; SET F = 10, T = 0 ---> S2
Med_Support
ModeratorGary Bamberger
The program does extend the retractable levers when the START command is issued, but then they stay extended for the rest of the session.
Gary
Med_Support
Moderatorsdesai44
Hi,
Thanks for the post
do retractable levers get extend/retract any time in this procedure?Med_Support
ModeratorGary Bamberger
In S.S.14 you are looking for a Response on Input 4. No where else in your program do you use this input. Input 3 is being used as the Lever input in S.S.4.
In S.S.15 you are looking for a Response on Input 3, but this is the Lever input. Input 5 is being used as the Magazine input in S.S.5.
Please let me know if this helps solve your problem.
GaryMed_Support
ModeratorGary Bamberger
Re: Matlab to Med-Pc compatibility
August 12, 2013, 11:46:42 amTo my knowledge there is no generic code available for calling commands in Matlab, but I believe that at least one of our customers has done it.
There are two common ways of communicating between programs:
1) Turn on an output in MED-PC and the other program receives that as an input and responds appropriately and vice versa.
2) MED-PC has the ability to call any DLL function. You just need to create a Pascal function header so that MED-PC knows how to call the function. For an example of this look at the ANL926.HED in the C:\MED-PC IV folder. The ANL-926.dll was written in C++, but the function declarations contained in the file are the Pascal equivalents. With the appropriate function declarations MED-PC is now able to call into the DLL.
When using this method be very careful that the functions you are calling do not take too long. If they do, it could interfere with the MED-PC timing and cause things to halt.
Gary
Med_Support
Moderatorjenn_op
Re: ERROR CHECK LOG!
July 24, 2013, 12:32:44 pmthank you

-
AuthorPosts