Home > eeg > utils > insert_marks.m

insert_marks

PURPOSE ^

This function can be called to load a set of region marks from a mat file

SYNOPSIS ^

function insert_marks(EEG)

DESCRIPTION ^

 This function can be called to load a set of region marks from a mat file
 to the .winrej field of 'UserData' in the eegplot figure showing data
 that is being edited.

 insert_marks(EEG);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function insert_marks(EEG)
0002 % This function can be called to load a set of region marks from a mat file
0003 % to the .winrej field of 'UserData' in the eegplot figure showing data
0004 % that is being edited.
0005 %
0006 % insert_marks(EEG);
0007 %
0008 
0009 % 27Jun2012 Petr Janata
0010 
0011 % Get the UserData from the current figure and make sure that it has a
0012 % .winrej field
0013 
0014 if nargin < 1
0015     error('Please provide EEG info structure')
0016 end
0017 
0018 g = get(gcf,'UserData');
0019 if ~isfield(g, 'winrej')
0020     error(['No winrej field found in UserData.' ...
0021         'Make sure that the EEG data are showing in a window'])
0022 end
0023 
0024 % Specify a file to read rejection information from
0025 [fpath,fstub,fext] = fileparts(EEG.filename);
0026 outfname = fullfile(EEG.filepath, sprintf('%s_marks.mat',fstub));
0027 
0028 % Make sure the file exists
0029 if ~exist(outfname,'file')
0030     error('File with marks does not exist: %s\n', outfname)
0031 end
0032 
0033 fprintf('Loading marks from file: %s\n', outfname);
0034 load(outfname, 'winrej');
0035 fprintf('Found %d marks\n', size(winrej,1));
0036 
0037 g.winrej = winrej;
0038 
0039 % Write the information out to the UserData associated with the figure
0040 % object
0041 set(gcf,'UserData',g);

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