
%   BAT.m

%   This software is protected by german copyright and international treaties.             
%   Copyright 2004 Markus Junghöfer & Peter Peyk. All Rights Reserved.                     
%                                                                                          
%   THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE        
%   NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,    
%   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE    
%   OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
%   TRADEMARKS OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT,       
%   INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE      
%   OR DOCUMENTATION.


DefFilePath=SetDefPath(1,'Batch*');
[NImg,ImgMat,VersionString,BatchFilePath]=ReadFileNames([],DefFilePath,'Please choose an .img batch file:');
NMat=zeros(NImg,74);
fid=fopen([BatchFilePath,'.quart.txt'],'w','b');
Str0='Path\t KonPat\t FpkFpnFluFor\t';
                                                                      
Str1='AllN\t AllPosN\t AllNegN\t AllSumAbs\t AllSumPos\t AllSumNeg\t AllMax\t AllMin\t FrontRightN\t FrontRightPosN\t';
Str2=' FrontRightNegN\t FrontRightSumAbs\t FrontRightSumPos\t FrontRightSumNeg\t FrontRightMax\t FrontRightMin\t BackRightN\t BackRightPosN\t BackRightNegN\t BackRightSumAbs\t';
Str3=' BackRightSumPos\t BackRightSumNeg\t BackRightMax\t BackRightMin\t BackLeftN\t BackLeftPosN\t BackLeftNegN\t BackLeftSumAbs\t BackLeftSumPos\t BackLeftSumNeg\t';
Str4=' BackLeftMax\t BackLeftMin\t FrontLeftN\t FrontLeftPosN\t FrontLeftNegN\t FrontLeftSumAbs\t FrontLeftSumPos\t FrontLeftSumNeg\t FrontLeftMax\t FrontLeftMin\t';
Str5=' FrontN\t FrontPosN\t FrontNegN\t FrontSumAbs\t FrontSumPos\t FrontSumNeg\t FrontMax\t FrontMin\t BackN\t BackPosN\t';
Str6=' BackNegN\t BackSumAbs\t BackSumPos\t BackSumNeg\t BackMax\t BackMin\t RightN\t RightPosN\t RightNegN\t RightSumAbs\t';
Str7=' RightSumPos\t RightSumNeg\t RightMax\t RightMin\t LeftN\t LeftPosN\t  LeftNegN\t LeftSumAbs\t LeftSumPos\t LeftSumNeg\t';
Str8=' LeftMax\t LeftMin';

fprintf(fid,[Str0 Str1 Str2 Str3 Str4 Str5 Str6 Str7 Str8]);
fprintf(fid,'\n');
for ImgInd=1:NImg
    [File,Path,FilePath]=GetFileNameOfMat(ImgMat,ImgInd);
    Tmp=findstr(Path,filesep);
    SubPath=Path(Tmp(end-1)+1:Tmp(end)-1);
    fprintf(fid,'%s\t',SubPath);
    if ~isempty(findstr(FilePath,'FPKN'))
        NMat(ImgInd,1)=1;
    elseif ~isempty(findstr(FilePath,'FPP'))
        NMat(ImgInd,1)=2;
    end
    if ~isempty(findstr(FilePath,'FPK\'))
        NMat(ImgInd,2)=1;
    elseif ~isempty(findstr(FilePath,'FPN\'))
        NMat(ImgInd,2)=2;
    elseif ~isempty(findstr(FilePath,'Flucht'))
        NMat(ImgInd,2)=3;
    elseif ~isempty(findstr(FilePath,'Forensik'))
        NMat(ImgInd,2)=4;
    end
    if isempty(findstr(Path,'FPK\10')) & isempty(findstr(Path,'FPK\11'))
        [NVec,QuartMat,QuartFilePath]=Vox2Quart(FilePath);
        NVec=NVec';
    else
        NVec=zeros(1,72);
    end
    NMat(ImgInd,3:74)=NVec;
    fprintf(fid,'%g\t',NMat(ImgInd,1:73));
    fprintf(fid,'%g',NMat(ImgInd,74));
    fprintf(fid,'\n');
end
fclose(fid);
