function Info=readinfo(fid,display);

%READINFO   Read all EchoPAC file information
%
%   Info=READINFO(fid,{display});
%
%   Inputs: fid     - file identifier, see OPENCLP
%           display - Set display=0 to disable automatic
%                     display of Info.
%                     (Default is display=1)
%
%   Output: Info - vector containing all essential information
%                  for the file.
%          Empty if errors occured in reading information.
%
%   To get a complete display of the parameters in the Info-vector, use:
%       DISPINFO(Info)
%
%   To extract one specific parameter, use:
%       GETPARAM('parametername',Info)
% 
%   Parameters not found in the EchoPAC file are set = 0.
%
%   See also: OPENCLP, DISPINFO, GETPARAM, READECHO

% (c) GE Vingmed Ultrasound 1997-99. All rights reserved
% Written by: JK, 17.07.96
% Last update: 31.03.1998, JK

if nargin<1, error('Too few input arguments');end;
if nargin==1, display=1;end;

if isempty(fid)|prod(size(fid))>1|isstr(fid)|~isreal(fid),
    error('Invalid file identifier');
end;

if round(fid)~=fid|fid<3|~any(fopen(fid)),
    error('Invalid file identifier');
end;

v=version;v=str2num(v(1));
if v>4,
    bitprec='ubit1';
    byteprec='ubit8';
else
    bitprec='uint1';
    byteprec='uint8';
end;

starttime=clock;
%% Block Identifier Numbers:
SessionC       = 0;   %Date etc
SyncC          = 1;   %Block containing sync. traces: EKG, Aux1-6
ModeC          = 3;   %Block containing probe frequencies, amongst other
MovieInfoC     = 4;
ScreenCaptureC = 5;
ScreenCaptRGB_C = 8;

Ecg12bit       = 10;
sys5CFMstatusC = 133; %
RFparams       = 14;  %

DataTissueC    = 16; %Sectorprobe tissue data block
DataFlowC      = 17; %Sectorprobe flow data block
StatusTissueC  = 32; %Sectorprobe tissue info
StatusFlowC    = 33; %Sectorprobe flow info

DataTissMmodeC = 18; %MMode tissue data block
DataFlowMmodeC = 19; %MMode flow data block
StatTissMmodeC = 34; %MMode tissue info
StatFlowMmodeC = 35; %MMode flow info

DataSpectC     = 20; %Doppler Spectrum data block
StatusSpectC   = 36; %Doppler Spectrum info

StatTissueLinC = 30; %Linearprobe tissue info
StatFlowLinC   = 31; %Linearprobe flow info
DataTissueLinC = 21; %Linearprobe tissue data block
DataFlowLinC   = 22; %Linearprobe flow data block

CfmFrequencyEncoderC  = 26;   % Color flow mapping tables.
CfmArbitrationC       = 27;
TissueColorC          = 28;
CfmColorC             = 29;
CfmBandwidthEncoderC  = 40;
FlowTypeC             = 49;   % Type of flow record.

sys5ApplicationC      = 44;   % System FiVe application name.
heartRateC            = 131;


