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

quantizeImX moved from getImf

parent 1b24541c
No related branches found
No related tags found
No related merge requests found
*.png
src/MATLAB/clusterExamples/*.mat
*.xlsx
*.rtf
......@@ -35,9 +35,6 @@ while startTarget <= size(pData,1)
end
end
end
% NGPU = HIP.Cuda.DeviceCount;
% p = ljsStartParallel(8*NGPU);
end
startTarget = startTarget + N_CUDA_PROCS;
for i = 1:N_CUDA_PROCS
......@@ -47,52 +44,4 @@ while startTarget <= size(pData,1)
end
end
px = {}; % critical voxels
mx = []; % mean by stack
sx = []; % sigma by stack
for i = 1 : length(imf)
for c = 1:size(imf{i},4)
i1 = imf{i}(:,:,:,c);
px{i,c} = i1(find(i1));
mx(i,c) = mean(px{i,c});
sx(i,c) = std(px{i,c});
end
end
clipRange = [2.5,97.5];
% clipRange = [0.5,99.5];
for c = 1:size(imf{1},4)
p1 = vertcat(px{:,c});
px_pos = p1(p1>0);
px_neg = abs(p1(p1<0));
clip_pos(c,:) = prctile(px_pos,clipRange);
clip_neg(c,:) = prctile(px_neg,clipRange);
end
4;
for i = 1:length(imf)
for c = 1 : size(imf{i},4)
if all(0==imf{i}(:,:,c))
continue
end
imp = imf{i}(:,:,:,c);
imp(imp<0)=0;
imn = imf{i}(:,:,:,c);
imn(imn>0)=0;
imn=abs(imn);
imq_pos = SSF.quantize8(imp,clip_pos(c,:));
imq_neg = SSF.quantize8(imn,clip_neg(c,:));
if all(0==imq_pos)
imf{i}(:,:,:,c) = imq_neg;
else
% [0,127] for imq_neg, [128,255] imq_pos
imq_pos = (0.5 .* imq_pos) + uint8(128 .* (imq_pos>0));
imq_neg = 0.5 .* imq_neg ;
imf{i}(:,:,:,c) = (imq_neg + imq_pos);
end
end
imf{i} = uint8(imf{i});
end
4;
% imf is a cell array of images, e.g. per patient
function imf = quantizeImX(imf,clipRange)
%
px = {}; % critical voxels
for i = 1 : length(imf)
for c = 1:size(imf{i},4)
i1 = imf{i}(:,:,:,c);
px{i,c} = i1(find(i1));
end
end
if ~exist("clipRange",'var')
clipRange = [2.5,97.5];
% clipRange = [0.5,99.5];
% clipRange = [0,100]
end
for c = 1:size(imf{1},4)
p1 = vertcat(px{:,c});
px_pos = p1(p1>0);
px_neg = abs(p1(p1<0));
clip_pos(c,:) = prctile(px_pos,clipRange);
clip_neg(c,:) = prctile(px_neg,clipRange);
end
4;
for i = 1:length(imf)
for c = 1 : size(imf{i},4)
if all(0==imf{i}(:,:,c))
continue
end
imp = imf{i}(:,:,:,c);
imp(imp<0)=0;
imn = imf{i}(:,:,:,c);
imn(imn>0)=0;
imn=abs(imn);
imq_pos = SSF.quantize8(imp,clip_pos(c,:));
imq_neg = SSF.quantize8(imn,clip_neg(c,:));
if all(0==imq_pos)
imf{i}(:,:,:,c) = imq_neg;
else
% [0,127] for imq_neg, [128,255] imq_pos
imq_pos = (0.5 .* imq_pos) + uint8(128 .* (imq_pos>0));
imq_neg = 0.5 .* imq_neg ;
imf{i}(:,:,:,c) = (imq_neg + imq_pos);
end
end
imf{i} = uint8(imf{i});
end
tic
ROOT = '/g/leverjs/Schuman_OCT/OCT/qualifiedYes';
ROOT = '/g/leverjs/Schuman_OCT/OCT/qualified';
PID = 'P10010';
% PID = 'P10125'
......@@ -16,11 +16,13 @@ tblMeta = tblMeta(contains(tblMeta.scanType,'Optic'),:);
p = ljsStartParallel(96);
% radii = {[0.5,8,8],[5,5,5],[0,0,0]}; % plate,blob
radii = {[0.5,8,8]}; % plate
radii = {[0.5,8,8],[5,5,5],[0,0,0]}; % plate,blob
% radii = {[0.5,8,8]}; % plate
% radii = {[5,5,5]};
% radii = {[3]} % dark tubes
imf = RSF.getImf(tblMeta,radii);
imf = RSF.quantizeImX(imf,[2.5,97.5]);
d = [];
parfor i = 1:length(imf)
dj = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment