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

Updated the tif reader to match the new writer (3D support).

parent 41b45a2e
Branches
No related tags found
No related merge requests found
...@@ -65,15 +65,17 @@ if (isempty(args.normalize)) ...@@ -65,15 +65,17 @@ if (isempty(args.normalize))
args.normalize = false; args.normalize = false;
end end
if (~exist(fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,1,1,1)),'file')) dList = dir(fullfile(imPath,[imD.DatasetName,'_c*_t*.tif']));
if (isempty(dList))
warning('No image to read!'); warning('No image to read!');
return return
end end
useROI = (nnz(args.roi_xyz(:,1:2) ~= [1 1;imD.Dimensions(1:2)]) > 0); useROI = (nnz(args.roi_xyz(:,1:2) ~= [1 1;imD.Dimensions(1:2)]) > 0);
chkFilename = fullfile(imPath,sprintf('%s_c%02d_t%04d_z%04d.tif',imD.DatasetName,1,1,1)); filePerZ = ~isempty(regexpi(dList(1).name,'.*_z\d+.tif'));
inType = MicroscopeData.Helper.GetPixelTypeTIF(chkFilename);
inType = MicroscopeData.Helper.GetPixelTypeTIF(fullfile(imPath,dList(1).name));
inIdx = find(strcmp(inType,dataTypeLookup)); inIdx = find(strcmp(inType,dataTypeLookup));
if ( ~isempty(inIdx) ) if ( ~isempty(inIdx) )
inBytes = dataTypeSize(inIdx); inBytes = dataTypeSize(inIdx);
...@@ -117,16 +119,13 @@ if ( args.verbose ) ...@@ -117,16 +119,13 @@ if ( args.verbose )
(prod(imSize)*outBytes)/(1024*1024)); (prod(imSize)*outBytes)/(1024*1024));
end end
if ( args.verbose )
iter = imSize(5)*length(args.chanList)*imSize(3); iter = imSize(5)*length(args.chanList)*imSize(3);
cp = Utils.CmdlnProgress(iter,true,sprintf('Reading %s...',imD.DatasetName)); prgs = Utils.CmdlnProgress(iter,true,sprintf('Reading %s...',imD.DatasetName));
i=1;
end
tic
for t=1:imSize(5) for t=1:imSize(5)
timeVal = t+args.timeRange(1)-1; timeVal = t+args.timeRange(1)-1;
for c=1:length(args.chanList) for c=1:length(args.chanList)
if (filePerZ)
for z=1:imSize(3) for z=1:imSize(3)
zVal = z+args.roi_xyz(1,3)-1; zVal = z+args.roi_xyz(1,3)-1;
...@@ -136,10 +135,16 @@ for t=1:imSize(5) ...@@ -136,10 +135,16 @@ for t=1:imSize(5)
else else
im(:,:,z,c,t) = imread(tifName,'TIF'); im(:,:,z,c,t) = imread(tifName,'TIF');
end end
end
if ( args.verbose ) else
cp.PrintProgress(i); tifName = fullfile(imPath,sprintf('%s_c%02d_t%04d.tif',imD.DatasetName,args.chanList(c),timeVal));
i = i+1; for z=1:imSize(3)
zVal = z+args.roi_xyz(1,3)-1;
if (convert || useROI)
tempIm(:,:,z) = imread(tifName,'TIF','index',zVal);
else
im(:,:,z,c,t) = imread(tifName,'TIF','index',zVal);
end
end end
end end
...@@ -150,12 +155,14 @@ for t=1:imSize(5) ...@@ -150,12 +155,14 @@ for t=1:imSize(5)
elseif (useROI) elseif (useROI)
im(:,:,:,c,t) = tempIm(args.roi_xyz(1,2):args.roi_xyz(2,2),args.roi_xyz(1,1):args.roi_xyz(2,1),:); im(:,:,:,c,t) = tempIm(args.roi_xyz(1,2):args.roi_xyz(2,2),args.roi_xyz(1,1):args.roi_xyz(2,1),:);
end end
if ( args.verbose )
prgs.PrintProgress(c+(t-1)*length(args.chanList));
end
end end
end end
if ( args.verbose ) if ( args.verbose )
cp.ClearProgress(true); prgs.ClearProgress(true);
fprintf(' took:%s\n',Utils.PrintTime(toc));
end end
imD.Dimensions = Utils.SwapXY_RC(imSize(1:3)); imD.Dimensions = Utils.SwapXY_RC(imSize(1:3));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment