-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread3DstackDir.m
More file actions
27 lines (25 loc) · 993 Bytes
/
Copy pathread3DstackDir.m
File metadata and controls
27 lines (25 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function im_stack = read3DstackDir (Dir,varargin)
% function tiff_stack = read3DstackDir (Dir,filetype,framenums);
% reads a directory of tiff images (default) or other file types in directory Dir into im_stack
cd(Dir)
if nargin==0
fileNames=dir ('*.tif*');
im_stack = importdata(fileNames(1).name); % read in first image
%concatenate each successive tiff to tiff_stack
for ii = 2 : size(fileNames, 1)
thisFile=fileNames(ii).name;
thisIm=importdata(thisFile);
im_stack = cat(3 , im_stack, thisIm);
end
else
fileNames=dir (['*.',varargin{1},'*']);
sortedFileNames = natsortfiles({fileNames.name});
theseFileNames = sortedFileNames(varargin{2});
im_stack = importdata(theseFileNames{1}); % read in first image
%concatenate each successive tiff to tiff_stack
for ii = 2 : size(theseFileNames,2)
thisFile=theseFileNames{ii};
thisIm=importdata(thisFile);
im_stack = cat(3 , im_stack, thisIm);
end
end