|
1 |
| -function imData=read_file(path_to_file,sframe,num2read,options) |
| 1 | +function imData=read_file(path_to_file,sframe,num2read,options,im_info) |
2 | 2 |
|
3 | 3 | % Reads uncompressed multipage .tiff, .hdf5, .avi or .raw files
|
4 | 4 | % Usage: my_data=read_file('path_to_data_file, start frame, num to read);
|
|
8 | 8 | % sframe: first frame to read (optional, default: 1)
|
9 | 9 | % num2read: number of frames to read (optional, default: read the whole file)
|
10 | 10 | % options: options for reading .raw or .bin files
|
| 11 | +% im_info: information about the file (if already present) |
| 12 | + |
11 | 13 |
|
12 | 14 | % OUTPUT:
|
13 | 15 | % imData: data in array format
|
|
19 | 21 |
|
20 | 22 | [~,~,ext] = fileparts(path_to_file);
|
21 | 23 |
|
22 |
| -if strcmpi(ext,'.tiff') || strcmpi(ext,'.tif') || strcmpi(ext,'.btf'); |
23 |
| - imData = loadtiff(path_to_file,sframe,num2read); |
24 |
| - %imData = bigread2(path_to_file,sframe,num2read); |
25 |
| -elseif strcmpi(ext,'.hdf5') || strcmpi(ext,'.h5'); |
| 24 | +if strcmpi(ext,'.tiff') || strcmpi(ext,'.tif') || strcmpi(ext,'.btf') |
| 25 | + if ~exist('im_info','var') |
| 26 | + im_info = imfinfo(path_to_file); |
| 27 | + end |
| 28 | + TifLink = Tiff(path_to_file, 'r'); |
| 29 | + num2read = min(num2read,length(im_info)-sframe+1); |
| 30 | + imData = zeros(im_info(1).Height,im_info(1).Width,num2read,'like',TifLink.read()); |
| 31 | + for i=1:num2read |
| 32 | + TifLink.setDirectory(i+sframe-1); |
| 33 | + imData(:,:,i)=TifLink.read(); |
| 34 | + end |
| 35 | + TifLink.close() |
| 36 | + %imData = loadtiff(path_to_file,sframe,num2read); |
| 37 | +elseif strcmpi(ext,'.hdf5') || strcmpi(ext,'.h5') |
26 | 38 | % info = hdf5info(path_to_file);
|
27 | 39 | % dims = info.GroupHierarchy.Datasets.Dims;
|
28 | 40 | % name = info.GroupHierarchy.Datasets.Name;
|
|
0 commit comments