function [id,duration] = find_id_duration(labels,behav_bin)

duration = []; id = [];
i = 1;
while i <= length(labels)

    if labels(i) == 1
        temp = find(labels(i+1:end) ~= 1,1,'first');
        if length(temp) == 0 
            temp = length(labels(i:end));
        end
        duration = [duration temp];
        id = [id 1];
        i = i + temp;
    elseif labels(i) == 2
        temp = find(labels(i+1:end) ~= 2,1,'first');
        if length(temp) == 0
            temp = length(labels(i:end));
        end
        duration = [duration temp];
        id = [id 2];
        i = i + temp;
    elseif labels(i) == 3
        temp = find(labels(i+1:end) ~= 3,1,'first');
        if length(temp) == 0
            temp = length(labels(i:end));
        end
        duration = [duration temp];
        id = [id 3];
        i = i + temp;
    elseif labels(i) == 0
        temp = find(labels(i+1:end) ~= 0,1,'first');
        if length(temp) == 0
            temp = length(labels(i:end));
        end
        duration = [duration temp];
        id = [id 0];
        i = i + temp;
    end
end

duration = duration*behav_bin; 







