generate a cstream containing the shared values in a set of variables [cstream] = cstream_shared(data, p) this function takes a cell array of cstream variables that are already timely synched and with the same dimension, and then generate a new combined cstream with non-zero items in the new stream referring to values that are above a pre-defined threshould p, indicating the consensus between those variables. Data is a cell array of cstream variables p is the threshold of the consensus 0<p<1 cstream is a return cstream variable nx2 there are two main usages of this funciton. 1. finding the shared moments of multiple cevent varialbes. setting p = 1, it is like a logical AND opertion for categorical events. 2. finding the consensus of the data. In the case that each cevent is the data from one person, we can call this function to get the concensus (e.g. 80% of Ss are looking at a location). Another example is a set of cevent derived from the same person, this function can be used to calculate the person is both looking at, manipulating, and heading toward, naming the same object, for instance. Plus, this funciton is more general than binary event-based operations, therefore it can be used instead of event_and().

- temp INHAND_DATA = INHAND_DATA

- cevent_shared cevent_shared takes two cevent and find the shared segments
- cstream_best_overlap this function attempts to align one cstream to the other and finds the

0001 function [cstream] = cstream_shared(data, p) 0002 % 0003 % generate a cstream containing the shared values in a set of variables 0004 %[cstream] = cstream_shared(data, p) 0005 % this function takes a cell array of cstream variables that are already 0006 % timely synched and with the same dimension, and then generate a new combined cstream with non-zero items 0007 % in the new stream referring to values that are above a pre-defined threshould p, indicating the consensus between those variables. 0008 % 0009 % Data is a cell array of cstream variables 0010 % p is the threshold of the consensus 0<p<1 0011 % cstream is a return cstream variable nx2 0012 % 0013 % there are two main usages of this funciton. 0014 % 1. finding the shared moments of multiple cevent varialbes. setting p = 0015 % 1, it is like a logical AND opertion for categorical events. 0016 % 0017 % 2. finding the consensus of the data. In the case that each cevent is the 0018 % data from one person, we can call this function to get the concensus 0019 % (e.g. 80% of Ss are looking at a location). Another example is a set of 0020 % cevent derived from the same person, this function can be used to 0021 % calculate the person is both looking at, manipulating, and heading 0022 % toward, naming the same object, for instance. 0023 % 0024 % Plus, this funciton is more general than binary event-based operations, 0025 % therefore it can be used instead of event_and(). 0026 % 0027 0028 nvar = size(data,2); 0029 0030 if nvar < 2 0031 fprintf(1,'you need to input at least more than two variables'); 0032 return; 0033 elseif ((p>1) || (p<0)) 0034 fprintf(1, 'the consensus parameter should be between 0 and 1'); 0035 return; 0036 end; 0037 0038 % check timestamps in all the variables, they should be the same (synched) 0039 for i= 1 : nvar-1 0040 if (size(data{i},1) ~= size(data{i+1},1)) 0041 fprintf(1, 'variables have different lengths\n'); 0042 return; 0043 end; 0044 if (data{i}(:,1) ~= data{i+1}(:,1)) 0045 fprintf(1,'data are not synched \n'); 0046 return; 0047 end; 0048 end; 0049 0050 % extracting value columns 0051 for i = 1 : nvar 0052 data1(:,i) = data{i}(:,2); 0053 end; 0054 0055 % ini a new stream 0056 cstream = zeros(size(data{1})); 0057 cstream(:,1) = data{1}(:,1); 0058 0059 % extracting shared moments (the total number of shared elements is greater than the threshold) 0060 for i = 1 : size(data1,1) 0061 list = sort(unique(data1(i,:))); 0062 freq = histc(data1(i,:), list); 0063 [temp index] = max(freq); 0064 if ( freq(index)/sum(freq) >= p) 0065 cstream(i,2) = list(index); 0066 0067 end; 0068 end; 0069 0070

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