Debugging code where 2 inputs have different outputs
MEDState Notation Repository › Forums › Coding Help Archive › Debugging code where 2 inputs have different outputs
- This topic has 1 reply, 1 voice, and was last updated 8 years, 9 months ago by
Med_Support.
-
AuthorPosts
-
May 7, 2014 at 4:11 pm #13007
Med_Support
Moderatorlmreynolds
Hi!
I am working on writing some code for operant mouse nose-poke boxes. I have no experience programming before writing this. It is a reaction time task where the mouse has a certain amount of time to respond to a cue light. I am having some problems with debugging. The code compiles fine but does not function completely properly. I wrote an autoshaping program to precede this and it is functioning as expected. In breaking this program down to smaller parts, I have found that the state sets seem to work individually with the exception of the first one. The issue seems to be related to SS1, S2 where I am evaluating 2 inputs (a response or a time out) both with different outputs. I am not sure if there is maybe just a better way to set this up. I have been using the programming manual but it only seems to address multiple inputs if they have the same output.Here is the description of the task:
Each trial starts with a 10 second ITI. Then, there is a pretrial period with a random duration of between 9 – 24 seconds in 3 second increments. Responses during this pretrial period return to the ITI, and are recorded as premature responses. After the pretrial period there is a 3 second trial where the active nose poke hole is illuminated. A response during this 3 second trial results in the delivery of a pellet (with clicker) and the cue light is turned off. The house light remains on for 3 seconds, after which time it is turned off and the 10 second ITI begins. Nose poke holes and house light remain unlit for the duration of the ITI. If the mouse fails to nose poke during the 3 second trial, no food pellet is delivered and the cue illumination and house light are turned off. Each daily session is 40 min long.
And here is my code:
\ outputs ^Pellet_dispenser = 3 ^Left_nose_light = 4 ^Right_nose_light = 5 ^Tone = 6 ^House_light = 7 ^Clicker = 8 ^Shocker = 9 ^Fan = 10 \ inputs ^Left_nose_poke = 1 ^Right_nose_poke = 2 \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) 3.0": Z6 ---> S1 #R^Left_nose_poke: ON^Pellet_dispenser; ON^Clicker ---> S3 S3, \after 0.1sec turn off dispenser and clicker; issue Z2; move to S1 (only after response) 0.1": OFF^Pellet_dispenser; OFF^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^Left_nose_poke: OFF^House_light; 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.0": ON^House_light; 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^Left_nose_light; Z1 ---> S4 S4, \turn off cue light after reward delivery; go to S5 #Z2: OFF^Left_nose_light ---> S5 S5, \ 3 seconds after cue light off, turn off house light, go to S2 for 10 sec ITI 3": OFF^House_light ---> S2 S6, \ At Z6 (omission) turn off house and cue lights; go to S2 to for 10 sec ITI #Z6 : OFF^Left_nose_light; OFF^House_light --->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, #Z2: 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^Left_nose_poke: 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: SHOW 1, Session, N; SET M = 40 ---> 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": ---> STOPABORT
Please let me know what I am missing here! Thank you!!
May 8, 2014 at 9:35 am #13008Med_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": ---> STOPABORTFLUSH -
AuthorPosts
- You must be logged in to reply to this topic.