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.1.tar.gz (10.5 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.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for videocutter-2024.12.17.1.tar.gz
Algorithm Hash digest
SHA256 a7f2b02814a52c3f250216ac62ede14a73642a6bf0fd637083429e8ed79196f9
MD5 be5d348a1ec99b5f588726f22abe26bb
BLAKE2b-256 8769ba859db015310d67e812034753ab497a0248825fdc4dc96bf3068de050e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for videocutter-2024.12.17.1.tar.gz:

Publisher: python-publish.yml on TeamNCMC/videocutter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for videocutter-2024.12.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a7f716c7aabac3513d670ee0a022c97f42627ae1495ecd42f63888f397a0016
MD5 5312e08fc00573a1a0d6c1e1b2548df9
BLAKE2b-256 6a8408292efc6f0577299531d46a980625a854f1b5d7e3d706df546a738bd236

See more details on using hashes here.

Provenance

The following attestation bundles were made for videocutter-2024.12.17.1-py3-none-any.whl:

Publisher: python-publish.yml on TeamNCMC/videocutter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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