Skip to content

Display and Save Video from Blackfly Camera, Digital trigger Analog and metadata information saved trought DAQmx or Arduino. Initially designed for neuroscience experiments

License

Notifications You must be signed in to change notification settings

pmgarderes/TrigVideoCapture

Repository files navigation

🧪 TrigVideoCapture Toolbox

This is a Python-based toolbox for high-speed video acquisition with FLIR/Blackfly USB3 cameras using the Spinnaker SDK (PySpin). It supports: Camera live display and aquisition with trigger and metadata information(DAQmx or arduino) A Python-based toolbox using FLIR/Blackfly camera, initially for neuroscience experiments

  • ✅ Real-time video display and recording
  • ✅ Timestamp logging for each frame
  • ✅ Dual analog input support:
    • NI DAQmx (e.g. PCIe-6351)
    • OR Arduino-based serial decoding of trial/stimulus signals
  • ✅ Auto-generated filenames and safe overwrite checks
  • ✅ CSV metadata logging
  • ✅ Optional split-recording (WIP)

🚀 Usage Modes

Mode Input Device Notes
main (default) NI DAQ Reads analog line continuously (e.g. voltage-encoded trial number)
arduino-version Arduino Reads decoded trial/stim values via serial from Arduino Mega 2560

🔌 Feldman lab --- Hardware Connections

Source / Device Destination Notes
Vout (Adafruit MCP4725 DAC) Arduino A0 (analog input) Common GND between DAC and Arduino
TDT Start Signal Arduino digital pin 2 Use a shared ground with the TDT system
Arduino → Camera Trigger Camera Line 3 (green wire on the Hirose 6-pin connector) Connect Line 3 and Camera GND
Arduino USB (Serial) Acquisition Computer (Igor workstation) Check COM port in Device Manager
Camera USB 3.0 Acquisition Computer (same machine running the Python toolbox) Plug directly into a USB 3.0 port for full bandwidth

🧰 Requirements

  • Python 3.10 (conda recommended)
  • FLIR Spinnaker SDK
  • PySpin (installed from SDK) ---- >> SEE BELOW additional instruction
  • installed with requirements:

    • OpenCV
    • numpy
    • tkinter (bundled with Python)
    • For DAQ version: nidaqmx
    • For Arduino version: standard pyserial

📦 Installation

We recommend creating a conda environment : in an anaconda command prompt ( !!! start promtp as administrator on windows !!!), type:

conda create -n TrigVideoCapture python=3.10
conda activate TrigVideoCapture
cd PathToThetoolbox
# recommend installing spinnaker sdk at that moment 
pip install "YOURPATH\spinnaker_python-4.2.0.88-cp310-cp310-win_amd64.whl"
# test installation pf PySpin
python -c "import PySpin; print('PySpin OK')"

pip install -r requirements.txt

🚀 Use

Camera is fully parametrized in Spinnaker SDK GUI (frame rate, exposure time, etc... ) After activation of the environment in the anaconda command prompt :

conda activate TrigVideoCapture
cd PathToThetoolbox

run the file accorindng to your setup

python Display_Record_Arduino_AIO.py

or

python Display_Record_DAQmx_AIO.py

The software will prompt you to choose a folder and filename to save output. A window will open with 20Hz dipslay, and camera video is saved at the set framerate ( set in spinnaker SDK) an additional metadata file is daved along with the video with the same name

to exit the program, simply press "q" with the video display window active emergency stop the program by pressing Ctrl-C in the command bash

About

Display and Save Video from Blackfly Camera, Digital trigger Analog and metadata information saved trought DAQmx or Arduino. Initially designed for neuroscience experiments

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published