Interval timing tasks

129 views
Skip to first unread message

Lupeng Wang

unread,
Jul 3, 2023, 1:01:07 PM7/3/23
to FEDforum
We are interested in the precision of interval timing in mice, and wondering whether folks in the forum have tried programming the FED3 with interval timing tasks.

In these tasks, behavioral responses of mice (pokes) are reinforced (pellet) at a fixed interval (e.g. 10s) and the precision of the learned interval will be tested in a small fraction of randomly interleaved peak interval (PI) trials, where no reinforcement will be delivered. I would like to use FED3 to perform the task.

Here is the task structure I'm thinking. A simpler version will only have a single interval (e.g. 20s), with just one nose-port being active (e.g. left). A single poke (either left or right) initiate a trial, turning the left LED pixel on, mouse should keep poking on the left. If the mouse poked or its nose remained in the port 20s after LED is on, a pellet will be delivered (along with neopixel/audio ON) and the left LED will be turned off, the trial goes into ITI for 60s (or 3 times of the interval). If no poke in the first 20s, LED will be off at 20s, audio click and trial enters a 3-min timeout (or just ITI). Then 20% trials will be PI trials, similar structure, except that left LED will be on 60s (3X interval) and no pellet will be delivered, trial then enters the ITI.  Poke time and duration in both trial types will be analyzed.

A more elaborated version will be having two interval, each associated with a particular port and randomly interleaved in a session.

I believe FED3 should have every bits to do this, right? Has anyone tried similar things with FED?  I'm not entirely sure how to keep LED on for a fixed time, apparently I should not use timeout, since I need to record all the poking events during the interval. I think ITI I can use timeout, since pokes during ITI are less important. Any suggestion on this will be greatly appreciated.

Lex Kravitz

unread,
Jul 4, 2023, 9:13:37 PM7/4/23
to FEDforum
Hi Lupeng!  I have not heard of anyone developing this task with FED3 but it should definitely be possible.  Have you tried modifying any of the example scripts?  I would start there to get a bit of experience with how to modify the code.  If you get started and post some of your attempts I may be able to help you with more specific questions as they come up.  I am pretty sure FED3 can do this, but it will likely take a bit of trial and error to get it to work! Best, -Lex

Lupeng Wang

unread,
Jul 6, 2023, 12:39:36 PM7/6/23
to FEDforum
Hi Lex,

I just created an example script for the task. the basic backbone is working, a poke is reinforced at a specific interval. But somehow the poketimes are not logged for all poke types. Specifically, leftpokes during timeout do not have poke times, only shows NAN. It is a bit odd. In those cases, the left pokes are active pokes, but right poke during timeout could still have poke time recorded.
Do you have an idea why leftpoke during timeout do not a valid poketime?

I've attached script and related .h and .cpp files (those are defaults, I didn't edit).

thanks! 

FED3.cpp
sketch_jul05a_1.ino
FED3.h

Lex Kravitz

unread,
Jul 7, 2023, 5:07:03 PM7/7/23
to FEDforum
Hi Lupeng,
Thanks for sharing your code.  I see why this is happening!  When the FED3 logs data, it only logs the poketimes for Left pokes if the fed3.Event variable is set to "Left", "LeftShort", "LeftWithPellet", "LeftinTimeout", "LeftDuringDispense".  I notice you're calling the event many other things, but unfortunately the base library is not expecting this and so will not log them.  To correct this for your task you will have to edit the FED3.cpp file to allow your other variables (or get rid of the contingency altogether, the purpose of this was just to print a "NAN' if it was a pellet and not a poke).  Here are the relevant lines (Lines 1166 to 1172 of the FED3.cpp file):

  else if ((Event == "Left") or (Event == "LeftShort") or (Event == "LeftWithPellet") or (Event == "LeftinTimeout") or (Event == "LeftDuringDispense")) {  //
    logfile.println(leftInterval/1000.000); // print left poke timing
  }

  else if ((Event == "Right") or (Event == "RightShort") or (Event == "RightWithPellet") or (Event == "RightinTimeout") or (Event == "RightDuringDispense")) {  //
    logfile.println(rightInterval/1000.000); // print left poke timing
  }

Best,
-Lex

Lupeng Wang

unread,
Jul 10, 2023, 11:40:53 AM7/10/23
to FEDforum
Hi Lex,

Thanks for pointing me to the right direction! The part I still could not figure out is poke time in "LifeinTimeout" still logs as NANs, even though it is the original Event variable. However, "RightinTimeout" can log the poke time just fine. Any insights on that? 

Best,
-Lupeng

Lex Kravitz

unread,
Jul 10, 2023, 1:58:47 PM7/10/23
to FEDforum
Hi again Lupeng, after looking more into this, I think you've found a bug that hasn't been reported before!  

In line 424 of the FED3.cpp file (in the Timeout function) it sets the "Event" variable to be "LeftinTimeOut" (note the capital O in "Out"):
      Event = "LeftinTimeOut";
      logdata();

And in the logging function we ask if the Event is "LeftinTimeout" (note the lowercase "o")!
else if ((Event == "Left") or (Event == "LeftShort") or (Event == "LeftWithPellet") or (Event == "LeftinTimeout") or (Event == "LeftDuringDispense")) {  //
    logfile.println(leftInterval/1000.000); // print left poke timing
  }

I'll fix this in a future library update (I have one on deck that should be released soon.  But in the meantime here's a workaround: can you open the FED3.cpp file in a text editor (Spyder, VSCode, Notepad even will all work) and edit line 424 to be:
      Event = "LeftinTimeout";

And write back if that fixes the logging for these pokes?  Thanks for finding this!  -Lex

Lupeng Wang

unread,
Jul 11, 2023, 9:19:14 AM7/11/23
to FEDforum
Hey Lex,

Yes, it works. After editing line 424, it now can log poke time during LeftinTimeout!

Best,
-Lupeng 

Lex

unread,
Jul 11, 2023, 9:32:32 AM7/11/23
to Lupeng Wang, FEDforum
Thanks for finding this, and for the quick update!  I'll fix this bug in the next library update.

--
You received this message because you are subscribed to the Google Groups "FEDforum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fedforum+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fedforum/95e5bfd1-eb0e-40b8-b953-6dc63d8a398dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages