Skip to content

[ENH] BEP047 - Add audio/video recordings to behavioral experiments - #2231

Open
bendichter wants to merge 70 commits into
masterfrom
audio-video-clean
Open

[ENH] BEP047 - Add audio/video recordings to behavioral experiments#2231
bendichter wants to merge 70 commits into
masterfrom
audio-video-clean

Conversation

@bendichter

@bendichter bendichter commented Oct 25, 2025

Copy link
Copy Markdown
Contributor

Add comprehensive support for audio and video recordings in behavioral
experiments:

- Add audio file extensions (mp3, wav) and video file extensions
  (mp4, mkv, avi) with corresponding _audio and _video suffixes
- Document usage of audio/video recordings in beh directory for
  capturing vocalizations, speech, facial expressions, and body movements
- Add metadata schema for audio/video device information and stream
  properties
- Include privacy warnings about personally identifiable information
  in human subject recordings
- Update behavioral experiments title to remove "with no neural
  recordings" restriction, clarifying data can be stored with or
  without neural recordings
- Add examples for file organization including multi-angle recordings
  and split files
- Define optional entities: task, acquisition, run, recording, split
Comment thread src/schema/objects/metadata.yaml Outdated
Comment thread src/schema/objects/metadata.yaml Outdated
Comment thread src/schema/objects/metadata.yaml Outdated
Comment thread src/modality-specific-files/behavioral-experiments.md Outdated
Comment thread src/modality-specific-files/behavioral-experiments.md Outdated
@yarikoptic yarikoptic changed the title SCHEMA: Add audio video SCHEMA: Add audio video behavioral data support Oct 25, 2025
@yarikoptic yarikoptic added the schema Issues related to the YAML schema representation of the specification. Patch version release. label Oct 25, 2025
…ee macros

- Change section title from 'Behavioral experiments' to 'Behavioral recordings'
- Convert file tree examples to use MACROS___make_filetree_example for consistent rendering
- Address review comments from @yarikoptic in PR #2231
Comment thread src/modality-specific-files/behavioral-experiments.md

@effigies effigies left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this makes sense to me. It would be good to get some feedback from contributors to related BEPs, such as eye-tracking (20), motion (29), stimuli (44) and physio (45). Even if this PR doesn't propose adding this as an associated file to those data types, the potential is there and it's worth getting opinions and identifying potential conflicts.

cc @bids-standard/bep029 @bids-standard/bep044
cc @mszinte @julia-pfarr @oesteban (BEP020)
cc @m-miedema @smoia @SouravKulkarni (?) (BEP045)

Comment thread src/modality-specific-files/behavioral-experiments.md Outdated
Comment thread src/modality-specific-files/behavioral-experiments.md Outdated
Comment thread src/schema/rules/sidecars/beh.yaml Outdated
@effigies effigies changed the title SCHEMA: Add audio video behavioral data support [ENH] Add audio/video recordings to behavioral experiments Oct 28, 2025
@codecov

codecov Bot commented Oct 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.07%. Comparing base (4235ae7) to head (07ca171).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2231   +/-   ##
=======================================
  Coverage   83.07%   83.07%           
=======================================
  Files          22       22           
  Lines        1696     1696           
=======================================
  Hits         1409     1409           
  Misses        287      287           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Chris Markiewicz <markiewicz@stanford.edu>
Comment thread src/modality-specific-files/behavioral-experiments.md
Comment thread src/schema/rules/files/raw/beh.yaml
yarikoptic and others added 3 commits June 3, 2026 12:35
Per PR review discussion on thread r2989972681 (h-mayorquin proposed,
@CodyCBakerPhD raised the image-vs-video tension on r3349547943):
ImagePixelFormat (FFmpeg pix_fmt) deterministically encodes bit depth
for any FFmpeg-readable file, so ImageBitDepth is redundant for video.
However:

- Common PIL modes (L, RGB, RGBA, P, ...) are implicitly 8-bit-per-
  channel and do not encode bit depth in the mode name. Image-domain
  tooling (Pillow, libtiff, PNG library) surfaces bit depth as a
  first-class integer rather than as part of a pix_fmt string.
- For image-only sidecars whose producing tools do not naturally go
  through FFmpeg, ImagePixelFormat may be absent and bit depth is the
  only color-precision field available.
- An integer is more directly discoverable for the typical researcher
  than the FFmpeg pix_fmt naming convention.

Added as OPTIONAL with an explicit "redundant with ImagePixelFormat
when both present; the two MUST agree" note in the description, so the
redundancy is acknowledged rather than hidden.

Co-authored-by: Heberto Mayorquin <h.mayorquin@gmail.com>
Co-authored-by: Cody Baker <CodyCBakerPhD@gmail.com>
Co-Authored-By: Claude Code 2.1.161 / Claude Opus 4.7 <noreply@anthropic.com>
…definitions)

This branch builds off PR #2367 ("Add common media file definitions for
BEP044/BEP047") and layers PR #2231 ("BEP047 - Add audio/video recordings
to behavioral experiments") on top.

