📄 readlocs.m
字号:
% readlocs() - read electrode location coordinates and other information from a file. % Several standard file formats are supported. Users may also specify % a custom column format. Defined format examples are given below % (see File Formats).% Usage:% >> eloc = readlocs( filename );% >> EEG.chanlocs = readlocs( filename, 'key', 'val', ... ); % >> [eloc, labels, theta, radius, indices] = readlocs( filename, 'key', 'val', ... );%% Inputs:% filename - Name of the file containing the electrode locations% Default is 2-D polar coordinates (see >> help topoplot )%% Optional inputs:% 'filetype' - ['loc'|'sph'|'sfp'|'xyz'|'asc'|'polhemus'|'besa'|'chanedit'|'custom'] % Type of the file to read. By default the file type is determined % using the file extension (see below under File Formats):% 'loc' - an EEGLAB 2-D polar coordinates channel locations file % Coordinates are theta and radius (see definitions below).% 'sph' - Matlab spherical coordinates (Note: spherical% coordinates used by Matlab functions are different % from spherical coordinates used by BESA - see below).% 'sfp' - EGI Cartesian coordinates (NOT Matlab Cartesian - see below).% 'xyz' - Matlab/EEGLAB Cartesian coordinates (NOT EGI Cartesian).% z is toward nose; y is toward left ear; z is toward vertex% 'asc' - Neuroscan polar coordinates.% 'polhemus' or 'polhemusx' - Polhemus electrode location file recorded % with 'X' on sensor pointing to subject (see below and readelp()).% 'polhemusy' - Polhemus electrode location file recorded with % 'Y' on sensor pointing to subject (see below and readelp()).% 'besa' - BESA-'.elp' spherical coordinates. (Not MATLAB spherical -% see below).% 'chanedit' - EEGLAB channel location file created by pop_chanedit().% 'custom' - Ascii file with columns in user-defined 'format' (see below).% 'format' - [cell array] Format of a 'custom' channel location file (see above).% Default, if no file type is defined. The cell array contains% labels defining the meaning of each column of the input file:% 'channum' [positive integer] channel number % 'labels' [string] channel name (no spaces)% 'theta' [real degrees] 2-D angle in polar coordinates; % positive = rotating from nose (0) toward left ear % 'radius' [real] radius for 2-D polar coords; 0.5 is the head % disk radius and limit for topoplot() plotting)% 'X' [real] Matlab-Cartesian X coordinate (to nose)% 'Y' [real] Matlab-Cartesian Y coordinate (to left ear)% 'Z' [real] Matlab-Cartesian Z coordinate (to vertex)% '-X','-Y','-Z' Matlab-Cartesian coordinates pointing opposite% to the above.% 'sph_theta' [real degrees] Matlab spherical horizontal angle; % positive = rotating from nose (0) toward left ear.% 'sph_phi' [real degrees] Matlab spherical elevation angle;% positive = rotating from horizontal (0) upwards.% 'sph_radius' [real] distance from head center (unused) % 'sph_phi_besa' [real degrees] BESA phi angle from vertical; % positive = rotating from vertex (0) towards right ear.% 'sph_theta_besa' [real degrees] BESA theta horiz/azimuthal angle; % positive = rotating from right ear (0) toward nose.% 'ignore' ignore column% The input file may also contain other channel information fields% 'type' channel type: 'EEG', 'MEG', 'EMG', 'ECG', others ...% 'calib' [real near 1.0] channel calibration value.% 'gain' [real > 1] channel gain. % 'custom1' custom field #1.% 'custom2', 'custom3', 'custom4', etc. more custom fields% 'skiplines' - [integer] Number of header lines to skip (in 'custom' file types only).% Note: Characters on a line following '%' will be treated as comments.% 'readchans' - [integer array] indices of electrodes to read. Default is all.% 'center' - [(1,3) real array or 'auto'] center of xyz coordinates for conversion % to spherical or polar, Specify the center of the sphere here, or 'auto'. % This uses the center of the sphere that best fits all the electrode % locations read. Default is [0 0 0].% Outputs:% eloc - structure containing the channel names and locations (if present).% It has three fields: 'eloc.labels', 'eloc.theta' and 'eloc.radius' % identical in meaning to the EEGLAB struct 'EEG.chanlocs'.% labels - cell array of strings giving the names of the electrodes. NOTE: Unlike the% three outputs below, includes labels of channels *without* location info.% theta - vector (in degrees) of polar angles of the electrode locations.% radius - vector of polar-coordinate radii (arc_lengths) of the electrode locations % indices - indices, k, of channels with non-empty 'locs(k).theta' coordinate%% File formats:% If 'filetype' is unspecified, the file extension determines its type.%% '.loc' or '.locs': % polar coordinates. Notes: angles in degrees: % right ear is 90; left ear -90; head disk radius is 0.5. % Fields: N angle radius label% Sample: 1 -18 .511 Fp1 % 2 18 .511 Fp2 % 3 -90 .256 C3% 4 90 .256 C4% ...% Note: In previous releases, channel labels had to contain exactly % four characters (spaces replaced by '.'). This format still works, % though dots are no longer required.% '.sph':% Matlab spherical coordinates. Notes: theta is the azimuthal/horizontal angle% in deg.: 0 is toward nose, 90 rotated to left ear. Following this, performs% the elevation (phi). Angles in degrees.% Fields: N theta phi label% Sample: 1 18 -2 Fp1% 2 -18 -2 Fp2% 3 90 44 C3% 4 -90 44 C4% ...% '.elc':% Cartesian 3-D electrode coordinates scanned using the EETrak software. % See readeetraklocs().% '.elp': % Polhemus-.'elp' Cartesian coordinates. By default, an .elp extension is read% as PolhemusX-elp in which 'X' on the Polhemus sensor is pointed toward the % subject. Polhemus files are not in columnar format (see readelp()).% '.elp':% BESA-'.elp' spherical coordinates: Need to specify 'filetype','besa'.% The elevation angle (phi) is measured from the vertical axis. Positive % rotation is toward right ear. Next, perform azimuthal/horizontal rotation % (theta): 0 is toward right ear; 90 is toward nose, -90 toward occiput. % Angles are in degrees. If labels are absent or weights are given in % a last column, readlocs() adjusts for this. Default labels are E1, E2, ...% Fields: label phi theta % Sample: Fp1 -92 -72 % Fp2 92 72 % C3 -46 0 % C4 46 0 % ...% '.xyz': % Matlab/EEGLAB Cartesian coordinates. Here. x is towards the nose, % y is towards the left ear, and z towards the vertex.% Fields: channum x y z label% Sample: 1 .950 .308 -.035 Fp1% 2 .950 -.308 -.035 Fp2% 3 0 .719 .695 C3% 4 0 -.719 .695 C4% ...% '.asc', '.dat': % Neuroscan-.'asc' or '.dat' Cartesian polar coordinates text file.% '.sfp': % BESA/EGI-xyz Cartesian coordinates. Notes: For EGI, x is toward right ear, % y is toward the nose, z is toward the vertex. EEGLAB converts EGI % Cartesian coordinates to Matlab/EEGLAB xyz coordinates. % Fields: label x y z% Sample: Fp1 -.308 .950 -.035 % Fp2 .308 .950 -.035 % C3 -.719 0 .695 % C4 .719 0 .695 % ...% '.ced': % ASCII file saved by pop_chanedit(). Contains multiple MATLAB/EEGLAB formats.% Cartesian coordinates are as in the 'xyz' format (above).% Fields: channum label theta radius x y z sph_theta sph_phi ...% Sample: 1 Fp1 -18 .511 .950 .308 -.035 18 -2 ...% 2 Fp2 18 .511 .950 -.308 -.035 -18 -2 ...% 3 C3 -90 .256 0 .719 .695 90 44 ...% 4 C4 90 .256 0 -.719 .695 -90 44 ...% ...% The last columns of the file may contain any other defined fields (gain,% calib, type, custom).%% Author: Arnaud Delorme, Salk Institute, 8 Dec 2002 (expanded from the previous EEG/ICA % toolbox function)%% See also: readelp(), writelocs(), topo2sph(), sph2topo(), sph2cart()%123456789012345678901234567890123456789012345678901234567890123456789012% Copyright (C) Arnaud Delorme, CNL / Salk Institute, 28 Feb 2002%% 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: readlocs.m,v $% Revision 1.64 2004/03/23 00:37:56 scott% clarifying help msg re meaning of 'indices' output%% Revision 1.63 2004/03/23 00:22:51 scott% clarified meaning of output 'indices'%% Revision 1.62 2004/02/24 17:17:32 arno% dbug message%% Revision 1.61 2004/01/01 19:12:08 scott% help message edits%% Revision 1.60 2004/01/01 18:57:26 scott% edit text outputs%% Revision 1.59 2004/01/01 01:47:34 scott% franglais -> anglais%% Revision 1.58 2003/12/17 00:55:07 arno% debug last%% Revision 1.57 2003/12/17 00:50:10 arno% adding index for non-empty electrodes%% Revision 1.56 2003/12/05 18:37:56 arno% debug polhemus x and y fixed%% Revision 1.55 2003/12/02 03:21:39 arno% neuroscan format%% Revision 1.54 2003/11/27 00:38:13 arno% conversion elc%% Revision 1.53 2003/11/27 00:31:30 arno% debuging elc format%% Revision 1.52 2003/11/27 00:25:51 arno% automatically detecting elc files%% Revision 1.51 2003/11/05 17:20:23 arno% first convert spherical instead of carthesian%% Revision 1.50 2003/09/18 00:07:05 arno% further checks for neuroscan%% Revision 1.49 2003/07/16 18:52:21 arno% allowing file type locs%% Revision 1.48 2003/06/30 15:00:43 arno% fixing inputcheck problem%% Revision 1.47 2003/05/13 23:31:25 arno% number of lines to skip in chanedit format%% Revision 1.46 2003/05/13 22:09:01 arno% updating sph format%% Revision 1.45 2003/05/13 22:07:07 arno% removing labels in sfp format%% Revision 1.44 2003/05/13 21:14:11 arno% only write a subset of file format%% Revision 1.43 2003/03/10 16:28:12 arno% removing help for elc%% Revision 1.42 2003/03/10 16:26:59 arno% adding then removing .elc format%% Revision 1.41 2003/03/08 17:36:13 arno% import spherical EGI files correctly%% Revision 1.40 2003/03/05 15:38:15 arno% fixing '.' bug%% Revision 1.39 2003/03/04 20:04:44 arno% adding neuroscan .asc format%% Revision 1.38 2003/01/30 16:45:12 arno% debugging ced format%% Revision 1.37 2003/01/10 17:40:11 arno% removing trailing dots%% Revision 1.36 2003/01/03 22:47:00 arno% typo in warning messages%% Revision 1.35 2003/01/03 22:45:48 arno% adding another warning message%% Revision 1.34 2003/01/03 22:41:38 arno% autodetect format .sfp%% Revision 1.33 2003/01/03 22:38:39 arno% adding warning message%% Revision 1.32 2002/12/29 23:04:00 scott% header%% Revision 1.31 2002/12/29 22:37:15 arno% txt -> ced%% Revision 1.30 2002/12/29 22:35:35 arno% adding coords. info for file format in header, programming .sph, ...%% Revision 1.29 2002/12/29 22:00:10 arno% skipline -> skiplines%% Revision 1.28 2002/12/28 23:46:45 scott% header%% Revision 1.27 2002/12/28 02:02:35 scott% header details%% Revision 1.26 2002/12/28 01:32:41 scott% worked on header information - axis details etcetc. -sm & ad%% Revision 1.25 2002/12/27 23:23:35 scott% edit header msg - NEEDS MORE DETAILS -sm%% Revision 1.24 2002/12/27 22:57:23 arno% debugging polhemus%% Revision 1.23 2002/12/27 17:47:32 arno% compatible with more BESA formats%% Revision 1.22 2002/12/26 16:41:23 arno% new release%% Revision 1.21 2002/12/24 02:51:22 arno% new version of readlocs%function [eloc, labels, theta, radius, indices] = readlocs( filename, varargin ); if nargin < 1 help readlocs; return;end;% to add a new channel format% ---------------------------% 1) add the format name at the end of the listtype variable list% 2) enter the column type in a new list at the end of the listimportformat variable% 3) enter the number of lines to skip at the end of the listskiplines array% Note: these infos are also used by writelocs() and pop_readlocs() but% you do not have to edit these functions.listtype = { ... 'polhemus' ... 'polhemusX' ... 'polhemusY' ...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -