-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadData.m
72 lines (65 loc) · 1.95 KB
/
loadData.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function [im,path] = loadData(path)
if nargin < 1
[fname,pname] = uigetfile('*.*');
path = [pname,filesep,fname];
end
ind = strfind(path,'.');
tag = path(ind(end)+1:end);
if strcmp(tag,'tif') || strcmp(tag,'tiff')
info = imfinfo(path);
w = info(1).Width; h = info(1).Height;
bd = info(1).BitDepth/8;
nf = floor(info(1).FileSize/(bd*w*h));
keepReading = 1; k = 1;
im = zeros(h,w,nf);
warning('off')
while keepReading
try
im(:,:,k) = imread(path,k);
k = k+1;
catch
keepReading = 0;
disp('Finished reading... ')
disp(['Stack size : ',num2str(size(im))])
end
end
warning('on')
elseif strcmp(tag,'dat')
warning('off')
fin =fopen(path,'r');
info = dir(path);
pathInfo = strrep(path,'.dat','.info');
infoLabview = getInfoLabview(pathInfo);
row = str2double(infoLabview.ROI_CAM0.VWid);
col = str2double(infoLabview.ROI_CAM0.HWid);
if row == 0
row = 600;
col = 2048;
end
nframes = info.bytes/(2*row*col);
I=fread(fin,row*col*nframes,'uint16=>uint16');
im=reshape(swapbytes(I),col,row,nframes);
im = permute(im,[2 1 3]);
fclose(fin);
disp('Finished reading... ')
disp(['Stack size : ',num2str(size(im))])
elseif strcmp(tag,'bin')
warning('off')
fin =fopen(path,'r');
info = dir(path);
pathInfo = strrep(path,'.bin','.info');
infoLabview = getInfoLabview(pathInfo);
row = (infoLabview.ROI_CAM0.VWid);
col = (infoLabview.ROI_CAM0.HWid);
if row == 0
row = 600;
col = 2048;
end
nframes = info.bytes/(2*row*col);
I=fread(fin,row*col*nframes,'uint16=>uint16');
im=reshape(swapbytes(I),col,row,nframes);
im = permute(im,[2 1 3]);
fclose(fin);
disp('Finished reading... ')
disp(['Stack size : ',num2str(size(im))])
end