Skip to content
Snippets Groups Projects
Commit 5d7a561e authored by Eric Wait's avatar Eric Wait
Browse files

Fixed roi reading in KLB

parent 44dcb998
Branches
No related tags found
No related merge requests found
...@@ -136,7 +136,7 @@ function [im, imD] = ReaderKLB(varargin) ...@@ -136,7 +136,7 @@ function [im, imD] = ReaderKLB(varargin)
roi_xyz = args.roi_xyz; roi_xyz = args.roi_xyz;
roi_xyz(:,4) = [args.chanList(1);args.chanList(end)]; roi_xyz(:,4) = [args.chanList(1);args.chanList(end)];
roi_xyz(:,5) = args.timeRange'; roi_xyz(:,5) = args.timeRange';
im = readKLBChunk(imD,args.outType,roi_xyz,filePerC,filePerT,prgsIn); im = readKLBChunk(imD,args.outType,roi_xyz,args.chanList,filePerC,filePerT,args.outType,prgsIn);
if (args.verbose) if (args.verbose)
prgs.ClearProgress(true); prgs.ClearProgress(true);
...@@ -170,7 +170,7 @@ function [im, imD] = ReaderKLB(varargin) ...@@ -170,7 +170,7 @@ function [im, imD] = ReaderKLB(varargin)
end end
end end
function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs) function im = readKLBChunk(imD,outType,roi_xyz,chanList,filePerC,filePerT,cnvrtType,prgs)
im = zeros(Utils.SwapXY_RC(roi_xyz(2,:)-roi_xyz(1,:))+1,outType); im = zeros(Utils.SwapXY_RC(roi_xyz(2,:)-roi_xyz(1,:))+1,outType);
myCluster = parcluster('local'); myCluster = parcluster('local');
...@@ -180,10 +180,11 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs) ...@@ -180,10 +180,11 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs)
if (filePerT) if (filePerT)
% individual image per c and t % individual image per c and t
i = 0; i = 0;
for t=roi_xyz(1,5):roi_xyz(2,5) for t=1:length(roi_xyz(1,5):roi_xyz(2,5))
for c=roi_xyz(1,4):roi_xyz(2,4) for c=1:length(chanList)
fileName = sprintf('%s_c%d_t%04d.klb',imD.DatasetName,c,t); fileName = sprintf('%s_c%d_t%04d.klb',imD.DatasetName,chanList(c),t+roi_xyz(1,5)-1);
im(:,:,:,c,t) = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:3),1,1]; [roi_xyz(2,1:3),1,1]]),threads); imTemp = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:3),1,1]; [roi_xyz(2,1:3),1,1]]),threads);
im(:,:,:,c,t) = ImUtils.ConvertType(imTemp,cnvrtType,false);
i = i +1; i = i +1;
if (~isempty(prgs)) if (~isempty(prgs))
prgs.PrintProgress(i); prgs.PrintProgress(i);
...@@ -193,9 +194,10 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs) ...@@ -193,9 +194,10 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs)
else else
% only split by c % only split by c
i=0; i=0;
for c=roi_xyz(1,4):roi_xyz(2,4) for c=1:length(chanList)
fileName = sprintf('%s_c%d.klb',imD.DatasetName,c); fileName = sprintf('%s_c%d.klb',imD.DatasetName,chanList(c));
im(:,:,:,c,:) = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:3),1,roi_xyz(1,5)]; [roi_xyz(2,1:3),1,roi_xyz(2,5)]]),threads); imTemp = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:3),1,roi_xyz(1,5)]; [roi_xyz(2,1:3),1,roi_xyz(2,5)]]),threads);
im(:,:,:,c,:) = ImUtils.ConvertType(imTemp,cnvrtType,false);
i = i +1; i = i +1;
if (~isempty(prgs)) if (~isempty(prgs))
prgs.PrintProgress(i*imD.NumberOfFrames); prgs.PrintProgress(i*imD.NumberOfFrames);
...@@ -205,9 +207,10 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs) ...@@ -205,9 +207,10 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs)
elseif (filePerT) elseif (filePerT)
% only split by t % only split by t
i = 0; i = 0;
for t=roi_xyz(1,5):roi_xyz(2,5) for t=1:length(roi_xyz(1,5):roi_xyz(2,5))
fileName = sprintf('%s_t%04d.klb',imD.DatasetName,t); fileName = sprintf('%s_t%04d.klb',imD.DatasetName,t+roi_xyz(1,5)-1);
im(:,:,:,:,t) = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:4),1]; [roi_xyz(2,1:4),1]]),threads); imTemp = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,fileName), Utils.SwapXY_RC([[roi_xyz(1,1:4),1]; [roi_xyz(2,1:4),1]]),threads);
im(:,:,:,:,t) = ImUtils.ConvertType(imTemp,cnvrtType,false);
i = i +1; i = i +1;
if (~isempty(prgs)) if (~isempty(prgs))
prgs.PrintProgress(i*imD.NumberOfChannels); prgs.PrintProgress(i*imD.NumberOfChannels);
...@@ -215,6 +218,6 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs) ...@@ -215,6 +218,6 @@ function im = readKLBChunk(imD,outType,roi_xyz,filePerC,filePerT,prgs)
end end
else else
% only one file % only one file
im = MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,[imD.DatasetName '.klb']),Utils.SwapXY_RC(roi_xyz),threads); im = ImUtils.ConvertType(MicroscopeData.KLB.readKLBroi(fullfile(imD.imageDir,[imD.DatasetName '.klb']),Utils.SwapXY_RC(roi_xyz),threads),cnvrtType,false);
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment