📄 ctf_write_mri.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 ctf_write_mri</title> <meta name="keywords" content="ctf_write_mri"> <meta name="description" content="ctf_write_mri - write a CTF .mri file"> <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> > ctf_write_mri.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>ctf_write_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_write_mri - write 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 ctf_write_mri(mri, fileName, force) </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_write_mri - write a CTF .mri file
ctf_write_mri(mri,fileName,force)
mri is a data struct returned from ctf_read_mri. It may contain
mri.file, in which case, you do not need the fileName input here. If the
file exists, you are prompted for a new file name, unless force = 1.
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
<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %
< > %
< DISCLAIMER: > %
< > %
< THIS PROGRAM IS INTENDED FOR RESEARCH PURPOSES ONLY. > %
< THIS PROGRAM IS IN NO WAY INTENDED FOR CLINICAL OR > %
< OFFICIAL USE. > %
< > %
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<> %</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_write(fid,Version_2_Header),</a></li><li><a href="#_sub2" class="code">function headModel_write(fid,HeadModel_Info),</a></li><li><a href="#_sub3" class="code">function imageInfo_write(fid,Image_Info),</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 ctf_write_mri(mri, fileName, force)</a>0002 0003 <span class="comment">% ctf_write_mri - write a CTF .mri file</span>0004 <span class="comment">%</span>0005 <span class="comment">% ctf_write_mri(mri,fileName,force)</span>0006 <span class="comment">%</span>0007 <span class="comment">% mri is a data struct returned from ctf_read_mri. It may contain</span>0008 <span class="comment">% mri.file, in which case, you do not need the fileName input here. If the</span>0009 <span class="comment">% file exists, you are prompted for a new file name, unless force = 1.</span>0010 <span class="comment">%</span>0011 <span class="comment">% The CTF MRI File format used by MRIViewer consists of a binary file with</span>0012 <span class="comment">% a 1,028 byte header. The MRI data can be in 8-bit (unsigned character) or</span>0013 <span class="comment">% 16-bit (unsigned short integer) format and consists of 256 x 256 pixel</span>0014 <span class="comment">% slices, stored as 256 contiguous sagittal slices from left to right (or</span>0015 <span class="comment">% right to left if head orientation is left-on-right). Each slice is stored</span>0016 <span class="comment">% as individual pixels starting at the left, anterior, superior</span>0017 <span class="comment">% corner and scanning downwards row by row. Therefore the coronal</span>0018 <span class="comment">% position is fastest changing, axial position second fastest</span>0019 <span class="comment">% changing and sagittal position slowest changing value in the</span>0020 <span class="comment">% file, always in the positive direction for each axis (see section</span>0021 <span class="comment">% on Head Coordinate System for axis definitions). By default CTF</span>0022 <span class="comment">% MRI files have the file extension .mri</span>0023 <span class="comment">%</span>0024 <span class="comment">% <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> %</span>0025 <span class="comment">% < > %</span>0026 <span class="comment">% < DISCLAIMER: > %</span>0027 <span class="comment">% < > %</span>0028 <span class="comment">% < THIS PROGRAM IS INTENDED FOR RESEARCH PURPOSES ONLY. > %</span>0029 <span class="comment">% < THIS PROGRAM IS IN NO WAY INTENDED FOR CLINICAL OR > %</span>0030 <span class="comment">% < OFFICIAL USE. > %</span>0031 <span class="comment">% < > %</span>0032 <span class="comment">% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<> %</span>0033 <span class="comment">%</span>0034 0035 0036 0037 <span class="comment">% $Revision: 1.1 $ $Date: 2004/05/21 18:58:11 $</span>0038 0039 <span class="comment">% Licence: GNU GPL, no implied or express warranties</span>0040 <span class="comment">% History: 08/2003, Darren.Weber_at_radiology.ucsf.edu</span>0041 <span class="comment">% - adapted from an appendex to CTF document</span>0042 <span class="comment">% MRIConverter.pdf, which is copied at the end of this</span>0043 <span class="comment">% function.</span>0044 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0045 0046 0047 ver = <span class="string">'[$Revision: 1.1 $]'</span>;0048 fprintf(<span class="string">'\nCTF_WRITE_MRI [v%s]\n'</span>,ver(12:16)); tic;0049 0050 <span class="keyword">if</span> ~exist(<span class="string">'mri'</span>,<span class="string">'var'</span>), error(<span class="string">'no input mri data struct'</span>); <span class="keyword">end</span>0051 <span class="keyword">if</span> isempty(mri), error(<span class="string">'empty input mri data struct'</span>); <span class="keyword">end</span>0052 0053 <span class="keyword">if</span> ~exist(<span class="string">'force'</span>,<span class="string">'var'</span>), force = 0; <span class="keyword">end</span> <span class="comment">% don't overwrite</span>0054 <span class="keyword">if</span> isempty(force), force = 0; <span class="keyword">end</span>0055 0056 <span class="keyword">if</span> ~exist(<span class="string">'fileName'</span>,<span class="string">'var'</span>),0057 <span class="keyword">if</span> isfield(mri,<span class="string">'file'</span>),0058 file = mri.file;0059 <span class="keyword">else</span>0060 [fileName, filePath, filterIndex] = uigetfile(<span class="string">'*.mri'</span>, <span class="string">'Locate CTF .mri file'</span>);0061 file = fullfile(filePath, fileName);0062 <span class="keyword">end</span>0063 <span class="keyword">else</span>0064 [filePath, fileName, fileExt] = fileparts(fileName);0065 file = fullfile(filePath, [fileName,<span class="string">'.mri'</span>]);0066 <span class="keyword">end</span>0067 0068 <span class="keyword">if</span> isempty(file),0069 error(<span class="string">'...file is empty\n'</span>);0070 <span class="keyword">end</span>0071 0072 <span class="keyword">if</span> exist(file,<span class="string">'file'</span>),0073 <span class="keyword">if</span> force,0074 fprintf(<span class="string">'...file already exists, overwriting it.\n'</span>);0075 <span class="keyword">else</span>0076 fprintf(<span class="string">'...file already exists\n'</span>);0077 [fileName, pathName] = uiputfile(<span class="string">'*.mri'</span>, <span class="string">'Specify CTF .mri file to write'</span>);0078 file = fullfile(filePath, [fileName,<span class="string">'.mri'</span>]);0079 <span class="keyword">end</span>0080 <span class="keyword">end</span>0081 0082 0083 0084 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0085 <span class="comment">% open the file for writing</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -