Skip to main content

Split videos around time points.

Project description

videocutter

This script (/scripts/video_cutter.py) is used to cut long recordings containing multiple stimulations into single-stimulation clips.

It uses the video file and a corresponding stimulation trace stored as a text (Labscribe) or binary file (Bonsai)

The script processes all videos found in the input directory that have a txt/csv/bin file with the same name. The latter is read to determine the stimulation onsets. Extracted clips are created in {video-name}-cropped subfolder and are numbered from 0 to the number of stimulations found in the stimulation file.

The stimulation trace files can either be :

  • A text/CSV file with two columns, the first one being the time and the second the voltage.
  • A binary file saved with Bonsai, with three columns, the first one being the time steps, the second one being the blue laser voltage and the third one the orange laser voltage.

Install

Within a virtual environment with Python 3.12, install with pip from the terminal :

pip install videocutter

Usage

As a command line interface (CLI)

From a terminal within the virtual environment in which you installed videocutter, you can check the default values with :

videocutter --help

Then, use it like so :

  1. With text files, with all default values
videocutter /path/to/your/videos
  1. With Bonsai files, extract blue laser and use all default values
videocutter /path/to/your/videos blue
  1. With text files, changing the time before and after onset :
videocutter /path/to/your/videos --time-before 1 --time-after 2
  1. With binary files, extract another laser color and change video files extension :
videocutter /path/to/your/videos orange --video-ext avi

From a Python script

Copy the example from examples/cut_videos.py, fill in the parameters and run the script.

Notes

  • The format of txt files exported from Labscribe depends on its version... Sometimes the values are separated by commas (,), sometimes tabulations. To be sure, open the file with a text editor and see if there are "," or big spaces between values on a row. Edit the SEP parameter accordingly in the example script or with the --sep argument in the CLI.
  • Again with Labscribe, it's unclear when or which versions creates a header to this text file (names for each columns). The two should work : if there are non-numeric values on the first line of the file, it will be considered as a header and discarded.
  • If the stimulation trace was edited in Labscribe (for example, if you annotated the traces), the exported file might contain a third column and it will most likely not work.

Credits

videocutter has been primarly developed by Guillaume Le Goc in Julien Bouvier's lab at NeuroPSI, with Edwin Gatier's algorithm for trial detection.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

videocutter-2024.12.17.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

videocutter-2024.12.17-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file videocutter-2024.12.17.tar.gz.

File metadata

  • Download URL: videocutter-2024.12.17.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for videocutter-2024.12.17.tar.gz
Algorithm Hash digest
SHA256 5d74e9890513485f4f0c8d68d1d68484515bc75259b8b8063c245b4cc8d7a3d1
MD5 a04f905246f0efece34981437ab515ea
BLAKE2b-256 710f259b6ff71572e878433783560972230c8e101a44427fd66659379b3fdb58

See more details on using hashes here.

File details

Details for the file videocutter-2024.12.17-py3-none-any.whl.

File metadata

File hashes

Hashes for videocutter-2024.12.17-py3-none-any.whl
Algorithm Hash digest
SHA256 f3cd303312af7423ba803019f69c62b18eda0db0cdec7cd80e947a6b5d2ea827
MD5 702665dcd8037b87238072e965f33b63
BLAKE2b-256 15a92f4c5c93e122d7a854917ddb9e52570a1cbcc5757fa0c8069b7bd51bf653

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page