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 73 74 75 76 77 78 79
| function [data,back,ref]=sifread(file)
fileIn = fopen('FileName.dat','r');
file=fgetl(fileIn)
fclose(fileIn)
f=fopen(file,'r');
for n=1:2
fgetl(f);
end
o=fscanf(f,'%d',6);
info.temperature=o(6);
fread(f,10,'uint8');
o=fscanf(f,'%f',5);
info.exposureTime=o(2);
info.cycleTime=o(3);
info.accumulateCycles=o(5);
info.accumulateCycleTime=o(4);
fread(f,2,'uint8');
o=fscanf(f,'%f',2);
info.stackCycleTime=o(1);
info.pixelReadoutTime=o(2);
o=fscanf(f,'%d',3);
info.gainDAC=o(3);
fgetl(f);
info.detectorType=fgetl(f);
info.detectorSize=fscanf(f,'%d',[1 2]);
info.fileName=readString(f);
for n=1:3
fgetl(f);
end
fread(f,14,'uint8');
info.shutterTime=fscanf(f,'%f',[1 2]);
for n=1:8
fgetl(f);
end
if strmatch('Unknown',info.detectorType)
for n=1:7 % Sif_v2 : 7 sinon 2
fgetl(f);
end
end
% info.frameAxis=readString(f); % Sif_v1 : mis en commentaire
%o=fscanf(f,'%c',27); % Sif_v3 : à rajouter
info.dataType=readString(f); % Sif_v3 : mis en commentaire
info.imageAxis=readString(f);
o=fscanf(f,'65538 %d %d %d %d %d %d %d %d 65538 %d %d %d %d %d %d',14);
info.imageArea=[o(1) o(4) o(6);o(3) o(2) o(5)];
info.frameArea=[o(9) o(12);o(11) o(10)];
info.frameBins=[o(14) o(13)];
s=(1 + diff(info.frameArea))./info.frameBins;
z=1 + diff(info.imageArea(5:6));
if prod(s) ~= o(8) | o(8)*z ~= o(7)
fclose(f);
error('Inconsistent image header.');
end
info.timeStamp=fread(f,1,'uint16');
for n=1:z
o=readString(f);
end
info.imageData=reshape(fread(f,prod(s)*z,'single=>single'),[s z]);
dataimage([])=info.imageData;
fileOut = fopen('Result.dat','w');
for n=1:(1024*255)
fprintf(fileOut,'%d\t',dataimage([n]));
end
fclose(fileOut)
next=fscanf(f,'%d',1);
back=struct([]);
ref=back;
fclose(f);
function o=readString(f)
n=fscanf(f,'%d',1);
if isempty(n) | n < 0 | isequal(fgetl(f),-1)
fclose(f);
error('Inconsistent string.');
end
o=fread(f,[1 n],'uint8=>char'); |
Partager