📄 pop_erpimage.m
字号:
{ 'Style', 'text', 'string', 'Inter-trial coherence options', 'fontweight', 'bold'} ... { 'Style', 'text', 'string', 'Frequency (Hz | minHz maxHz)', 'tooltipstring', [ '[freq] -> plot erp plus amp & coher at freq (Hz)' 10 ... '[minHz maxHz] -> find max in frequency range' 10 '(or at phase freq above, if specified)']} ... { 'Style', 'text', 'string', 'Signif. level (<0.20)', 'tooltipstring', 'add coher. signif. level line at alpha (alpha range: (0,0.1])' } ... { 'Style', 'text', 'string', 'Amplitude limits (dB)' } ... { 'Style', 'text', 'string', 'Coher limits (<=1)' } ... { 'Style', 'checkbox', 'string', 'Image amps', 'tooltipstring', context('plotamps',vars,txt), 'value', getkeyval(lastcom, 'plotamps', 'present', 0), 'tag', 'plotamps' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'coher', [1:2]), 'tag', 'coher', 'callback', commandcoher } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'coher', [3]), 'tag', 'coher2' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'limits',[5:6]), 'tag', 'limamp' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'limits',[7:8]), 'tag', 'limcoher' } {'style', 'text', 'string', ' (Requires signif.)' } ... {} ... { 'Style', 'text', 'string', 'Other options', 'fontweight', 'bold'} ... { 'Style', 'text', 'string', 'Plot spectrum (minHz maxHz)','tooltipstring', context('spec',vars,txt)} ... { 'Style', 'text', 'string', 'Baseline ampl. (dB)', 'tooltipstring', 'Use it to fix baseline amplitude' } ... { 'Style', 'text', 'string', 'Mark times (ms)','tooltipstring', context('vert',vars,txt)} ... { 'Style', 'text', 'string', 'More options (see >> help erpimage)' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'spec'), 'tag', 'spec' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'limits',9), 'tag', 'limbaseamp' } ... { 'Style', 'edit', 'string', getkeyval(lastcom, 'vert'), 'tag', 'vert' } ... { 'Style', 'edit', 'string', '', 'tag', 'others' } ... }; if typeplot == 0 % add extra param for components geometry = { [1 1 0.1 0.8 2.1] geometry{:} }; uilist = { { } { } { } { } { } uilist{:}}; uilist{1} = uilist{6}; uilist{2} = uilist{7}; uilist{6} = { 'Style', 'text', 'string', 'Project to channel #', 'fontweight', 'bold','tooltipstring', ['Project component(s) to data channel' 10 ... 'This allow to plot component activity in microvolt'] }; uilist{7} = { 'Style', 'edit', 'string', getkeyval(lastcom, 4), 'tag', 'projchan' }; end; [oldres a b res] = inputgui( geometry, uilist, 'pophelp(''pop_erpimage'');', ... fastif( typeplot, 'Channel ERP image -- pop_erpimage()', 'Component ERP image -- pop_erpimage()')); if isempty(oldres), return; end; % first rows % --------- limits(1:8) = NaN; channel = eval( [ '[' res.chan ']' ]); titleplot = res.title; if isfield(res, 'projchan'), projchan = str2num(res.projchan); else, projchan = []; end; options = ''; if ~typeplot & isempty(projchan) options = [options ',''yerplabel'',''''' ]; else options = [options ',''yerplabel'',''\muV''' ]; end; if isempty(titleplot) if typeplot==1 if isempty(EEG.chanlocs) % if channel plot titleplot = [ EEG.chanlocs(channel).labels ]; else, titleplot = [ int2str(channel) ]; end else titleplot = [ 'Comp. ' int2str(channel) ]; if ~isempty(projchan), if ~isempty(EEG.chanlocs) % if channel plot titleplot = [ titleplot ' -> ' EEG.chanlocs(projchan).labels ]; else, titleplot = [ titleplot ' -> Chan. ' int2str(projchan) ]; end end; end end; smooth = eval(res.smooth); if res.plotmap if isfield(EEG.chanlocs, 'theta') if typeplot == 0 options = [options ',''topo'', { EEG.icawinv(:,' int2str(channel) ') EEG.chanlocs } ']; else options = [options ',''topo'', { ' int2str(channel) ' EEG.chanlocs } ']; end; end; end; decimate = eval( res.decimate ); if res.erp options = [options ',''erp''']; end; % finding limits % -------------- if ~isempty(res.limerp) limits(3:4) = eval( [ '[' res.limerp ']' ]); end; if ~isempty(res.limtime) % time limits if ~strcmp(res.limtime, num2str(1000*[EEG.xmin EEG.xmax])) limits(1:2) = eval( [ '[' res.limtime ']' ]); end; end; if ~isempty(res.limamp) limits(5:6) = eval( [ '[' res.limamp ']' ]); end; if ~isempty(res.limcoher) limits(7:8) = eval( [ '[' res.limcoher ']' ]); end; if ~isempty(res.limbaseamp) limits(9) = eval( res.limbaseamp ); %bamp end; if ~all(isnan(limits)) options = [ options ',''limits'',' vararg2str(limits) '' ]; end; % color limits % -------------- if res.cbar options = [options ',''cbar''']; end; if res.caxis options = [options ',''caxis'', [' res.caxis ']' ]; end; % event rows % ---------- if res.nosort options = [options ',''nosort''']; end; try, sortingeventfield = eval( res.field ); catch, sortingeventfield = res.field; end; sortingtype = parsetxt(res.type); sortingwin = eval( [ '[' res.eventrange ']' ] ); if ~isempty(res.field) & ~strcmp(res.renorm, 'no') options = [options ',''renorm'', ''' res.renorm '''' ]; end; if ~isempty(res.align) options = [options ',''align'', ' res.align ]; end; if res.noplot options = [options ',''noplot''']; end; % phase rows % ---------- tmpphase = []; if ~isempty(res.phase) tmpphase = eval( [ '[ 0 0 ' res.phase ']' ]); end; if ~isempty(res.phase2) tmpphase(2) = eval( res.phase2 ); end; if ~isempty(res.phase3) tmpphase(1) = eval( res.phase3 ); end; if ~isempty(tmpphase) options = [ options ',''phasesort'',' vararg2str(tmpphase) ]; end; % coher row % ---------- tmpcoher = []; if res.plotamps options = [options ',''plotamps''']; end; if ~isempty(res.coher) tmpcoher = eval( [ '[' res.coher ']' ]); end; if ~isempty(res.coher2) if length(tmpcoher) == 1 tmpcoher(2) = tmpcoher(1); end; tmpcoher(3) = eval( res.coher2 ); end; if ~isempty(tmpcoher) options = [ options ',''coher'',' vararg2str(tmpcoher) ]; end; % options row % ------------ if ~isempty(res.spec) options = [options ',''spec'', [' res.spec ']' ]; end; if ~isempty(res.vert) options = [options ',''vert'', [' res.vert ']' ]; end; if ~isempty(res.others) options = [ options ',' res.others ]; end; figure;else options = ''; if nargin < 4 projchan = []; end; if nargin < 5 titleplot = ' '; end; if nargin < 6 smooth = 5; end; if nargin < 7 decimate = 0; end; if nargin < 8 sortingtype = []; end; if nargin < 9 sortingwin = []; end; if nargin < 10 sortingeventfield = []; end; for i=1:length( varargin ) if isstr( varargin{ i } ) options = [ options ', ''' varargin{i} '''' ]; else if ~iscell( varargin{ i } ) options = [ options ', [' num2str(varargin{i}) ']' ]; else options = [ options ', { [' num2str(varargin{ i }{1}') ']'' EEG.chanlocs }' ]; end; end; end; end;try, icadefs; set(gcf, 'color', BACKCOLOR,'Name',' erpimage()'); catch, end;% testing inputs% --------------if typeplot == 0 & length(channel) > 1 & isempty(projchan) error('A channel must be selected for plotting several components');end;% find sorting latencies% ---------------------typetxt = '';if ~isempty(sortingeventfield) %events = eeg_getepochevent( EEG, sortingtype, sortingwin, sortingeventfield); events = sprintf('eeg_getepochevent( EEG, %s)', vararg2str({sortingtype, sortingwin, sortingeventfield})); % generate text for the command % ----------------------------- for index = 1:length(sortingtype) if isstr(sortingtype{index}) typetxt = [typetxt ' ''' sortingtype{index} '''' ]; else typetxt = [typetxt ' ' num2str(sortingtype{index}) ]; end; end; % $$$ % renormalize latencies if necessary% $$$ % ----------------------------------% $$$ switch lower(renorm)% $$$ case 'yes',% $$$ disp('Pop_erpimage warning: *** sorting variable renormalized ***');% $$$ events = (events-min(events)) / (max(events) - min(events)) * ...% $$$ 0.5 * (EEG.xmax*1000 - EEG.xmin*1000) + EEG.xmin*1000 + 0.4*(EEG.xmax*1000 - EEG.xmin*1000);% $$$ case 'no',;% $$$ otherwise,% $$$ locx = findstr('x', lower(renorm))% $$$ if length(locx) ~= 1, error('Pop_erpimage error: unrecognize renormalazing formula'); end;% $$$ eval( [ 'events =' renorm(1:locx-1) 'events' renorm(locx+1:end) ';'] );% $$$ end;else events = 'ones(1, EEG.trials)*EEG.xmax*1000'; %events = ones(1, EEG.trials)*EEG.xmax*1000; sortingeventfield = '';end; if typeplot == 1 tmpsig = ['EEG.data(' int2str(channel) ', :)'];else % test if ICA was computed or if one has to compute on line % --------------------------------------------------------- eeg_options; % changed from eeglaboptions 3/30/02 -sm if option_computeica tmpsig = ['EEG.icaact([' int2str(channel) '], :)']; else tmpsig = ['EEG.icaact([' int2str(channel) '], :)']; tmpsig = ['EEG.icaweights([' int2str(channel) '],:)*EEG.icasphere*reshape(EEG.data, EEG.nbchan, EEG.trials*EEG.pnts)']; end; if ~isempty(projchan) tmpsig = [ 'EEG.icawinv(' int2str(projchan) ',[' int2str(channel) '])*' tmpsig ]; end;end;% outputs% -------outstr = '';if ~popup for io = 1:nargout, outstr = [outstr 'varargout{' int2str(io) '},' ]; end; if ~isempty(outstr), outstr = [ '[' outstr(1:end-1) '] =' ]; end;end;% plot the datas and generate output command% --------------------------------------------if length( options ) < 2 options = '';end;% varargout{1} = sprintf('figure; pop_erpimage(%s,%d,%d,''%s'',%d,%d,{%s},[%s],''%s'',''%s''%s);', inputname(1), typeplot, channel, titleplot, smooth, decimate, typetxt, int2str(sortingwin), sortingeventfield, renorm, options);popcom = sprintf('figure; pop_erpimage(%s,%d, [%s],[%s],''%s'',%d,%d,{%s},[%s],''%s'' %s);', inputname(1), typeplot, int2str(channel), int2str(projchan), titleplot, smooth, decimate, typetxt, int2str(sortingwin), sortingeventfield, options);com = sprintf('%s erpimage( %s, %s, linspace(EEG.xmin*1000, EEG.xmax*1000, EEG.pnts), ''%s'', %d, %d %s);', outstr, tmpsig, events, titleplot, smooth, decimate, options);disp('Command executed by pop_erpimage:');disp(' '); disp(com); disp(' ');eval(com)if popup varargout{1} = popcom; % [10 '% Call: ' com];end;return;% get contextual help% -------------------function txt = context(var, allvars, alltext); loc = strmatch( var, allvars); if ~isempty(loc) txt= alltext{loc(1)}; else disp([ 'warning: variable ''' var ''' not found']); txt = ''; end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -