RTXI 1.3
hdf/RTXIh5_MATLAB/rtxiplot.m File Reference

Go to the source code of this file.

Functions

 setappdata (fig,'meta', meta)
 setappdata (fig,'reset', 1)
clear listbox contents rtxibrowse (fig, meta.fname, meta.trialNum)
else msgbox ('This is the first trial in the file!')
end function next_button_callback (src, eventdata) fig
else msgbox ('This is the last trial in the file!')
end function rtxiplot_onselectionchange (listbox, event)%%Fired when the selected list item changes.fig
if isempty (index) ax
 rtxiplot_hideaxes (ax)
elseif strcmp (get(panels(i),'Tag'),'bottomplot') bottomaxesparent
end end switch get (fig, 'SelectionType') case 'open'%%when you double-click
if ~isempty (caption) meta
allaxes ()
elseif get (allaxes(2),'Parent')
end elseif strcmp (tag,'listbox2')%find axes handle for bottom plot if get(allaxes(1)
end end end if numel (args) > 0 &&isa(args
unwrap function handle from
cell array 
fun (ax, args{2:end})
ax rtxiplot_error ()
 rethrow (me)
end else rtxiplot_plot (ax, args{:})
end set (ax, 'Visible', 'on')
 set (ax, 'Visible', 'off')
function rtxiplot_error (ax) rtxiplot_hideaxes(ax)
 msgbox ('Error while plotting data to axes, see console for details.',... 'Plot error', 'error')

Variables

function fig
parameter counter if k<=numel(varargin)&&isscalar(varargin{k})&&ishandle(varargin{k})%re-use existing figurefig=varargin{k};tag=get(fig, 'Tag');assert(~isempty(tag)&&strcmp(tag, '__rtxiplot__'),...%verify figure tag 'rtxiplot:ArgumentTypeMismatch', 'An rtxiplot figure is expected.');k=k+1;elseif k<=numel(varargin)&&ischar(varargin{k})&&strcmp('new', varargin{k})%force creation of new figurefig=rtxiplot_figure();k=k+1;elsecurfig=get(0,'CurrentFigure');h=findobj('Type', 'figure', 'Tag', '__rtxiplot__');if isempty(h)%create new figure if no rtxiplot figure exists yetfig=rtxiplot_figure();setappdata(fig,'reset', 0);%do not reset listbox contentselseif isscalar(h)%a single rtxiplot figure existsif~isempty(curfig)&&h==curfig%currently active figure is an rtxiplot figurefig=curfig;elsefig=h;figure(fig);%currently active figure is not an rtxiplot figure, activate the only rtxiplot figureendelse%multiple rtxiplot figures existif~isempty(curfig) ix=find(h==curfig);%ix is either empty or a scalarelseix=[];endif isscalar(ix)%current figure is an rtxiplot figurefig=curfig;else%isempty(ix) fig=h(1);%use rtxiplot figure topmost in stacking orderfigure(fig);warning('rtxiplot:InvalidOperation',... 'Currently active figure is not an rtxiplot figure, the topmost rtxiplot figure has been activated.');endendendif k<=numel(varargin)&&ischar(varargin{k})%get channel names as captions for listboxcaption=varargin{k};k=k+1;else%use default captioncaption=[];endif k<=numel(varargin)&&isstruct(varargin{k})%get parametersparameters=varargin{k};k=k+1;else%use default captionparameters=[];endif k<=numel(varargin)&&isstruct(varargin{k})%get meta datameta=varargin{k};k=k+1;else%use default captionmeta=[];endsetappdata(fig,'meta', meta) if k > numel(varargin)%nothing to plotif~isempty(caption) warning('rtxiplot:InvalidOperation',... 'A caption is specified but no data to plot has been passed.');return;endreturn;endvarargin=varargin(k:end);%drop preprocessed argumentsppanel=findobj(fig,'Tag','parameterpanel');uicontrol(ppanel,... 'Style','text',... 'Units','normalized',... 'Position',[0.9 1 0.1],... 'String','INITIAL PARAMETERS');if(ischar(parameters.values{1}))%is stringpstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', parameters.values{1}];else%get the second value, the first is the timestamppstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', num2str(parameters.values{1}{1, 2})];end%pstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', num2str(parameters.values{1}{1, 2})];if size(parameters.values{1}, 1)>1pstr=[pstr,'*''}'];elsepstr=[pstr,'''}'];endfor p=2:length(parameters.parameterName) if(ischar(parameters.values{p}))%get stringpstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', parameters.values{p}];else%get the second value, the first is the timestamppstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', num2str(parameters.values{p}{1, 2})];end%pstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', num2str(parameters.values{p}{1, 2})];if size(parameters.values{p}, 1)>1pstr=[pstr,'*''}'];elsepstr=[pstr,'''}'];endendpstr=[pstr,']'];eval(['uicontrol(ppanel,''Style'',''text'',''Units'',''normalized'',''FontSize'', 9,''Position'',[.03 0 0.95 0.95],''HorizontalAlignment'',''Left'',''String'',', pstr,');']);listbox1=findobj(fig, 'Type', 'uicontrol', 'Tag', 'listbox1');string=get(listbox1, 'String');%cell array of all the item stringsif getappdata(fig,'reset')==1;userdata={};string={};set(listbox1,'Value', 1);elseuserdata=get(listbox1, 'UserData');endif numel(string) > 100warning('rtxiplot:InvalidOperation', 'There are too many plots, new plot has not been added.');return;endif numel(string)==1 &&strcmp(string, '[empty]')%there is only the placeholder item in the liststring={};%clear placeholder itemuserdata={};enduserdata{numel(userdata)+1}=varargin;%add arguments to plot functionif isempty(caption) caption=sprintf('Plot%d', numel(userdata));endstring{numel(string)+1}=caption;%add caption used in list boxset(listbox1,... 'String', string,... 'TooltipString', 'Double-click item(or hit ENTER) to plot in new figure window.',... 'UserData', userdata);if numel(string)<=1rtxiplot_onselectionchange(listbox1);%show first selection by defaultendlistbox2=findobj(fig, 'Type', 'uicontrol', 'Tag', 'listbox2');string=get(listbox2, 'String');if getappdata(fig,'reset')==1;userdata={};string={};set(listbox2,'Value', 1);elseuserdata=get(listbox2, 'UserData');endif numel(string) > 100warning('rtxiplot:InvalidOperation', 'There are too many plots, new plot has not been added.');return;endif numel(string)==1 &&strcmp(string, '[empty]')%there is only the placeholder item in the liststring={};%clear placeholder itemuserdata={};enduserdata{numel(userdata)+1}=varargin;%add arguments to plot functionif isempty(caption) caption=sprintf('Plot%d', numel(userdata));endstring{numel(string)+1}=caption;%add caption used in list boxset(listbox2,... 'String', string,... 'TooltipString', 'Double-click item(or hit ENTER) to plot in new figure window.',... 'UserData', userdata);if numel(string)<=1rtxiplot_onselectionchange(listbox2);%show first selection by defaultendsetappdata(fig,'reset', 0);function fig=rtxiplot_figure()%Creates a new rtxiplot figure.fig=figure(... 'Tag', '__rtxiplot__');%ensures that all necessary controls are presenttry%try to use uisplitter if available[leftpanel, rightpanel]=uisplitpane(fig,'DividerWidth', 2,'DividerLocation', 0.25,'Orientation','hor');[boxpanel, plotpanel]=uisplitpane(rightpanel,'DividerWidth', 2,'DividerLocation', 0.25,'Orientation','hor');[topbox, bottombox]=uisplitpane(boxpanel,'DividerWidth', 2,'DividerLocation', 0.5,'Orientation','vert');[topplot, bottomplot]=uisplitpane(plotpanel, 'DividerWidth', 2,'Orientation','vert');[bttnpanel, ppanel]=uisplitpane(leftpanel,'DividerWidth', 2,'DividerLocation', 0.1,'Orientation','vert');set(leftpanel,'Tag','leftpanel');set(ppanel,'Tag','parameterpanel');set(bttnpanel,'Tag','buttonpanel');set(rightpanel,'Tag','rightpanel');set(boxpanel,'Tag','leftpanel');set(plotpanel,'Tag','plotpanel');set(topbox,'Tag','topbox');set(bottombox,'tag','bottombox');set(bottomplot,'Tag','bottomplot');set(topplot,'Tag','topplot');catchmsgbox('Get uisplitter!');endprev_button=uicontrol(bttnpanel,'Style','pushbutton',... 'Units','normalized',... 'String','Prev',... 'Position',[0.03 0.15 0.4 0.8],... 'Callback',@prev_button_callback);next_button=uicontrol(bttnpanel,'Style','pushbutton',... 'Units','normalized',... 'String','Next',... 'Position',[0.5 0.15 0.4 0.8],... 'Callback',@next_button_callback);listbox1=uicontrol(topbox,...%allows selection of data to plot 'Style', 'listbox',... 'Units', 'normalized',... 'Position',[.03 0.03 0.95.95],... 'String',{'[empty]'},...%placeholder item 'Tag', 'listbox1',... 'Callback',@rtxiplot_onselectionchange);listbox2=uicontrol(bottombox,...%allows selection of data to plot 'Style', 'listbox',... 'Units', 'normalized',... 'Position',[0.03 0.03 0.95.95],... 'String',{'[empty]'},...%placeholder item 'Tag', 'listbox2',... 'Callback',@rtxiplot_onselectionchange);axes('Parent', topplot);axes('Parent', bottomplot);set(listbox2, 'UserData',{{}});%no plot arguments belong to placeholder itemset(listbox1, 'UserData',{{}});%no plot arguments belong to placeholder itemfunction rtxiplot_plot(ax, varargin)%Plots data in an rtxiplot figure with the specified plot arguments.%%Input arguments:%ax:%an axes handle graphics object%varargin(optional):%parameters to pass to the plot functionif nargin >=2tryplot(ax, varargin{:});xlabel(ax,'time(s)');catch medisp('plot function produces an error when passed parameters:');args=varargin(:);disp(args);rtxiplot_error(ax);rethrow(me);endelse%nothing to plotrtxiplot_hideaxes(ax);endfunction prev_button_callback(src, eventdata) fig=ancestor(src, 'figure');meta=getappdata(fig,'meta');if meta.trialNum-1 >
meta trialNum = meta.trialNum - 1
 meta = getappdata(fig,'meta')
 index = get(listbox, 'Value')
 tag = get(listbox,'Tag')
 return
end userdata = get(listbox, 'UserData')
 args = userdata{index}
 allaxes = findobj(fig,'Type','axes')
 panels = findobj(fig,'Type','uipanel')
for i
end end switch copies plot to
new figure 
string = get(listbox, 'String')
 caption = string{index}
 newfigname = [meta.fname,' | Trial ',num2str(meta.trialNum),'/',num2str(meta.numTrials),' | ',caption]
 newfig = figure('Name', newfigname)
end ax = axes('Parent', newfig)
end elseif Parent
function_handle try fun = args{1}
function reset

Function Documentation

1 allaxes ( ) [virtual]
unwrap function handle from cell array fun ( ax  )
end end switch get ( fig  ,
'SelectionType'   
)
elseif get ( allaxes(2)  ,
'Parent  
)
Initial value:
=bottomaxesparent
        ax = allaxes(2)
if isempty ( index  )
else msgbox ( 'This is the first trial in the file!'  )
msgbox ( 'Error while plotting data to  axes,
see console for details.'  ,
... 'Plot error'  ,
'error'   
)
else msgbox ( 'This is the last trial in the file!'  )
end function next_button_callback ( src  ,
eventdata   
)
end end end if numel ( args  )

Definition at line 369 of file rtxiplot.m.

rethrow ( me  )
clear listbox contents rtxibrowse ( fig  ,
meta.  fname,
meta.  trialNum 
)
function rtxiplot_error ( ax  )
ax rtxiplot_error ( ) [virtual]
rtxiplot_hideaxes ( ax  )
end function rtxiplot_onselectionchange ( listbox  ,
event   
)
end else rtxiplot_plot ( ax  )
set ( ax  ,
'Visible'  ,
'off'   
)
end set ( ax  ,
'Visible'  ,
'on'   
)
setappdata ( fig  ,
'reset ,
 
)
setappdata ( fig  ,
'meta ,
meta   
)
end elseif strcmp ( tag  ,
'listbox2'   
)
elseif strcmp ( get(panels(i),'Tag')  ,
'bottomplot'   
)
if ~isempty ( caption  )

Variable Documentation

allaxes = findobj(fig,'Type','axes')

Definition at line 330 of file rtxiplot.m.

Definition at line 329 of file rtxiplot.m.

end ax = axes('Parent', newfig)

Definition at line 351 of file rtxiplot.m.

Definition at line 343 of file rtxiplot.m.

Initial value:
"Next"
% buttons are only applicable in this scenario since it uses metadata such
% as the HDF5 file name to browse through all the trials.
%
% AUTHOR: Risa Lin
% DATE:   10/31/2010
%
% MODIFIED:
% 9/27/2011 - supports unmatlabized RTXI files and strings

k = 1

Definition at line 1 of file rtxiplot.m.

function_handle try fun = args{1}

Definition at line 371 of file rtxiplot.m.

for i
Initial value:
length(panels):-1:1
  if strcmp(get(panels(i),'Tag'),'topplot')
    topaxesparent = panels(i)

Definition at line 332 of file rtxiplot.m.

index = get(listbox, 'Value')

Definition at line 320 of file rtxiplot.m.

parameter counter if k<=numel(varargin)&&isscalar(varargin{k})&&ishandle(varargin{k})%re-use existing figurefig=varargin{k};tag=get(fig, 'Tag');assert(~isempty(tag)&&strcmp(tag, '__rtxiplot__'),...%verify figure tag 'rtxiplot:ArgumentTypeMismatch', 'An rtxiplot figure is expected.');k=k+1;elseif k<=numel(varargin)&&ischar(varargin{k})&&strcmp('new', varargin{k})%force creation of new figurefig=rtxiplot_figure();k=k+1;elsecurfig=get(0,'CurrentFigure');h=findobj('Type', 'figure', 'Tag', '__rtxiplot__');if isempty(h)%create new figure if no rtxiplot figure exists yetfig=rtxiplot_figure();setappdata(fig,'reset', 0);%do not reset listbox contentselseif isscalar(h)%a single rtxiplot figure existsif~isempty(curfig)&&h==curfig%currently active figure is an rtxiplot figurefig=curfig;elsefig=h;figure(fig);%currently active figure is not an rtxiplot figure, activate the only rtxiplot figureendelse%multiple rtxiplot figures existif~isempty(curfig)ix=find(h==curfig);%ix is either empty or a scalarelseix=[];endif isscalar(ix)%current figure is an rtxiplot figurefig=curfig;else%isempty(ix)fig=h(1);%use rtxiplot figure topmost in stacking orderfigure(fig);warning('rtxiplot:InvalidOperation',... 'Currently active figure is not an rtxiplot figure, the topmost rtxiplot figure has been activated.');endendendif k<=numel(varargin)&&ischar(varargin{k})%get channel names as captions for listboxcaption=varargin{k};k=k+1;else%use default captioncaption=[];endif k<=numel(varargin)&&isstruct(varargin{k})%get parametersparameters=varargin{k};k=k+1;else%use default captionparameters=[];endif k<=numel(varargin)&&isstruct(varargin{k})%get meta datameta=varargin{k};k=k+1;else%use default captionmeta=[];endsetappdata(fig,'meta', meta) if k > numel(varargin)%nothing to plotif~isempty(caption)warning('rtxiplot:InvalidOperation',... 'A caption is specified but no data to plot has been passed.');return;endreturn;endvarargin=varargin(k:end);%drop preprocessed argumentsppanel=findobj(fig,'Tag','parameterpanel');uicontrol(ppanel,... 'Style','text',... 'Units','normalized',... 'Position',[0.9 1 0.1],... 'String','INITIAL PARAMETERS');if(ischar(parameters.values{1}))%is stringpstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', parameters.values{1}];else%get the second value, the first is the timestamppstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', num2str(parameters.values{1}{1, 2})];end%pstr=['[{''', parameters.modelName{1},': ', parameters.parameterName{1},': ', num2str(parameters.values{1}{1, 2})];if size(parameters.values{1}, 1)>1pstr=[pstr,'*''}'];elsepstr=[pstr,'''}'];endfor p=2:length(parameters.parameterName)if(ischar(parameters.values{p}))%get stringpstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', parameters.values{p}];else%get the second value, the first is the timestamppstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', num2str(parameters.values{p}{1, 2})];end%pstr=[pstr,';{''', strrep(parameters.modelName{p},'''',''''''),': ', strrep(parameters.parameterName{p},'''',''''''),': ', num2str(parameters.values{p}{1, 2})];if size(parameters.values{p}, 1)>1pstr=[pstr,'*''}'];elsepstr=[pstr,'''}'];endendpstr=[pstr,']'];eval(['uicontrol(ppanel,''Style'',''text'',''Units'',''normalized'',''FontSize'', 9,''Position'',[.03 0 0.95 0.95],''HorizontalAlignment'',''Left'',''String'',', pstr,');']);listbox1=findobj(fig, 'Type', 'uicontrol', 'Tag', 'listbox1');string=get(listbox1, 'String');%cell array of all the item stringsif getappdata(fig,'reset')==1;userdata={};string={};set(listbox1,'Value', 1);elseuserdata=get(listbox1, 'UserData');endif numel(string) > 100warning('rtxiplot:InvalidOperation', 'There are too many plots, new plot has not been added.');return;endif numel(string)==1 &&strcmp(string, '[empty]')%there is only the placeholder item in the liststring={};%clear placeholder itemuserdata={};enduserdata{numel(userdata)+1}=varargin;%add arguments to plot functionif isempty(caption)caption=sprintf('Plot%d', numel(userdata));endstring{numel(string)+1}=caption;%add caption used in list boxset(listbox1,... 'String', string,... 'TooltipString', 'Double-click item(or hit ENTER) to plot in new figure window.',... 'UserData', userdata);if numel(string)<=1rtxiplot_onselectionchange(listbox1);%show first selection by defaultendlistbox2=findobj(fig, 'Type', 'uicontrol', 'Tag', 'listbox2');string=get(listbox2, 'String');if getappdata(fig,'reset')==1;userdata={};string={};set(listbox2,'Value', 1);elseuserdata=get(listbox2, 'UserData');endif numel(string) > 100warning('rtxiplot:InvalidOperation', 'There are too many plots, new plot has not been added.');return;endif numel(string)==1 &&strcmp(string, '[empty]')%there is only the placeholder item in the liststring={};%clear placeholder itemuserdata={};enduserdata{numel(userdata)+1}=varargin;%add arguments to plot functionif isempty(caption)caption=sprintf('Plot%d', numel(userdata));endstring{numel(string)+1}=caption;%add caption used in list boxset(listbox2,... 'String', string,... 'TooltipString', 'Double-click item(or hit ENTER) to plot in new figure window.',... 'UserData', userdata);if numel(string)<=1rtxiplot_onselectionchange(listbox2);%show first selection by defaultendsetappdata(fig,'reset', 0);function fig=rtxiplot_figure()%Creates a new rtxiplot figure.fig=figure(... 'Tag', '__rtxiplot__');%ensures that all necessary controls are presenttry%try to use uisplitter if available[leftpanel, rightpanel]=uisplitpane(fig,'DividerWidth', 2,'DividerLocation', 0.25,'Orientation','hor');[boxpanel, plotpanel]=uisplitpane(rightpanel,'DividerWidth', 2,'DividerLocation', 0.25,'Orientation','hor');[topbox, bottombox]=uisplitpane(boxpanel,'DividerWidth', 2,'DividerLocation', 0.5,'Orientation','vert');[topplot, bottomplot]=uisplitpane(plotpanel, 'DividerWidth', 2,'Orientation','vert');[bttnpanel, ppanel]=uisplitpane(leftpanel,'DividerWidth', 2,'DividerLocation', 0.1,'Orientation','vert');set(leftpanel,'Tag','leftpanel');set(ppanel,'Tag','parameterpanel');set(bttnpanel,'Tag','buttonpanel');set(rightpanel,'Tag','rightpanel');set(boxpanel,'Tag','leftpanel');set(plotpanel,'Tag','plotpanel');set(topbox,'Tag','topbox');set(bottombox,'tag','bottombox');set(bottomplot,'Tag','bottomplot');set(topplot,'Tag','topplot');catchmsgbox('Get uisplitter!');endprev_button=uicontrol(bttnpanel,'Style','pushbutton',... 'Units','normalized',... 'String','Prev',... 'Position',[0.03 0.15 0.4 0.8],... 'Callback',@prev_button_callback);next_button=uicontrol(bttnpanel,'Style','pushbutton',... 'Units','normalized',... 'String','Next',... 'Position',[0.5 0.15 0.4 0.8],... 'Callback',@next_button_callback);listbox1=uicontrol(topbox,...%allows selection of data to plot 'Style', 'listbox',... 'Units', 'normalized',... 'Position',[.03 0.03 0.95.95],... 'String',{'[empty]'},...%placeholder item 'Tag', 'listbox1',... 'Callback',@rtxiplot_onselectionchange);listbox2=uicontrol(bottombox,...%allows selection of data to plot 'Style', 'listbox',... 'Units', 'normalized',... 'Position',[0.03 0.03 0.95.95],... 'String',{'[empty]'},...%placeholder item 'Tag', 'listbox2',... 'Callback',@rtxiplot_onselectionchange);axes('Parent', topplot);axes('Parent', bottomplot);set(listbox2, 'UserData',{{}});%no plot arguments belong to placeholder itemset(listbox1, 'UserData',{{}});%no plot arguments belong to placeholder itemfunction rtxiplot_plot(ax, varargin)%Plots data in an rtxiplot figure with the specified plot arguments.%%Input arguments:%ax:%an axes handle graphics object%varargin(optional):%parameters to pass to the plot functionif nargin >=2tryplot(ax, varargin{:});xlabel(ax,'time(s)');catch medisp('plot function produces an error when passed parameters:');args=varargin(:);disp(args);rtxiplot_error(ax);rethrow(me);endelse%nothing to plotrtxiplot_hideaxes(ax);endfunction prev_button_callback(src, eventdata) fig=ancestor(src, 'figure');meta=getappdata(fig,'meta');if meta.trialNum-1 >
Initial value:
 1
  trial = getTrial(meta.fname,meta.trialNum-1)

Definition at line 290 of file rtxiplot.m.

meta = getappdata(fig,'meta')

Definition at line 303 of file rtxiplot.m.

open new figure window else newfig = figure('Name', newfigname)

Definition at line 347 of file rtxiplot.m.

newfigname = [meta.fname,' | Trial ',num2str(meta.trialNum),'/',num2str(meta.numTrials),' | ',caption]

Definition at line 346 of file rtxiplot.m.

panels = findobj(fig,'Type','uipanel')

Definition at line 331 of file rtxiplot.m.

end elseif Parent
Initial value:
=bottomaxesparent
        ax = allaxes(1)

Definition at line 361 of file rtxiplot.m.

Definition at line 384 of file rtxiplot.m.

Definition at line 325 of file rtxiplot.m.

end end switch copies plot to new figure string = get(listbox, 'String')

Definition at line 342 of file rtxiplot.m.

tag = get(listbox,'Tag')

Definition at line 321 of file rtxiplot.m.

meta trialNum = meta.trialNum - 1

Definition at line 292 of file rtxiplot.m.

end userdata = get(listbox, 'UserData')

Definition at line 328 of file rtxiplot.m.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines