Home > vbmeg > demo > test_scripts > sbi > readDICOMtbl.m

readDICOMtbl

PURPOSE ^

read DICOMtbl : Rev.1.0, 2001-11-17

SYNOPSIS ^

function [samp,sloc,ier]=readDICOMtbl(dname,fname)

DESCRIPTION ^

 read DICOMtbl : Rev.1.0, 2001-11-17
 read DICOM table

 history
   2001-11-16  S.Kajihara

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [samp,sloc,ier]=readDICOMtbl(dname,fname)
0002 % read DICOMtbl : Rev.1.0, 2001-11-17
0003 % read DICOM table
0004 %
0005 % history
0006 %   2001-11-16  S.Kajihara
0007 %
0008 % Copyright (C) 2011, ATR All Rights Reserved.
0009 % License : New BSD License(see VBMEG_LICENSE.txt)
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, ...  % slice number
0035     'nxy',nxy, ...  % voxel size
0036     'xdir',sx, ...  % Direction Cosine to X axis
0037     'ydir',sy, ...  % Direction Cosine to Y axis
0038     'zdir',sz, ...  % Direction Cosine to Z axis
0039     'z0',s0, ...  % slize origin
0040     'pxspace',ss, ...  % pixel space
0041     'slpitch',sp1);  % slice pitch
0042     
0043 
0044 clear a;
0045

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005