image thumbnail

TriggeredAverageMov​ie(Data, Timepoints, Width, Path, Frame)

version 1.0.0.0 (3.54 KB) by Anastasia Greenberg
This function creates an AVI movie that is a triggered-average based on specific time points.

21 Downloads

Updated 29 Aug 2017

View License

% 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 (2022). 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
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!