Conflict resolutions (preferred #2367's canonical media definitions for all
shared objects, kept #2231's unique behavioral additions):
- extensions.yaml: kept #2367 generic descriptions for mkv/mp3/mp4/ogg/wav/avi;
  dropped #2231 duplicate avi/wav entries.
- suffixes.yaml: kept #2367 generic audio/audiovideo/image/video suffixes;
  dropped #2231 duplicate behavioral-specific versions.
  NOTE: #2367 defines 'video' as video-only (no audio); #2231 had treated
  'video' as possibly containing audio. Resolved in favor of #2367.
- metadata.yaml: dropped #2231 duplicate AudioChannelCount/AudioSampleRate
  (kept #2367's richer versions); retained #2231-only fields (AudioDuration,
  AudioBitDepth, CameraPosition, Duration, FrameRate, Height, Width).
- behavioral-experiments.md: kept #2367's updated examples-page URL.

NOTE: #2231 uses generic metadata names (FrameRate/Width/Height/Duration)
while #2367 uses prefixed names (VideoFrameRate/VideoWidth/...). Both sets
coexist after this merge and should be reconciled by maintainers.

Schema loads cleanly; no duplicate keys remain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bendichter and others added 2 commits June 4, 2026 16:12
Per review on the mediafiles PR: remove redundant generic metadata and
sidecar rules that re-declare what the common media file definitions
(media.yaml / #2367) already provide.

- metadata.yaml: drop Duration, AudioDuration, FrameRate, Height, Width
  (superseded by RecordingDuration, VideoFrameRate, ImageWidth/ImageHeight).
  Keep behavioral-specific Device, AudioBitDepth, CameraPosition.
- rules/sidecars/beh.yaml: drop AudioVideoDuration/AudioStreams/VideoStreams/
  ImageProperties groups (covered by media.yaml's MediaDuration/
  MediaAudioProperties/MediaVideoProperties/MediaImageProperties). Keep only
  behavioral additions (Device/License, AudioBitDepth, CameraPosition) and
  fix the stale 'behimage' suffix -> 'image'.
- behavioral-experiments.md: point sidecar tables at the common media groups
  and update JSON examples to the canonical field names.

Schema loads; behavioral example validates with 0 errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
These are generic media properties usable by any modality that stores
audio, so define them alongside the other common media file definitions:
- flac (.flac) lossless audio extension
- AudioBitDepth metadata, added as an optional field of MediaAudioProperties

Moved here from the BEP047 behavioral PR per review discussion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bendichter and others added 6 commits June 4, 2026 16:21
flac (extension) and AudioBitDepth (metadata) are generic media properties,
now defined in the common media definitions (mediafiles PR, yarikoptic#3).
Remove them from the BEP047 layer and the behavioral AudioBitDepthProperties
sidecar group; AudioBitDepth is now an optional field of MediaAudioProperties.
Device stays here as a behavioral-specific field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add flac extension and AudioBitDepth to common media definitions
@yarikoptic

Copy link
Copy Markdown
Collaborator

A great usecase came from @xiaonansun is video recording of epileptic patients along with EEG or iEEG or other (single units) recording.

@yarikoptic

Copy link
Copy Markdown
Collaborator

and @mvdm 's lab records rodent faces for eye tracking + potential whiskers analysis etc!

bendichter and others added 2 commits July 1, 2026 10:48
Per the July 1 BEP047 discussion, generalize the camera-position field so it
also covers audio recording devices (for example, microphone arrays):

- Rename the `CameraPosition` metadata object to `DevicePosition` and broaden
  its description to any recording device.
- Move it into the `AudioVideoImageDevice` sidecar group so it applies to the
  `audio`, `video`, `audiovideo`, and `image` suffixes, and drop the separate
  `CameraProperties` group.
- Update the behavioral-experiments tables and example sidecar accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	src/schema/objects/extensions.yaml
@bendichter
bendichter force-pushed the audio-video-clean branch from 9418f93 to 07ca171 Compare July 1, 2026 14:58
bendichter added a commit to bendichter/bids-examples that referenced this pull request Jul 1, 2026
The BEP047 metadata field was generalized from `CameraPosition` to
`DevicePosition` (bids-standard/bids-specification#2231) so it applies to
any recording device. Update the example sidecars and README accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bendichter

Copy link
Copy Markdown
Contributor Author

Consolidation update

This PR now carries the complete BEP047 proposal in one place. It combines what were previously three separate PRs:

Both upstream PRs have been closed with pointers here, so #2231 is the single canonical PR to review. The branch has been merged onto current master.

What's included (12 files)

  • src/appendices/media-files.md — shared appendix defining media file naming, accepted formats/codecs, and common stream metadata (duration, audio/video/image properties). Applies to both BEP044 (stimuli) and BEP047 (recordings).
  • src/modality-specific-files/behavioral-experiments.md — the BEP047 behavioral layer: _audio, _video, _audiovideo, and _image recordings in beh/, with the recording/run/split entities and behavioral-specific device metadata.
  • Schema objects/rules (extensions, suffixes, metadata, rules/files/raw/beh, rules/sidecars/{beh,media}) plus the mkdocs/macro plumbing for the metadata tables.

@bendichter

Copy link
Copy Markdown
Contributor Author

bids-standard/bids-examples#523 is up do date with this branch

Comment thread tools/mkdocs_macros_bids/macros.py

@yarikoptic yarikoptic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is in a good shape and would allow also BEP042 to start making use of the metadata fields and macros

@yarikoptic

yarikoptic commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Since this would relate to the software which would use such recordings, I would love to invite @talmo @MMathisLab @niksirbi @roaldarbol as relating to

Please have a look at this PR changes and/or rendered version at https://bids-specification--2231.org.readthedocs.build/en/2231/modality-specific-files/behavioral-experiments.html . It would be great to hear your opinion about the suggested BIDS file naming conventions for audiovideo recordings and metadata to come along in the sidecars.

edit: note -- you are welcome to submit an "official" review of the PR

@niksirbi

Copy link
Copy Markdown

Thanks for tagging me @yarikoptic! I'm quite busy at the moment, but would definitely want to review this. Is there a time horizon / deadline for the review period?

@roaldarbol

Copy link
Copy Markdown

Currently on holidays, I'll have a look in early August. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BEP for audio/video capture of behaving subjects