Skip to content
Snippets Groups Projects
Commit 2b7ad96d authored by ac's avatar ac
Browse files

clipQuantiles linear

parent 242bbfd7
Branches
No related tags found
No related merge requests found
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');
mx = mean(voxels);
sx = std(voxels);
cl = [mx-sx, mx+sx];
if all(voxels<0)
cl(2) = max(voxels);
end
clipLimits = h.BinEdges;
if all(voxels>0)
cl(1) = min(voxels);
end
clipLimits = linspace(cl(1),cl(2),nQuant);
4;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment