Pellet Well checking modification

127 views
Skip to first unread message

Laura Milton

unread,
Apr 4, 2022, 10:33:56 PM4/4/22
to FEDforum
Hey Lex, just updating you on how i've modified our codes to implement your pellet well checking code.

For context, and in relation to the Random Ratio task in the thread below, we have been wanting to be able to determine whether an animal checks the magazine to see if a pellet has been dispensed (which became increasingly important during the unpredictable reward delivery of the RR task).

Lex created a simple code to log pellet checks (i.e. when the IR beam in the magazine breaks without a pellet dispensed) by co-opting the RightPoke log (Foldi_PelletWellTest attached for those that are unaware of it and may be interested in using it). I have tweaked this such that we can now log RightPokes AND “MagChecks” (A Laura lexicon innovation) without each action influencing each other’s counts overall. This version is now compatible with all operant tasks that I have tried.

It involves addition of these lines in the void setup() function:

//Add these two lines to disable sleep and monitor the pellet well from the Arduino script
  fed3.disableSleep();                                  
  pinMode (1, INPUT_PULLUP);


Additionally, for each program in our menu that we want MagChecks to be recorded a third if statement is required (for example here is a FR1 task, my tweak is in red):

//                                                                     Mode 2: Fixed Ratio 1
//

  if (fed3.FEDmode == 1)  {
    fed3.sessiontype = "FR1";    //The text in "sessiontype" will appear on the screen and in the logfile
    if (fed3.Left) {
      fed3.logLeftPoke();                               //Log left poke
      if (fed3.LeftCount % fed3.FR == 0) {              //if fixed ratio is  met
        fed3.ConditionedStimulus();                     //deliver conditioned stimulus (tone and lights)
        fed3.Feed();                                    //deliver pellet
      }
    }
    if (fed3.Right) {                                    //If right poke is triggered
      fed3.logRightPoke();
    }
    if (digitalRead(1) == LOW) {                                   //If magazine break is triggered
      fed3.logRightPoke();                                //Log FAUX right poke
      delay(500);
    }

  }


I have called it a FAUX right poke as i have modified the log right poke function in the accompanying cpp file thus (my tweak is in red):

//log right poke
void FED3::logRightPoke(){
  if (PelletAvailable == false){
    if (digitalRead(1) == LOW){
      Event = "MagCheck";
      logdata();
      Right = false;
      }

    else{
      rightPokeTime = millis();
      RightCount ++;
      rightInterval = 0.0;
      while (digitalRead (RIGHT_POKE) == LOW) {} //Hang here until poke is clear
      rightInterval = (millis()-rightPokeTime);
      UpdateDisplay();
      DisplayRightInt();
      if (rightInterval < minPokeTime) {
        Event = "RightShort";
      }
      else{
        Event = "Right";
      }
      logdata();
      Right = false;
    }
  }
}


This means that if the magazine is broken by the rat/mouse the csv file records a line of data with a timestamp and event reading "MagCheck" without changing the on screen pellet counts (there is no on screen record of the MagCheck, and no automatic count of MagChecks but this is easy enough to do in post processing with Python).

I have attached our menu and cpp file that these were taken from so you can all see them in context, hope this is helpful to others.

Cheers,

Laura Milton
Random_Ratio_Menu_Left_LKM.ino
Foldi_PelletWellTest.ino
FED3_random_LKM.cpp

Lex Kravitz

unread,
Apr 5, 2022, 5:32:17 PM4/5/22
to FEDforum
Thanks for sharing this!  I'm curious - how often are you detecting pellet "checks" between pellets?  I always assumed their noses wouldn't be able to get down that far into the well but it seems like I'm wrong!  Thanks again!

Phillip Baker

unread,
Feb 23, 2023, 4:23:28 PM2/23/23
to FEDforum
Hi Laura,

I was looking to record pellet checks for extinction as well. I added the code to my cpp file and loaded your random ratio code. I was unable to see any MagCheck events in the csv file however while testing. I am somewhat new to this so I may have missed a step but am stumped at this point. Any help would be appreciated.

Thanks!

Reply all
Reply to author
Forward
0 new messages