0001 function [imageVol, lastfile] = GE_readVolume(startDir, passnum, volSize, depth, im_offset)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 nX = volSize(1);
0017 nY = volSize(2);
0018 nZ = volSize(3);
0019 sliceSize = nX*nY;
0020 imageVol = zeros(nX, nY, nZ);
0021 [path_stem, path_start] = fileparts(startDir);
0022
0023 for i = 1:nZ
0024
0025 filenum = (passnum-1)*nZ + i;
0026 filep = ceil(filenum/999) - 1;
0027 filen = filenum - 999*filep;
0028 path_num = str2num(path_start) + 20*filep;
0029 path_now = sprintf('00%d',path_num);
0030 path_now = path_now(length(path_now)-2:length(path_now));
0031 path = fullfile(path_stem, path_now);
0032 stub = sprintf('00%d',filen);
0033 stub = stub(length(stub)-2:length(stub));
0034 imageFile = fullfile(path,['I.' stub]);
0035
0036
0037 [fid,message] = fopen(imageFile,'r','b');
0038 if (fid == -1)
0039 fprintf('Cannot Open %s.\n',imageFile);
0040 passnum
0041 break
0042 end
0043
0044
0045 fseek(fid,im_offset,-1);
0046
0047 buffer = fread(fid,sliceSize,sprintf('int%d',depth));
0048
0049 imageVol(:,:,i) = reshape(buffer, nX, nY);
0050
0051
0052 status = fclose(fid);
0053
0054
0055 lastfile = imageFile;
0056 end
0057
0058 return