Pulsegenerator function in standby?

51 views
Skip to first unread message

Andrew Hardaway

unread,
Sep 16, 2023, 12:39:59 PMSep 16
to FEDforum
Hi Lex,

Sending this behalf of my student, Zoe Fokakis, who is using FED3 combined with fiber photometry in the striatum. I think this may be due to the pulsegenerator function not working while there is a pellet in the hopper and device is in standby? We are seeing some events logged on the FED but not in our event interpreter via Bonsai.

many thanks!

Hi Lex,Our lab is working on a project combining FED FR1 training and neurophotometric recording. We are using the ClassicFED3_TTLpulses_30secTO.ino file to record Pellet Retrieval as 0.001 ms pulsewidths, Left Poke as 0.002 ms pulsewidths, and 0.003 ms pulsewidths in a csv file with their timestamps that we can then analyze in conjunction with the photometry signals. In this system, the left poke triggers a pellet dispense and the right poke yields no reward. I have noticed that during the FR1 training there is a time out occurring so that 1) no pokes occurring before the first pellet retrieval are recorded and 2) no pokes between an active poke and pellet retrieval are recorded.For example, if a mouse were to engage with the FED in the sequence L poke, R poke, Pellet retrieval, L poke, L poke, R poke, Pellet retrieval, Right poke, then what would be recorded in Bonsai is timestamps corresponding to "pellet retrieval, L poke, Pellet retrieval, R poke". So essentially, no actions between the poke that initiates a reward and the retrieval of that pellet are recorded, as well as any pokes before the first pellet retrieval.We were wondering if you could assist us in altering the code on the FED so that it does not time out while the pellet is sitting in the hopper, so that all interactions with the FED device are recorded on Bonsai. Thanks in advance for your help.Best,
Zoe Fokakis

Lex Kravitz

unread,
Sep 16, 2023, 1:22:15 PMSep 16
to FEDforum
Hi Andrew and Zoe!  What's likely happening is that once you trigger an active poke FED3 enters the Feed() function and stays there until the Feed() function finishes (until the mouse retrieves the pellet).  If you want additional pulses to be sent while the FED3 is in its Feed() function you will have to add them to the function in the FED3.cpp file.  Check out line 234 for how to send a 1ms pulse, you can copy/paste this line wherever you want in the Feed() function.  Let me know if it's clear what I'm talking about!  -Lex

Andrew Hardaway

unread,
Sep 16, 2023, 1:29:40 PMSep 16
to FEDforum
Great! We will try that. Amazing response time too! Happy saturday all.

Zoe Fokakis

unread,
Oct 22, 2023, 10:59:59 AMOct 22
to FEDforum
Hey Lex,

Thank you for your assistance earlier. I think I may not have been specific in my original message, so I wanted to clarify based on some confusion that Dr. Hardaway and I had when looking at the FED3.cpp to edit. During the Feed() function, the FED is still recording the nose pokes, but we are not getting any TTL pulses sent to the NPM system during this time. Andrew noticed that in the ClassicFED3_TTLpulses_30secTO.ino file, the fed3.pulseGenerator(1, 20, 1) function (ln70) is entered after the fed3.Feed() function (ln69), and in the FED3.cpp file Feed() function there is a function to log pokes internally, but not for the pulse generator to send a TTL to the NPM. So in the FED3.cpp file, within the lines 179-201 (shown in screenshot attached), could we add in the "fed3.pulsegenerator(2, 20,1)" and "fed3.pulsegenerator(3,20,1)" functions from the TTLpulses ino file to achieve this? Or is the BNC (pulse) function from ln 234 of FED3.cpp more appropriate to have the TTL pulse sent?

Thank you,
Zoe and Andrew

On Saturday, September 16, 2023 at 12:22:15 PM UTC-5 lex.k...@gmail.com wrote:
IMG_0722.png

Lex

unread,
Oct 24, 2023, 8:09:08 AMOct 24
to Zoe Fokakis, FEDforum
Hi Zoe!  I understand your issue - I would add these lines to the Feed() function where you want the pulses to be sent, instead of editing the BNC function!  -Lex

--
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/9af11bb7-7e0f-4013-871c-b71638e9e48fn%40googlegroups.com.

Andrew Hardaway

unread,
Oct 25, 2023, 7:19:49 PMOct 25
to Lex, Zoe Fokakis, FEDforum
Hi Lex,

Just checking to see if this is what you had in mind. We need to specify ms pulsewidths for left and right so for left this is what we were going to try in the Feed function in the .cpp file:

//Log pokes while pellet is present
        if (digitalRead(LEFT_POKE) == LOW) {             //If left poke is triggered
          leftPokeTime = millis();
          LeftCount ++;
          leftInterval = 0.0;
          while (digitalRead (LEFT_POKE) == LOW) {}  //Hang here until poke is clear
          leftInterval = (millis()-leftPokeTime);
          UpdateDisplay();
          Event = "LeftWithPellet";
          logdata();
          fed3.pulsegenerator(2, 20,1)
          }

Or will that not work since the pulsegenerator function is specified later and you can't reference functions internally and only in a sketch? Also I'm assuming we will need to add a pulse step for both the under 60 second logging condition and the over 60 second condition?

thank you for helping us sort this out,

Andrew




--
J, Andrew Hardaway
Assistant Professor
Department of Psychiatry & Behavioral Neurobiology
University of Alabama at Birmingham School of Medicine
he/him/his

Lex

unread,
Oct 26, 2023, 3:35:35 PMOct 26
to Andrew Hardaway, Zoe Fokakis, FEDforum
Yes that's what I meant!  You just don't need to reference the fed3 library from within the library.  So like this:

//Log pokes while pellet is present
        if (digitalRead(LEFT_POKE) == LOW) {             //If left poke is triggered
          leftPokeTime = millis();
          LeftCount ++;
          leftInterval = 0.0;
          while (digitalRead (LEFT_POKE) == LOW) {}  //Hang here until poke is clear
          leftInterval = (millis()-leftPokeTime);
          UpdateDisplay();
          Event = "LeftWithPellet";
          logdata();
          pulsegenerator(2, 20,1)
          }

And yup you will need to do this everywhere you want pulses to be sent!

Andrew Hardaway

unread,
Oct 26, 2023, 4:54:28 PMOct 26
to Lex, Zoe Fokakis, FEDforum
Awesome. Thank you so much for confirming. Hopefully more from us soon on the FEDforum for other users wanting to integrate photometry with FEDs.
Reply all
Reply to author
Forward
0 new messages