


UImovieplayer Show a 3-D matrix as an XY-T movie.
UImovieplayer(DATA), for a M x N x P matrix DATA, creates a new figure
and shows the frames DATA(:,:,k), 1 <= k <= P, as a movie.
UImovieplayer(DATA, Fs) specifies the temporal sampling rate of the
frames. This value is used for displaying time and for temporal
filtering on the time-series axes (see below).
UImovieplayer(DATA, Fs, FRAME), where 1 <= FRAME <= P, specifies the
index of the frame to display when the UImovieplayer starts.
Several tools control the resulting movieplayer figure:
The following keystroke commands change frames (all except Pause are
disabled during automatic playback):
'<' Rewind to first frame (frame 1)
',' Rewind by 1 frame (or 'Skip' frames, see above)
' ' (space bar) Pause/unpause automatic playback.
'.' Advance by 1 frame (or 'Skip' frames, see above)
'>' Advance to last frame (frame P)
Right clicking the data invokes a menu with the following commands:
Play Automatic playback (frame 1 -> frame P).
Reverse Automatic playback in reverse (frame P -> frame 1).
Interpolate Toggles interpolated color display.
OpenGL Toggles between the OpenGL and zbuffer renderers.
Params Creates a dialog box to ask for timing parameters:
Skip (default: 1 frms) # frames to advance btw frames.
Slow (default: 0 msec) # msec to pause btw frame advances.
Fs (default: 1 Hz ) temporal sampling rate
Left clicking over the data plots the time-series for the clicked
pixel in the lower axes. Double click on the time-series axes
background to clear them.
Left click and drag the time cursor on the time-series axes to rapidly
move to another part of the recording.
Right-clicking the time-series axes invokes these menu options:
Expand Axes Toggles a zoomed view; see UIsubzoom.
Temporal Diff Temporal differences of time-series data.
Show Legend Toggles legend display.
The colorbar alters the color scale; see UIcolorshift.
H = UImovieplayer(...) returns a handle to the new movieplayer figure.
Technical note:
The interpolation option is disabled when the number of spatial data
points (M x N) exceeds 2500 (since such large movies are rendered
using a technique that does not support interpolation). However, when
M x N is less than 2500, interpolation can be used for spatial data
smoothing. Note that OpenGL and zbuffer interpolate differently; in
general, zbuffer interpolates in the colormap and is thus a more
accurate spatial smoothing. However, OpenGL may be faster on systems
where hardware OpenGL acceleration is available.

0001 function hfig = UImovieplayer(data, Fs, frame) 0002 %UImovieplayer Show a 3-D matrix as an XY-T movie. 0003 % UImovieplayer(DATA), for a M x N x P matrix DATA, creates a new figure 0004 % and shows the frames DATA(:,:,k), 1 <= k <= P, as a movie. 0005 % 0006 % UImovieplayer(DATA, Fs) specifies the temporal sampling rate of the 0007 % frames. This value is used for displaying time and for temporal 0008 % filtering on the time-series axes (see below). 0009 % 0010 % UImovieplayer(DATA, Fs, FRAME), where 1 <= FRAME <= P, specifies the 0011 % index of the frame to display when the UImovieplayer starts. 0012 % 0013 % Several tools control the resulting movieplayer figure: 0014 % 0015 % The following keystroke commands change frames (all except Pause are 0016 % disabled during automatic playback): 0017 % '<' Rewind to first frame (frame 1) 0018 % ',' Rewind by 1 frame (or 'Skip' frames, see above) 0019 % ' ' (space bar) Pause/unpause automatic playback. 0020 % '.' Advance by 1 frame (or 'Skip' frames, see above) 0021 % '>' Advance to last frame (frame P) 0022 % 0023 % Right clicking the data invokes a menu with the following commands: 0024 % Play Automatic playback (frame 1 -> frame P). 0025 % Reverse Automatic playback in reverse (frame P -> frame 1). 0026 % Interpolate Toggles interpolated color display. 0027 % OpenGL Toggles between the OpenGL and zbuffer renderers. 0028 % Params Creates a dialog box to ask for timing parameters: 0029 % Skip (default: 1 frms) # frames to advance btw frames. 0030 % Slow (default: 0 msec) # msec to pause btw frame advances. 0031 % Fs (default: 1 Hz ) temporal sampling rate 0032 % 0033 % Left clicking over the data plots the time-series for the clicked 0034 % pixel in the lower axes. Double click on the time-series axes 0035 % background to clear them. 0036 % 0037 % Left click and drag the time cursor on the time-series axes to rapidly 0038 % move to another part of the recording. 0039 % 0040 % Right-clicking the time-series axes invokes these menu options: 0041 % Expand Axes Toggles a zoomed view; see UIsubzoom. 0042 % Temporal Diff Temporal differences of time-series data. 0043 % Show Legend Toggles legend display. 0044 % 0045 % The colorbar alters the color scale; see UIcolorshift. 0046 % 0047 % H = UImovieplayer(...) returns a handle to the new movieplayer figure. 0048 % 0049 % Technical note: 0050 % The interpolation option is disabled when the number of spatial data 0051 % points (M x N) exceeds 2500 (since such large movies are rendered 0052 % using a technique that does not support interpolation). However, when 0053 % M x N is less than 2500, interpolation can be used for spatial data 0054 % smoothing. Note that OpenGL and zbuffer interpolate differently; in 0055 % general, zbuffer interpolates in the colormap and is thus a more 0056 % accurate spatial smoothing. However, OpenGL may be faster on systems 0057 % where hardware OpenGL acceleration is available. 0058 0059 % programmer note -- at some point, should allow non-square X-Y grid 0060 0061 %state = warning; warning off; 0062 surfimg_cutoff = 2500; % pixels 0063 0064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0065 if (nargin == 1), frame = 1; Fs = 1; 0066 elseif (nargin == 2), frame = 1; 0067 end 0068 0069 [M,N,P] = size(data); T = (1:P)./Fs; AVG = mean(data,3); 0070 if (M*N < surfimg_cutoff), hires = 0; else hires = 1; end; 0071 ROWpad = NaN*ones(1,N+1); COLpad = NaN*ones(M,1); 0072 0073 slow = 0; skip = 1; tslist = []; 0074 if (frame<1 || frame>P), error('Requested start frame does not exist.'); end; 0075 if (Fs<=0), error('Sampling rate must be positive.'); end; 0076 0077 if (~isreal(data)), error('DATA must be real'); % get data limits 0078 elseif (isa(data, 'uint8')), CLIM = [ 0 255]; 0079 elseif (isa(data, 'int8')), CLIM = [-128 127]; 0080 elseif (isa(data, 'double')), CLIM = minmax(data); % (faster then min/max) 0081 else CLIM(1) = min(data(:)); CLIM(2) = max(data(:)); 0082 end 0083 0084 hfig = figure('Position', [500 300 600 600]); 0085 subplot(5,1,5); hax2 = gca; hcsr = []; % cursor invisible 0086 subplot(5,1,1:4); haxs = gca; hdtx = []; % no time series to start ... 0087 if (hires), hdat = imagesc(data(:,:,frame)); 0088 else hdat = pcolor(1:(N+1),1:(M+1),[double(data(:,:,1)) COLpad; ROWpad]); 0089 end 0090 saturate; 0091 httl = title(''); 0092 hxlb = ylabel('See UImovieplayer help for controls.'); 0093 0094 %%%%%%%%%%%%%%%%%%% Movieplayer Control Callbacks %%%%%%%%%%%%%%%%%%%%% 0095 cmenu = uicontextmenu; set(hdat, 'UIContextMenu', cmenu); 0096 0097 menu.play = uimenu(cmenu, 'Checked', 'off', 'Label', 'Play', 'Callback', ... 0098 @CB_movieplayer); 0099 menu.rply = uimenu(cmenu, 'Checked', 'off', 'Label', 'Reverse', 'Callback', ... 0100 @CB_movieplayer); 0101 0102 menu.intp = uimenu(cmenu, 'Checked', 'off', 'Label', 'Interpolate', 'Callback', ..., 0103 @CB_movieplayer, 'Separator', 'on'); 0104 menu.rndr = uimenu(cmenu, 'Checked', 'on', 'Label', 'OpenGL', 'Callback', ..., 0105 @CB_movieplayer); % toggled on->off by default below 0106 0107 menu.parm = uimenu(cmenu, 'Checked', 'off', 'Label', 'Timing Params', 'Callback', ..., 0108 @CB_movieplayer, 'Separator', 'on'); 0109 0110 if (hires), set(menu.intp, 'Checked', 'off', 'Enable', 'off'); end; 0111 set(hfig, 'KeyPressFcn', @CB_movieplayer); 0112 set(hdat, 'ButtonDownFcn', @CB_movieplayer); 0113 0114 set(hax2, 'ButtonDownFcn', @CB_movieplayer, 'Units', 'pixels'); UIsubzoom(hax2); 0115 cmenu2 = get(hax2, 'UIContextMenu'); 0116 menu.dxdt = uimenu(cmenu2, 'Tag', 'dx/dt', 'Checked', 'off', ... 0117 'Label', 'Temporal Diff', 'Callback', @CB_movieplayer); 0118 menu.legd = uimenu(cmenu2, 'Tag', 'ShowLegend', 'Checked', 'off', ... 0119 'Label', 'Show Legend', 'Callback', @CB_movieplayer); 0120 0121 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Store UserData %%%%%%%%%%%%%%%%%%%%%%%%%% 0122 udlist = {'data', 'N', 'M', 'P', 'T', 'CLIM', 'AVG', 'hires', ... 0123 'hdat', 'hfig', 'haxs', 'hax2', 'httl', 'hcsr', 'hdtx', 'cmenu', 'cmenu2', 'menu', ... 0124 'frame', 'slow', 'skip', 'Fs', 'tslist', 'COLpad', 'ROWpad',}; 0125 guidata(hfig, structpack(udlist)); 0126 0127 0128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% Default State %%%%%%%%%%%%%%%%%%%%%%%%%% 0129 % Signaling function for mouse presses 0130 set(hfig, 'WindowButtonUpFcn', 'h = guidata(gcbo); h.buttondown = 0; guidata(gcbo, h);'); 0131 set(hfig, 'WindowButtonMotionFcn', '% dummy function to force CurrentPoint updates'); 0132 set(hfig, 'Name', 'UImovieplayer', 'NumberTitle', 'off'); 0133 set(haxs, 'CLim', CLIM); UIcolorshift; 0134 axis xy square equal; % default since we're usu looking at data instead of an image 0135 CB_movieplayer(menu.rndr); % force a redraw to set shading/limits 0136 set(hfig, 'CurrentCharacter', '?'); CB_movieplayer(hfig); % force redraw for text 0137 0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cleanup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0139 if (nargout == 0), clear hfig; end 0140 %warning(state);