Home > . > DIVA_ModelStatePlot.m

DIVA_ModelStatePlot

PURPOSE ^

DIVA_ModelStatePlot DIVA architecture plotting module. Displays

SYNOPSIS ^

function out=DIVA_ModelStatePlot(varargin);

DESCRIPTION ^

 DIVA_ModelStatePlot DIVA architecture plotting module.  Displays
 a plot of active module components complete with time point of activity

 DIVA_ModelStatePlot('init' [,SessionName]);          Initializes the module
 DIVA_ModelStatePlot('save' [,SessionName] );         Saves state 
 DIVA_ModelStatePlot('exit');                         Exits the module (without saving)
 DIVA_ModelStatePlot(PropertyName [,PropertyValue] )  Reads and writes internal model properties

 DIVA_ModelStatePlot(ChannelName1,ChannelValue1,...
               ChannelName2,ChannelValue2,...); Executes module process(es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function out=DIVA_ModelStatePlot(varargin);
0002 % DIVA_ModelStatePlot DIVA architecture plotting module.  Displays
0003 % a plot of active module components complete with time point of activity
0004 %
0005 % DIVA_ModelStatePlot('init' [,SessionName]);          Initializes the module
0006 % DIVA_ModelStatePlot('save' [,SessionName] );         Saves state
0007 % DIVA_ModelStatePlot('exit');                         Exits the module (without saving)
0008 % DIVA_ModelStatePlot(PropertyName [,PropertyValue] )  Reads and writes internal model properties
0009 %
0010 % DIVA_ModelStatePlot(ChannelName1,ChannelValue1,...
0011 %               ChannelName2,ChannelValue2,...); Executes module process(es)
0012 %
0013 
0014 % Dependencies:
0015 %
0016 
0017 out=[];
0018 global DIVA_ModelStatePlot_data
0019 
0020 for indexargin=1:2:nargin,  
0021   switch(varargin{indexargin}),
0022    case 'init',
0023     SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0024     if nargin<indexargin+1 | isempty(varargin{indexargin+1}), 
0025       initfile='';
0026     else, 
0027       initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; 
0028     end
0029     if isempty(initfile) | isempty(dir(initfile)),
0030       % INITIALIZES INTERNAL MODULE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0031       DIVA_ModelStatePlot_data.params=struct(...
0032           'historylength',200,...
0033           'plotdata',{... % info for plotting known channels: x coordinate, y coordinate, point type
0034               {... 
0035                   340+(0:30:90),245+0*(0:30:90),'ks',...     % VocalTract motor
0036                   780+.7*(0:30:90),135+.7*(0:30:90),'ks',... % AuditoryCortex target
0037                   500+(0:30:90),75+0*(0:30:90),'ks',...      % AuditoryCortex sound
0038                   830-.7*(0:30:90),310+.7*(0:30:90),'ks',... % SomatosensoryCortex target
0039                   500+(0:30:90),420+0*(0:30:90),'ks',...     % SomatosensoryCortex somatosensory
0040                   640+(0:30:90),245+0*(0:30:90),'ks',...     % MotorCortex target
0041                   630-.7*(0:30:90),135+.7*(0:30:90),'ks',... % MotorCortex error_sound
0042                   575+.7*(0:30:90),310+.7*(0:30:90),'ks',... % MotorCortex error_somatosensory
0043                   820+(0:30:90),75+0*(0:30:90),'ks',...      % AuditoryCortexCategorical sound
0044                   940-.7*(0:30:90),135+.7*(0:30:90),'ks'...  % SoundMap target
0045               }},...
0046           'plotdatanames',{{... % names of module channels in the plot window
0047               'VocalTract','motor';
0048               'AuditoryCortex','target';
0049               'AuditoryCortex','sound';
0050               'SomatosensoryCortex','target';
0051               'SomatosensoryCortex','somatosensory';
0052               'MotorCortex','target';
0053               'MotorCortex','error_sound';
0054               'MotorCortex','error_somatosensory';
0055               'AuditoryCortexCategorical','sound';
0056               'SoundMap','target'}});
0057       % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0058       
0059     else,
0060       data=load(initfile,'-mat');
0061       DIVA_ModelStatePlot_data.params=data.params;
0062     end
0063     % INITIALIZES OTHER (TEMPORAL) PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0064     h=findobj('name','DIVA model state plot');
0065     if isempty(h), 
0066       h=figure('name','DIVA model state plot',...
0067                'numbertitle','off',...
0068                'units','norm',...
0069                'position',[.5,.5,.45,.35],...
0070                'menu','none',...
0071                'doublebuffer','on',...
0072                'color','w',...
0073                'deletefcn','DIVA(''exit'');'); 
0074     else, 
0075       figure(h); 
0076     end
0077     
0078     DIVA_ModelStatePlot_data.current=struct(...
0079         'figurehandle',h,...
0080         'figuredata',imread([mfilename,'.tif']),...
0081         'Now',DIVA('Now'),...
0082         'markers','^>v<'); 
0083     
0084     subplot(211); 
0085     imagesc(DIVA_ModelStatePlot_data.current.figuredata); 
0086     axis equal; 
0087     axis tight; 
0088     axis off; 
0089     hold on; 
0090     set(gca,'units','norm','position',[0,.5,1,.5]);
0091     DIVA_ModelStatePlot_data.current.plotdata = ...
0092         plot(DIVA_ModelStatePlot_data.params.plotdata{:}); 
0093     hold off;
0094     
0095     set(DIVA_ModelStatePlot_data.current.plotdata,'markerfacecolor','k','markersize',1);
0096     DIVA_ModelStatePlot_data.current.plotdatanames = ...
0097         DIVA_ModelStatePlot_data.params.plotdatanames;
0098     DIVA_ModelStatePlot_data.current.history = ...
0099         zeros([size(DIVA_ModelStatePlot_data.current.plotdatanames,1),...
0100                DIVA_ModelStatePlot_data.params.historylength]);
0101     
0102     subplot(212); 
0103     DIVA_ModelStatePlot_data.current.historydata = ...
0104         imagesc(DIVA_ModelStatePlot_data.current.history); 
0105     axis tight; 
0106     for n1=1:size(DIVA_ModelStatePlot_data.current.plotdatanames,1), 
0107       ticklabel{n1} = strcat(DIVA_ModelStatePlot_data.current.plotdatanames{n1,1},' -  ',...
0108                              DIVA_ModelStatePlot_data.current.plotdatanames{n1,2}); 
0109     end
0110     
0111     set(gca,'units','norm','position',[.05,.05,.65,.45],...
0112             'clim',[0,1],'xtick',0:10:DIVA_ModelStatePlot_data.params.historylength,...
0113             'ytick',1:size(DIVA_ModelStatePlot_data.current.plotdatanames,1),...
0114             'yticklabel',ticklabel,'yaxislocation','right',...
0115             'fontsize',6,'box','off','xticklabel',[]); 
0116     xlabel('==== TIME ===>')
0117     set(DIVA_ModelStatePlot_data.current.historydata,'erasemode','none'); 
0118     colormap([1,1,1;.8,.8,.8]);
0119     % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0120     
0121     % LIST OF MODULE CHANNELS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0122     out={}; 
0123     % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0124     
0125    case 'save',
0126     SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0127     if nargin<indexargin+1, 
0128       initfile=[SessionFolder,'Session_','default',filesep,mfilename,'.mat']; 
0129     else, 
0130       initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; 
0131     end
0132     params=DIVA_ModelStatePlot_data.params;
0133     save(initfile,'params'); 
0134     
0135    case 'exit',
0136     if ishandle(DIVA_ModelStatePlot_data.current.figurehandle), 
0137       set(DIVA_ModelStatePlot_data.current.figurehandle,'deletefcn','');
0138       delete(DIVA_ModelStatePlot_data.current.figurehandle); 
0139     end
0140     clear DIVA_ModelStatePlot_data;
0141     % CODE FOR CLEARING MEMORY OR THE LIKE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0142     % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0143     
0144    case 'disp',
0145     disp(DIVA_ModelStatePlot_data.params);
0146     out=fieldnames(DIVA_ModelStatePlot_data.params);
0147     
0148     % CODE IMPLEMENTING THIS MODULE PROCESS(ES) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0149     
0150    case {DIVA_ModelStatePlot_data.current.plotdatanames{:,1}},
0151     Now=DIVA('Now');
0152     if Now~=DIVA_ModelStatePlot_data.current.Now, 
0153       set(DIVA_ModelStatePlot_data.current.historydata,...
0154           'cdata',DIVA_ModelStatePlot_data.current.history);
0155       drawnow; 
0156       DIVA_ModelStatePlot_data.current.history(:,1:end-1) = ...
0157           DIVA_ModelStatePlot_data.current.history(:,2:end); 
0158       DIVA_ModelStatePlot_data.current.history(:,end)=0;
0159       set(DIVA_ModelStatePlot_data.current.plotdata,'markersize',1); 
0160     end
0161     index=intersect(...
0162         strmatch(varargin{indexargin},...
0163                  {DIVA_ModelStatePlot_data.current.plotdatanames{:,1}},'exact'),...
0164         strmatch(varargin{indexargin+1},...
0165                  {DIVA_ModelStatePlot_data.current.plotdatanames{:,2}},'exact'));
0166     if ~isempty(index), 
0167       DIVA_ModelStatePlot_data.current.history(index,end)=1;
0168       set(DIVA_ModelStatePlot_data.current.plotdata(index),...
0169           'markersize',5,...
0170           'marker',DIVA_ModelStatePlot_data.current.markers(1+mod(Now+min(index),4))); 
0171     end
0172     DIVA_ModelStatePlot_data.current.Now=Now;
0173     
0174     % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0175     
0176    otherwise,
0177     if isfield(DIVA_ModelStatePlot_data.params,varargin{indexargin}),
0178       if indexargin==nargin, 
0179         out=DIVA_ModelStatePlot_data.params.(varargin{indexargin}); 
0180       else, 
0181         DIVA_ModelStatePlot_data.params.(varargin{indexargin})=varargin{indexargin+1}; 
0182       end
0183     else, 
0184       warning('DIVA_ModelStatePlot: wrong argument'); 
0185     end
0186   end
0187 end
0188

Generated on Tue 27-Mar-2007 12:06:24 by m2html © 2003