📄 pop_editset.m
字号:
{ 'Style', 'text', 'string', 'Dataset name (optional):', 'horizontalalignment', 'right', 'fontweight', 'bold' }, ... { 'Style', 'pushbutton', 'string', 'About', 'callback', editcomments }, ... { 'Style', 'edit', 'string', EEG.setname }, { 'Style', 'text', 'string', '(EEG.setname)' }... ... { 'Style', 'text', 'string', 'Data file or array', 'horizontalalignment', 'right', 'fontweight', 'bold' }, ... { }, { }, { 'Style', 'text', 'string', '(EEG.data)' }, ... ... { 'Style', 'text', 'string', 'Channels in data:', 'horizontalalignment', 'right', 'fontweight', 'bold' }, {}, ... { 'Style', 'text', 'string', num2str(EEG.nbchan), 'horizontalalignment', 'center' }, ... { 'Style', 'text', 'string', '(EEG.nbchan)' } ... ... { 'Style', 'text', 'string', 'Time points per epoch:', 'horizontalalignment', 'right', 'fontweight', 'bold' }, ... { }, { 'Style', 'edit', 'string', num2str(EEG.pnts) }, {'Style', 'text', 'string', '(EEG.pnts)' } ... ... { 'Style', 'text', 'string', 'Data sampling rate (Hz):', 'horizontalalignment', 'right', 'fontweight', 'bold' }, { }, ... { 'Style', 'edit', 'string', num2str(EEG.srate) }, {'Style', 'text', 'string', '(EEG.srate)' },... ... { 'Style', 'text', 'string', 'Epoch start time (sec):', 'horizontalalignment', 'right', 'fontweight', 'bold' }, { }, ... { 'Style', 'edit', 'string', num2str(EEG.xmin) }, {'Style', 'text', 'string', '(EEG.xmin)' },... ... { 'Style', 'text', 'string', 'Channel position file or array:', 'horizontalalignment', 'right', 'fontweight', 'bold' }, ... {'Style', 'pushbutton', 'string', 'Help', 'callback', 'pophelp(''readlocs'');' }, ... { 'Style', 'edit', 'string', fastif(isempty(EEG.chanlocs), '', 'EEG.chanlocs'), 'horizontalalignment', 'left', 'tag', 'chanfile' }, ... { 'Style', 'pushbutton', 'string', 'Browse', 'callback', [ 'tagtest = ''chanfile'';' commandload ] }, ... ... { 'Style', 'text', 'string', 'ICA weight array or text file (if any):', 'horizontalalignment', 'right' }, { }, ... { 'Style', 'edit', 'string', fastif(isempty(EEG.icaweights), '', 'EEG.icaweights'), 'horizontalalignment', 'left', 'tag', 'weightfile' }, ... { 'Style', 'pushbutton', 'string', 'Browse', 'callback', [ 'tagtest = ''weightfile'';' commandload ] }, ... ... { 'Style', 'text', 'string', 'ICA sphere array or text file (if any):', 'horizontalalignment', 'right' }, { }, ... { 'Style', 'edit', 'string', fastif(isempty(EEG.icasphere), '', 'EEG.icasphere'), 'horizontalalignment', 'left', 'tag', 'sphfile' } ... { 'Style', 'pushbutton', 'string', 'Browse', 'callback', [ 'tagtest = ''sphfile'';' commandload ] } ... ... { 'Style', 'text', 'string', 'Data reference'} { } ... { 'Style', 'text', 'string', curref }, { 'Style', 'text', 'string', '(EEG.ref)'} ... }; if EEG.trials == 1, uilist(21:24) = []; geometry(6) = []; end; [results newcomments] = inputgui( geometry, uilist, 'pophelp(''pop_editset'');', ... fastif(isempty(EEG.data), 'Import dataset info -- pop_editset()', 'Edit dataset info -- pop_editset()'), EEG.comments); if length(results) == 0, return; end; args = {}; if ~strcmp( results{1}, EEG.setname ), args = { args{:}, 'setname', results{1} }; end; if ~strcmp( results{2}, num2str(EEG.pnts) ) , args = { args{:}, 'pnts', str2num(results{2}) }; end; if ~strcmp( results{3}, num2str(EEG.srate) ) , args = { args{:}, 'srate', str2num(results{3}) }; end; if EEG.trials ~= 1, if ~strcmp( results{4}, num2str(EEG.xmin) ), args = { args{:}, 'xmin', str2num(results{4}) }; end; i = 5; else i = 4; end; if ~strcmp( results{i }, fastif(isempty(EEG.chanlocs), '', 'EEG.chanlocs') ) , args = { args{:}, 'chanlocs' , results{i} }; end; if ~strcmp( results{i+1}, fastif(isempty(EEG.icaweights), '', 'EEG.icaweights') ), args = { args{:}, 'icaweights', results{i+1} }; end; if ~strcmp( results{i+2}, fastif(isempty(EEG.icasphere), '', 'EEG.icasphere') ) , args = { args{:}, 'icasphere', results{i+2} }; end; if ~strcmp(EEG.comments, newcomments), args = { args{:}, 'comments' , newcomments }; end;else % no interactive inputs args = varargin; % Do not copy varargin % -------------------- %for index=1:2:length(args) % if ~isempty(inputname(index+2)) & ~isstr(args{index+1}) & length(args{index+1})>1, % args{index+1} = inputname(index+1); % end; %end; end;% create structure% ----------------if ~isempty(args) try, g = struct(args{:}); catch, disp('Setevent: wrong syntax in function arguments'); return; end;else g = [];end;% test the presence of variables% ------------------------------try, g.dataformat; catch, g.dataformat = 'ascii'; end;% assigning values% ----------------tmpfields = fieldnames(g);for curfield = tmpfields' switch lower(curfield{1}) case {'dataformat' }, ; % do nothing now case 'setname' , EEGOUT.setname = getfield(g, {1}, curfield{1}); case 'pnts' , EEGOUT.pnts = getfield(g, {1}, curfield{1}); case 'comments', EEGOUT.comments = getfield(g, {1}, curfield{1}); case 'averef' , disp('The ''averef'' argument is obsolete; use function pop_reref() instead'); case 'nbchan' , EEGOUT.nbchan = getfield(g, {1}, curfield{1}); case 'xmin' , oldxmin = EEG.xmin; EEGOUT.xmin = getfield(g, {1}, curfield{1}); if ~isempty(EEG.event) if nargin < 2 if ~popask( ['Warning: changing the starting point of epochs will' 10 'lead to recomputing epoch event latencies ?'] ) error('Pop_editset: transformation cancelled by user'); end; end; if isfield(EEG.event, 'latency') for index = 1:length(EEG.event) EEG.event(index).latency = EEG.event(index).latency - (EEG.xmin-oldxmin)*EEG.srate; end; end; end; case 'srate' , EEGOUT.srate = getfield(g, {1}, curfield{1}); case 'chanlocs', varname = getfield(g, {1}, curfield{1}); if isempty(varname) EEGOUT.chanlocs = []; elseif isstr(varname) & exist( varname ) == 2 fprintf('Pop_editset: channel locations file ''%s'' found\n', varname); EEGOUT.chanlocs = readlocs(varname); elseif isstr(varname) EEGOUT.chanlocs = evalin('base', varname, 'fprintf(''Pop_editset warning: variable ''''%s'''' not found, ignoring\n'', varname)' ); else EEGOUT.chanlocs = varname; end; case 'icaweights', varname = getfield(g, {1}, curfield{1}); if isstr(varname) & exist( varname ) == 2 fprintf('Pop_editset: ICA weight matrix file ''%s'' found\n', varname); try, EEGOUT.icaweights = load(varname, '-ascii'); EEGOUT.icawinv = []; catch, try EEGOUT.icaweights = floatread(varname, [1 Inf]); EEGOUT.icaweights = reshape( EEGOUT.icaweights, [length(EEGOUT.icaweights)/EEG.nbchan EEG.nbchan]); catch fprintf('Pop_editset warning: error while reading filename ''%s'' for ICA weight matrix\n', varname); end; end; else if isempty(varname) EEGOUT.icaweights = []; elseif isstr(varname) EEGOUT.icaweights = evalin('base', varname, 'fprintf(''Pop_editset warning: variable ''''%s'''' not found, ignoring\n'', varname)' ); EEGOUT.icawinv = []; else EEGOUT.icaweights = varname; EEGOUT.icawinv = []; end; end; if ~isempty(EEGOUT.icaweights) & isempty(EEGOUT.icasphere) EEGOUT.icasphere = eye(size(EEGOUT.icaweights,2)); end; case 'icasphere', varname = getfield(g, {1}, curfield{1}); if isstr(varname) & exist( varname ) == 2 fprintf('Pop_editset: ICA sphere matrix file ''%s'' found\n', varname); try, EEGOUT.icasphere = load(varname, '-ascii'); EEGOUT.icawinv = []; catch, try EEGOUT.icasphere = floatread(varname, [1 Inf]); EEGOUT.icasphere = reshape( EEGOUT.icasphere, [length(EEGOUT.icasphere)/EEG.nbchan EEG.nbchan]); catch fprintf('Pop_editset warning: erro while reading filename ''%s'' for ICA weight matrix\n', varname); end; end; else if isempty(varname) EEGOUT.icasphere = []; elseif isstr(varname) EEGOUT.icasphere = evalin('base', varname, 'fprintf(''Pop_editset warning: variable ''''%s'''' not found, ignoring\n'', varname)' ); EEGOUT.icawinv = []; else EEGOUT.icaweights = varname; EEGOUT.icawinv = []; end; end; if ~isempty(EEGOUT.icaweights) & isempty(EEGOUT.icasphere) EEGOUT.icasphere = eye(size(EEGOUT.icaweights,2)); end; case 'data' , varname = getfield(g, {1}, curfield{1}); if isnumeric(varname) EEGOUT.data = varname; elseif exist( varname ) == 2 & ~strcmp(lower(g.dataformat), 'array'); fprintf('Pop_editset: raw data file ''%s'' found\n', varname); switch lower(g.dataformat) case 'ascii' , try, EEGOUT.data = load(varname, '-ascii'); catch, error(['Pop_editset error: cannot read ascii file ''' varname ''' ']); end; if ndims(EEGOUT.data)<3 & size(EEGOUT.data,1) > size(EEGOUT.data,2), EEGOUT.data = transpose(EEGOUT.data); end; case 'matlab', try, x = whos('-file', varname); if length(x) > 1, error('Pop_editset error: .mat file must contain a single variable'); end; tmpdata = load(varname, '-mat'); EEGOUT.data = getfield(tmpdata,{1},x(1).name); clear tmpdata; catch, error(['Pop_editset error: cannot read .mat file ''' varname ''' ']); end; if ndims(EEGOUT.data)<3 & size(EEGOUT.data,1) > size(EEGOUT.data,2), EEGOUT.data = transpose(EEGOUT.data); end; case {'float32le' 'float32be'}, if EEGOUT.nbchan == 0, error(['Pop_editset error: to read float32 data you must first specify the number of channels']); end; try, EEGOUT.data = floatread(varname, [EEGOUT.nbchan Inf], ... fastif(strcmpi(g.dataformat, 'float32le'), 'ieee-le', 'ieee-be')); catch, error(['Pop_editset error: cannot read float32 data file ''' varname ''' ']); end; otherwise, error('Pop_editset error: unrecognized file format'); end; elseif isstr(varname) % restoration command %-------------------- try res = evalin('base', ['exist(''' varname ''') == 1']); catch disp('Pop_editset warning: cannot find specified variable in global workspace!'); end; if ~res, error('Pop_editset: cannot find specified variable.'); end; testval = evalin('base', ['isglobal(' varname ')']); warning off; if ~testval commandrestore = [ ' tmpp = ' varname '; clear global ' varname ';' varname '=tmpp;clear tmpp;' ]; else commandrestore = []; end; % make global, must make these variable global, if you try to evaluate them direclty in the base % workspace, with a large array the computation becomes incredibly slow. %-------------------------------------------------------------------- comglobal = sprintf('global %s;', varname); evalin('base', comglobal); eval(comglobal); eval( ['EEGOUT.data = ' varname ';' ]); try, evalin('base', commandrestore); catch, end; warning on; else EEGOUT.data = varname; if ndims(EEGOUT.data)<3 & size(EEGOUT.data,1) > size(EEGOUT.data,2), EEGOUT.data = transpose(EEGOUT.data); end; end; otherwise, error(['Pop_editset error: unrecognized field ''' curfield{1} '''']); end;end;% generate the output command% ---------------------------if nargout > 1 com = sprintf( '%s = pop_editset(%s', inputname(1), inputname(1) ); for i=1:2:length(args) if ~isempty( args{i+1} ) if isstr( args{i+1} ) com = sprintf('%s, ''%s'', %s', com, args{i}, vararg2str(args{i+1}) ); else com = sprintf('%s, ''%s'', [%s]', com, args{i}, num2str(args{i+1}) ); end; else com = sprintf('%s, ''%s'', []', com, args{i} ); end; end; com = [com ');'];end;return;function num = popask( text ) ButtonName=questdlg2( text, ... 'Confirmation', 'Cancel', 'Yes','Yes'); switch lower(ButtonName), case 'cancel', num = 0; case 'yes', num = 1; end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -