0001 function [samp,sloc,ier]=readDICOMtbl(dname,fname)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 ier=0;
0012
0013 fname1=sprintf('%s%s',dname,fname);
0014 fid=fopen(fname1);
0015 if fid==-1, disp('XXX Error : Cannot open mri-table file !!\n'); ier=1; return; end
0016
0017 a=fscanf(fid,'%s'); fclose(fid);
0018 sx=str2num(a(findstr(a,'image_x_vector=')+15:findstr(a,'image_y_vector=')-1));
0019 sy=str2num(a(findstr(a,'image_y_vector=')+15:findstr(a,'image_z_vector=')-1));
0020 sz=str2num(a(findstr(a,'image_z_vector=')+15:findstr(a,'pixel_spacing=')-1));
0021 s0=str2num(a(findstr(a,'z0_slice_origin=')+16:findstr(a,'magnification=')-1));
0022 ss=str2num(a(findstr(a,'pixel_spacing=')+14:findstr(a,'z0_slice_origin=')-1));
0023 sp1=findstr(a,'slice_pitch=')+12; sp2=findstr(a(sp1:size(a,2)),'te=')-1; sp=str2num(a(sp1:sp1+sp2-1));
0024 nsl=str2num(a(findstr(a,'number_of_slices=')+17:findstr(a,'number_of_echos=')-1));
0025 nxy=str2num(a(findstr(a,'image_size=')+11:findstr(a,'examination_date=')-1));
0026
0027 b=1; sloc=[]; fid=fopen(fname1);
0028 while b,
0029 if ~isempty(findstr(char(fgets(fid)),'slice_location_table')), b=0; end
0030 end
0031 for i=1:nsl, sloc(i)=str2num(char(fgets(fid))); end
0032 fclose(fid);
0033
0034 samp=struct('nsl',nsl, ...
0035 'nxy',nxy, ...
0036 'xdir',sx, ...
0037 'ydir',sy, ...
0038 'zdir',sz, ...
0039 'z0',s0, ...
0040 'pxspace',ss, ...
0041 'slpitch',sp1);
0042
0043
0044 clear a;
0045