Code covered by the BSD License  

Highlights from
Align repeated trials of analog data to a variable event

Be the first to rate this file! 1 Download (last 30 days) File Size: 2.27 KB File ID: #19545

Align repeated trials of analog data to a variable event

by Matthew Nelson

 

11 Apr 2008 (Updated 23 Mar 2009)

Align matrices of repeated trials of analog data to a variable event without a for loop over trials.

| Watch this File

File Information
Description

% function varargout=ADAlignTrials(AlignEv,win,t0,varargin)
%
% Aligns matrices of analog data samples per trial to a given event at
% variables times during the each trial. Handy for digitally sampled
% analog data (which I refer to as AD data) stored in a repeated trial
% structure as often found in behavioral neuroscienc research. This
% doesn't use a big for loop (i.e. a for loop across trials) and so
% should be fairly quick.
%
% Example of how this is called:
% [AlX,AlY]=ADAlignTrials(Saccade,[-300 300],0,EyeX,EyeY);
%
% Where Saccade is a nTr x 1 vector of saccade onset times (in ms) for
% each trial, EyeX and EyeY are nTr x nSampsPerTrial matrices of analog
% eye positions (sampled at 1 kHz) per tial in the X and Y dimensions
% respectively. AlX and AlY will be nTr x 601 matrices of the eye
% position samples in the X and Y dimensions respectively from 300 ms
% before to 300 ms after the saccade onset in every trial, thus aligned
% on the saccade onset. t0 is the common reference time of the first
% sample in the EyeX and EyeY input matrices that Saccade is also
% appropriately referenced to.
%
% The program will align every input AD data matrix in the varargin to
% the same AlignEv each time it is run, so the number of output matrices
% will be the same as the number of input matrices in varargin.
%
% Presently this assumes a sampling rate of 1kHz for the AD data for ease
% of mental math, but allowing for different sampling rates could easily
% be done by scaling the time inputs (win, t0, AlignEv). If the aligned
% time windows go beyond the extent of the input matrices for a given
% trial, the beginning or end of the output for that trial wis padded
% with Nans.
%
% This is written not to accept NaNs in the input for AlignEv.

Acknowledgements
This submission has inspired the following:
SDFConv
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
15 Apr 2008

Added keywords, and made minor code change to remove an M-Lint message

23 Mar 2009

Removed the use of a personalized function isbetween that wasn't included with original submission.

Tag Activity for this File
Tag Applied By Date/Time
matrices Matthew Nelson 22 Oct 2008 09:57:18
trial Matthew Nelson 22 Oct 2008 09:57:18
saccade Matthew Nelson 22 Oct 2008 09:57:18
analog Matthew Nelson 22 Oct 2008 09:57:18
eye position Matthew Nelson 22 Oct 2008 09:57:18
align Matthew Nelson 22 Oct 2008 09:57:18
event Matthew Nelson 22 Oct 2008 09:57:18
neuroscience Matthew Nelson 22 Oct 2008 09:57:18
psyc Matthew Nelson 22 Oct 2008 09:57:18

Contact us at files@mathworks.com