Response counting during random interval
MEDState Notation Repository › Forums › Coding Help Archive › Response counting during random interval
- This topic has 5 replies, 1 voice, and was last updated 8 years, 9 months ago by
Med_Support.
-
AuthorPosts
-
July 17, 2017 at 2:09 pm #12615
Med_Support
Moderatortyrsu
Hello!
I am pretty new to this coding language but I have put together this Go/No-Go task where mice are trained to nosepoke in response to an auditory GoCue (pure tone) and withhold nosepoking in response to an auditory NoGo cue (White Noise).
There there are four distinct periods within a trial: ITI; Pre Cue; Cue (either Go or No Go); and Reward.The Pre Cue is meant to be a random interval between 9″ and 24″ – and responses in the final 3″ result in a “Premature Response” outcome, terminating the trial and jumping directly to the ITI.
I am trying to code it to choose a random time from a list (List M) which is a list of times between 6″ and 21″ – during which nosepokes are counted but not rewarded. This is then followed by a second separate 3″ period in which nosepokes terminate the trial and initiate the ITI period.
Does this code register all of the nosepokes (via #R^NosePoke) during the random interval? Or does it start counting nosepokes after the random interval? (NB – this is just the trial logic – the counting and data collection is done in a later S.S.X using the #R and #Z pulses – the whole code is attached for reference)
Thank you very much for your time!
Suszie\*********************************************************** \ 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" [/size]\*********************************************************** \ 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 #R^NosePoke : Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes --> S8 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_ITI ; Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes ; Z^Z_PreCueFail ----> S2 \S2 is the ITI logic 3" : OFF ^Laser ; Z^Z_PreCueSuccess ---> S9 \if not, initiate trial randomisation in S9
July 18, 2017 at 3:08 pm #12611Med_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.
GaryJuly 20, 2017 at 5:54 am #13330Med_Support
Moderatortyrsu
Thank you so much Gary! It is now throwing me this error message:
"ERROR # 5 M#T:--->S7 Offending text: M Attempt to use an array variable without a subscript or undeclared constant"
I have defined List M under the variables – is there somewhere else I need to declare it?
Problem 2:
I’m also really struggling with defining my arrays – I keep getting error messages like:
“Attempt to use a variable as an array without declaration via DIM or LIST”It appears I am not declaring the array variables properly – but unfortunately I can’t find any insight into what I am doing wrong in the programmer’s manual. Is it obvious to you where I am going wrong? (whole program attached)
Background info:
Basically all I need is a second-by-second read out of my Z-pulses and the NosePokes (Input 1) which I have tried to code into the array E(K) (counted in S.S.6,).For convenience I have aso tried to add arrays to calculate trial-by-trial data for nose-pokes in each period and the response outcomes in D(J), as well as an array to collect my totals in B() – (these are both also counted in S.S.6,), and finally an array to collect trial-by-trial data of the latency until first nosepoke and period duration for each of the trial periods (pre-cue, cue, reward, ITI) in array F(G) (collected in S.S.2,).
S.S.1, – Trial logic
S.S.2, – Latency to first response & Period Duration for F(G) data collection
S.S.3, – Increment Time Bin array every 0.2″ for E(K) data collection
S.S.4, – Increment Latency & Duration array at the beginning of every trial for F(G) data collection
S.S.5, – Increment Response/Nosepoke array at the beginning of every trial for D(J) data collection
S.S.6, – Data collection for totals B(), time bin E(K), and trial by trial response D(J) data
S.S.7, – Count and Display Logic
S.S.8, – Session end by MaxTrials logic
S.S.9, – Session end by MaxDuration logicIt may just be that I am making it too complicated – do you think I should just stick to one second-by-second array counting all my nosepokes and Z pulses and then transfer the data to Matlab or somewhere to bin it by trial and time-stamps?
Thank you so much for your time, Gary!
SuszieJuly 21, 2017 at 1:48 pm #13333Med_Support
ModeratorGary Bamberger
Hi Suszie,
I have to apologize. My last post had a bug in the code. Here is the code in question:
S5, \Initiate random time selected from List M (6-21")move on to S6 1" : SET T = T+1; RANDD X = M ---> S6 S6, \Count NosePokes - register both Pre-Cue NosePokesand for total #NosePokes M#T : ---> S7 #R^NosePoke : Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes ---> SX
In S5 we randomly drew a value from LIST M. We now want to use that value which is in the variable X. We need to use X in the timed input statement instead of M:
S6, \Count NosePokes - register both Pre-Cue NosePokesand for total #NosePokes X#T : ---> S7 #R^NosePoke : Z^Z_PreCueNosePoke ; Z^Z_TotalNosePokes ---> SX
There is also a bug in S.S.6, S1:
S1, \ Wait for ITI Cue 0.001" : SET E(K+12) = -987.987 ; SET F(G+11)= -987.987 ; SET D(J+9) = -987.987 ; SET B() = -987.987 ---> SX
There is no subscript in the () for the B array. Since B is only 11 elements long I would just remove it:
S1, \ Wait for ITI Cue 0.001" : SET E(K+12) = -987.987 ; SET F(G+11)= -987.987 ; SET D(J+9) = -987.987 ---> SX
Gary
July 24, 2017 at 3:05 pm #13335Med_Support
Moderatortyrsu
Thanks again Gary! That fixed the random-interval generator!
I’m still getting an error message for my SHOW logic for one particular constant – but there is no difference to any of the other constants so I have no idea what is going wrong! I tried changing the letter in case I double-booked the letter W but it’s still throwing this error message:ERROR # 1
#Z^Z_PreCueFail:ADDN;SHOW3,premature,N ;#Z^Z_GoCorrect:ADDW;SHOW4,gocorrect,W ;#Z^Z_GoFail:ADDP;SHOW5,gofail,P ;#Z^Z_NoGoCorrect:ADDQ;SHOW6,nogocorrect,Q ;#Z^Z_NoGoFail:ADDR;SHOW7,nogofail,R ;#Z^Z_TotalNosePokes:ADDS;SHOW8,totalnosepokes,S —> SX
Offending text: ^Z_GOCORRECT:ADDW
A constant is missing ‘^’ or undeclared constant
Can you see why? (Full code attached for more context)\*********************************************************** \ Count & Display Logic \*********************************************************** S.S.7, \Count and display: four totals of each response type (3-7) and total NosePokes (8) S1, #START : SHOW 3,premature,N ; SHOW 4,gocorrect,W ; SHOW 5,gofail,P ; SHOW 6,nogocorrect,Q ; SHOW 7,nogofail,R ; SHOW 8,totalnosepokes,S ---> S2 S2, #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ; #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ; #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ; #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ; #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ; #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX \*******************************************************************
Another issue: Trial by Trial / Bin by Bin Data collection using arrays:
I’m trying to use the Trial-by-Trial data collection code shared by Dave Hughes ( http://204.15.131.62/mednr/forum/index.php?topic=253.0 (http://204.15.131.62/mednr/forum/index.php?topic=253.0) ) but have been having some trouble with the data output not doing what I thought it would.
I tried to simplify it down for a habituation session just monitoring nosepokes in ~2 second bins over 1 min with the house light on via this code:
\S.S.1, – incrementing K every 2″ for the E(K) time bin array
\S.S.2, – count nosepokes for B (totals), E(K) (time bin) array, and SHOW logic for B
\S.S.3, – control house light and count trials (1 in this case) in B(0)\*********************************************************** \ Inputs ^NosePoke = 1 \ Outputs ^House = 8 \House \*********************************************************** \ Variables \*********************************************************** \Data Variables \B() = Totals \B(0) = Total number of Trials (determined by how many ITIs have been) \B(1) = Total number of NosePokes \E() = Time bin data \E(K) = Not used \E(K+1) = #R^NosePoke \T = time counter for E(K) DIM E = 100 DIM B = 2 \*********************************************************** \ Trial Logic \*********************************************************** S.S.1, S1, \Set array to increment every 2 seconds #START : ---> S2 S2, 1" : ADD T ; IF T >= 2 [@True, @False] @True : SET K = K+2, T = 0 ; SET E(K+2) = -987.987---> SX @False : ---> SX S.S.2, S1, \Show total # nosepokes and count nosepokes into B(1) total \and E(K) second-by-second arrays #START : SHOW 1,nosepokes,B(1) ---> S2 S2, #R^NosePoke : ADD B(1), E(K+1) ; SHOW 1,nosepokes,B(1) ---> SX S.S.3, \count a trial and turn on lights for 10 minutes then turn off and save data S1, #START : ON ^House ; ADD B(0) ---> S2 S2, 1' : OFF ^House ---> STOPABORTFLUSH ********************************************************************
I don’t get any error messages and the B (totals) output is fine, but the data comes out with nothing in the E() output.
Can you see what I am doing wrong?Thank you Gary – I really appreciate your help!
SuszieJuly 24, 2017 at 3:51 pm #13337Med_Support
ModeratorGary Bamberger
Hi Suszie,
Here is the code in question:
S2, #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ; #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ; #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ; #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ; #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ; #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX
The problem is you have multiple inputs, but only one —>
S2, #Z^Z_PreCueFail : ADD N; SHOW 3,premature,N ; ---> SX #Z^Z_GoCorrect : ADD W; SHOW 4,gocorrect,W ; ---> SX #Z^Z_GoFail : ADD P; SHOW 5,gofail,P ; ---> SX #Z^Z_NoGoCorrect : ADD Q; SHOW 6,nogocorrect,Q ; ---> SX #Z^Z_NoGoFail : ADD R; SHOW 7,nogofail,R ; ---> SX #Z^Z_TotalNosePokes : ADD S; SHOW 8,totalnosepokes,S ---> SX
For your trial by trial data you need to zero out the previous array seal when you move it
S.S.1, S1, \Set array to increment every 2 seconds #START : ---> S2 S2, 1" : ADD T ; IF T >= 2 [@True, @False] @True : SET K = K+2, T = 0 ; SET E(K) = 0, E(K+2) = -987.987---> SX @False : ---> SX
If you get no response, then when the program ends it will stop saving data at the first array seal.
If you did get a response, then you would see something like -986.987 or -985.987 because you incremented the value that was already there.I hope that this information helps.
GaryP.S. Please post the MPC file instead of a PDF file. The formatting gets lost when I try to copy the text into Trans.
-
AuthorPosts
- You must be logged in to reply to this topic.