TriggeredAverageMovie(Data, Timepoints, Width, Path, Frame)
% TriggeredAverageMovie creates and saves an AVI movie of data (typically
% 4D) that is an average based on specified timepoints. Therefore, the
% movie is not a single instance (unless length(Timepoints) = 1) of
% activity in the data, but rather average activity within a window of time
% averaged across specific events.
%
% Thus, the functions starts with the given Data that is composed of
% Width X Length X Time (2D image by frame) and based on given timepoints
% (e.g. everytime a stimulus is delivered) it will create an average movie.
% The user specifies the window of time for averaging.
%
%
% INPUT / OUTPUT:
% Data: An M x N x T matrix. The first two dimensions (M x N) represent
% a 2D data image and the third dimensions (T) represents the frame
% (time) for the movie.
% Types: SINGLE, DOUBLE.
%
% Timepoints: A vector that specifies which timepoints to use for the
% center of averaging. The vector contains each time point (a single
% number) to be used and this number represents the actual MATLAB time
% stamp (arbitrary with respect to real time).
% For example, Timepoints = [1, 10, 200] means that the averaged movie will be based on 3
% trials/events that occurred at time points 1, 10 and 200. These are the
% time stamps located in the Data matrix in the third dimesion.
%
% Width: Width is a single number that specifies the window of averaging
% in both directions of time. For example, Width = 100 means that the
% movie will be 201 in length (based on MATLAB units). This is because
% for every trial, 100 points before and 100 points after this event will
% be used as a window.
%
% Path: This is a character string that specifies the path for saving the
% AVI move. For example: Path = 'D:\VSDI\Analysis\Videos\Test.avi';
% The Path variable MUST end in .avi to specify that this is a movie.
%
% Frame: This a single number that specifies the frame rate to be used
% for creating the movie. Frame = 5 means that the frame rate will be 5
% frames per second in the final movie.
%
% AVG: This is the output matrix that the movie is created from. This is
% an M x N x T matrix with the first two dimensions representing the 2D
% data (M x N) and the third dimension (T) representing the averaged data
% of the length Width*2+1.
%
% NOTES:
% NAN values not allowed. Replace NANs with zeros for missing data.
%
% Note that the averaged movie will have the trigger points located in the
% middle of the movie. For each Timepoint, the Width slides backwards and
% forwards in time and thus the trigger point is exactly in the middle.
%
%
%
% Author: Anastasia Greenberg (C) 2017
%
% $License: BSD (use/copy/change/redistribute on own risk, mention the author) $
Cite As
Anastasia Greenberg (2026). TriggeredAverageMovie(Data, Timepoints, Width, Path, Frame) (https://www.mathworks.com/matlabcentral/fileexchange/64277-triggeredaveragemovie-data-timepoints-width-path-frame), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Image Processing and Computer Vision > Computer Vision Toolbox > Tracking and Motion Estimation > Motion Detection >
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 | added photo to description |
