diff --git a/matlab/+SSF/getClipQuantiles.m b/matlab/+SSF/getClipQuantiles.m index 6e1267c3932970dffde7b2b76430743ab25f12e5..9605efffdf13d973df3c61b2c521cf2ec509b7ad 100644 --- a/matlab/+SSF/getClipQuantiles.m +++ b/matlab/+SSF/getClipQuantiles.m @@ -1,33 +1,13 @@ function clipLimits = getClipQuantiles(voxels,nQuant) -% mx = mean(voxels); -% sx = std(voxels); -% cl = [mx-sx, mx+sx]; -% q1 = length(find(voxels<cl(1)))./length(voxels); -% q2 = 1 - length(find(voxels>cl(2)))./length(voxels); -% pxTarget = linspace(q1,q2,nQuant); -% clipLimits = quantile(voxels,pxTarget); - -% clipLimits = linspace(min(voxels),max(voxels),nQuant+2); -% clipLimits = clipLimits(2:end-1); -% pxTarget = linspace(2.5,97.5,nQuant); -% clipLimits = prctile(voxels,pxTarget); -% -% if max(voxels)<0 -% pxTarget = linspace(2.5,100,nQuant); -% else -% pxTarget = linspace(0,97.5,nQuant); -% end -% clipLimits = prctile(voxels,pxTarget); - -% clipLimits = multithresh(voxels,20); -[~ , clipLimits] = histcounts(voxels); -if length(clipLimits>nQuant) - h = histogram(voxels,'Visible','off'); - while length(h.BinEdges)>nQuant - N = fewerbins(h); - h = histogram(voxels,N,'Visible','off'); - end - clipLimits = h.BinEdges; +mx = mean(voxels); +sx = std(voxels); +cl = [mx-sx, mx+sx]; +if all(voxels<0) + cl(2) = max(voxels); +end +if all(voxels>0) + cl(1) = min(voxels); end +clipLimits = linspace(cl(1),cl(2),nQuant); 4;