Hello,
We are trying to get a rat to run back and forth on a linear track to get rewards. We want to force the animal to travel from one end to the other, and avoid it learning going just outside the ROI and back to get a reward faster.
For example, after the animal has been rewarded in A, only entering the opposite ROI B should trigger a reward. Rewards will be dispensed when TTL pulses are sent to the arduino on different pins.
To this end, we have tried to create a bonsai workflow with two ROIs: one at each end of the linear track. Entering the ROI should trigger 1) a change in a dynamic variable (e.g. SideA and SideB) from 0 to 1 to keep track of the visited ROI and 2) a TTL pulse to an arduino.
We want this change of variable from 0 to 1 to prevent a TTL activation in the previously visited ROI by "blocking" that workflow branch.
Example:
Variables SideA and SideB are initialised to 0 (neither branch visited yet).
The animal goes to ROI A, and gets a reward. SideA= 1 and SideB= 0
Program waits until animal enters ROI B, entering ROI A should not trigger anything.
Animal goes to ROI B, gets a reward, updating to SideA= 0 and SideB= 1.
etc...
We are stuck at trying to update the integer values after each ROI activation and making it loop back around. Maybe there is a more efficient and logical way of doing this ?
We have looked at previously answered question on slightly different tasks, but condition expressions are quite difficult to understand for beginners (and to write!).
Also, Bonsai crashes when we attempt to run our code.
Thank you very much in advance for your help !
