File size: 690 Bytes
6654bb7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function [EEG did_epoch] = h_epoch(EEG,markers,epoch_length)
tempevents={EEG.event(:).type};
if isnumeric(tempevents{1});
	tempevents2=textscan(sprintf('%d ',tempevents{:}),'%s ');
	tempevents2=tempevents2{1}';

	events = unique(tempevents2);

else

	events = unique(tempevents);

end

if ~iscell(markers)

	epoch_markers=textscan(num2str(markers),'%s ');
	epoch_markers=epoch_markers{1}';

else

	epoch_markers=markers;

end

[cell_markers ia]=intersect(events,epoch_markers);

if ~isempty(ia)

    EEG=pop_epoch(EEG,cell_markers,epoch_length);

    did_epoch=1;

else

    warning('No epochs that were specified are present in the file. Data was not epoched.')

    did_epoch=0;

end