Home > bioelectromagnetism > elec_load_brainstorm.m

elec_load_brainstorm

PURPOSE ^

elec_load_brainstorm - Load brainstorm Channel data into eeg_toolbox

SYNOPSIS ^

function[p] = elec_load_brainstorm(p)

DESCRIPTION ^

 elec_load_brainstorm - Load brainstorm Channel data into eeg_toolbox
 
 Usage: [p] = elec_load_brainstorm(p)
 
 where:    p.elec.path & p.elec.file define the brainsform file
 
 The brainstorm file consists of Channel, which is an array of 
 structures.  The fields are:
           
     Loc     - a 3x2 matrix of electrode coordinates (x,y,z in rows).
               BrainStorm (x,y,z meters) = 3Dspace (x,y,z cm) / 100.
     Orient  - a corresponding matrix of sensor orientations (MEG); 
               all zero for EEG.
     Weight  - a vector of relative or absolute weights (eg, amplification);
               all ones for this routine.
     Type    - a character string, 'EEG' in this case.
     Name    - a charater string indicating the electrode name.
     Comment - a charater string indicating the reference electrode.  Empty
               for active electrodes and 'EEG REF' for reference electrode.
 
 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_load_brainstorm(p)
0002 
0003 % elec_load_brainstorm - Load brainstorm Channel data into eeg_toolbox
0004 %
0005 % Usage: [p] = elec_load_brainstorm(p)
0006 %
0007 % where:    p.elec.path & p.elec.file define the brainsform file
0008 %
0009 % The brainstorm file consists of Channel, which is an array of
0010 % structures.  The fields are:
0011 %
0012 %     Loc     - a 3x2 matrix of electrode coordinates (x,y,z in rows).
0013 %               BrainStorm (x,y,z meters) = 3Dspace (x,y,z cm) / 100.
0014 %     Orient  - a corresponding matrix of sensor orientations (MEG);
0015 %               all zero for EEG.
0016 %     Weight  - a vector of relative or absolute weights (eg, amplification);
0017 %               all ones for this routine.
0018 %     Type    - a character string, 'EEG' in this case.
0019 %     Name    - a charater string indicating the electrode name.
0020 %     Comment - a charater string indicating the reference electrode.  Empty
0021 %               for active electrodes and 'EEG REF' for reference electrode.
0022 %
0023 % See brainstorm website at http://neuroimage.usc.edu/, including a
0024 % download pdf file describing the brainstorm database formats.
0025 %
0026 
0027 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0028 
0029 % Licence:  GNU GPL, no express or implied warranties
0030 % History:  11/2002, Darren.Weber_at_radiology.ucsf.edu
0031 %
0032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0033 
0034 if ~exist('p', 'var'), error('...no p struct input\n');
0035 elseif isempty(p),     error('...no p struct input\n');
0036 end
0037 
0038 fprintf('\nELEC_LOAD_BRAINSTORM...\n'); tic;
0039 
0040 fprintf('...Converting brainstorm to p structure.\n');
0041 
0042 
0043 [path,file,ext] = fileparts(strcat(p.elec.path,filesep,p.elec.file));
0044 bsfile = fullfile(path,[file ext]);
0045 
0046 load(bsfile, 'Channel');
0047 
0048 for i=1:length(Channel),
0049     
0050     if findstr(lower(Channel(i).Comment),'ref'),
0051         p.elec.data.ref = Channel(i).Loc(:,1)';
0052     else
0053         p.elec.data.x(i,1) = Channel(i).Loc(1,1);
0054         p.elec.data.y(i,1) = Channel(i).Loc(2,1);
0055         p.elec.data.z(i,1) = Channel(i).Loc(3,1);
0056         p.elec.data.label{i,1} = Channel(i).Name;
0057     end
0058 end
0059 
0060 p.elec.data.centroid = [0 0 0];
0061 p.elec.data.nasion = [];
0062 p.elec.data.lpa = [];
0063 p.elec.data.rpa = [];
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