⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctf_read_mri.html

📁 mri_toolbox是一个工具用来MRI. 来自于SourceForge, 我上传这个软件,希望能结识对医疗软件感兴趣的兄弟.
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head>  <title>Description of ctf_read_mri</title>  <meta name="keywords" content="ctf_read_mri">  <meta name="description" content="ctf_read_mri - read a CTF .mri file">  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <meta name="generator" content="m2html &copy; 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> &gt;  <a href="index.html">mri_toolbox</a> &gt; ctf_read_mri.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td><td align="right"><a href="index.html">Index for mri_toolbox&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>ctf_read_mri</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>ctf_read_mri - read a CTF .mri file</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 mri = ctf_read_mri(file) </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"> ctf_read_mri - read a CTF .mri file

 mri = ctf_read_mri(fileName)

 The CTF MRI File format used by MRIViewer consists of a binary file with
 a 1,028 byte header. The MRI data can be in 8-bit (unsigned character) or
 16-bit (unsigned short integer) format and consists of 256 x 256 pixel
 slices, stored as 256 contiguous sagittal slices from left to right (or
 right to left if head orientation is left-on-right). Each slice is stored
 as individual pixels starting at the left, anterior, superior
 corner and scanning downwards row by row. Therefore the coronal
 position is fastest changing, axial position second fastest
 changing and sagittal position slowest changing value in the
 file, always in the positive direction for each axis (see section
 on Head Coordinate System for axis definitions). By default CTF
 MRI files have the file extension .mri</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 Version_2_Header = Version_2_Header_read(fid),</a></li><li><a href="#_sub2" class="code">function HeadModel_Info = headModel(fid),</a></li><li><a href="#_sub3" class="code">function Image_Info = imageInfo(fid),</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 mri = ctf_read_mri(file)</a>0002 0003 <span class="comment">% ctf_read_mri - read a CTF .mri file</span>0004 <span class="comment">%</span>0005 <span class="comment">% mri = ctf_read_mri(fileName)</span>0006 <span class="comment">%</span>0007 <span class="comment">% The CTF MRI File format used by MRIViewer consists of a binary file with</span>0008 <span class="comment">% a 1,028 byte header. The MRI data can be in 8-bit (unsigned character) or</span>0009 <span class="comment">% 16-bit (unsigned short integer) format and consists of 256 x 256 pixel</span>0010 <span class="comment">% slices, stored as 256 contiguous sagittal slices from left to right (or</span>0011 <span class="comment">% right to left if head orientation is left-on-right). Each slice is stored</span>0012 <span class="comment">% as individual pixels starting at the left, anterior, superior</span>0013 <span class="comment">% corner and scanning downwards row by row. Therefore the coronal</span>0014 <span class="comment">% position is fastest changing, axial position second fastest</span>0015 <span class="comment">% changing and sagittal position slowest changing value in the</span>0016 <span class="comment">% file, always in the positive direction for each axis (see section</span>0017 <span class="comment">% on Head Coordinate System for axis definitions). By default CTF</span>0018 <span class="comment">% MRI files have the file extension .mri</span>0019 <span class="comment">%</span>0020 0021 <span class="comment">% $Revision: 1.1 $ $Date: 2004/05/21 18:58:11 $</span>0022 0023 <span class="comment">% Licence:  GNU GPL, no implied or express warranties</span>0024 <span class="comment">% History:  08/2003, Darren.Weber_at_radiology.ucsf.edu</span>0025 <span class="comment">%                    - adapted from an appendex to CTF document</span>0026 <span class="comment">%                    MRIConverter.pdf, which is copied at the end of this</span>0027 <span class="comment">%                    function.</span>0028 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0029 0030 0031 ver = <span class="string">'[$Revision: 1.1 $]'</span>;0032 fprintf(<span class="string">'\nCTF_READ_MRI [v%s]\n'</span>,ver(12:16));  tic;0033 0034 fprintf(<span class="string">'...checking file input parameter\n'</span>);0035 0036 <span class="keyword">if</span> ~exist(<span class="string">'file'</span>,<span class="string">'var'</span>),0037   [fileName, filePath, filterIndex] = uigetfile(<span class="string">'*.mri'</span>, <span class="string">'Locate CTF .mri file'</span>);0038   file = fullfile(filePath, fileName);0039 <span class="keyword">elseif</span> isempty(file),0040   fprintf(<span class="string">'...file is empty\n'</span>);0041   [fileName, filePath, filterIndex] = uigetfile(<span class="string">'*.mri'</span>, <span class="string">'Locate CTF .mri file'</span>);0042   file = fullfile(filePath, fileName);0043 <span class="keyword">end</span>0044 <span class="keyword">if</span> ~exist(file,<span class="string">'file'</span>),0045   fprintf(<span class="string">'...file does not exist\n'</span>);0046   [fileName, filePath, filterIndex] = uigetfile(<span class="string">'*.mri'</span>, <span class="string">'Locate CTF .mri file'</span>);0047   file = fullfile(filePath, fileName);0048 <span class="keyword">end</span>0049 0050 mri.file = file;0051 0052 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0053 <span class="comment">% open the file for reading</span>0054 <span class="comment">%    'ieee-be.l64' or 's' - IEEE floating point with big-endian byte</span>0055 <span class="comment">%                            ordering and 64 bit long data type.</span>0056 [fid,message] = fopen(mri.file,<span class="string">'rb'</span>,<span class="string">'s'</span>);0057 <span class="keyword">if</span> fid &lt; 0, error(<span class="string">'cannot open file'</span>); <span class="keyword">end</span>0058 0059 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0060 <span class="comment">% read the file header</span>0061 fprintf(<span class="string">'...reading header '</span>);0062 mri.hdr = <a href="#_sub1" class="code" title="subfunction Version_2_Header = Version_2_Header_read(fid),">Version_2_Header_read</a>(fid);0063 0064 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0065 <span class="comment">% check header size, header should be 1028 bytes</span>0066 header_bytes = ftell(fid);0067 fprintf(<span class="string">'(%d bytes)\n'</span>,header_bytes);0068 <span class="keyword">if</span> header_bytes ~= 1028,0069   msg = sprintf(<span class="string">'failed to read 1028 bytes from the header, read %d bytes'</span>,header_bytes);0070   error(msg);0071 <span class="keyword">end</span>0072 0073 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0074 <span class="comment">% seek beyond the header, to the beginning of the data matrix</span>0075 fseek(fid,1028,<span class="string">'bof'</span>);0076 0077 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0078 <span class="comment">% check if the data is 8 or 16 bits</span>0079 <span class="keyword">switch</span> mri.hdr.dataSize,0080   <span class="keyword">case</span> 1, <span class="comment">% we have 8 bit data</span>0081     fprintf(<span class="string">'...reading 8 bit image data\n'</span>);0082     precision = <span class="string">'uchar'</span>;0083   <span class="keyword">case</span> 2, <span class="comment">% we have 16 bit data</span>0084     fprintf(<span class="string">'...reading 16 bit image data\n'</span>);0085     precision = <span class="string">'int16'</span>;0086   <span class="keyword">otherwise</span>,0087     msg = sprintf(<span class="string">'unknown mri.hdr.dataSize: %g'</span>,mri.hdr.dataSize);0088     error(msg);0089 <span class="keyword">end</span>0090 0091 0092 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0093 <span class="comment">% read the image data array</span>0094 0095 <span class="comment">% adjust for matlab version</span>0096 ver = version;0097 ver = str2num(ver(1));0098 <span class="keyword">if</span> ver &lt; 6,0099   data = fread(fid,inf,sprintf(<span class="string">'%s'</span>,precision));0100 <span class="keyword">else</span>,0101   data = fread(fid,inf,sprintf(<span class="string">'%s=&gt;double'</span>,precision));0102 <span class="keyword">end</span>0103 fclose(fid);0104 0105 0106 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0107 <span class="comment">% now we have the data array, allocate it to a 3D matrix</span>0108 0109 <span class="comment">% The CTF MRI File format used by MRIViewer consists of a binary file with a</span>0110 <span class="comment">% 1,028 byte header. The MRI data can be in 8-bit (unsigned character) or 16-bit</span>0111 <span class="comment">% (unsigned short integer) format and consists of 256 x 256 pixel slices, stored as</span>0112 <span class="comment">% 256 contiguous sagittal slices from left to right (or right to left if head orientation</span>0113 <span class="comment">% is &quot;left-on-right&quot;). Each slice is stored as individual pixels starting at the</span>0114 <span class="comment">% top left corner and scanning downwards row by row. Therefore the coronal</span>0115 <span class="comment">% position is fastest changing, axial position second fastest changing and sagittal</span>0116 <span class="comment">% position slowest changing value in the file, always in the positive direction for</span>0117 <span class="comment">% each axis (see section on Head Coordinate System for axis definitions). By</span>0118 <span class="comment">% default CTF MRI files have the file extension &quot;.mri&quot;</span>0119 0120 <span class="comment">% MRIViewer uses these cardinal directions as axes in an internal coordinate system</span>0121 <span class="comment">% where sagittal = X, coronal = Y and axial = Z forming an additional</span>0122 <span class="comment">% right-handed coordinate system which is translated and rotated with respect to</span>0123 <span class="comment">% the Head Coordinate System and has its origin at the upper left anterior corner</span>0124 <span class="comment">% of the volume.</span>0125 0126 PixelDim = 256;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -