Home > eeg > utils > convert_biosemi_locs.m

convert_biosemi_locs

PURPOSE ^

convert_biosemi_locs.m

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 convert_biosemi_locs.m

 Creates .ced files from Biosemi files

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % convert_biosemi_locs.m
0002 %
0003 % Creates .ced files from Biosemi files
0004 
0005 fpath = '/afs/cmb.ucdavis.edu/share/matlab/janata/eeg/electrode_files';
0006 
0007 files = {'biosemi_128ch.txt', ...
0008       'biosemi_256ch.txt'};
0009 
0010 nfiles = length(files);
0011 
0012 for ifile = 1:nfiles
0013   fname = fullfile(fpath, files{ifile});
0014   fprintf('Converting file: %s\n', fname);
0015   
0016   eloc = readlocs(fname,'filetype','custom',...
0017     'format',{'labels','custom1','custom2','custom3'});
0018 
0019   nchan = length(eloc);
0020   for ichan = 1:nchan
0021     % Convert phi coordinates
0022     eloc(ichan).sph_phi = -abs(eloc(ichan).custom1)+90;
0023     
0024     % Convert the theta coordinates
0025     eloc(ichan).sph_theta = eloc(ichan).custom2-90*sign(eloc(ichan).custom1);
0026   end
0027   
0028   % Remove the custom fields
0029   rmfield(eloc,{'custom1','custom2','custom3'});
0030   
0031   % Save as .ced file
0032   [fpath,fstub] = fileparts(fname);
0033   outfname = fullfile(fpath, sprintf('%s.ced',fstub));
0034   fprintf('Writing new electrode location file to: %s\n', outfname);
0035   writelocs(eloc,outfname,'filetype','chanedit');
0036 end % for ifile=

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003