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

📄 avw_img_write.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 avw_img_write</title>  <meta name="keywords" content="avw_img_write">  <meta name="description" content="avw_img_write - write Analyze image files (*.img)">  <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; avw_img_write.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>avw_img_write</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>avw_img_write - write Analyze image files (*.img)</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 avw_img_write(avw, fileprefix, IMGorient, machine) </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"> avw_img_write - write Analyze image files (*.img)
 
 avw_img_write(avw, fileprefix, [IMGorient], [machine])
 
 avw.img    - a 3D matrix of image data (double precision).
 avw.hdr    - a struct with image data parameters.  If
              not empty, this function calls avw_hdr_write.
 
 fileprefix - a string, the filename without the .img
              extension. If empty, may use avw.fileprefix
 
 IMGorient - optional int, force writing of specified 
             orientation, with values:
 
   [],  if empty, will use avw.hdr.hist.orient field
    0,  transverse/axial unflipped (default, radiological)
    1,  coronal unflipped
    2,  sagittal unflipped
    3,  transverse/axial flipped, left to right
    4,  coronal flipped, anterior to posterior
    5,  sagittal flipped, superior to inferior
 
 This function will set avw.hdr.hist.orient and write the 
 image data in a corresponding order.  This function is 
 in alpha development, so it has not been exhaustively 
 tested (07/2003). See avw_img_read for more information 
 and documentation on the orientation option.  
 Orientations 3-5 are NOT recommended!  They are part 
 of the Analyze format, but only used in Analyze
 for faster raster graphics during movies.
 
 machine - a string, see machineformat in fread for details.
           The default here is 'ieee-le'.
 
 Tip: to change the data type, set avw.hdr.dime.datatype to:
 
     1    Binary             (  1 bit  per voxel)
     2    Unsigned character (  8 bits per voxel)
     4    Signed short       ( 16 bits per voxel)
     8    Signed integer     ( 32 bits per voxel)
    16    Floating point     ( 32 bits per voxel)
    32    Complex, 2 floats  ( 64 bits per voxel), not supported
    64    Double precision   ( 64 bits per voxel)
   128    Red-Green-Blue     (128 bits per voxel), not supported
 
 See also: <a href="avw_write.html" class="code" title="function avw_write(avw, fileprefix, IMGorient, machine)">avw_write</a>, <a href="avw_hdr_write.html" class="code" title="function avw_hdr_write(avw, fileprefix, machine)">avw_hdr_write</a>,           <a href="avw_read.html" class="code" title="function [ avw, machine ] = avw_read(fileprefix,IMGorient,machine)">avw_read</a>, <a href="avw_hdr_read.html" class="code" title="function [ avw, machine ] = avw_hdr_read(fileprefix, machine)">avw_hdr_read</a>, <a href="avw_img_read.html" class="code" title="function [ avw, machine ] = avw_img_read(fileprefix,IMGorient,machine)">avw_img_read</a>, <a href="avw_view.html" class="code" title="function [ varargout ] = avw_view(avw,parent,command),">avw_view</a></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)"><li><a href="avw_hdr_write.html" class="code" title="function avw_hdr_write(avw, fileprefix, machine)">avw_hdr_write</a>	AVW_HDR_WRITE - Write Analyze header file (*.hdr)</li><li><a href="avw_img_write.html" class="code" title="function avw_img_write(avw, fileprefix, IMGorient, machine)">avw_img_write</a>	avw_img_write - write Analyze image files (*.img)</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="avw_converter_script.html" class="code" title="">avw_converter_script</a>	avw_converter_script - convert byte order of .img files</li><li><a href="avw_img_write.html" class="code" title="function avw_img_write(avw, fileprefix, IMGorient, machine)">avw_img_write</a>	avw_img_write - write Analyze image files (*.img)</li><li><a href="avw_write.html" class="code" title="function avw_write(avw, fileprefix, IMGorient, machine)">avw_write</a>	avw_write - write Analyze files (*.img & *.hdr)</li></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 avw = write_image(fid,avw,fileprefix,IMGorient,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 avw_img_write(avw, fileprefix, IMGorient, machine)</a>0002 0003 <span class="comment">% avw_img_write - write Analyze image files (*.img)</span>0004 <span class="comment">%</span>0005 <span class="comment">% avw_img_write(avw, fileprefix, [IMGorient], [machine])</span>0006 <span class="comment">%</span>0007 <span class="comment">% avw.img    - a 3D matrix of image data (double precision).</span>0008 <span class="comment">% avw.hdr    - a struct with image data parameters.  If</span>0009 <span class="comment">%              not empty, this function calls avw_hdr_write.</span>0010 <span class="comment">%</span>0011 <span class="comment">% fileprefix - a string, the filename without the .img</span>0012 <span class="comment">%              extension. If empty, may use avw.fileprefix</span>0013 <span class="comment">%</span>0014 <span class="comment">% IMGorient - optional int, force writing of specified</span>0015 <span class="comment">%             orientation, with values:</span>0016 <span class="comment">%</span>0017 <span class="comment">%   [],  if empty, will use avw.hdr.hist.orient field</span>0018 <span class="comment">%    0,  transverse/axial unflipped (default, radiological)</span>0019 <span class="comment">%    1,  coronal unflipped</span>0020 <span class="comment">%    2,  sagittal unflipped</span>0021 <span class="comment">%    3,  transverse/axial flipped, left to right</span>0022 <span class="comment">%    4,  coronal flipped, anterior to posterior</span>0023 <span class="comment">%    5,  sagittal flipped, superior to inferior</span>0024 <span class="comment">%</span>0025 <span class="comment">% This function will set avw.hdr.hist.orient and write the</span>0026 <span class="comment">% image data in a corresponding order.  This function is</span>0027 <span class="comment">% in alpha development, so it has not been exhaustively</span>0028 <span class="comment">% tested (07/2003). See avw_img_read for more information</span>0029 <span class="comment">% and documentation on the orientation option.</span>0030 <span class="comment">% Orientations 3-5 are NOT recommended!  They are part</span>0031 <span class="comment">% of the Analyze format, but only used in Analyze</span>0032 <span class="comment">% for faster raster graphics during movies.</span>0033 <span class="comment">%</span>0034 <span class="comment">% machine - a string, see machineformat in fread for details.</span>0035 <span class="comment">%           The default here is 'ieee-le'.</span>0036 <span class="comment">%</span>0037 <span class="comment">% Tip: to change the data type, set avw.hdr.dime.datatype to:</span>0038 <span class="comment">%</span>0039 <span class="comment">%     1    Binary             (  1 bit  per voxel)</span>0040 <span class="comment">%     2    Unsigned character (  8 bits per voxel)</span>0041 <span class="comment">%     4    Signed short       ( 16 bits per voxel)</span>0042 <span class="comment">%     8    Signed integer     ( 32 bits per voxel)</span>0043 <span class="comment">%    16    Floating point     ( 32 bits per voxel)</span>0044 <span class="comment">%    32    Complex, 2 floats  ( 64 bits per voxel), not supported</span>0045 <span class="comment">%    64    Double precision   ( 64 bits per voxel)</span>0046 <span class="comment">%   128    Red-Green-Blue     (128 bits per voxel), not supported</span>0047 <span class="comment">%</span>0048 <span class="comment">% See also: avw_write, avw_hdr_write,</span>0049 <span class="comment">%           avw_read, avw_hdr_read, avw_img_read, avw_view</span>0050 <span class="comment">%</span>0051 0052 <span class="comment">% $Revision: 1.8 $ $Date: 2004/02/07 01:41:51 $</span>0053 0054 <span class="comment">% Licence:  GNU GPL, no express or implied warranties</span>0055 <span class="comment">% History:  05/2002, Darren.Weber@flinders.edu.au</span>0056 <span class="comment">%                    The Analyze format is copyright</span>0057 <span class="comment">%                    (c) Copyright, 1986-1995</span>0058 <span class="comment">%                    Biomedical Imaging Resource, Mayo Foundation</span>0059 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0060 0061 0062 <span class="comment">%------------------------------------------------------------------------</span>0063 <span class="comment">% Check inputs</span>0064 0065 <span class="keyword">if</span> ~exist(<span class="string">'avw'</span>,<span class="string">'var'</span>),0066     doc <a href="avw_img_write.html" class="code" title="function avw_img_write(avw, fileprefix, IMGorient, machine)">avw_img_write</a>;0067     msg = sprintf(<span class="string">'\n...no input avw.\n'</span>);0068     error(msg);0069 <span class="keyword">elseif</span> isempty(avw),0070     msg = sprintf(<span class="string">'\n...empty input avw.\n'</span>);0071     error(msg);0072 <span class="keyword">elseif</span> ~isfield(avw,<span class="string">'img'</span>),0073     msg = sprintf(<span class="string">'\n...empty input avw.img\n'</span>);0074     error(msg);0075 <span class="keyword">end</span>0076 0077 <span class="keyword">if</span> ~exist(<span class="string">'fileprefix'</span>,<span class="string">'var'</span>),0078     <span class="keyword">if</span> isfield(avw,<span class="string">'fileprefix'</span>),0079         <span class="keyword">if</span> ~isempty(avw.fileprefix),0080             fileprefix = avw.fileprefix;0081         <span class="keyword">else</span>0082             fileprefix = <span class="string">''</span>;0083         <span class="keyword">end</span>0084     <span class="keyword">end</span>0085 <span class="keyword">end</span>0086 <span class="keyword">if</span> isempty(fileprefix),0087     doc <a href="avw_img_write.html" class="code" title="function avw_img_write(avw, fileprefix, IMGorient, machine)">avw_img_write</a>;0088     fprintf(<span class="string">'\n...no input fileprefix - see help avw_img_write\n'</span>);0089     <span class="keyword">return</span>;0090 <span class="keyword">end</span>0091 0092 <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>0093 <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>0094 0095 <span class="keyword">if</span> findstr(<span class="string">'.hdr'</span>,fileprefix),0096 <span class="comment">%    fprintf('AVW_IMG_WRITE: Removing .hdr extension from ''%s''\n',fileprefix);</span>0097     fileprefix = strrep(fileprefix,<span class="string">'.hdr'</span>,<span class="string">''</span>);0098 <span class="keyword">end</span>0099 <span class="keyword">if</span> findstr(<span class="string">'.img'</span>,fileprefix),0100 <span class="comment">%    fprintf('AVW_IMG_WRITE: Removing .img extension from ''%s''\n',fileprefix);</span>0101     fileprefix = strrep(fileprefix,<span class="string">'.img'</span>,<span class="string">''</span>);0102 <span class="keyword">end</span>0103 0104 0105 0106 <span class="comment">%------------------------------------------------------------------------</span>0107 <span class="comment">% MAIN</span>0108 0109 version = <span class="string">'[$Revision: 1.8 $]'</span>;0110 fprintf(<span class="string">'\nAVW_IMG_WRITE [v%s]\n'</span>,version(12:16));  tic;0111 0112 fid = fopen(sprintf(<span class="string">'%s.img'</span>,fileprefix),<span class="string">'w'</span>,machine);0113 <span class="keyword">if</span> fid &lt; 0,0114     msg = sprintf(<span class="string">'Cannot open file %s.img\n'</span>,fileprefix);0115     error(msg);0116 <span class="keyword">else</span>0117     avw = <a href="#_sub1" class="code" title="subfunction avw = write_image(fid,avw,fileprefix,IMGorient,machine)">write_image</a>(fid,avw,fileprefix,IMGorient,machine);0118 <span class="keyword">end</span>0119 0120 t=toc; fprintf(<span class="string">'...done (%5.2f sec).\n\n'</span>,t);0121 0122 <span class="comment">% MUST write header after the image, to ensure any</span>0123 <span class="comment">% orientation changes during image write are saved</span>0124 <span class="comment">% in the header</span>0125 <a href="avw_hdr_write.html" class="code" title="function avw_hdr_write(avw, fileprefix, machine)">avw_hdr_write</a>(avw,fileprefix,machine);0126 0127 <span class="keyword">return</span>0128 0129 0130 0131 0132 <span class="comment">%-----------------------------------------------------------------------------------</span>0133 0134 <a name="_sub1" href="#_subfunctions" class="code">function avw = write_image(fid,avw,fileprefix,IMGorient,machine)</a>0135 0136 <span class="comment">% short int bitpix;    /* Number of bits per pixel; 1, 8, 16, 32, or 64. */</span>0137 <span class="comment">% short int datatype   /* Datatype for this image set */</span>0138 <span class="comment">% /*Acceptable values for datatype are*/</span>0139 <span class="comment">% #define DT_NONE             0</span>0140 <span class="comment">% #define DT_UNKNOWN          0    /*Unknown data type*/</span>0141 <span class="comment">% #define DT_BINARY           1    /*Binary             ( 1 bit per voxel)*/</span>0142 <span class="comment">% #define DT_UNSIGNED_CHAR    2    /*Unsigned character ( 8 bits per voxel)*/</span>0143 <span class="comment">% #define DT_SIGNED_SHORT     4    /*Signed short       (16 bits per voxel)*/</span>0144 <span class="comment">% #define DT_SIGNED_INT       8    /*Signed integer     (32 bits per voxel)*/</span>0145 <span class="comment">% #define DT_FLOAT           16    /*Floating point     (32 bits per voxel)*/</span>0146 <span class="comment">% #define DT_COMPLEX         32    /*Complex,2 floats   (64 bits per voxel)/*</span>0147 <span class="comment">% #define DT_DOUBLE          64    /*Double precision   (64 bits per voxel)*/</span>0148 <span class="comment">% #define DT_RGB            128    /*A Red-Green-Blue datatype*/</span>0149 <span class="comment">% #define DT_ALL            255    /*Undocumented*/</span>

⌨️ 快捷键说明

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