Repository navigation
Conversation
Reading video (.mp4/.avi/.mov) through NDR previously required NANSEN via ndr.reader.imagestack. ndr.reader.video uses only MATLAB's built-in VideoReader and implements the same frame API (numframes, framesize, dimensionorder, datatype, frametimes, readframes, epochclock, t0_t1, getchannelsepoch, metadata) with the YXCZT dimension model. Frame times are VideoReader CurrentTime recorded before each readFrame (correct for variable frame rate), cached per file. Registered in ndr_reader_types.json as "video" (aliases videoreader, mp4, avi, mov). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
| % | ||
| end % ndr.reader.video.video | ||
|
|
||
| function filename = videofile(video_obj, epochstreams) |
| v = VideoReader(video_obj.videofile(epochstreams)); | ||
| end % videoobject() | ||
|
|
||
| function n = numframes(video_obj, epochstreams, epoch_select) |
| sz = [v.Height v.Width C 1 T]; | ||
| end % framesize() | ||
|
|
||
| function order = dimensionorder(video_obj, epochstreams, epoch_select) |
| sz = [v.Height v.Width C 1 T]; | ||
| end % framesize() | ||
|
|
||
| function order = dimensionorder(video_obj, epochstreams, epoch_select) |
| sz = [v.Height v.Width C 1 T]; | ||
| end % framesize() | ||
|
|
||
| function order = dimensionorder(video_obj, epochstreams, epoch_select) |
| frames = ndr.reader.base.selectframeCZ(frames, options.SelectC, options.SelectZ); | ||
| end % readframes() | ||
|
|
||
| function ec = epochclock(video_obj, epochstreams, epoch_select) |
| end | ||
| end % t0_t1() | ||
|
|
||
| function channels = getchannelsepoch(video_obj, epochstreams, epoch_select) |
| end | ||
| end % t0_t1() | ||
|
|
||
| function channels = getchannelsepoch(video_obj, epochstreams, epoch_select) |
| end | ||
| end % t0_t1() | ||
|
|
||
| function channels = getchannelsepoch(video_obj, epochstreams, epoch_select) |
| channels(1).time_channel = []; | ||
| end % getchannelsepoch() | ||
|
|
||
| function m = metadata(video_obj, epochstreams, epoch_select) |
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #140 +/- ##
==========================================
+ Coverage 53.26% 53.71% +0.45%
==========================================
Files 160 161 +1
Lines 9190 9308 +118
==========================================
+ Hits 4895 5000 +105
- Misses 4295 4308 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Until now, the only NDR reader that could open video (
.mp4/.avi/.mov) wasndr.reader.imagestack, and it depends on NANSEN. This PR addsndr.reader.video, which reads video with MATLAB's built-inVideoReaderand nothing else. NDI can then read video throughndi.daq.reader.image.ndr('video')with no extra toolboxes.+ndr/+reader/video.m(subclass ofndr.reader.base). It has the same frame API asimagestack/tiffstack:numframes,framesize,dimensionorder,datatype,frametimes,readframes(includingSelectC/SelectZ),epochclock,t0_t1,getchannelsepochandmetadata.[Y X C Z T]in'YXCZT'order, with Z=1. RGB video gives C=3 and greyscale gives C=1. Both C and the datatype are read from the first decoded frame, so they always match whatreadframesreturns.epochprobemap.ndi) are ignored. The reader raises an error unless exactly one video file remains.dev_local_time.frametimesgives seconds from the start of the file, using VideoReader'sCurrentTimerecorded before eachreadFrame. This is correct for variable-frame-rate files, where(k-1)/FrameRatewould drift. The scan decodes every frame once, so its result is cached for the session, keyed by path, size and modification date.t0_t1is[first frame time, last frame time], the same convention astiffstackandimagestack.NumFrames, or counts frames by decoding if the container does not report a count.read(v, idx), with onereadcall per run of consecutive indices.israster=false; onlyframe_period = 1/FrameRateis filled in.resource/ndr_reader_types.jsonwith typesvideo,videoreader,mp4,avi,mov.tools/tests/+ndr/+unittest/+reader/TestVideo.mwrites 12-frame 24x32 synthetic videos at 4 fps.known_readerslisting, frame times and spacing,t0_t1, random access with a mixed-order subset,SelectC, companion files being ignored, the errors for zero, multiple or bad indices, andmetadata.Test plan
Test codeworkflow (run_tests.yml) green on this PR🤖 Generated with Claude Code
https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
Generated by Claude Code