function [latenciez_o_pre,latenciez_a_pre,latenciez_b_pre,crit_o_pre,crit_a_pre,crit_b_pre,latenciez_o_post,latenciez_a_post,latenciez_b_post,crit_o_post,crit_a_post,crit_b_post]...
    =find_detection_crits_and_latencies(indivcritlength,preinduction_crit,postinduction_crit,thresh);

latenciez_o_pre=zeros(1,size(preinduction_crit,2));latenciez_a_pre=latenciez_o_pre;latenciez_b_pre=latenciez_o_pre;
crit_o_pre=latenciez_o_pre;crit_a_pre=latenciez_o_pre;crit_b_pre=latenciez_o_pre;
for p=1:size(preinduction_crit,2)
    if find(preinduction_crit(1:indivcritlength,p)>thresh),...
            above_crit_o=find(preinduction_crit(1:indivcritlength,p)>thresh);
        latenciez_o_pre(p)=above_crit_o(1);end
    if find(preinduction_crit((indivcritlength+1):(2*indivcritlength),p)>thresh),...
            above_crit_a=find(preinduction_crit((indivcritlength+1):(2*indivcritlength),p)>thresh);
        latenciez_a_pre(p)=above_crit_a(1);end 
    if find(preinduction_crit((2*indivcritlength+1):(3*indivcritlength),p)>thresh),...
            above_crit_b=find(preinduction_crit((2*indivcritlength+1):(3*indivcritlength),p)>thresh);
        latenciez_b_pre(p)=above_crit_b(1);end 
end
crit_o_pre(find(latenciez_o_pre))=1;crit_a_pre(find(latenciez_a_pre))=1;crit_b_pre(find(latenciez_b_pre))=1;

latenciez_o_post=zeros(1,size(postinduction_crit,2));latenciez_a_post=latenciez_o_post;latenciez_b_post=latenciez_o_post;
crit_o_post=latenciez_o_post;crit_a_post=latenciez_o_post;crit_b_post=latenciez_o_post;
for p=1:size(postinduction_crit,2)
    if find(postinduction_crit(1:indivcritlength,p)>thresh),...
            above_crit_o=find(postinduction_crit(1:indivcritlength,p)>thresh);
        latenciez_o_post(p)=above_crit_o(1);end
    if find(postinduction_crit((indivcritlength+1):(2*indivcritlength),p)>thresh),...
            above_crit_a=find(postinduction_crit((indivcritlength+1):(2*indivcritlength),p)>thresh);
        latenciez_a_post(p)=above_crit_a(1);end 
    if find(postinduction_crit((2*indivcritlength+1):(3*indivcritlength),p)>thresh),...
            above_crit_b=find(postinduction_crit((2*indivcritlength+1):(3*indivcritlength),p)>thresh);
        latenciez_b_post(p)=above_crit_b(1);end 
end
crit_o_post(find(latenciez_o_post))=1;crit_a_post(find(latenciez_a_post))=1;crit_b_post(find(latenciez_b_post))=1;