📄 adjustlocs.m
字号:
% adjustlocs() - read neuroscan polar location file (.asc)%% Usage:% >> chanlocs = adjustlocs( chanlocs );% >> chanlocs = adjustlocs( chanlocs, 'key1', val1, 'key2', val2, ...);%% Inputs:% chanlocs - EEGLAB channel location data structure. See% help readlocs()%% Optional inputs:% 'center' - [cell array] one or several electrode names to compute% center location (if several electrodes are provided, the% function use their iso-barycenter). Ex: { 'cz' } or % { 'fz' 'pz' }.% 'autocenter' - ['on'|'off'] attempt to automatically detect all symetrical% electrode in the 10-20 system to compute the center. % Default: 'on'.% 'rotate' - [cell array] name and planar angle of landmark electrodes% to use as template planar rotation. Ex: { 'c3', 90 }.% 'autorotate' - ['on'|'off'] attempt to automatically detect % electrode in the 10-20 system to compute the average% planar rotation. Default 'on'.% 'scale' - [cell array] name and phi angle of electrodes along% horizontal central line. Ex: { 'c3' 44 }. Scale uniformly% all direction. Use 'hscale' and 'vscale' for scaling x and% y axis independently.% 'hscale' - [cell array] name and phi angle of electrodes along% honrizontal central line. Ex: { 'c3' 44 }.% 'vscale' - [cell array] name and phi angle of one electrodes along% central vertical axis. Ex: { 'fz' 44 }.% 'autoscale' - ['on'|'off'] automatic scaling with 10-20 system used as% reference. Default is 'on'.% 'uniform' - ['on'|'off'] force the scaling to be uniform along the X% and the Y axis. Default is 'on'.% 'coordinates' - ['pol'|'sph'|'cart'] use polar coordinates ('pol'), sperical% coordinates ('sph') or cartesian ('cart'). Default is 'sph'.% (Note that using polar and spherical coordinates have the % same effect, except that units are different). % Default is 'sph'.%% Outputs:% chanlocs - EEGLAB channel location data structure. See% help readlocs()%% Note: operations are performed in the following order, first re-centering% then planar rotation and finally sperical re-scaling.%% Author: Arnaud Delorme, CNL / Salk Institute, 1 Dec 2003%% See also: readlocs()%123456789012345678901234567890123456789012345678901234567890123456789012% Copyright (C) 2003 Arnaud Delorme, Salk Institute, arno@salk.edu%% This program is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2 of the License, or% (at your option) any later version.%% This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA% $Log: adjustlocs.m,v $% Revision 1.4 2003/12/17 23:18:02 arno% debug scaling%% Revision 1.3 2003/12/10 01:19:28 arno% typo%% Revision 1.2 2003/12/02 19:16:54 arno% remove verbose option%% Revision 1.1 2003/12/02 02:34:33 arno% Initial revision%function chanlocs = adjustlocs( chanlocs, varargin) if nargin < 1 help adjustlocs; return; end; % check input parameters % ---------------------- g = finputcheck( varargin, { 'hscale' 'cell' [] {}; 'vscale' 'cell' [] {}; 'scale' 'cell' [] {}; 'center' 'cell' [] {}; 'rotate' 'cell' [] {}; 'autoscale' 'string' { 'on' 'off' } 'off'; 'autocenter' 'string' { 'on' 'off' } 'on'; 'autorotate' 'string' { 'on' 'off' } 'on'; 'uniform' 'string' { 'on' 'off' } 'on'; 'coordinates' 'string' { 'pol' 'sph' 'cart' } 'sph' }); if isstr(g), error(g); end; names = { chanlocs.labels }; % auto center % ----------- if strcmpi(g.autocenter, 'on') & isempty(g.center) disp('Reading template 10-20 file'); locs1020 = readlocs('eeglab1020.ced'); % scan electrodes for horiz pos % ----------------------------- tmpnames = lower(names); tmpnames1020 = lower({ locs1020.labels }); [tmp indelec] = intersect(tmpnames1020, tmpnames); % remove non-symetrical electrodes % -------------------------------- if ~isempty(indelec) if find(indelec == 79), indelec(end+1) = 80; end; % for Cz ind2remove = []; for index = 1:length(indelec) if mod(indelec(index),2) if ~ismember(indelec(index)+1, indelec) ind2remove = [ ind2remove index ]; end; else if ~ismember(indelec(index)-1, indelec) ind2remove = [ ind2remove index ]; end; end; end; indelec(ind2remove) = []; if find(indelec == 80), indelec(end) = []; end; % for Cz g.center = tmpnames1020(indelec); end; if isempty(g.center) disp('No electrodes found for auto-centering') else disp([ num2str(length(g.center)) ' landmark electrodes found for position auto-centering' ]) end; end; % auto rotate % ----------- if strcmpi(g.autorotate, 'on') & isempty(g.rotate) if exist('locs1020') ~= 1 disp('Reading template 10-20 file'); locs1020 = readlocs('eeglab1020.ced'); end; % scan electrodes for horiz pos % ----------------------------- tmpnames = lower(names); tmpnames1020 = lower({ locs1020.labels }); tmptheta1020 = { locs1020.theta }; [tmp indelec] = intersect(tmpnames1020(1:end-1), tmpnames); % do not use cz g.rotate(1:2:2*length(indelec)) = tmpnames1020 (indelec); g.rotate(2:2:2*length(indelec)+1) = tmptheta1020(indelec); if isempty(g.rotate) disp('No electrodes found for auto planar rotation') else disp([ num2str(length(g.rotate)/2) ' landmark electrodes found for auto planar rotation' ]) end; end; % auto scale % ---------- if strcmpi(g.autoscale, 'on') & isempty(g.hscale) & isempty(g.vscale) if exist('locs1020') ~= 1 disp('Reading template 10-20 file'); locs1020 = readlocs('eeglab1020.ced'); end; if strcmpi(g.uniform, 'off') % remove all vertical electrodes for horizontal scaling % ----------------------------------------------------- theta = cell2mat({locs1020.theta}); indxh = find(abs(theta) == 90); indxv = union(find(theta == 0) , find(theta == 180)); locs1020horiz = locs1020(indxh); locs1020vert = locs1020(indxv); % scan electrodes for horiz pos % ----------------------------- tmpnames = lower(names); tmpnames1020 = lower({ locs1020horiz.labels }); tmpradius1020 = { locs1020horiz.radius }; [tmp indelec] = intersect(tmpnames1020, tmpnames); if isempty(indelec) disp('No electrodes found for horiz. position spherical re-scaling') else disp([ num2str(length(indelec)) ' landmark electrodes found for horiz. position spherical re-scaling' ]); if strcmpi(g.coordinates, 'cart') g.hscale(2:2:2*length(indelec)+1) = cell2mat({ locs1020horiz.Y }); else g.hscale(2:2:2*length(indelec)+1) = tmpradius1020(indelec); end; end; % scan electrodes for vert. pos % ----------------------------- tmpnames1020 = lower({ locs1020vert.labels }); tmpradius1020 = { locs1020vert.radius }; [tmp indelec] = intersect(tmpnames1020, tmpnames); if isempty(indelec) disp('No electrodes found for vertical position spherical re-scaling') else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -