⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eeg_toolbox_defaults.m

📁 Matlab下的EEG处理程序库
💻 M
字号:
function [p] = eeg_toolbox_defaults(action,p);

% EEG_TOOLBOX_DEFAULTS - Create, read, write eeg_toolbox defaults
%
% Useage:   [p] = eeg_toolbox_defaults(action,[p])
%
% action  =   'create'
%             'read'
%             'write' or 'write_other'
% p       =   structure returned by create|read action
%             structure to write for write action
%
% All read and write actions are to a matlab .mat file.  The
% 'write_other' action 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('write',p);  % write current p as default
% eeg_toolbox_defaults('write_other',p); % write current p data
%
% The 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.
%

% $Revision: 1.3 $ $Date: 2003/04/07 06:12:02 $

% Licence:  GNU GPL, no express or implied warranties
% Created:  01/2002 Darren.Weber@flinders.edu.au
% Modified: 02/2002 Darren.Weber@flinders.edu.au
%           - adapted read/write output from .txt format 
%             to .mat format so it will contain data structures.
%             Hence, it is no longer editable text.
%           08/2002 Darren.Weber@flinders.edu.au
%                   added MRI defaults
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~exist('action','var'), action = 'create'; end

% try to locate the installation path
eegPath = fileparts(which('eeg_toolbox'));
if isempty(eegPath),
    msg = sprintf('Cannot find eeg_toolbox on the matlab path.\nPlease use the addpath command.\n\n');
    error(msg);
else
    eegPath = strcat(eegPath,filesep);
end


% try to locate the mri_toolbox installation path
mriPath = fileparts(which('avw_view'));
if isempty(mriPath),
    msg = sprintf('Cannot find mri_toolbox on the matlab path.\nPlease install and use the addpath command.\n\n');
    warning(msg);
    mriPath = eegPath;
else
    mriPath = strcat(mriPath,filesep);
end



switch action
case 'create'
    
    % default location for parameter file
    p.file = strcat(eegPath,'eeg_example_data',filesep,'eeg_toolbox_defaults.mat');
    
    % parameters for 'elec_load' routine, see that for more information
    p.elec.path     = strcat(eegPath,'eeg_example_data',filesep);
    p.elec.file     = 'elec_124_cart.txt';
    p.elec.n        = 129;         % how many electrodes to load
    p.elec.type     = 'Cartesian'; % see elec_load for avail. options
    p.elec.shape    = 'sphere';    % original = '', 'sphere', or 'ellipse'
    p.elec.data     = [];
    p.elec.plot     = 0; % plot electrode positions
    p.elec.plotSurf = 1; % plot electrode surface (from convhull)
    
    % parameters for 'mesh_open' & 'mesh_plot', see these for more information
    p.mesh.path         = strcat(eegPath,'eeg_example_data',filesep);
    p.mesh.file         = 'BrainStorm_subjecttess.mat';
    p.mesh.type         = 'BrainStorm'; % see mesh_open.m for options
    p.mesh.data         = []; % init for mesh_open.m
    p.mesh.plot         = 0; % boolean arg for mesh_open.m
    p.mesh.plot.overlay = 0; % Overlay arg in mesh_plot.m
    p.mesh.plotSurf     = 0; % plot scalp mesh surface (eeg_contours_engine)
    p.mesh.reload       = 1; % boolean, 1 = reload mesh data
    p.mesh.samplePoint  = [];
    
    % parameters for 'mri_open' & 'avw_view', see these for more information
    p.mri.path          = strcat(mriPath,'mri_example_data',filesep);
    p.mri.file          = 'T1.img';  % SPM T1 template
    p.mri.type          = 'Analyze'; % Analyze files
    p.mri.orient        = 'auto';
    p.mri.data          = [];
    p.mri.fiducials     = []; % MRI fiducial points
    p.mri.IEEEMachine   = 'ieee-le'; % Assume little endian MRI data
    p.mri.plot          = 0;
    
    % parameters for 'eeg_open' routine, see that for more information
    p.volt.path                 = strcat(eegPath,'eeg_example_data',filesep);
    p.volt.file                 = 'eeg_124ch.dat';
    p.volt.type                 = 'ASCII'; % see eeg_open.m for valid options
    
    p.volt.data                 = []; % potential (uV)
    p.volt.var                  = []; % variance for ERP (uV^2)
    p.volt.timeArray            = []; % The timing of each sample point (msec)
    p.volt.points               = []; % Number of sample points in epoch
    p.volt.sampleHz             = []; % Sample rate (Hz)
    p.volt.sampleMsec           = []; % Sample rate (msec)
    p.volt.sampleTime           = []; % Time of current sample point (msec)
    p.volt.samplePoint          = []; % single or start time point (row of p.volt.data)
    p.volt.channels             = []; % Number of channels/electrodes
    p.volt.epochStart           = []; % Time of epoch start (msec)
    p.volt.epochEnd             = []; % Time of epoch end (msec)
    p.volt.sweeps               = []; % Number of accepted sweeps
    p.volt.peaks                = []; % Data array of ERP peak values
    p.volt.interpZero           = 1;  % Interpolate time zero ERP potential,
    % mainly for ascii versions of NeuroScan data
    
    
    % parameters for 'eeg_contours_engine', see that for more information
    p.rangeMethod                 = 'minmaxabs' ; % minmax? = 'abs','one','all','giv'
    p.minimumIntensity            =  -10    ;	
    p.maximumIntensity            =   10    ;
    p.interpMethod                = 'cubic' ;   % matlab griddata interpolation method
    
    p.timeMethod                  =    1    ;   % 1=single time point, 2=range of time points
    p.endTime                     =    2    ;   % finish time point (row of p.volt.data)
    
    p.contour.stepMethod          =  0; % 0 is step size, 1 is number of steps
    p.contour.Nsteps              = 10;
    p.contour.stepSize            =  1; % 1 uV or similar units
    p.contour.raw2D               =  0; % plot 2D contours
    p.contour.plot2D              =  0; % plot projected 2D contours
    p.contour.plot3D              =  0; % plot 3D surface contours
    
    % Now defunct (02/2003), as topo maps now use triangulations, rather than meshgrid
    % keeping for now, just in case they prove useful at some later date
    p.grid.method                  =    1    ;   % Use grid size method
    p.grid.size                    =  100    ;
    p.grid.sizeMin                 =   10    ;
    p.grid.sizeMax                 =  210    ;
    p.grid.res                     =    0.1  ;   % 1 mm
    p.grid.resMin                  =    0.01 ;
    p.grid.resMax                  =    2.01 ;
    
    % Miscellaneous
    p.clickTimePoint              = 0;   % select a time point interactively
    p.saveGraphics                = 'No Save Plots'; % Do not save graphic files by default
    p.topoView                    = '2D'; % Default topography view
    p                             = eeg_colormap(p); % Return defaults for 'eeg_colormap'
    p.hold                        = 0;   % default for GUI hold checkboxes
    
case 'read'
    
    % Look for default file 
    [path,name,ext] = fileparts(strcat(eegPath,'eeg_toolbox_defaults.mat'));
    p.file = fullfile(path,[name ext]);
    file = exist(p.file);
    if file == 2,
        fprintf('...reading eeg_toolbox defaults from:\n%s\n\n',p.file);
        load(p.file);
    else
        fprintf('...cannot locate eeg_toolbox defaults - recreating defaults.\n\n');
        p = eeg_toolbox_defaults;
    end
    
case 'write'
    
    if ~exist('p','var'),
        msg = sprintf('p argument is essential: eeg_toolbox_defaults(''write'',p)\n');
        error(msg);
    end
    
    [path,name,ext] = fileparts(strcat(eegPath,'eeg_toolbox_defaults.mat'));
    p.file = fullfile(path,[name ext]);
    
    save(p.file,'p');
    
    fprintf('...saved eeg_toolbox defaults to:\n%s\n\n',p.file);
    
case 'write_other'
    
    if ~exist('p','var'),
        msg = sprintf('p argument is essential: eeg_toolbox_defaults(''write_other'',p)\n');
        error(msg);
    end
    
    [path,name,ext] = fileparts(strcat(p.volt.path, filesep, p.volt.file));
    ext = '.mat';
    p.file = fullfile(path,[name ext]);
    
    save(p.file,'p');
    
    fprintf('...saved eeg_toolbox parameters to:\n%s\n',p.file);
    
    recentfiles = eeg_toolbox_recent(p.file);
    
otherwise
    error('Invalid action\n');
end

return

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -