Home > bioelectromagnetism > eeg_toolbox_defaults.m

eeg_toolbox_defaults

PURPOSE ^

eeg_toolbox_defaults - Create, read, write eeg_toolbox defaults

SYNOPSIS ^

function [p] = eeg_toolbox_defaults(command,p);

DESCRIPTION ^

 eeg_toolbox_defaults - Create, read, write eeg_toolbox defaults

 Useage: [p] = eeg_toolbox_defaults(command,[p])

 command  =  'create'
             'read'
             'save'   | 'write'
             'saveas' | 'write_other'
 p        =  structure returned by create|read command
             structure to write for write command
 
 All read and write commands are to a matlab .mat file.  The
 'saveas' or 'write_other' command will write out a data specific archive
 that can be accessed from the recent files list.  It will be located in
 the folder where the eeg data is opened.
 
 Examples:
[p] = eeg_toolbox_defaults; % create new defaults
[p] = eeg_toolbox_defaults('read'); % read saved defaults
 eeg_toolbox_defaults('save',p);  % write current p as default
 eeg_toolbox_defaults('saveas',p); % write current p data

 The save or write command will write to the eeg_toolbox
 installation folder.  The read command will first 
 try to find the paramater file in the eeg_toolbox
 installation and otherwise recreates the defaults.

 Notes:    Handles parameter structure for the 
           eeg_toolbox routines.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [p] = eeg_toolbox_defaults(command,p);
0002 
0003 % eeg_toolbox_defaults - Create, read, write eeg_toolbox defaults
0004 %
0005 % Useage: [p] = eeg_toolbox_defaults(command,[p])
0006 %
0007 % command  =  'create'
0008 %             'read'
0009 %             'save'   | 'write'
0010 %             'saveas' | 'write_other'
0011 % p        =  structure returned by create|read command
0012 %             structure to write for write command
0013 %
0014 % All read and write commands are to a matlab .mat file.  The
0015 % 'saveas' or 'write_other' command will write out a data specific archive
0016 % that can be accessed from the recent files list.  It will be located in
0017 % the folder where the eeg data is opened.
0018 %
0019 % Examples:
0020 %[p] = eeg_toolbox_defaults; % create new defaults
0021 %[p] = eeg_toolbox_defaults('read'); % read saved defaults
0022 % eeg_toolbox_defaults('save',p);  % write current p as default
0023 % eeg_toolbox_defaults('saveas',p); % write current p data
0024 %
0025 % The save or write command will write to the eeg_toolbox
0026 % installation folder.  The read command will first
0027 % try to find the paramater file in the eeg_toolbox
0028 % installation and otherwise recreates the defaults.
0029 %
0030 % Notes:    Handles parameter structure for the
0031 %           eeg_toolbox routines.
0032 %
0033 
0034 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0035 
0036 % Licence:  GNU GPL, no express or implied warranties
0037 % Created:  01/2002 Darren.Weber_at_radiology.ucsf.edu
0038 % Modified: 02/2002 Darren.Weber_at_radiology.ucsf.edu
0039 %           - adapted read/write output from .txt format
0040 %             to .mat format so it will contain data structures.
0041 %             Hence, it is no longer editable text.
0042 %           08/2002 Darren.Weber_at_radiology.ucsf.edu
0043 %                   added MRI defaults
0044 %
0045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0046 
0047 eegversion = '$Revision: 1.1 $';
0048 fprintf('\nEEG_TOOLBOX_DEFAULTS [v %s]\n',eegversion(11:15));
0049 
0050 if version('-release') < 10,
0051     msg = printf('matlab release < version 10, eeg_toolbox GUIs may fail.\n');
0052     warning(msg);
0053 end
0054 
0055 if ~exist('command','var'), command = 'create'; end
0056 
0057 % try to locate the installation path
0058 eegPath = eeg_toolbox_path;
0059 
0060 
0061 % try to locate the mri_toolbox installation path
0062 mriPath = fileparts(which('avw_view'));
0063 if isempty(mriPath),
0064     msg = sprintf('Cannot find mri_toolbox on the matlab path.\nPlease install and use the addpath command.\n\n');
0065     warning(msg);
0066     mriPath = eegPath;
0067 else
0068     mriPath = strcat(mriPath,filesep);
0069 end
0070 
0071 % remove any saved preferences
0072 if ispref('eeg_toolbox'),
0073     rmpref('eeg_toolbox');
0074 end
0075 
0076 
0077 switch command
0078 case 'create',
0079     
0080     fprintf('...creating eeg_toolbox defaults\n\n');
0081     
0082    [p] = [];
0083     
0084     % default location for parameter file
0085     p.file = strcat(eegPath,'eeg_example_data',filesep,'eeg_toolbox_defaults.mat');
0086     
0087     % parameters for 'elec_load' routine, see that for more information
0088     p.elec.path     = strcat(eegPath,'eeg_example_data',filesep);
0089     p.elec.file     = 'elec_124_cart.txt';
0090     p.elec.n        = 129;         % how many electrodes to load
0091     p.elec.type     = 'Cartesian'; % see elec_load for avail. options
0092     p.elec.shape    = 'sphere';    % original = '', 'sphere', or 'ellipse'
0093     p.elec.data     = [];
0094     p.elec.plot     = 0; % plot electrode positions
0095     p.elec.plotSurf = 1; % plot electrode surface (from convhull)
0096     
0097     % parameters for 'mesh_open' & 'mesh_plot', see these for more information
0098     p.mesh.path         = strcat(eegPath,'eeg_example_data',filesep);
0099     p.mesh.file         = 'BrainStorm_subjecttess.mat';
0100     p.mesh.type         = 'BrainStorm'; % see mesh_open.m for options
0101     p.mesh.data         = []; % init for mesh_open.m
0102     p.mesh.plot.open    = 0; % boolean arg for mesh_open.m
0103     p.mesh.plot.overlay = 0; % Overlay arg in mesh_plot.m
0104     p.mesh.plotSurf     = 0; % plot scalp mesh surface (eeg_contours_engine)
0105     p.mesh.reload       = 1; % boolean, 1 = reload mesh data
0106     p.mesh.samplePoint  = [];
0107     p.mesh.sampleTime   = []; % Time of current sample point (msec)
0108     p.mesh.sampleMsec   = []; % Sample rate (msec)
0109     p.mesh.sampleHz     = []; % Sample rate (Hz)
0110     
0111     % parameters for 'eeg_open' routine, see that for more information
0112     p.volt.path                 = strcat(eegPath,'eeg_example_data',filesep);
0113     p.volt.file                 = 'eeg_124ch.dat';
0114     p.volt.type                 = 'ascii'; % see eeg_open.m for valid options
0115     
0116     p.volt.data                 = []; % potential (uV)
0117     p.volt.var                  = []; % variance for ERP (uV^2)
0118     p.volt.timeArray            = []; % The timing of each sample point (msec)
0119     p.volt.points               = []; % Number of sample points in epoch
0120     p.volt.sampleHz             = 400; % Sample rate (Hz)
0121     p.volt.sampleMsec           = 2.5; % Sample rate (msec)
0122     p.volt.sampleTime           = 400; % Time of current sample point (msec)
0123     p.volt.samplePoint          = 250; % single or start time point (row of p.volt.data)
0124     p.volt.channels             = []; % Number of channels/electrodes
0125     p.volt.epochStart           = -200; % Time of epoch start (msec)
0126     p.volt.epochEnd             = 1500; % Time of epoch end (msec)
0127     p.volt.sweeps               = []; % Number of accepted sweeps
0128     p.volt.peaks                = []; % Data array of ERP peak values
0129     p.volt.interpZero           = 1;  % Interpolate time zero ERP potential,
0130     % mainly for ascii versions of NeuroScan data
0131     
0132     p.cnt.path                  = strcat(eegPath,'eeg_example_data',filesep);
0133     p.cnt.file                  = 'scan41_short.cnt';
0134     p.cnt.type                  = 'scan4x_cnt';
0135     
0136     p.eeg.path                  = strcat(eegPath,'eeg_example_data',filesep);
0137     p.eeg.file                  = 'scan41_short.eeg';
0138     p.eeg.type                  = 'scan4x_eeg';
0139     
0140     
0141     
0142     % parameters for 'erf_open' routine, see that for more information
0143     p.erf.path                 = strcat(eegPath,'eeg_example_data',filesep);
0144     p.erf.file                 = 'eeg_124ch.dat';
0145     p.erf.type                 = 'ascii'; % see eeg_open.m for valid options
0146     
0147     p.erf.data                 = [];   % potential (Tesla)
0148     p.erf.var                  = [];   % variance for ERF (T^2)
0149     p.erf.timeArray            = [];   % The timing of each sample point (msec)
0150     p.erf.points               = [];   % Number of sample points in epoch
0151     p.erf.sampleHz             = 400;  % Sample rate (Hz)
0152     p.erf.sampleMsec           = 2.5;  % Sample rate (msec)
0153     p.erf.sampleTime           = 400;  % Time of current sample point (msec)
0154     p.erf.samplePoint          = 250;  % single or start time point (row of p.erf.data)
0155     p.erf.channels             = [];   % Number of channels/electrodes
0156     p.erf.epochStart           = -200; % Time of epoch start (msec)
0157     p.erf.epochEnd             = 1500; % Time of epoch end (msec)
0158     p.erf.sweeps               = [];   % Number of accepted sweeps
0159     p.erf.peaks                = [];   % Data array of ERP peak values
0160     p.erf.interpZero           = 0;    % Interpolate time zero ERF potential
0161     
0162     
0163                                        
0164     % parameters for 'eeg_contours_engine', see that for more information
0165     p.rangeMethod                 = 'minmaxabs' ; % minmax? = 'abs','one','all','giv'
0166     p.minimumIntensity            =  -10    ;    
0167     p.maximumIntensity            =   10    ;
0168     p.interpMethod                = 'cubic' ;   % matlab griddata interpolation method
0169     
0170     p.timeMethod                  =    1    ;   % 1=single time point, 2=range of time points
0171     p.endTime                     =    2    ;   % finish time point (row of p.volt.data)
0172     
0173     p.contour.stepMethod          =  0; % 0 is step size, 1 is number of steps
0174     p.contour.Nsteps              = 10;
0175     p.contour.stepSize            =  1; % 1 uV or similar units
0176     p.contour.raw2D               =  0; % plot 2D contours
0177     p.contour.plot2D              =  0; % plot projected 2D contours
0178     p.contour.plot3D              =  0; % plot 3D surface contours
0179     
0180     % Now defunct (02/2003), as topo maps now use triangulations, rather than meshgrid
0181     % keeping for now, just in case they prove useful at some later date
0182     p.grid.method                  =    1    ;   % Use grid size method
0183     p.grid.size                    =  100    ;
0184     p.grid.sizeMin                 =   10    ;
0185     p.grid.sizeMax                 =  210    ;
0186     p.grid.res                     =    0.1  ;   % 1 mm
0187     p.grid.resMin                  =    0.01 ;
0188     p.grid.resMax                  =    2.01 ;
0189     
0190     % Miscellaneous
0191     p.clickTimePoint              = 0;   % select a time point interactively
0192     p.saveGraphics                = 'No Save Plots'; % Do not save graphic files by default
0193     p.topoView                    = '2D'; % Default topography view
0194     p                             = eeg_colormap(p); % Return defaults for 'eeg_colormap'
0195     p.hold                        = 0;   % default for GUI hold checkboxes
0196     
0197 case 'read'
0198     
0199     % Look for default file
0200     [path,name,ext] = fileparts(strcat(eegPath,'eeg_toolbox_defaults.mat'));
0201     p.file = fullfile(path,[name ext]);
0202     file = exist(p.file);
0203     if file == 2,
0204         fprintf('...reading eeg_toolbox defaults from:\n%s\n\n',p.file);
0205         load(p.file);
0206     else
0207         fprintf('...cannot locate eeg_toolbox defaults - recreating defaults.\n\n');
0208        [p] = eeg_toolbox_defaults;
0209     end
0210     
0211     % verify that path to default files exists;
0212     % if not, create defaults again (I hope this will avoid
0213     % new installation problems)
0214     voltPathExist = exist(p.volt.path);
0215     if ~voltPathExist,
0216         fprintf('...voltage path does not exist - reinitializing defaults.\n');
0217        [p] = eeg_toolbox_defaults('create');
0218         eeg_toolbox_defaults('write',p);
0219     end
0220     
0221 case {'write','save'}
0222     
0223     if ~exist('p','var'),
0224         msg = sprintf('p argument is essential: eeg_toolbox_defaults(''write'',p)');
0225         error(msg);
0226     end
0227     
0228     [path,name,ext] = fileparts(strcat(eegPath,'eeg_toolbox_defaults.mat'));
0229     p.file = fullfile(path,[name ext]);
0230     
0231     save(p.file,'p');
0232     
0233     fprintf('...saved eeg_toolbox defaults to:\n%s\n\n',p.file);
0234     
0235 case {'write_other','saveas'}
0236     
0237     if ~exist('p','var'),
0238         msg = sprintf('p argument is essential: eeg_toolbox_defaults(''write_other'',p)');
0239         error(msg);
0240     end
0241     
0242     [path,name,ext] = fileparts(strcat(p.volt.path, filesep, p.volt.file));
0243     ext = '.mat';
0244     p.file = fullfile(path,[name ext]);
0245     
0246     
0247     [newfile,newpath] = uiputfile(p.file,'Save EEG_TOOLBOX Parameters to File:');
0248     if (newfile == 0) & (newpath == 0),
0249         fprintf('...aborting save\n\n');
0250     else
0251         [path,name,ext] = fileparts(strcat(newpath, filesep, newfile));
0252         ext = '.mat';
0253         p.file = fullfile(path,[name ext]);
0254         save(p.file,'p');
0255         fprintf('...saved eeg_toolbox parameters to:\n%s\n\n',p.file);
0256         recentfiles = eeg_toolbox_recent(p.file);
0257     end
0258     
0259 otherwise
0260     error('...invalid command\n\n');
0261 end
0262 
0263 return

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