Real_Time_Place_Preference - KravitzLab/KreedLabWiki GitHub Wiki

To get started:

  • Arduino UNO (firmata flashed) to control stimulation device via pin-controlled TTL (laser, LED, auxillary device)
  • Adafruit M0 board if you need to excite light in a certain frequency. You do not need this if you want light being constant ON when the mouse is in the stimulation chamber.
  • Top down camera tracking.
  • Place preference arena with background to segment mouse coat color.
  • Blue laser for ChR2 and green laser for some inhibition experiments, such as inhibition with Arch.
  • Fiber optic rotatory joint patch cables for optogenetics (it can prevent fiber damage from specimen movement in freely moving set up).
  • Computer running Bonsai RTPP script

Experimental execution:

  • Run a 15 minute baseline period with no stimulation applied to either side
  • Run a 30 minute ON period with stimulation applied to a specific side (left, right, arbitrary choice but keep track of the stimulated side)
  • Save files, clean chamber for next mouse.

Script tutorial:

image

  • Connect the camera to PC/laptop

image

  • We first apply a crop to fit the camera's tracking field of view to the dimensions of the arena. If we inspect the crop properties, we can see the dimensions of the cropped field in terms of pixels, the most important field here to check is the width, because we will use that information to determine when stimulation is triggered when the subject is at a specific point in the x/y space. Half of the width of the crop segments the arena symmetrically.

image

  • Adjust the HsvThreshold node to achieve the desired segmentation of your subject for centroid tracking. You can also play with the camera exposure settings and white balance as well.

image image

  • Find contour: set the MinArea to get rid of noisy dots.
  • The LessThanOrEqual node is important in setting when stimulation happens. You can see here it is configured at the half point (in pixels) of the crop x-dimensions (width). LessThanOrEqual configures the stimulation to be activated when the centroid x position is on the left side. You can change this node to GreaterThanOrEqual to flip the stimulation contingency to the right. When wiring up the hardware for triggering your stimulation device through Bonsai, be sure to set the correct COM port and pin based on your hardware wiring.

image image image

  • CsvWrite and VideoWrite: set the file name and where it should be stored.

Tutorials for trigger laser at certain frequency:

  • Flash M0 board with the example code for 20Hz stimulation, 10ms pulse width.
  • Wire the UNO with M0
  • Connect the UNO board to the PC and connect the M0 board to the laser driver.

Potential Issues and tips:

  • Use a sapre mouse to check your setting. You should see the centroid is on the mouse and you can see the DigitalOutput change from 1 to 0 when the mouse crosses the chamber. After this, you can turn on the laer driver to confirm that the laser is ON when the mouse travel to the stimulation chamber.
  • Check the laser power (check relevant paper for proper parameters). BE VERY CAREFUL WITH LASER. NEVER POINT IT TOWARDS SOMETHING REFLECTIVE.

  • If you do not find Firmata in the File - Example code, install Firmata first in the library manager.

  • If you open the Bonsai RTPP scrip and find the script looks like what is shown in the screenshot attached below, you need to install several packages in Manage Packages. Some packages to install: Bonsai.StarterPack; Bonsai.Arduino; Bonsai.Video; Bonsai.Video.Desgin; Bonsai.FFmpeg

Analysis: