Fixed ratio inappropriately counts nose pokes towards following pellet drop

60 views
Skip to first unread message

Nachi Kamatkar

unread,
Nov 22, 2022, 12:10:10 PM11/22/22
to FEDforum
Hello all,
We are working with a fixed ratio schedule that involves nose pokes and cued lights/sound. The basic protocol is thus: 
1) fixed ratio 3 schedule
2) cued lights and sound go off
3) 5 second delay
4) pellet drops

I would like the FED, however, to not count nose pokes during the cues and until after the retrieval. This timeout period is important so the animal learns that it requires exactly 3 pokes (when the cues go off) and a timeout of 5 seconds for the subsequent pellet drop. However, it seems that if the animal continues to nose poke during the timeout period, they are counted towards the next pellet drop in the fixed ratio schedule (FR = 3). For example, say the animal pokes 3 times for the first pellet, and the animal continues to nose poke an additional 2 (5 times total) prior to the first pellet drop, then it only requires to nose poke one more time for the second pellet instead of an additional 3 times. How do I prevent registration of the nose pokes to being counted for the following pellet drop? That is, have the entire system go in a proper timeout until after the pellet retrieval?

Thanks so much!

Best,
Nachi


#include <FED3.h>                                     //Include the FED3 library
String sketch = "FRCustom";                           //Unique identifier text for each sketch
FED3 fed3 (sketch);                                   //Start the FED3 object
int Delay_start = 1;                              //delay start

void setup() {
  fed3.begin();                                       //Setup the FED3 hardware
  fed3.Timeout (Delay_start);                         //(overnight) delay before task begins
  fed3.FR = FR;                                       //Share the FR ratio with the fed3 library so it is logged on the SD card and displayed on the screen
  if (LeftActive == false) {
    fed3.activePoke = 0;                              //update the activepoke variable in the FED3 library for logging and display. This defaults to 1, so only set to 0 if LeftActive == false
  }
}
void loop() {
 
  fed3.run();                                         //Call fed.run at least once per loop
  // If Left poke is triggered
  if (fed3.Left) {
    fed3.logLeftPoke();                               //Log left poke
    if (LeftActive == true) {
      if (fed3.LeftCount % FR == 0) {                 //if fixed ratio is  met
        fed3.Feed();                                  //deliver pellet    
      }
    }
  }

  // If Right poke is triggered
 
  if (fed3.Right) {
    fed3.logRightPoke();                              //Log Right poke
    if (LeftActive == false) {
      if (fed3.RightCount % FR == 0) {                //if fixed ratio is  met
        fed3.Tone(4000, 1000);
        fed3.pixelsOn(10, 10, 10, 10);
        fed3.timeout = 1;
        fed3.pixelsOff();
        fed3.timeout = 4;
        fed3.Feed();                                  //deliver pellet
      }
    }
  }
}

Lex Kravitz

unread,
Nov 25, 2022, 10:50:16 PM11/25/22
to FEDforum
Hi Nachi!  The issue here is FED3 counts *all* pokes in the RightCount and LeftCount variables, including pokes during the timeout, pokes during dispensing, and pokes with a pellet in the well.  Your code logic is asking if fed3.RightCount % 3 ==0.  Pokes during the timeout add to your RightCount, and therefore get counted in your FR3 task logic.

There are two solutions:
1) We could stop counting pokes during the Timeout. That can be done by modifying the fed3.Timeout function or by creating a second Timeout function that does not count pokes. This is OK but your task logic will still get tripped up by pokes during dispensing and pokes with a pellet in the well. So this isn't an ideal solution.

2) The other solution is to keep track of the pokes you want separately in two new variables: "NoTimeoutLeftCount" and "NoTimeoutRightCount".  If we then use these new variables in your pellet dispensing logic, ie: fed3.NoTimeoutRightCount %3 == 0 your task logic will work the way you want.  I've made you a modified code (attached) that does this logic.   

One thing to note - FED3 will still display the count for all pokes on the screen (it displays the "RightCount" and "LeftCount" variables), but in the logfile you will be able to distinguish and filter pokes made outside of the Timeout from other pokes because they will be labeled as "Left", " LeftinTimeout", etc.  

Also a minor point, I tested this with the latest FED3 library version 1.16.3, if you are on an old library you may need to update.  Please let me know if it works!   
-Lex
FR3_Nachi.ino
Reply all
Reply to author
Forward
0 new messages