Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
littlke fix with possible filename issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MPIBR-vollrathf committed Aug 12, 2016
1 parent 94ec74c commit cd52d25
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
save(fn, 'data_g', 'data_r', '-v7.3');
%% load files
%if you haven't used the shiftCorrection you have to load the already processed files
fn_green = 'processedData.mat';
fn= 'processedData.mat';
load(fn);
%% 1. PCA
%calculate PCAs
Expand Down
28 changes: 28 additions & 0 deletions readTif.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function out = readTif(fName)
% Function for speed-optimized reading of tif files, ignoring all meta-data
% and dimension sorting

ww = imfinfo(fName); % Tif file information
nCol = ww(1).SamplesPerPixel; % Number of color channels (NOT TESTED!)
nImg = numel(ww); % Number of frames
if ww(1).BitsPerSample(1) <= 16
out = zeros(ww(1).Height, ww(1).Width,nCol, nImg,'uint16');
else
out = zeros(ww(1).Height, ww(1).Width, nCol, nImg);
end
readLength = [ww(1).Width ww(1).Height]; % order has to be reversed for correct reading of data (don't know why)
gl_fid = fopen (fName, 'r', 'l');
for j=1:nImg
for col=1:nCol
fseek(gl_fid, ww(j).StripOffsets(col) , 'bof');
if ww(j).BitsPerSample(col) <=8
out(:,:,col,j) = uint16(fread(gl_fid,readLength, '*uint8'))';
elseif ww(j).BitsPerSample(col) <=16
out(:,:,col,j) = fread(gl_fid, readLength, '*uint16')';
else ww(j).BitsPerSample(col)
out(:,:,col,j) = fread(gl_fid,readLength, 'uint32')';
end
end
end
fclose(gl_fid);
out = squeeze(out);

0 comments on commit cd52d25

Please sign in to comment.