Skip to content

Fix deprecated avifile/addframe API and timeseries_extract_slice returning all zeros#70

Merged
torwager merged 3 commits into
masterfrom
copilot/fix-movie-tools-avifile-deprecation
Jun 26, 2026
Merged

Fix deprecated avifile/addframe API and timeseries_extract_slice returning all zeros#70
torwager merged 3 commits into
masterfrom
copilot/fix-movie-tools-avifile-deprecation

Conversation

Copilot AI commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

movie_tools and movie_of_slice_timeseries used the removed avifile()/addframe() API. timeseries_extract_slice returned all zeros due to double spm_vol remapping and was missing sagittal/coronal implementations entirely.

timeseries_extract_slice.m

  • Replaced broken delegation chain (get_ax_slicespm_volspm_slice_vol) with direct inline extraction using the spm_matrix + spm_slice_vol pattern from the working timeseries4.m
  • Added sagittal and coronal slice extraction (previously referenced but undefined)
  • Removed stale SPM version detection boilerplate

get_ax_slice.m

  • Replaced manual eye(4) + C(3,4) = slice_num with spm_matrix([0 0 slice_num]), consistent with cluster_orthviews.m
  • Use V(i).dim(1:2) per-volume instead of pre-computed V(1).dim(1:2)

movie_of_slice_timeseries.m

  • writeVideo(mov, H) passed a raw axes handle — fixed to writeVideo(mov, getframe(H))
  • mov.Quality was a bare property read (no-op) — fixed to mov.Quality = 75
  • Updated unused add_a_frame helper to match

movie_tools.m

  • Replaced avifile()/addframe() with VideoWriter/open/writeVideo/getframe in the 'avi' branch
% Before
mov = avifile('mymovie.avi', 'Quality', 75, 'Compression', 'None', 'Fps', fps);
mov = addframe(mov, H);

% After
mov = VideoWriter('mymovie.avi');
mov.Quality = 75;
mov.FrameRate = fps;
open(mov);
frame = getframe(H);
writeVideo(mov, frame);
Original prompt

This section details on the original issue you should resolve

<issue_title>movie_tools and movie_of_slice_timeseries calls deprecated avifile() function. timeseries_extract_slice returns all 0s.</issue_title>
<issue_description>movie_tools and movie_of_slice_timeseries are no longer functional because avifile() has been replaced by writeVideo().

timeseries_extract_slice, which is called in movie_of_slice_timeseries, returns all 0s.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: torwager <6262700+torwager@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix movie_tools and movie_of_slice_timeseries for avifile deprecation Fix deprecated avifile/addframe API and timeseries_extract_slice returning all zeros Mar 9, 2026
@torwager torwager marked this pull request as ready for review June 19, 2026 05:28
@torwager

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

# Conflicts:
#	CanlabCore/Data_extraction/timeseries_extract_slice.m
@torwager

Copy link
Copy Markdown
Contributor

Merged current master into this branch to resolve the conflict. The only conflict was in timeseries_extract_slice.m: master had a cosmetic refactor of the spm('Ver') defaults block, but this PR deletes that whole block as part of its rewrite — so I kept this PR's version of the file (master's hunk lived entirely inside the removed block, nothing of it to preserve). The other three files auto-merged.

Heads-up for review (not a conflict): this rewrite drops the spm_defaults() initialization call along with the version switch. That's almost certainly fine in context — callers run with SPM initialized, and spm_vol/spm_slice_vol don't require it — but worth a confirming glance before merge.

Static analysis is clean (only pre-existing preallocation hints in the slice loop).

🤖 Generated with Claude Code

@torwager torwager merged commit d53ea34 into master Jun 26, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

movie_tools and movie_of_slice_timeseries calls deprecated avifile() function. timeseries_extract_slice returns all 0s.

2 participants