Home > bioelectromagnetism > elec_write_brainstorm.m

elec_write_brainstorm

PURPOSE ^

elec_write_brainstorm - Write p.elec.data to brainstorm file

SYNOPSIS ^

function [p] = elec_write_brainstorm(p)

DESCRIPTION ^

 elec_write_brainstorm - Write p.elec.data to brainstorm file
 
 Useage: [p] = elec_write_brainstorm(p)
 
 The electrode orientation saved is consistent with the BrainStorm
 'Neuromag' orientation system, where +x is through the right ear
 and +y is through the nasion.
 
 See brainstorm website at http://neuroimage.usc.edu/, including a
 download pdf file describing the brainstorm database formats.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [p] = elec_write_brainstorm(p)
0002 
0003 % elec_write_brainstorm - Write p.elec.data to brainstorm file
0004 %
0005 % Useage: [p] = elec_write_brainstorm(p)
0006 %
0007 % The electrode orientation saved is consistent with the BrainStorm
0008 % 'Neuromag' orientation system, where +x is through the right ear
0009 % and +y is through the nasion.
0010 %
0011 % See brainstorm website at http://neuroimage.usc.edu/, including a
0012 % download pdf file describing the brainstorm database formats.
0013 %
0014 
0015 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:34 $
0016 
0017 % Licence:  GNU GPL, no express or implied warranties
0018 % History:  10/2002, Darren.Weber_at_radiology.ucsf.edu
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 tic;
0023 
0024 fprintf('\nELEC_WRITE_BRAINSTORM...\n');
0025 fprintf('...Converting to brainstorm structure.\n');
0026 
0027 Ee = p.elec.data.label;
0028 Xe = p.elec.data.x;
0029 Ye = p.elec.data.y;
0030 Ze = p.elec.data.z;
0031 
0032 Eref = 'Ref';
0033 Xref = p.elec.data.ref(1);
0034 Yref = p.elec.data.ref(2);
0035 Zref = p.elec.data.ref(3);
0036 
0037 for i=1:length(Xe),
0038     Channel(i).Loc = [[Xe(i) Ye(i) Ze(i)]',[Xref Yref Zref]']; % See note below
0039     Channel(i).Orient = [];     % used for MEG rather than EEG
0040     Channel(i).Weight = 1;      % used for MEG rather than EEG
0041     Channel(i).Type = 'EEG';
0042     Channel(i).Name = char(Ee(i));
0043     Channel(i).Comment = '';
0044 end
0045 Channel(i+1).Loc = [[Xref Yref Zref]',[Xref Yref Zref]'];
0046 Channel(i+1).Orient = [];
0047 Channel(i+1).Weight = 1;
0048 Channel(i+1).Type = 'EEG';
0049 Channel(i+1).Name = char(Eref);
0050 Channel(i+1).Comment = 'EEG REF';
0051 
0052 
0053 [path,name,ext] = fileparts(strcat(p.elec.path,filesep,p.elec.file));
0054 name = sprintf('%s_channel',name);
0055 ext  = '.mat';
0056 file = fullfile(path,[name ext]);
0057 
0058 fprintf('...saving BrainStorm channel data to:\n\t%s\n',file);
0059 save(file, 'Channel');
0060 
0061 % channel(i).Loc field replicates the X,Y,Z coordinates of each
0062 % electrode to conform with a format that accommodates MEG coordinates,
0063 % which include two sensors per channel.
0064 
0065 t = toc; fprintf('...done (%6.2f sec).\n\n',t);
0066 
0067 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003