NPointsNew=250;
String=['Choose a SCADS *.at* file :'];
DefDataFilePath=SetDefPath(1,'*.at*');
[NFiles,FileMat]=ReadFileNames([],DefDataFilePath,String);

%   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.                                                                      
for FileIndex=1:NFiles
	
	[File,Path,FilePath]=GetFileNameOfMat(FileMat,FileIndex);
	FilePathNew=[FilePath(1:length(FilePath)-2),int2str(NPointsNew)]
	[AvgMat,File,Path,FilePath,NTrialAvgVec,StdChanTimeMat,SampRate,AvgRef,...
	Version,MedMedRawVec,MedMedAvgVec,EegMegStatus,NChanExtra]=ReadAvgFile(FilePath);
	[NChan,NPoints]=size(AvgMat);
	[AvgMat,BaseStartPoint,BaseEndPoint,CalcBaseStatus,BaseVec]=CalcBaseline(AvgMat,1,NPoints);
	AvgMatNew=zeros(NChan,NPointsNew);
	StdChanTimeNew=zeros(NChan,NPointsNew);
	if NPointsNew>=NPoints
		AvgMatNew(:,1:NPoints)=AvgMat;
		StdChanTimeNew(:,1:NPoints)=StdChanTimeMat;
	else
		AvgMatNew(:,1:NPointsNew)=AvgMat(:,1:NPointsNew);
		StdChanTimeNew(:,1:NPointsNew)=StdChanTimeMat(:,1:NPointsNew);
	end
	SaveAvgFile(FilePathNew,AvgMatNew,NTrialAvgVec,StdChanTimeMat,SampRate,MedMedRawVec,MedMedAvgVec,EegMegStatus,NChanExtra);
end
return;
