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