lickometer
MEDState Notation Repository › Forums › Coding Help Archive › lickometer
- This topic has 6 replies, 1 voice, and was last updated 8 years, 9 months ago by
Med_Support.
-
AuthorPosts
-
March 26, 2015 at 5:42 am #12514
Med_Support
ModeratorFlienard
Hi, everyone,
I am tying to measure number of licks, time of licks and time between licks by IRT but it doe not work.
I’ve attached the program I use. Someone could help me please to found what is wrong?Thank
Fabienne
March 26, 2015 at 2:58 pm #12516Med_Support
ModeratorJim Frei
Hi Fabienne,
This code should do what you want or get you started at least:
\Inputs ^rightLick = 1 ^leftLick = 2 \Control variables VAR_ALIAS Session Timer (sec) = A(0) \Default = 600 VAR_ALIAS Bin Timer (sec) = A(1) \Default = 60 ^sessionTimer = 0 ^binTimer = 1 \Data variables \B(E) = Right licks/bin \C(E) = Left licks/bin \D(F) = Time of each right lick \G(H) = Time of each left lick \I(J) = Array of ITR times DIM A = 1 DIM B = 100 DIM C = 100 DIM D = 10000 DIM G = 10000 DIM I = 10000 \Working variables \E = Bin number \F = Total right licks \H = Total left licks \J = I() index \R = IRT timer \S = Session timer \T = Bin timer \Z-Pulses \Z1 = Start program \Z2 = End program \********************************************* \ Initialize values \********************************************* S.S.1, S1, 0.001": SET A(^sessionTimer) = 600, A(^binTimer) = 60; SET E = 1, J = 1; SET B(E+1) = -987.987, C(E+1) = -987.987; SET D(F+1) = -987.987; SET G(H+1) = -987.987; SET I(J) = -987.987 ---> S2 S2, #START: Z1 ---> SX \******************************************** \ Session timer \******************************************** S.S.2, S1, #Z1: ---> S2 S2, 0.01": SET S = S + 0.01; SHOW 1, Session Timer, S; IF S >= A(^sessionTimer) [@T, @F] @T: Z2 ---> S1 @F: ---> SX \********************************************** \ Bin timer \********************************************** S.S.3, S1, #Z1: ---> S2 S2, 0.01": SET T = T + 0.01; SHOW 6, Bin Timer, T; IF T >= A(^binTimer) [@T, @F] @T: ADD E; SET T = 0; SET B(E) = 0, C(E) = 0; SET B(E+1) = -987.987, C(E+1) = -987.987---> S2 @F: ---> SX \********************************************* \ Record licks & IRT timer \********************************************* S.S.4, S1, #Z1: ---> S2 S2, \Record right licks #R^rightLick: ADD F; SET D(F) = S; SET D(F+1) = -987.987; ADD B(E); SET I(J) = R; ADD J; SET I(J) = -987.987; SET R = 0 ---> S2 \Record left licks #R^leftLick: ADD H; SET G(H) = S; SET G(H+1) = -987.987; ADD C(E); SET I(J) = R; ADD J; SET I(J) = -987.987; SET R = 0 ---> S2 0.01": SET R = R + 0.01; SHOW 8, IRT Timer, R ---> SX \****************************************** \ Update the display \******************************************** S.S.31, S1, 0.1": SHOW 2, Total Right Licks, F; SHOW 3, Total Left Licks, H; SHOW 7, Bin Number, E ---> SX \********************************************* \ End program \******************************************** S.S.32, S1, #Z2: ---> S2 S2, 1": ---> STOPABORTFLUSHMarch 27, 2015 at 4:08 am #12518Med_Support
ModeratorFlienard
Hi, Jim
Thank you so much
I will test your program now. And sure it will help me;
Thank you again
Fabienne…
Hi Jim,
We are using ENV-251L with photobeam sensor, I wonder if I should use beambreak code?Fabienne
March 30, 2015 at 8:16 am #12520Med_Support
ModeratorJim Frei
Hi Fabienne,
I misunderstood your question, when you said time of licks I thought you meant at what point in time the lick occurs, not how long the animal’s head is in the dispenser. Give me a little bit and I’ll see if I can adjust the code.
Jim
…
Hi Fabienne,
Here’s some sample code on how to time the length of an input. If you need more help let us know.
How to time the length of an input \*************************************************** \ RESPONSE DEFINED - 20ms BREAK, 20ms RELEASE \*************************************************** S.S.2, S1, \ Inputs in Level Mode generate an input "count" on each \ interrupt. With a 10 ms system resolution 2 counts \ will be reached in 20 ms. The Z3 pulse is used to \ signal a completed Response. The second statement \ resets the counter every 20 ms so that a partial \ Response of less than 20 ms will not be counted. #R1: ADD Y; IF Y >= 2 [@Response, @NoResponse] @Response: SET Y = 0; Z3 ---> S2 @NoResponse: ---> SX 0.02": SET Y = 0 ---> S1 S2, \ As long as the input is broken the second statement \ causes a re-entry to this State. This resets the \ internal 20 ms timer so it never times out. When the \ input is released for 20 ms the timer times out and a \ Z4 pulse signals the release. 0.02": Z4 ---> S1 #R1: ---> S2 \*************************************************** \ RESPONSE TIMER \*************************************************** S.S.3, S1, #START: SET Z(I) = -987.987 ---> S2 S2, \ Wait for a signal that the input has been broken. #Z3: SET T = 0 ---> S3 S3, \ Wait for signal that the input has been released. \ Record the length of the Response. 0.01": SET T = T + 0.01 ---> S3 #Z4: SET Z(I) = T; ADD I; SET Z(I) = -987.987 ---> S2March 30, 2015 at 9:33 am #12522Med_Support
ModeratorFlienard
Hi Jim,
You are right we need the time when the licks occur. But when I use the program you send us it gives me plenty of values for one lick and the array of irt is plenty of “0” and “0.01”, I do not understand why. This is why I thought the beam break code should ameliorate the result but I do not know if it is correct, if you said that the beam break code is used to measure the time spend by the animal in the dispenser.Fabienne
March 30, 2015 at 9:46 am #12524Med_Support
ModeratorJim Frei
Fabienne see my second post above please.
Jim
March 30, 2015 at 11:23 am #12527Med_Support
ModeratorFlienard
I do not understand why the first program you sent us does not work, do you have any idea?
Fabienne
…
Hi Jim,
Your first program works well now. Our Superport input settings JP3 and JP4 were placed on the level mode. I have changed for the transition mode and it works well now.Fabienne
-
AuthorPosts
- You must be logged in to reply to this topic.