function [StrucMat,FilePath,SizeStrucMat]=ReadStruc2Exp(DefPath,SaveStatus,SaveFilePath,Orient);
%   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.                                                                      
%==================================================================
%
%	ReadStruc2Exp
%
%
%	Markus Junghoefer	[2000]
%
%
%
%	Function definition
%
%
%=================================================================
if nargin<4; Orient='Coronal'; end
if nargin<3; SaveFilePath=[]; end
if nargin<2; SaveStatus=1; end
if nargin<1; DefPath=[]; end

if isempty(DefPath)
	DefFilePath=SetDefPath(1,'*');
	[File,DefPath]=ReadFilePath([],DefFilePath,'Choose an image file:');
	SetDefPath(2,DefPath);
	if File==0; return; end
else
	if ~strcmp(DefPath(length(DefPath)),filesep)
		DefPath=[DefPath,filesep];
	end
end
NSlice=60;
m=256;
n=256;
NSeek=7904;

clc;
ExpFilePath=[DefPath,'03.Str.img'];
ExpFid=fopen(ExpFilePath,'w','ieee-le');

for ImgInd=1:NSlice
	if ImgInd<10
		ImgIndStr=['00' int2str(ImgInd)];
	elseif ImgInd>9 & ImgInd <100
		ImgIndStr=['0' int2str(ImgInd)];
	elseif ImgInd>99 & ImgInd <1000
		ImgIndStr=[int2str(ImgInd)];
	else 
		error('ImgInd>1000 in ReadStruc')
	end
	FilePath=[DefPath,'I.',ImgIndStr];
	
	fprintf('\n')
	fprintf('Read file:  ')
	fprintf(FilePath)
	ImgFid=fopen(FilePath,'r','ieee-be');
	SeekStatus=fseek(ImgFid,NSeek,-1);
	Tmp=fread(ImgFid,[m,n],'int16');
	if strcmp(Orient,'Coronal')
		TmpTmp=rot90(Tmp);
% 	elseif strcmp(Orient,'Sagital')
% 		TmpTmp=rot90(squeeze(Tmp(:,SliceInd,:)));
% 	elseif strcmp(Orient,'Axial')
% 		TmpTmp=rot90(squeeze(Tmp(:,:,SliceInd)));
	end
	fwrite(ExpFid,TmpTmp,'int16');
	fclose(ImgFid);
end
fclose(ExpFid);
return;
