Home > data-analysis > manip > cevent > cevent_shared.m

cevent_shared

PURPOSE ^

cevent_shared takes two cevent and find the shared segments

SYNOPSIS ^

function [cevent] = cevent_shared(cevent1, cevent2)

DESCRIPTION ^

 cevent_shared takes two cevent and find the shared segments

 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.


 cevent_shared(cevent1, cevent2)
 Input: two cevents
 Output: a new event with shared moments of these two events

   this function will intersect two cevent variables and extrast a new
   list. Each event in the new list must 1) share the same category label;
   2) shared temporal moments.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [cevent] = cevent_shared(cevent1, cevent2)
0002 % cevent_shared takes two cevent and find the shared segments
0003 %
0004 % Warning: this is accomplished using a transformation to a cstream, so a cevent
0005 % that has overlapping events will lose this overlapping data!  Also, the start
0006 % and end times of the events may change by a small amount.
0007 %
0008 %
0009 % cevent_shared(cevent1, cevent2)
0010 % Input: two cevents
0011 % Output: a new event with shared moments of these two events
0012 %
0013 %   this function will intersect two cevent variables and extrast a new
0014 %   list. Each event in the new list must 1) share the same category label;
0015 %   2) shared temporal moments.
0016 %
0017 %
0018 
0019 % first convert two cevents into two cstreams
0020 timeInterval = 0.01; % this should be high enough
0021 startTime = 0; % default;
0022 defaultValue = 0; 
0023 cstream1 = cevent2cstream(cevent1, startTime, timeInterval, defaultValue);
0024 cstream2 = cevent2cstream(cevent2, startTime, timeInterval, defaultValue);
0025 
0026 % find the shared moments between two cstreams
0027 % these two need to have the same length
0028 [cstream1 cstream2] = cstream_equal_length(cstream1, cstream2);
0029 data{1} = cstream1; data{2} = cstream2;
0030 p = 1; 
0031 [cstream] = cstream_shared(data, p); 
0032 
0033 % convert it back to cevent
0034 cevent = cstream2cevent(cstream); 
0035

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005