The ethoscope stores periodic JPEG snapshots of the camera frame in the SQLite database (table IMG_SNAPSHOTS). The script video_from_ethoscope_db.py extracts these snapshots and compiles them into a standard MP4 video, with optional overlay of tracked fly positions.

Location

accessories/databases/video_from_ethoscope_db.py

Dependencies

Basic usage

To create a simple timelapse video from the snapshots stored in a .db file:

python video_from_ethoscope_db.py /path/to/database.db

This will produce an .mp4 file in the same directory as the input database, with each frame annotated with its timestamp.

Overlay tracked positions

Use the --track (or -t) flag to overlay the tracked fly coordinates on each frame. The script cross-references the ROI_* tracking tables with the snapshot timestamps, finding the nearest tracked position for each fly and drawing it as an ellipse:

python video_from_ethoscope_db.py /path/to/database.db --track

The ellipses match the style used in the live tracking view:

How it works

  1. Reads the METADATA table to retrieve the experiment start time
  2. Extracts all JPEG blobs from IMG_SNAPSHOTS with their timestamps