Home > data-analysis > manip > event > get_event_in_scope.m

get_event_in_scope

PURPOSE ^

event_in_scope: Return part of the events that is in the scope

SYNOPSIS ^

function event_in_scope = get_event_in_scope(event, scope)

DESCRIPTION ^

event_in_scope: Return part of the events that is in the scope
   USAGE: event_in_scope = get_event_in_scope(event, scope)
   Input:
     event: (binary) event data;
     scope: the range 
   Output:
     event_in_scope:   part of the events that is in the scope
   Example:
     data = get_variable(52, 'cont_cam1_obj1');
     event = get_variable(52,'event_motion_sensor1_orient');
     event_in_scope = get_event_in_scope(event, [data(1,1) data(length(data),1)]);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function event_in_scope = get_event_in_scope(event, scope)
0002 %event_in_scope: Return part of the events that is in the scope
0003 %   USAGE: event_in_scope = get_event_in_scope(event, scope)
0004 %   Input:
0005 %     event: (binary) event data;
0006 %     scope: the range
0007 %   Output:
0008 %     event_in_scope:   part of the events that is in the scope
0009 %   Example:
0010 %     data = get_variable(52, 'cont_cam1_obj1');
0011 %     event = get_variable(52,'event_motion_sensor1_orient');
0012 %     event_in_scope = get_event_in_scope(event, [data(1,1) data(length(data),1)]);
0013 %
0014 
0015 if isempty(event)
0016     event_in_scope = [];
0017     return
0018 end
0019 
0020 start_too_late = event(:, 1) > scope(2);
0021 end_too_soon = event(:, 2) < scope(1);
0022 omit = start_too_late | end_too_soon;
0023 
0024 shaggy = event(~ omit, :);
0025 
0026 % now we trim it..
0027 event_in_scope = [ max(shaggy(:, 1), scope(1)) , min(shaggy(:, 2), scope(2)) ];
0028 if size(shaggy, 2) > 2
0029     event_in_scope = [ event_in_scope, shaggy(:, 3:end) ];
0030 end

Generated on Wed 24-May-2017 00:00:56 by m2html © 2005