📄 siemens_ima_read.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head> <title>Description of siemens_ima_read</title> <meta name="keywords" content="siemens_ima_read"> <meta name="description" content="SIEMENS_IMA_READ - read Siemens .ima data file (*.ima)"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="m2html © 2003 Guillaume Flandin"> <meta name="robots" content="index, follow"> <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> > <a href="index.html">mri_toolbox</a> > siemens_ima_read.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td><td align="right"><a href="index.html">Index for mri_toolbox <img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>siemens_ima_read</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>SIEMENS_IMA_READ - read Siemens .ima data file (*.ima)</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function [ ima, machine ] = siemens_ima_read(fileprefix,IMGorient) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment"> SIEMENS_IMA_READ - read Siemens .ima data file (*.ima)
[ ima, machine ] = siemens_ima_read(fileprefix, orient, machine)
fileprefix - a string, the filename without the .ima extension
orient - force reading of specified orientation, integer values:
'', read header history orient field
0, transverse/axial unflipped
1, coronal unflipped
2, sagittal unflipped
3, transverse/axial flipped
4, coronal flipped
5, sagittal flipped
machine - a string, see machineformat in fread for details.
The default here is 'ieee-be' but the routine
will automatically switch between little and big
endian. It reports the appropriate machine
format and can return the machine value.
Returned values:
ima.hdr - a struct with image data parameters.
ima.img - a 3D matrix of image data (double precision).
See also: IMA_HDR_READ (called by this function)</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"></ul><!-- crossreference --><h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><ul style="list-style-image:url(../matlabicon.gif)"><li><a href="#_sub1" class="code">function [ ima ] = read_image(fid,fileprefix,IMGorient,machine)</a></li><li><a href="#_sub2" class="code">function [ ima, machine ] = ima_hdr_read(fileprefix,machine)</a></li></ul><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [ ima, machine ] = siemens_ima_read(fileprefix,IMGorient)</a>0002 0003 <span class="comment">% SIEMENS_IMA_READ - read Siemens .ima data file (*.ima)</span>0004 <span class="comment">%</span>0005 <span class="comment">% [ ima, machine ] = siemens_ima_read(fileprefix, orient, machine)</span>0006 <span class="comment">%</span>0007 <span class="comment">% fileprefix - a string, the filename without the .ima extension</span>0008 <span class="comment">%</span>0009 <span class="comment">% orient - force reading of specified orientation, integer values:</span>0010 <span class="comment">%</span>0011 <span class="comment">% '', read header history orient field</span>0012 <span class="comment">% 0, transverse/axial unflipped</span>0013 <span class="comment">% 1, coronal unflipped</span>0014 <span class="comment">% 2, sagittal unflipped</span>0015 <span class="comment">% 3, transverse/axial flipped</span>0016 <span class="comment">% 4, coronal flipped</span>0017 <span class="comment">% 5, sagittal flipped</span>0018 <span class="comment">%</span>0019 <span class="comment">% machine - a string, see machineformat in fread for details.</span>0020 <span class="comment">% The default here is 'ieee-be' but the routine</span>0021 <span class="comment">% will automatically switch between little and big</span>0022 <span class="comment">% endian. It reports the appropriate machine</span>0023 <span class="comment">% format and can return the machine value.</span>0024 <span class="comment">%</span>0025 <span class="comment">% Returned values:</span>0026 <span class="comment">%</span>0027 <span class="comment">% ima.hdr - a struct with image data parameters.</span>0028 <span class="comment">% ima.img - a 3D matrix of image data (double precision).</span>0029 <span class="comment">%</span>0030 <span class="comment">% See also: IMA_HDR_READ (called by this function)</span>0031 <span class="comment">%</span>0032 0033 <span class="comment">% $Revision: 1.6 $ $Date: 2004/02/07 01:41:51 $</span>0034 0035 <span class="comment">% Licence: GNU GPL, no express or implied warranties</span>0036 <span class="comment">% History: 10/2002, Darren.Weber@flinders.edu.au</span>0037 <span class="comment">%</span>0038 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0039 0040 0041 fprintf(<span class="string">'\n\nUnder development - not functional yet...sorry.\n\n'</span>);0042 <span class="keyword">return</span>0043 0044 0045 <span class="keyword">if</span> ~exist(<span class="string">'fileprefix'</span>,<span class="string">'var'</span>),0046 fprintf(<span class="string">'SIEMENS_IMA_READ: No input fileprefix - see help siemens_ima_read\n'</span>);0047 <span class="keyword">return</span>;0048 <span class="keyword">end</span>0049 <span class="keyword">if</span> ~exist(<span class="string">'IMGorient'</span>,<span class="string">'var'</span>), IMGorient = <span class="string">''</span>; <span class="keyword">end</span>0050 <span class="keyword">if</span> ~exist(<span class="string">'machine'</span>,<span class="string">'var'</span>), machine = <span class="string">'ieee-le'</span>; <span class="keyword">end</span>0051 0052 0053 <span class="comment">% MAIN</span>0054 0055 fid = fopen(sprintf(<span class="string">'%s.ima'</span>,fileprefix),<span class="string">'r'</span>,machine);0056 <span class="keyword">if</span> fid < 0,0057 msg = sprintf(<span class="string">'Cannot open file %s.ima\n'</span>,fileprefix);0058 error(msg);0059 <span class="keyword">else</span>0060 ima = <a href="#_sub1" class="code" title="subfunction [ ima ] = read_image(fid,fileprefix,IMGorient,machine)">read_image</a>(fid,fileprefix,IMGorient,machine);0061 ima.fileprefix = fileprefix;0062 <span class="keyword">end</span>0063 0064 <span class="keyword">return</span>0065 0066 0067 0068 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0069 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0070 <a name="_sub1" href="#_subfunctions" class="code">function [ ima ] = read_image(fid,fileprefix,IMGorient,machine)</a>0071 0072 <span class="comment">% Read the file header</span>0073 [ ima, machine ] = <a href="#_sub2" class="code" title="subfunction [ ima, machine ] = ima_hdr_read(fileprefix,machine)">ima_hdr_read</a>(fileprefix,machine);0074 0075 <span class="keyword">if</span> ~isequal(ima.hdr.hk.sizeof_hdr,6144),0076 fprintf(<span class="string">'SIEMENS_IMA_READ: Failed reading %s Analyze image\n'</span>,fileprefix);0077 ima.img = [];0078 fclose(fid);0079 <span class="keyword">return</span>0080 <span class="keyword">end</span>0081 0082 0083 <span class="comment">% read the whole .img file into matlab (faster)</span>0084 fprintf(<span class="string">'SIEMENS_IMA_READ: Reading Siemens image data.\n'</span>);0085 fseek(fid,6144,<span class="string">'bof'</span>);0086 precision = <span class="string">'double'</span>;0087 tmp = fread(fid,inf,sprintf(<span class="string">'%s=>double'</span>,precision));0088 fclose(fid);0089 0090 <span class="comment">% Now partition the img data into xyz</span>0091 0092 0093 0094 PixelDim = double(ima.hdr.dime.dim(2));0095 RowDim = double(ima.hdr.dime.dim(3));0096 SliceDim = double(ima.hdr.dime.dim(4));0097 0098 0099 0100 <span class="keyword">if</span> ~isempty(IMGorient), ima.hdr.hist.orient = IMGorient; <span class="keyword">end</span>,0101 0102 0103 <span class="keyword">switch</span> double(ima.hdr.hist.orient),0104 0105 <span class="keyword">case</span> 0, <span class="comment">% transverse/axial unflipped</span>0106 0107 <span class="comment">% For the 'transverse unflipped' type, the voxels are stored with</span>0108 <span class="comment">% Pixels in 'x' axis (varies fastest) - from patient right to left</span>0109 <span class="comment">% Rows in 'y' axis - from patient posterior to anterior</span>0110 <span class="comment">% Slices in 'z' axis - from patient inferior to superior</span>0111 0112 fprintf(<span class="string">'SIEMENS_IMA_READ: Image orient appears to be axial unflipped\n'</span>);0113 0114 ima.img = zeros(PixelDim,RowDim,SliceDim);0115 0116 n = 1;0117 <span class="keyword">for</span> z = 1:SliceDim,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -