Skip to content

Bonsai_Triggered_Recording

Kravitz Lab edited this page Feb 6, 2025 · 5 revisions
  1. Open the "singleTriggeredCamera" workflow, available here. This workflow will monitor a camera, and when a pulse is detected on an Arduino pin it will record a video that starts N seconds before the pulse, and records for M seconds after.

  2. Plug in a USB camera and Arduino via USB. Make sure the Arduino is flashed with "Firmata Standard" code (it's in the Arduino IDE examples).
    image

Also make sure the Digital Input node has the correct port and pin settings for the Arduino
image

  1. Check that the correct camera is selected. This is set by changing the "Index" argument in VideoCaptureDevice, you may see the name of the camera pop up, but if not just try changing the index to 0, 1, or 2 and see which camera shows up.
    image

  2. Open the "Select Many" node and make sure the VideoWriter path is set to where you want to write videos. It is critical to give the file an extension, ie: ".avi", so a full path might be: Yiru\TriggeredSocialVideos\SocialVideo.avi
    image

  3. If you want to set the duration of the video before the pulse change the "Delay" node:
    image

  4. If you want to change the duration of the video after the pulse change the "WindowTrigger" node:
    image

  5. If you open the "Crop" node you can see the live view of the camera, and if you open the "VideoWriter" node when triggered you will see what's being written to the video file (this will start seconds before the pulse)
    image

  6. This script will result in a library of videos, recorded for each pulse:
    image

🧠 Home


πŸ“˜ General Information

EHS and DCM procedures

🐭 Animal policies


πŸ§ͺ Experimental Protocols

Weighing mice and food

βœ‚οΈ Intracranial Surgical Protocols

βœ‚οΈ Other Surgical Protocols

🩸 Blood collection

🍬 Glucose tolerance testing

Intracranial injections

🧬 Biomolecular protocols

Von Frey testing

🧬 Virus Injections

πŸ’‘ Photometry

Acquisition

Analysis

In vivo electrophysiology

πŸ§ͺ Pharmacology

Behavior Chambers

Bonsai workflows

πŸ”¬ Histology

Microscopy


Devices

πŸ› οΈ Arduino

Sippers

Tumble Feeder

Social Door


πŸ“Š Data Analysis

Electrophysiology

Ex Vivo

In Vivo


πŸŽ₯ Imaging

Miniscopes

1P Imaging with Mightex OASIS


🧱 Miscellaneous Tools

Clone this wiki locally