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

📄 cor_img_read.html

📁 mri_toolbox是一个工具用来MRI. 来自于SourceForge, 我上传这个软件,希望能结识对医疗软件感兴趣的兄弟.
💻 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 cor_img_read</title>  <meta name="keywords" content="cor_img_read">  <meta name="description" content="COR_IMG_READ - Read Freesurfer format data (COR-001 to COR-256)">  <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; cor_img_read.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>cor_img_read</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>COR_IMG_READ - Read Freesurfer format data (COR-001 to COR-256)</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, machine ] = cor_img_read(path,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"> COR_IMG_READ - Read Freesurfer format data (COR-001 to COR-256)

 [ avw, machine ] = cor_img_read(path, machine)

 path - the full path to the COR-??? image files.  If empty,
        this function uses uigetfile to locate COR-???.
 
 machine - a string, see machineformat in fread for details.
           The default here is 'ieee-le' but the routine
           will automatically switch between little and big
           endian to read any such Analyze header.  It
           reports the appropriate machine format and can
           return the machine value.

 This function returns an Analyze data structure, with fields:
 
 avw_hdr - a struct with image data parameters.
 avw_img - a 3D matrix of image data (double precision).

 See also: AVW_IMAGE_READ, AVW_HEADER_READ</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_make.html" class="code" title="function [ avw ] = avw_hdr_make">avw_hdr_make</a>	AVW_HDR_MAKE - Create Analyze format data header (avw.hdr)</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="mri_open.html" class="code" title="function [mri] = mri_open(mri)">mri_open</a>	mri_open - function to call various mri data tools</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 ] = read_image(path,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, machine ] = cor_img_read(path,machine)</a>0002 0003 <span class="comment">% COR_IMG_READ - Read Freesurfer format data (COR-001 to COR-256)</span>0004 <span class="comment">%</span>0005 <span class="comment">% [ avw, machine ] = cor_img_read(path, machine)</span>0006 <span class="comment">%</span>0007 <span class="comment">% path - the full path to the COR-??? image files.  If empty,</span>0008 <span class="comment">%        this function uses uigetfile to locate COR-???.</span>0009 <span class="comment">%</span>0010 <span class="comment">% machine - a string, see machineformat in fread for details.</span>0011 <span class="comment">%           The default here is 'ieee-le' but the routine</span>0012 <span class="comment">%           will automatically switch between little and big</span>0013 <span class="comment">%           endian to read any such Analyze header.  It</span>0014 <span class="comment">%           reports the appropriate machine format and can</span>0015 <span class="comment">%           return the machine value.</span>0016 <span class="comment">%</span>0017 <span class="comment">% This function returns an Analyze data structure, with fields:</span>0018 <span class="comment">%</span>0019 <span class="comment">% avw_hdr - a struct with image data parameters.</span>0020 <span class="comment">% avw_img - a 3D matrix of image data (double precision).</span>0021 <span class="comment">%</span>0022 <span class="comment">% See also: AVW_IMAGE_READ, AVW_HEADER_READ</span>0023 <span class="comment">%</span>0024 0025 <span class="comment">% $Revision: 1.4 $ $Date: 2003/07/09 05:25:04 $</span>0026 0027 <span class="comment">% Licence:  GNU GPL, no express or implied warranties</span>0028 <span class="comment">% History:  06/2002, Darren.Weber@flinders.edu.au</span>0029 <span class="comment">%</span>0030 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0031 0032 0033 <span class="keyword">if</span> ~exist(<span class="string">'path'</span>,<span class="string">'var'</span>),0034     fprintf(<span class="string">'No input path - see help cor_img_read\n'</span>);0035     [file, path] = uigetfile({<span class="string">'*.*'</span>},<span class="string">'Select COR-001 File'</span>);0036 <span class="keyword">end</span>0037 <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>0038 0039 [path,name,ext] = fileparts(strcat(path,filesep,<span class="string">'COR-001'</span>));0040 file = fullfile(path,[name ext]);0041 fid = fopen(file,<span class="string">'r'</span>,machine);0042 0043 <span class="keyword">if</span> fid &lt; 0,0044     fprintf(<span class="string">'Cannot open file %s\n'</span>,file);0045     fclose(fid);0046 <span class="keyword">else</span>0047     fclose(fid);0048     avw = <a href="#_sub1" class="code" title="subfunction [ avw ] = read_image(path,machine)">read_image</a>(path,machine);0049 <span class="keyword">end</span>0050 0051 <span class="keyword">return</span>0052 0053 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0054 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>0055 <a name="_sub1" href="#_subfunctions" class="code">function [ avw ] = read_image(path,machine)</a>0056     0057     0058     <span class="comment">% Create the file header, 256^3, 1 mm^3, uchar, etc</span>0059     avw = <a href="avw_hdr_make.html" class="code" title="function [ avw ] = avw_hdr_make">avw_hdr_make</a>;0060     0061     avw.hdr.dime.dim    =  int16([4 256 256 256 1 0 0 0]);0062     avw.hdr.dime.pixdim = single([0   1   1   1 0 0 0 0]);0063     0064     PixelDim = double(avw.hdr.dime.dim(2));0065     RowDim   = double(avw.hdr.dime.dim(3));0066     SliceDim = double(avw.hdr.dime.dim(4));0067     0068     <span class="comment">% Allocate memory for the image</span>0069     avw.img = zeros(PixelDim,SliceDim,RowDim);0070     0071     <span class="comment">% Read one file/slice at a time</span>0072     <span class="keyword">for</span> y = 1:SliceDim,0073         0074         file = sprintf(<span class="string">'COR-%03d'</span>,y);0075         fprintf(<span class="string">'COR_IMAGE_READ:  Reading %s %s image.\n'</span>,machine,file);0076         0077         [path,name,ext] = fileparts(strcat(path,filesep,file));0078         file = fullfile(path,[name ext]);0079         0080         <span class="comment">% read the whole image into matlab (faster)</span>0081         fid = fopen(file,<span class="string">'r'</span>,machine); fseek(fid,0,<span class="string">'bof'</span>);0082         tmp = fread(fid,inf,<span class="string">'uchar=&gt;double'</span>);0083         fclose(fid);0084         0085         <span class="comment">% Arrange image into avw.img xyz matrix</span>0086         <span class="comment">% For Freesurfer COR files the voxels are stored with</span>0087         <span class="comment">% Pixels in 'x' axis (varies fastest) - from patient right to left</span>0088         <span class="comment">% Rows in   'z' axis                  - from patient superior to inferior</span>0089         <span class="comment">% Slices in 'y' axis                  - from patient posterior to anterior</span>0090         0091         n = 1;0092         <span class="keyword">for</span> z = RowDim:-1:1,0093             x = 1:PixelDim;0094             avw.img(x,y,z) = tmp(n:n+(PixelDim-1));0095             n = n + PixelDim;0096         <span class="keyword">end</span>0097     <span class="keyword">end</span>0098     0099     0100     avw.hdr.hist.orient = 0;0101     0102 <span class="keyword">return</span></pre></div><hr><address>Generated on Fri 21-May-2004 12:38:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address></body></html>

⌨️ 快捷键说明

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