%% Scan file
fseek(fid,0,1);
filelength=ftell(fid);
frewind(fid);
badcounter=0;
badlimit=2000;
recoverlimit=200000;
magicN=hex2dec('AA6C');
blkpos=[];
blktype=[];
firstRec=[];
numberRecs=[];
recSize=[];
warningflag=0;
firstflag=0;
%n=sum(fread(fid,[1 2],byteprec).*[256 1]);
[readtwobyte,count]=fread(fid,[1 2],byteprec);
while ~feof(fid)
    if count==2,
        n=sum(readtwobyte.*[256 1]);
        if n==magicN,
            firstflag=1;
            blkpos=[blkpos;(ftell(fid)-2)];
            blktype=[blktype;sum(fread(fid,[1 2],byteprec).*[256 1])];
            firstRec=[firstRec;sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]])];
            No=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
            Si=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
            numberRecs=[numberRecs;No];
            recSize=[recSize;Si];
            fseek(fid,No*Si,0);
            %n=sum(fread(fid,[1 2],byteprec).*[256 1]);
        else
            if firstflag,
                firstflag=0;
                if any(blkpos),
                    fseek(fid,max(blkpos)+3,-1);
                end;
                if ~warningflag,
                    warningflag=1;
                    disp('File warning: EchoPAC file corrupted. Trying to recover. Please wait.');
                    currpos=ftell(fid);
                    badlimit=min(recoverlimit,filelength-currpos-1+badcounter);
                end;
            end;
            badcounter=badcounter+1;
            if badcounter>badlimit,
                fseek(fid,128,-1);
                dicm=fread(fid,4,byteprec);
                if strcmp(lower(setstr(dicm(:)')),'dicm'),
                    error('File format is Dicom. Refer to System 5 manual for how to store EchoPAC files');
                else 
                    fseek(fid,0,1);%goto end of file
                    fread(fid,1,byteprec);%read past end of file
                end;
             end;
             n=256*rem(n,256)+fread(fid,1,byteprec);
        end;%if n==magicN
    end; %if count
    [readtwobyte,count]=fread(fid,[1 2],byteprec);
end;%while ~feof(fid)

if ~any(blkpos),
    error('File error: Corrupted or not EchoPAC');
end;

%% Status and contents field
Tissue=sum(numberRecs(find(blktype==DataTissueC)));
Flow=sum(numberRecs(find(blktype==DataFlowC)));
sectIQ=0;

MTissue=sum(numberRecs(find(blktype==DataTissMmodeC)));
MFlow=sum(numberRecs(find(blktype==DataFlowMmodeC)));
MIQ=0;

LinTissue=sum(numberRecs(find(blktype==DataTissueLinC)));
LinFlow=sum(numberRecs(find(blktype==DataFlowLinC)));
LinIQ=0;

Spect=sum(numberRecs(find(blktype==DataSpectC)));
Sync=prod(size(find(blktype==SyncC)));
RFPar=prod(size(find(blktype==RFparams)));

spare=0; % used for RFinfo below

RGBdump=sum(numberRecs(find(blktype==ScreenCaptRGB_C)));
ScreenDump=sum(numberRecs(find(blktype==ScreenCaptureC)));
MovieInfo=sum(numberRecs(find(blktype==MovieInfoC)));
PatientInfo=0;

Info=[Tissue Flow sectIQ MTissue MFlow MIQ LinTissue LinFlow LinIQ Spect Sync];
Info=[Info, RFPar spare RGBdump ScreenDump MovieInfo PatientInfo];

%% Filename
Filename=fopen(fid);
FilenameLength=length(Filename);
Info=[Info, FilenameLength, real(Filename)];

%% Length of file
Info=[Info, filelength];

%% Read date and time
desblock1=min(find(blktype==SessionC));
desblock2=min(find(blktype==MovieInfoC));
if desblock1,
    fseek(fid,blkpos(desblock1)+16,-1);
    date=setstr(fread(fid,[1 17],byteprec)); %%YY-MM-DD-hh-mm-ss
    year=eval(date(1:2)','0');
    month=eval(date(4:5)','0');
    day=eval(date(7:8)','0');
    hour=eval(date(10:11)','0');
    minute=eval(date(13:14)','0');
    second=eval(date(16:17)','0');
    clear('date');
elseif desblock2,
    fseek(fid,blkpos(desblock2)+16,-1);
    year=rem(sum(fread(fid,[1 2],byteprec).*[256 1]),100);
    month=fread(fid,1,byteprec);
    day=fread(fid,1,byteprec);
    hour=fread(fid,1,byteprec);
    minute=fread(fid,1,byteprec);
    second=fread(fid,1,byteprec);
else
    year=0;
    month=0;
    day=0;
    hour=0;
    minute=0;
    second=0;
end;
Info=[Info, year, month, day, hour, minute, second];


%Read application name:
desblock=min(find(blktype==sys5ApplicationC));
if any(desblock),
    fseek(fid,blkpos(desblock),-1);
    fseek(fid,16,0);
    appname=fread(fid,[72 1],byteprec);
    appname=appname(2:appname(1)+1);
else
    appname=[];
end;


%% Read patient information:
desblock=min(find(blktype==SessionC));
if desblock,
    fseek(fid,blkpos(desblock)+16,-1);
    SessionRecSize=recSize(desblock);
    sesstr=fread(fid,[SessionRecSize 1],byteprec);
    endlines=find(sesstr==0);
    if length(endlines==7)
        Date              =sesstr(1:endlines(1)-1);
        PatientID         =sesstr(endlines(1)+1:endlines(2)-1);
        OperatorID        =sesstr(endlines(2)+1:endlines(3)-1);
        SiteID            =sesstr(endlines(3)+1:endlines(4)-1);
        ScanType          =sesstr(endlines(4)+1:endlines(5)-1);
        ScanVersion       =sesstr(endlines(5)+1:endlines(6)-1);
        TypeOfMeasurement =sesstr(endlines(6)+1:endlines(7)-1);
    else
        Date              =real(' ');
        PatientID         =real(' ');
        OperatorID        =real(' ');
        SiteID            =real(' ');
        ScanType          =real(' ');
        ScanVersion       =real(' ');
        TypeOfMeasurement =real(' ');
    end;    

    beforelength=length(Info);
    Info=[Info,length(Date),Date',length(PatientID),PatientID',length(OperatorID),OperatorID'];
    Info=[Info,length(SiteID),SiteID',length(ScanType),ScanType',length(ScanVersion),ScanVersion'];
    Info=[Info,length(TypeOfMeasurement),TypeOfMeasurement',length(appname),appname'];
    afterlength=length(Info);
    PatientInfo=afterlength-beforelength;
    Info(17)=PatientInfo;
    clear beforelength afterlength
end;


%% Read Probe frequencies:
desblock=min(find(blktype==ModeC));
if desblock,
    fseek(fid,blkpos(desblock)+16,-1);
    Timeslice=fread(fid,1,'float32');
    fseek(fid,8,0);
    TPFrequency=fread(fid,1,'float32');
    %fseek(fid,16,0);
     TPSkindistance=fread(fid,1,'float32');
     fseek(fid,9,0);
     TPProbeType=fread(fid,1,byteprec);
     fseek(fid,2,0);
    FPFrequency=fread(fid,1,'float32');
    %fseek(fid,16,0);
     FPSkindistance=fread(fid,1,'float32');
     fseek(fid,9,0);
     FPProbeType=fread(fid,1,byteprec);
     fseek(fid,2,0);
    SPFrequency=fread(fid,1,'float32');
     SPSkindiatance=fread(fid,1,'float32');
     fseek(fid,9,0);
     SPProbeType=fread(fid,1,byteprec);
else
    Timeslice=0;
    TPFrequency=0;
    FPFrequency=0;
    SPFrequency=0;
end;

Info=[Info,Timeslice,TPFrequency,FPFrequency,SPFrequency];


%% Read flow type
desblock=min(find(blktype==FlowTypeC));
if any(desblock),
    fseek(fid,blkpos(desblock),-1);
    fseek(fid,16,0);
    flowtype=sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
else
    flowtype=0;
end;


%% Read Heart Rate
desblock=min(find(blktype==heartRateC));
if any(desblock),
    fseek(fid,blkpos(desblock),-1);
    fseek(fid,16,0);
    HeartRate=fread(fid,1,'float32');
else
    HeartRate=0;
end;


%% Read RF parameters
if RFPar,
    desblock=min(find(blktype==RFparams));
    fseek(fid,blkpos(desblock)+16,-1);
    probename       = fread(fid,[52 1],byteprec);
    probenamelength = probename(1);
    probename       = probename(2:probenamelength+1);
    fprobe          = fread(fid,1,'float32');
    fburst          = fread(fid,1,'float32');
    tburst          = fread(fid,1,'float32');
    xmitamplitude   = fread(fid,1,'float32');
    interleave      = sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
    mlas            = sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
    prf             = fread(fid,1,'float32');
    spr             = sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
    framerate       = fread(fid,1,'float32');
    demodfrequency  = fread(fid,[1 256],byteprec);
    demodfrequency  = eval(setstr(demodfrequency(2:demodfrequency(1)+1)),'0');
    tgc             = fread(fid,[1 256],byteprec);
    tgc             = eval(setstr(tgc(2:tgc(1)+1)),'0');
    atgc            = fread(fid,[1 256],byteprec);
    atgc            = eval(setstr(atgc(2:atgc(1)+1)),'0');
    tgcdepth        = fread(fid,[1 256],byteprec);
    tgcdepth        = eval(setstr(tgcdepth(2:tgcdepth(1)+1)),'0');
    atgcdepth       = fread(fid,[1 256],byteprec);
    atgcdepth       = eval(setstr(atgcdepth(2:atgcdepth(1)+1)),'0');
    inputdec        = sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
    inputwritedec   = sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
    dynrange        = fread(fid,1,'float32');
    feflowgain      = fread(fid,1,'float32');
    roispan         = fread(fid,1,'float32');
    roicenter       = fread(fid,1,'float32');
    precompress     = fread(fid,1,'float32');

    RFinfo=[probenamelength,probename',fprobe,fburst,tburst,xmitamplitude];
    RFinfo=[RFinfo,interleave,mlas,prf,spr,framerate];
    RFinfo=[RFinfo,length(demodfrequency),demodfrequency,length(tgc),tgc,length(atgc),atgc];
    RFinfo=[RFinfo,length(tgcdepth),tgcdepth,length(atgcdepth),atgcdepth,inputdec,inputwritedec];
    RFinfo=[RFinfo,dynrange,feflowgain,roispan,roicenter,precompress,flowtype,HeartRate];
    Info=[Info,RFinfo];
    Info(13)=length(RFinfo);
end;

%% Sector probe:
if Tissue>0, %read sector tissue parameters
    desblock=min(find(blktype==StatusTissueC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        StartDepth      =fread(fid,1,'float32');
        DepthIncrement  =fread(fid,1,'float32');
        StartAngle      =fread(fid,1,'float32');
        AngleIncrement  =fread(fid,1,'float32');
        AcqTimeLine     =fread(fid,1,'float32');
        Samples         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        Beams           =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSize       =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        CompRej        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        GainTGC        =fread(fid,[8 1],byteprec);
        Frames          =Tissue;
        Info=[Info,StartDepth,DepthIncrement,StartAngle,AngleIncrement,...
                   AcqTimeLine,Samples,Beams,DataSize,CompRej,GainTGC',Frames];
    else
        disp('Warning: Missing tissue parameters!!');

    end;
end;

if Flow>0, %read sector flow parameters
    desblock=min(find(blktype==StatusFlowC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        StartDepthF     =fread(fid,1,'float32');
        DepthIncrementF =fread(fid,1,'float32');
        StartAngleF     =fread(fid,1,'float32');
        AngleIncrementF =fread(fid,1,'float32');
        AcqTimeLineF    =fread(fid,1,'float32');
        NyquistVelocityF=fread(fid,1,'float32');
        SamplesF        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        BeamsF          =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSizeF       =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        MappingTypeF    =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        IntensityIncrF  =fread(fid,1,byteprec);
        CompressionF    =fread(fid,1,byteprec);
        RejectF         =fread(fid,1,byteprec);
        OverallGainF    =fread(fid,1,byteprec);
        TgcF            =fread(fid,[1 6],byteprec);
        spare           =fread(fid,[1 2],byteprec);
        
        FramesF         =Flow;
        if DataSizeF>16, %% IQ data
            %IQ=Flow;Flow=0;
            Info(3)=Flow;Info(2)=0;
            spr=DataSizeF/32;
        elseif DataSizeF==16, %% Colorflow
            %Flow=Flow;IQ=0;
            spr=0;
        end;
        Info=[Info,StartDepthF,DepthIncrementF,StartAngleF,AngleIncrementF,...
                   AcqTimeLineF,NyquistVelocityF,SamplesF,BeamsF,DataSizeF,...
                   MappingTypeF,IntensityIncrF,CompressionF,RejectF,OverallGainF,...
                   TgcF,FramesF,spr];
    else
        disp('Warning: Missing flow parameters!!');
    end;
end;

%% M-mode
if MTissue>0, %read Mmode tissue parameters
    desblock=min(find(blktype==StatTissMmodeC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        StartDepth      =fread(fid,1,'float32');
        DepthIncrement  =fread(fid,1,'float32');
        BeamAngle       =fread(fid,1,'float32');
        AcqTimeLine     =fread(fid,1,'float32');
        Samples         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSize        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        %Compression    =fread(fid,1,byteprec);
        %Reject         =fread(fid,1,byteprec);
        %Gain           =fread(fid,1,byteprec);
        %Tgc            =fread(fid,[6 1],byteprec);
        %spare          =fread(fid,[3 1],byteprec);
        Frames          =MTissue;
        %Calculate number of Mmode flow beams
        pos=blkpos(find(blktype==DataTissMmodeC));
        fseek(fid,max(pos)+4,-1); %Go to last block,skip magicnumber
        frstRec=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
        nmbrRecs=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
        Beams=frstRec+nmbrRecs-1; clear('frstRec','nmbrRecs');
        Info=[Info,StartDepth,DepthIncrement,BeamAngle,AcqTimeLine,Samples,...
                   Frames,Beams];
    else
        disp('Warning: Missing Mmode tissue parameters!!');
    end;
end;

if MFlow>0, %read Mmode flow parameters
    desblock=min(find(blktype==StatFlowMmodeC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        StartDepthF     =fread(fid,1,'float32');
        DepthIncrementF =fread(fid,1,'float32');
        BeamAngleF      =fread(fid,1,'float32');
        AcqTimeLineF    =fread(fid,1,'float32');
        NyquistVelocityF=fread(fid,1,'float32');
        SamplesF        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSizeF       =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        %MappingType    =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        %IntensityIncr  =fread(fid,1,byteprec);
        %Compression    =fread(fid,1,byteprec);  
        %Reject         =fread(fid,1,byteprec); 
        %OverallGain    =fread(fid,1,byteprec);
        %Tgc            =fread(fid,[1 6],byteprec);
        FramesF         =MFlow;
        %Calculate number of Mmode flow beams
        pos=blkpos(find(blktype==DataFlowMmodeC));
        fseek(fid,max(pos)+4,-1); %Go to last block,skip magicnumber
        frstRec=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
        nmbrRecs=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);
        BeamsF=frstRec+nmbrRecs-1; clear('frstRec','nmbrRecs');
        if DataSizeF>16, %% In RF mode!!
            %MIQ=MFlow;MFlow=0;
            Info(6)=MFlow;Info(5)=0;
            spr=DataSizeF/32;
        else
            %MFLow=MFlow;MIQ=0;
            spr=0;
        end;
        Info=[Info,StartDepthF,DepthIncrementF,BeamAngleF,AcqTimeLineF,...
                   NyquistVelocityF,SamplesF,FramesF,BeamsF,spr];
    else
        disp('Warning: Missing Mmode flow parameters!!');
    end;
end;


%% Linear probe
if LinTissue>0, %read linear tissue parameters
    desblock=min(find(blktype==StatTissueLinC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        StartDepth      =fread(fid,1,'float32');
        DepthIncrement  =fread(fid,1,'float32');
        Width           =fread(fid,1,'float32');
        Angle           =fread(fid,1,'float32');
        AcqTimeLine     =fread(fid,1,'float32');
        Samples         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        Beams           =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSize        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        CompRej         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        GainTGC         =fread(fid,[1 8],byteprec);
        Frames          =LinTissue;
        Info=[Info,StartDepth,DepthIncrement,Width,Angle,AcqTimeLine,...
                   Samples,Beams,CompRej,GainTGC,Frames];
    else
        disp('Warning: Missing linear tissue parameters!!');
    end;
end;

if LinFlow>0, %read linear flow parameters
    desblock=min(find(blktype==StatFlowLinC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        startDepthF     =fread(fid,1,'float32');
        beamLengthF     =fread(fid,1,'float32');
        relHorizontalOffset =fread(fid,1,'float32');
        angleF          =fread(fid,1,'float32');
        widthF          =fread(fid,1,'float32');
        acqTimeLineF    =fread(fid,1,'float32');
        nyquistVelocityF=fread(fid,1,'float32');
        samplesF        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        beamsF          =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        dataSizeF       =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        mappingTypeF    =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        intensityIncrF  =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        overallGainF    =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        compressF       =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        rejectF         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        tgcF            =fread(fid,[1 6],byteprec);
        
        FramesF         =LinFlow;
        if dataSizeF>16, %% In RF mode!!
            %LinIQ=LinFlow;LinFlow=0;
            Info(9)=LinFlow;Info(8)=0;
            spr=dataSizeF/32;
        else
            %LinFlow=LinFlow;LinIQ=0;
            spr=0;
        end;
        Info=[Info,startDepthF,beamLengthF,relHorizontalOffset,angleF,...
                   widthF,acqTimeLineF,nyquistVelocityF,samplesF,beamsF,...
                   dataSizeF,mappingTypeF,intensityIncrF,overallGainF,...
                   compressF,rejectF,tgcF,FramesF,spr];
    else
        disp('Warning: Missing linear flow parameters!!');
    end;
end;

%% Doppler spectrum
if Spect>0, %read doppler spectrum parameters
    desblock=min(find(blktype==StatusSpectC));
    if desblock,
        fseek(fid,blkpos(desblock)+16,-1);
        SampleVolDepth  =fread(fid,1,'float32');
        PulseLength     =fread(fid,1,'float32');
        Beamangle       =fread(fid,1,'float32');
        CorrectionAngle =fread(fid,1,'float32');
        AcqTimeLine     =fread(fid,1,'float32');
        Fs2Velocity     =fread(fid,1,'float32');
        LowVelocReject  =fread(fid,1,'float32');
        CenterFrequency =fread(fid,1,'float32');
        PRF             =fread(fid,1,'float32');
        Samples         =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        DataSize        =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        Mode            =sum(fread(fid,[1 16],bitprec).*[-2^15 ,2.^[14:-1:0]]);
        Compression     =fread(fid,1,byteprec);
        Reject          =fread(fid,1,byteprec);
        VerticalSmooth  =fread(fid,1,byteprec);
        TemporalAverage =fread(fid,1,byteprec);
        Gain            =fread(fid,1,byteprec);
        baseline        =fread(fid,1,byteprec);
        Records         =Spect;
        Info=[Info,SampleVolDepth,PulseLength,Beamangle,CorrectionAngle,AcqTimeLine,Fs2Velocity,LowVelocReject,...
              CenterFrequency,PRF,Samples,DataSize,Mode,Compression,Reject,VerticalSmooth,TemporalAverage,...
              Gain, baseline, Records];
    else
        disp('Warning: Missing doppler spectral parameters!!');
    end;
end;
frewind(fid);

%% Sync information
if Sync>0,
    SyncBlocks=Sync;
    SyncRecPos=blkpos(find(blktype==SyncC));
    fseek(fid,SyncRecPos(1)+8,-1); %go to first Sync block,skip magicnumber & firstrecord
    RecsPrBlock=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);

    fseek(fid,SyncRecPos(Sync)+4,-1); %go to last Sync block, skip magicnumber
    firstSyncRec=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);     %first record of last block
    RecsLastBlock=sum(fread(fid,[1 32],bitprec).*[-2^31 ,2.^[30:-1:0]]);    %records in last block

    TotalSyncRecs=firstSyncRec+(RecsLastBlock-1);
    if (TotalSyncRecs~=((SyncBlocks-1)*RecsPrBlock)+RecsLastBlock),
        disp('Warning: Sync blocks have different number of Sync records!');
    end;
    Info=[Info, SyncBlocks, TotalSyncRecs];
end;

%% Add blockposition and blocktype vectors to Info vector:
BlocksInFile=length(blkpos);
Info=[Info, BlocksInFile,blkpos',blktype',recSize',numberRecs'];

frewind(fid);
endtime=clock;
usedtime=etime(endtime,starttime);

if any(display),
    dispinfo(Info);
end;