cevent_diff takes two cevents and find the moments in these two lists that have non-zero different category labels. Warning: this is accomplished using a transformation to a cstream, so a cevent that has overlapping events will lose this overlapping data! Also, the start and end times of the events may change by a small amount. Input: two cevents Output: DiffEvent: Nx4 [onset offset label_in_cevent1 label_in_cevent2] this function will intersect two cevent variables to find shared moments that both have non-zero values and extrast a new list that contain only the moments they have different values

- cevent2cstream cevent2cstream Generte stream from event
- cevent_remove_small_segments cevent_remove_small_segments deletes event intervals that are too small
- cevent_shared cevent_shared takes two cevent and find the shared segments
- cstream2cevent cstream2cevent Convert cstream data to cevent data
- cstream_equal_length

0001 function [diffEvent] = cevent_diff(cevent1, cevent2) 0002 % cevent_diff takes two cevents and find the moments in these two lists that have non-zero different category labels. 0003 % 0004 % 0005 % Warning: this is accomplished using a transformation to a cstream, so a cevent 0006 % that has overlapping events will lose this overlapping data! Also, the start 0007 % and end times of the events may change by a small amount. 0008 % 0009 % Input: two cevents 0010 % Output: DiffEvent: Nx4 [onset offset label_in_cevent1 label_in_cevent2] 0011 % 0012 % this function will intersect two cevent variables to find shared moments that both have non-zero values 0013 % and extrast a new list that contain only the moments they have different 0014 % values 0015 % 0016 0017 % first find the shared cevent3 0018 cevent3 = cevent_shared(cevent1, cevent2); 0019 0020 % convert cevent1 and cevent 3 into two streams 0021 timeInterval = 0.005; % this should be high enough 0022 startTime = 0; % default; 0023 defaultValue = 0; 0024 cstream1 = cevent2cstream(cevent1, startTime, timeInterval, defaultValue); 0025 cstream2 = cevent2cstream(cevent2, startTime, timeInterval, defaultValue); 0026 cstream3 = cevent2cstream(cevent3, startTime, timeInterval, defaultValue); 0027 [cstream1 cstream2] = cstream_equal_length(cstream1, cstream2); 0028 [cstream1 cstream3] = cstream_equal_length(cstream1, cstream3); 0029 0030 % assigne all non-zero shared items to be zero 0031 index3 = find(cstream3(:,2) ~= 0); 0032 index1 = find(cstream1(:,2) == 0); 0033 index2 = find(cstream2(:,2) == 0); 0034 index = union(union(index1,index2), index3); 0035 cstream1(index,2) = 0; 0036 cstream2(index,2) = 0; 0037 0038 factor = ceil(log10(cstream1(:,2))); 0039 cstream3 = cstream1; 0040 cstream3(:,3) = cstream1(:,2) + factor .* cstream2(:,2); 0041 % convert it back to cevent 0042 cevent3 = cstream2cevent(cstream3, 0); 0043 cevent3 = cevent_remove_small_segments(cevent3,0.03); 0044 0045 % go back to real category values. 0046 diffEvent = cevent3; 0047 for i = 1 : size(diffEvent,1) 0048 index = find(cstream1(:,1) >= diffEvent(i,1)); 0049 diffEvent(i,3) = cstream1(index(1),2); 0050 index = find(cstream2(:,1) >= diffEvent(i,1)); 0051 diffEvent(i,4) = cstream2(index(1),2); 0052 end; 0053 0054

Generated on Tue 23-May-2017 20:00:55 by