function isActive = cba_threshold(p_vol, z, isbrain,q, isadapt)
 %active voxels with FDR:
 pvec = zeros(max(max(max(z))),1);
 ind=1;
for k=1:max(max(max(z)))
    if (sum(isbrain(z==k))>0)
        p = p_vol(z==k);
        pvec(ind) = p(1);
        ind = ind+1;
    end
end
pvec = pvec(1:ind-1);
 [pID,pN,pA] = fdr(pvec,q)
if isadapt==0 & ~isempty(pID)
     isActive = p_vol<=pID;   
    isActive(isbrain==0) = 0;
else
    if isadapt==1 & ~isempty(pA)
         isActive = p_vol<=pA;   
        isActive(isbrain==0) = 0;
    else
        isActive = zeros(size(z));
    end
end
number_of_active_voxels = sum(sum(sum(isActive)))    
    
