Skip to main content

WhiskiWrap

WhiskiWrap provides tools for running whisk (the Janelia whisker tracker) more easily and efficiently. It improves on whisk by:

  1. Robust input — it uses your system ffmpeg to read almost any video and to emit simple TIFF stacks that whisk traces reliably.
  2. Speed — it runs many trace processes in parallel on non-overlapping chunks of the video.
  3. Portability / memory — results are collected into HDF5 (or Parquet) files readable from Python or MATLAB, and can be read partially.

The codebase is split into modules: base (core utilities), pipeline (high-level workflows), io (video I/O), and wfile_io / mfile_io (ctypes readers for whisk .whiskers / .measurements files).

Installation

Requirements: Python ≥ 3.10 and ffmpeg on your PATH (ffmpeg -version should run). Windows, Linux and macOS are supported.

whisk is installed automatically as the whisk-janelia dependency — its prebuilt trace/measure/classify binaries (including native Windows .exes) are bundled in the wheel, so no separate whisk install or WHISKPATH setup is needed.

Install with uv (recommended) or pip:

# isolated environment
uv venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
uv pip install -e .            # editable; or: uv pip install .
# plain pip
pip install -e .               # or: pip install whiskiwrap

Verify:

python -c "import WhiskiWrap; print('ok')"

Build tools are only needed if a dependency lacks a wheel for your platform (Debian/Ubuntu: python3-dev build-essential; Fedora: python3-devel gcc; macOS: xcode-select --install; Windows: usually none, since wheels are used).

Quick start

import WhiskiWrap

# Copy the input next to a working directory — many temporary files are created.
input_video = 'test_video2.mp4'
output_file = 'output.hdf5'

# Trace (and optionally measure) in parallel chunks -> combined HDF5.
WhiskiWrap.pipeline_trace(input_video, output_file, n_trace_processes=4)

Read the per-frame summary (tip/follicle/angle/… of every whisker):

import tables, pandas
with tables.open_file(output_file) as fi:
    summary = pandas.DataFrame.from_records(fi.root.summary.read())

For bilateral tracking with measurement per side, use interleaved_split_trace_and_measure(...) (see WhiskiWrap/pipeline.py), which crops each face side, traces in chunks, and writes a per-side Parquet/HDF5 file.

How it works

  1. Split the video into epochs (~100k frames) read into memory one at a time.
  2. For each epoch: split into chunks (~1000 frames, optionally cropped), write each chunk as a TIFF stack, trace chunks with parallel trace instances, then append each chunk's .whiskers results to the output file.
  3. Optionally delete intermediate chunk files.

Key parameters:

  • n_trace_processes — parallel trace instances (≈ number of CPUs).
  • epoch_sz_frames — frames per epoch; as large as memory allows (e.g. 100000).
  • chunk_sz_frames — frames per chunk; ideally epoch_sz_frames / (N * n_trace_processes).
  • measure=True, face='left'|'right' — also run measure for the given face side.

Whisker linking & the learned add-on

whisk identity classification (classify/HMM reclassify) only operates within a chunk. Preserving whisker identity across chunks and across a whole session — so each wid follows the same physical whisker in every frame — is handled by the linking step in wwutils/classifiers/hmm_link.py (link_whiskers_hmm): per-side whisk-HMM reclassify → cross-chunk stitch → outlier filters.

The HMM linker is solid but hits two ceilings that hand-tuned heuristics can't clear: coverage (length/follicle/angle filters drop real, still-visible whiskers) and close-whisker identity (adjacent whiskers swap; they separate cleanly by length, which the position-keyed linker ignores). The learned add-on addresses both:

  • a coverage model — a shipped real-vs-noise classifier (wwutils/classifiers/models/coverage.joblib) that replaces the outlier filters and re-admits dropped detections. Real-vs-noise is universal and the features are scale-free, so it is trained once (on two animals, sc013 + seg04) and applied to any clip. Cross-session held-out AP ≈ 0.999.
  • an identity re-ranker — a per-clip model (no labels needed: bootstrapped from the HMM's own high-confidence runs) that uses length + normalized follicle position to fix close-whisker swaps via a conservative, no-flicker Hungarian re-rank that only overrides the HMM when its margin is large.

Day-to-day use

The add-on ships with the package and is off by default. To enable it, pass --learned to the tracking entry point (whisker_tracking.py in the thigmotaxis repo, or call link_whiskers_hmm(..., coverage_mode="model", identity_mode="bootstrap") directly):

  • Any new clip: add --learned. Zero-shot it already beats the baseline linker (seg04: missing detections 59 → 20, identity accuracy 0.969 → 0.981) — no per-clip setup.
  • An important clip you want pristine: label a few minutes in the GUI, then train a GT-backed identity model for that session — it drives id-switches down hard (seg04 32 → 4). See identity_model.train_identity(out, gt=...).
  • Tip: before labeling/seeking in the GUI, run the clip through a re-encode to an all-intra stream (ffmpeg -i in.mp4 -c:v libx264 -bf 0 -g 1 out.mp4) or trace with --enhance. Raw H.264 with B-frames over-reports the frame count and seeks inaccurately, so overlays can drift by a frame or two.

The add-on is additive and schema-preserving: with the flag off, the linker is byte-identical to before. Coverage is train-once-ship-everywhere; identity is per-session by design.

Requires scikit-learn and joblib (installed automatically as dependencies). The coverage model is bundled in the wheel.

Download files

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

Source Distribution

whiskiwrap-1.2.8.tar.gz (5.7 MB view details)

Uploaded Source

Built Distribution

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

whiskiwrap-1.2.8-py3-none-any.whl (5.7 MB view details)

Uploaded Python 3

File details

Details for the file whiskiwrap-1.2.8.tar.gz.

File metadata

  • Download URL: whiskiwrap-1.2.8.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.16

File hashes

Hashes for whiskiwrap-1.2.8.tar.gz
Algorithm Hash digest
SHA256 70d63fdbdecce928ef68df2753ccb0dbbc1b2d2831c1239cc1c29e9ad9256a0f
MD5 bc66a9ce89255c7ffe7096f879ff445e
BLAKE2b-256 181d04fdcd360a5689344aa689da5310f9e6778cda793af827215ea363dd7e73

See more details on using hashes here.

File details

Details for the file whiskiwrap-1.2.8-py3-none-any.whl.

File metadata

  • Download URL: whiskiwrap-1.2.8-py3-none-any.whl
  • Upload date:
  • Size: 5.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.16

File hashes

Hashes for whiskiwrap-1.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 74b8814fdd6a34b05fe60562393884249bb3378d050518cfc6a523f632460203
MD5 c6797eb6448df71e04b1fb9e7becf5e4
BLAKE2b-256 d140c9e07695f5d8d4f6f18b61e1d975f1d08ed26697e409fd3d257bafbef487

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.9

2 files

This release

1.2.8 This release

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.12

2 files

1.1.11

2 files

1.1.10

2 files

1.1.9

2 files

1.1.8

2 files

1.1.7

2 files

1.1.6

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page