function [lvl_mean,lvl_std,lvl_data] = Level_STD_Comp(I_array,sub_event_size)

ipt=findchangepts(I_array,'MaxNumChanges',2);

if isempty(ipt)==0
    ipt=sort(unique([1;ipt(1);ipt(end)-1;sub_event_size]));
    true_levels=length(ipt)-1;
    lvl_length=zeros(true_levels,1);
        for i=1:true_levels
            lvl_length(i)=ipt(i+1)-ipt(i);
        end

    [~,I]=max(lvl_length);
    lvl_data=I_array(ipt(I):ipt(I+1));
    lvl_mean=mean(lvl_data);
    lvl_std=std(lvl_data);
else
    lvl_data=I_array;
    lvl_mean=mean(lvl_data);
    lvl_std=std(lvl_data);
end
end