<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>img_e7.c Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">img_e7.c</div> </div> </div> <div class="contents"> <a href="img__e7_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/******************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> Copyright (c) 2007,2010 Turku PET Centre</span> <a name="l00004"></a>00004 <span class="comment"></span> <a name="l00005"></a>00005 <span class="comment"> Library: img_e7.c</span> <a name="l00006"></a>00006 <span class="comment"> Description: ECAT 7 I/O routines for IMG data.</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> This library is free software; you can redistribute it and/or</span> <a name="l00009"></a>00009 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span> <a name="l00010"></a>00010 <span class="comment"> License as published by the Free Software Foundation; either</span> <a name="l00011"></a>00011 <span class="comment"> version 2.1 of the License, or (at your option) any later version.</span> <a name="l00012"></a>00012 <span class="comment"></span> <a name="l00013"></a>00013 <span class="comment"> This library is distributed in the hope that it will be useful,</span> <a name="l00014"></a>00014 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00015"></a>00015 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</span> <a name="l00016"></a>00016 <span class="comment"> See the GNU Lesser General Public License for more details:</span> <a name="l00017"></a>00017 <span class="comment"> http://www.gnu.org/copyleft/lesser.html</span> <a name="l00018"></a>00018 <span class="comment"></span> <a name="l00019"></a>00019 <span class="comment"> You should have received a copy of the GNU Lesser General Public License</span> <a name="l00020"></a>00020 <span class="comment"> along with this library/program; if not, write to the Free Software</span> <a name="l00021"></a>00021 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </span> <a name="l00022"></a>00022 <span class="comment"></span> <a name="l00023"></a>00023 <span class="comment"> Turku PET Centre, Turku, Finland, http://www.turkupetcentre.fi/</span> <a name="l00024"></a>00024 <span class="comment"></span> <a name="l00025"></a>00025 <span class="comment"> Modification history:</span> <a name="l00026"></a>00026 <span class="comment"> 2007-02-27 Vesa Oikonen</span> <a name="l00027"></a>00027 <span class="comment"> Functions moved from imgfile.c.</span> <a name="l00028"></a>00028 <span class="comment"> Bug correction in imgWrite2DEcat7():</span> <a name="l00029"></a>00029 <span class="comment"> prompts were set after the header was written.</span> <a name="l00030"></a>00030 <span class="comment"> 2007-03-25 VO</span> <a name="l00031"></a>00031 <span class="comment"> Added functions imgReadEcat7Header(), imgEcat7Supported(),</span> <a name="l00032"></a>00032 <span class="comment"> imgReadEcat7Frame(), imgReadEcat7FirstFrame(), imgGetEcat7Fileformat(),</span> <a name="l00033"></a>00033 <span class="comment"> imgWriteEcat7Frame(), and imgSetEcat7SHeader().</span> <a name="l00034"></a>00034 <span class="comment"> 2007-04-03 VO</span> <a name="l00035"></a>00035 <span class="comment"> Added support for ECAT 7 polar maps.</span> <a name="l00036"></a>00036 <span class="comment"> 2007-17-07 Harri Merisaari</span> <a name="l00037"></a>00037 <span class="comment"> Modified timezone correction in for ANSI compatibility and for </span> <a name="l00038"></a>00038 <span class="comment"> other timezones in imgGetEcat7MHeader</span> <a name="l00039"></a>00039 <span class="comment"> 2007-09-07 VO</span> <a name="l00040"></a>00040 <span class="comment"> The rest of strcpy's replaced by strncpy's in imgGetEcat7MHeader(),</span> <a name="l00041"></a>00041 <span class="comment"> most importantly study_description, where overflow caused accidental </span> <a name="l00042"></a>00042 <span class="comment"> change of IMG type. </span> <a name="l00043"></a>00043 <span class="comment"> 2007-09-10 VO</span> <a name="l00044"></a>00044 <span class="comment"> Return value of localtime() is checked.</span> <a name="l00045"></a>00045 <span class="comment"> 2007-09-12 VO</span> <a name="l00046"></a>00046 <span class="comment"> Bug correction in imgReadEcat7Frame(): did not set 2D image plane numbers.</span> <a name="l00047"></a>00047 <span class="comment"> 2010-02-12 VO</span> <a name="l00048"></a>00048 <span class="comment"> Timezone correction added also into imgSetEcat7MHeader().</span> <a name="l00049"></a>00049 <span class="comment"></span> <a name="l00050"></a>00050 <span class="comment"></span> <a name="l00051"></a>00051 <span class="comment">******************************************************************************/</span> <a name="l00052"></a>00052 <span class="preprocessor">#include <stdio.h></span> <a name="l00053"></a>00053 <span class="preprocessor">#include <stdlib.h></span> <a name="l00054"></a>00054 <span class="preprocessor">#include <unistd.h></span> <a name="l00055"></a>00055 <span class="preprocessor">#include <math.h></span> <a name="l00056"></a>00056 <span class="preprocessor">#include <string.h></span> <a name="l00057"></a>00057 <span class="preprocessor">#include <time.h></span> <a name="l00058"></a>00058 <span class="comment">/*****************************************************************************/</span> <a name="l00059"></a>00059 <span class="preprocessor">#include "petc99.h"</span> <a name="l00060"></a>00060 <span class="preprocessor">#include "swap.h"</span> <a name="l00061"></a>00061 <span class="preprocessor">#include "halflife.h"</span> <a name="l00062"></a>00062 <span class="comment">/*****************************************************************************/</span> <a name="l00063"></a>00063 <span class="preprocessor">#include "<a class="code" href="img_8h.html">include/img.h</a>"</span> <a name="l00064"></a>00064 <span class="preprocessor">#include "<a class="code" href="ecat7_8h.html">include/ecat7.h</a>"</span> <a name="l00065"></a>00065 <span class="preprocessor">#include "<a class="code" href="imgmax_8h.html">include/imgmax.h</a>"</span> <a name="l00066"></a>00066 <span class="preprocessor">#include "<a class="code" href="imgdecay_8h.html">include/imgdecay.h</a>"</span> <a name="l00067"></a>00067 <span class="preprocessor">#include "<a class="code" href="imgfile_8h.html">include/imgfile.h</a>"</span> <a name="l00068"></a>00068 <span class="comment">/*****************************************************************************/</span> <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="comment">/*****************************************************************************/</span> <a name="l00083"></a><a class="code" href="imgfile_8h.html#a7d6df1a1fa3b56a9bfdf901eb348da4c">00083</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a7d6df1a1fa3b56a9bfdf901eb348da4c">imgReadEcat7</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l00084"></a>00084 FILE *fp; <a name="l00085"></a>00085 <span class="keywordtype">int</span> ret, m, i, fi, pi, xi, yi, frame, plane, prev_frame, prev_plane; <a name="l00086"></a>00086 <span class="keywordtype">int</span> dimx, dimy, dimz, planeNr, frameNr, blkNr=0, pxlNr; <a name="l00087"></a>00087 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l00088"></a>00088 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l00089"></a>00089 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> scan2d_header; <a name="l00090"></a>00090 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> scan_header; <a name="l00091"></a>00091 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> polmap_header; <a name="l00092"></a>00092 <a class="code" href="structECAT7__MATRIXLIST.html">ECAT7_MATRIXLIST</a> mlist; <a name="l00093"></a>00093 <a class="code" href="structECAT7__Matval.html">ECAT7_Matval</a> matval; <a name="l00094"></a>00094 <span class="keywordtype">float</span> *fdata=NULL, *fptr; <a name="l00095"></a>00095 <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"imgReadEcat7(%s, *img)\n"</span>, fname); <a name="l00098"></a>00098 <span class="comment">/* Check the arguments */</span> <a name="l00099"></a>00099 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span>(1); <a name="l00100"></a>00100 <span class="keywordflow">if</span>(img==NULL || img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>) { <a name="l00101"></a>00101 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00102"></a>00102 <a name="l00103"></a>00103 <span class="comment">/* Open file for read */</span> <a name="l00104"></a>00104 <span class="keywordflow">if</span>((fp=fopen(fname, <span class="stringliteral">"rb"</span>))==NULL) {<a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba9f298b5339db644dbc2b9dc01ef12006">STATUS_NOFILE</a>); <span class="keywordflow">return</span>(3);} <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="comment">/* Read main header */</span> <a name="l00107"></a>00107 ret=<a class="code" href="ecat7r_8c.html#a7d6241dd7a472a4f2aaf3eb16dc03dc1">ecat7ReadMainheader</a>(fp, &main_header); <a name="l00108"></a>00108 <span class="keywordflow">if</span>(ret) {fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba942f7c6c65ba2a702cd9c23550843003">STATUS_UNKNOWNFORMAT</a>); <span class="keywordflow">return</span>(4);} <a name="l00109"></a>00109 <span class="comment">/* Check for magic number */</span> <a name="l00110"></a>00110 <span class="keywordflow">if</span>(strncmp(main_header.<a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#a79ce0ec6cdde2ca6101c0bbc7c78beca">ECAT7V_MAGICNR</a>, 7)!=0) { <a name="l00111"></a>00111 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba942f7c6c65ba2a702cd9c23550843003">STATUS_UNKNOWNFORMAT</a>); <span class="keywordflow">return</span>(4); <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <span class="comment">/* Check if file_type is supported */</span> <a name="l00115"></a>00115 <span class="keywordflow">if</span>(<a class="code" href="img__e7_8c.html#a4b25c303088592c0518bf26df1d20aec">imgEcat7Supported</a>(&main_header)==0) { <a name="l00116"></a>00116 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>); <span class="keywordflow">return</span>(5); <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="comment">/* Read matrix list */</span> <a name="l00120"></a>00120 <a class="code" href="ecat7ml_8c.html#a0826a19efcf80e53e28473189d07949e">ecat7InitMatlist</a>(&mlist); <a name="l00121"></a>00121 ret=<a class="code" href="ecat7ml_8c.html#a0304c6b68597ab6fe00bb35a44c19dcb">ecat7ReadMatlist</a>(fp, &mlist); <a name="l00122"></a>00122 <span class="keywordflow">if</span>(ret || mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a><1 || <a class="code" href="ecat7ml_8c.html#ae366d8f1a8202f053debfdbe2a8c6be7">ecat7CheckMatlist</a>(&mlist)) { <a name="l00123"></a>00123 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae2d56db7d13d44bec04369ae30c44a6c">STATUS_INVALIDMATLIST</a>); <span class="keywordflow">return</span>(6);} <a name="l00124"></a>00124 <a class="code" href="ecat7ml_8c.html#a4c5fe6841c5c02db200f5aa92d652014">ecat7SortMatlistByPlane</a>(&mlist); <a name="l00125"></a>00125 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>2) <a class="code" href="ecat7ml_8c.html#ad50b3297af530071a5f115c14f40c701">ecat7PrintMatlist</a>(&mlist); <a name="l00126"></a>00126 <a name="l00127"></a>00127 <span class="comment">/* Calculate the number of planes, frames and gates */</span> <a name="l00128"></a>00128 <span class="comment">/* Check that all planes have equal nr of frames (gates) */</span> <a name="l00129"></a>00129 <span class="comment">/* and check that frames (gates) are consequentally numbered */</span> <a name="l00130"></a>00130 prev_plane=plane=-1; prev_frame=frame=-1; frameNr=planeNr=0; ret=0; <a name="l00131"></a>00131 <span class="keywordflow">for</span>(m=0; m<mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a>; m++) { <a name="l00132"></a>00132 <a class="code" href="ecat7ml_8c.html#a4cf0dc3b586a1c62d177f21b5e8e2328">ecat7_id_to_val</a>(mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a496411c7ccf25471dd7e7af220160ffd">id</a>, &matval); plane=matval.<a class="code" href="structECAT7__Matval.html#a041cdbab82513cac692f52c4e7364093">plane</a>; <a name="l00133"></a>00133 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>>=main_header.<a class="code" href="structecat7__mainheader.html#a45cd434d5473194ffdbb27c99d9d7e6a">num_gates</a>) frame=matval.<a class="code" href="structECAT7__Matval.html#afc531f65c0b1b58cbcffb947df62400b">frame</a>; <a name="l00134"></a>00134 <span class="keywordflow">else</span> frame=matval.<a class="code" href="structECAT7__Matval.html#a0f094bb9f2d880fa875ecc6110ace13b">gate</a>; <a name="l00135"></a>00135 <span class="keywordflow">if</span>(plane!=prev_plane) {frameNr=1; planeNr++;} <a name="l00136"></a>00136 <span class="keywordflow">else</span> {frameNr++; <span class="keywordflow">if</span>(prev_frame>0 && frame!=prev_frame+1) {ret=1; <span class="keywordflow">break</span>;}} <a name="l00137"></a>00137 prev_plane=plane; prev_frame=frame; <a name="l00138"></a>00138 <span class="comment">/* Calculate and check the size of one data matrix */</span> <a name="l00139"></a>00139 <span class="keywordflow">if</span>(m==0) { <a name="l00140"></a>00140 blkNr=mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>-mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>; <a name="l00141"></a>00141 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(blkNr!=mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>-mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>) { <a name="l00142"></a>00142 ret=2; <span class="keywordflow">break</span>; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 } <span class="comment">/* next matrix */</span> <a name="l00145"></a>00145 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>2) printf(<span class="stringliteral">"frameNr=%d planeNr=%d\n"</span>, frameNr, planeNr); <a name="l00146"></a>00146 <span class="keywordflow">if</span>(ret==1 || (frameNr*planeNr != mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a>)) { <a name="l00147"></a>00147 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bad6498890650ae8d01e69f43514eb4fed">STATUS_MISSINGMATRIX</a>); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(7);} <a name="l00148"></a>00148 <span class="keywordflow">if</span>(ret==2) { <a name="l00149"></a>00149 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae8ce9dbf165d2c5fdb9c4609c01d94e5">STATUS_VARMATSIZE</a>); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(8);} <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="comment">/* Read the first subheader to get planeNr from volumes and to get x&y dim */</span> <a name="l00152"></a>00152 m=0; dimz=1; <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae6ad5f97cf86fa7686fd12961e4ccdf4">STATUS_NOSUBHEADER</a>); <a name="l00153"></a>00153 <span class="keywordflow">switch</span>(main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00154"></a>00154 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00155"></a>00155 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00156"></a>00156 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00157"></a>00157 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: <a name="l00158"></a>00158 img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>; <a name="l00159"></a>00159 ret=<a class="code" href="ecat7r_8c.html#ac96bedc17610a5a05d95ce7742d44b5c">ecat7ReadImageheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &image_header); <a name="l00160"></a>00160 dimx=image_header.<a class="code" href="structecat7__imageheader.html#a37550f6ce6a114de12aa0d038f573230">x_dimension</a>; dimy=image_header.<a class="code" href="structecat7__imageheader.html#a217d17f8b1f921fad128ce923fa21c35">y_dimension</a>; <a name="l00161"></a>00161 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>>2 && image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>>1) <a name="l00162"></a>00162 planeNr=dimz=image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>; <a name="l00163"></a>00163 <span class="keywordflow">break</span>; <a name="l00164"></a>00164 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>: <a name="l00165"></a>00165 img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>; <a name="l00166"></a>00166 ret=<a class="code" href="ecat7r_8c.html#aa37d19fc4f30868ea0b062d39d9d8450">ecat7Read2DScanheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &scan2d_header); <a name="l00167"></a>00167 dimx=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#adfe07cff44e3145ca65c234079ff255a">num_r_elements</a>; dimy=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ad0d1958b231f10aa68d60c653ec30627">num_angles</a>; <a name="l00168"></a>00168 <span class="keywordflow">if</span>(scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a592447ad964ba95e2a29a7d3d2284576">num_dimensions</a>>2 && scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>>1) <a name="l00169"></a>00169 planeNr=dimz=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>; <a name="l00170"></a>00170 <span class="keywordflow">break</span>; <a name="l00171"></a>00171 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>: <a name="l00172"></a>00172 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>: <a name="l00173"></a>00173 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>: <a name="l00174"></a>00174 img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>; <a name="l00175"></a>00175 ret=<a class="code" href="ecat7r_8c.html#a37414b52ef395686b6a81d6229d13143">ecat7ReadScanheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &scan_header); <a name="l00176"></a>00176 dimx=scan_header.<a class="code" href="structecat7__scanheader.html#aee3fd0c2360973b3d53ad1adf6225d7d">num_r_elements</a>; dimy=scan_header.<a class="code" href="structecat7__scanheader.html#a4f58fe54c66427d34390f6530a12f8ed">num_angles</a>; <a name="l00177"></a>00177 <span class="keywordflow">for</span>(i=dimz=0; i<64; i++) dimz+=scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[i]; <a name="l00178"></a>00178 planeNr=dimz; <a name="l00179"></a>00179 <span class="comment">/*if(scan_header.axial_compression!=0) {img->statmsg=imgmsg[STATUS_UNSUPPORTEDAXIALCOMP]; ret=-1;}*/</span> <a name="l00180"></a>00180 <span class="keywordflow">break</span>; <a name="l00181"></a>00181 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: <a name="l00182"></a>00182 img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>; <a name="l00183"></a>00183 ret=<a class="code" href="ecat7r_8c.html#a498d383ca08a832895af8ead01e8c756">ecat7ReadPolmapheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &polmap_header); <a name="l00184"></a>00184 planeNr=dimz=dimy=1; dimx=0; <a name="l00185"></a>00185 <span class="keywordflow">for</span>(i=0; i<polmap_header.<a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>; i++) <a name="l00186"></a>00186 dimx+=polmap_header.<a class="code" href="structecat7__polmapheader.html#a7888f1b2bc8adcc5bcbf918bbbb82dbb">sectors_per_ring</a>[i]; <a name="l00187"></a>00187 <span class="keywordflow">break</span>; <a name="l00188"></a>00188 <span class="keywordflow">default</span>: dimx=dimy=dimz=planeNr=0; ret=-1; <a name="l00189"></a>00189 } <a name="l00190"></a>00190 pxlNr=dimx*dimy; <a name="l00191"></a>00191 <span class="keywordflow">if</span>(ret || pxlNr<1 || planeNr<1) { <a name="l00192"></a>00192 fclose(fp); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(9);} <a name="l00193"></a>00193 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00194"></a>00194 <a name="l00195"></a>00195 <span class="comment">/* Allocate memory for IMG data */</span> <a name="l00196"></a>00196 ret=<a class="code" href="img_8c.html#a9b2670da9c7685e6d53058cdf1db1199">imgAllocate</a>(img, planeNr, dimy, dimx, frameNr); <a name="l00197"></a>00197 <span class="keywordflow">if</span>(ret) { <a name="l00198"></a>00198 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>); <a name="l00199"></a>00199 <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(11); <a name="l00200"></a>00200 } <a name="l00201"></a>00201 <span class="comment">/* Copy information from mainheader */</span> <a name="l00202"></a>00202 <a class="code" href="img__e7_8c.html#a13c42900c44b97ed1b759d7ca6348ab6">imgGetEcat7MHeader</a>(img, &main_header); <a name="l00203"></a>00203 <span class="comment">/* Set fileFormat */</span> <a name="l00204"></a>00204 <span class="keywordflow">switch</span>(main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00205"></a>00205 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00206"></a>00206 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00207"></a>00207 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>; <span class="keywordflow">break</span>; <a name="l00208"></a>00208 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00209"></a>00209 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: <a name="l00210"></a>00210 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>; <span class="keywordflow">break</span>; <a name="l00211"></a>00211 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>: <a name="l00212"></a>00212 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>; <span class="keywordflow">break</span>; <a name="l00213"></a>00213 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>: <a name="l00214"></a>00214 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>: <a name="l00215"></a>00215 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>: <a name="l00216"></a>00216 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>; <span class="keywordflow">break</span>; <a name="l00217"></a>00217 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: <a name="l00218"></a>00218 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#aa0111a4761ce5db222757daff1f48dfe">IMG_POLARMAP</a>; <span class="keywordflow">break</span>; <a name="l00219"></a>00219 <span class="keywordflow">default</span>: <a name="l00220"></a>00220 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img_8h.html#a3aea8253aaffd2e73cf8641661f6a459">IMG_UNKNOWN</a>; <span class="keywordflow">break</span>; <a name="l00221"></a>00221 } <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordflow">if</span>(dimz>1) { <a name="l00224"></a>00224 <span class="comment">/* Read ECAT volume matrices */</span> <a name="l00225"></a>00225 fi=0; <a name="l00226"></a>00226 <span class="keywordflow">for</span>(m=0; m<mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a>; m++) { <a name="l00227"></a>00227 <span class="comment">/* Get matrix values */</span> <a name="l00228"></a>00228 <a class="code" href="ecat7ml_8c.html#a4cf0dc3b586a1c62d177f21b5e8e2328">ecat7_id_to_val</a>(mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a496411c7ccf25471dd7e7af220160ffd">id</a>, &matval); <a name="l00229"></a>00229 <span class="comment">/* Read subheader and data */</span> <a name="l00230"></a>00230 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) <a name="l00231"></a>00231 ret=<a class="code" href="ecat7r_8c.html#ac62693d7c451818000deb09e2f59cc68">ecat7ReadImageMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l00232"></a>00232 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &image_header, &fdata); <a name="l00233"></a>00233 <span class="keywordflow">else</span> <a name="l00234"></a>00234 ret=<a class="code" href="ecat7r_8c.html#aeed5aa16cd7ac3d07994e039ede3142d">ecat7ReadScanMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l00235"></a>00235 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &scan_header, &fdata); <a name="l00236"></a>00236 <span class="keywordflow">if</span>(ret || fdata==NULL) { <a name="l00237"></a>00237 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"ecat7ReadXMatrix()=%d\n%s\n"</span>, ret, <a class="code" href="ecat7_8h.html#a66c8b21d11aea27d874d191a12312207">ecat7errmsg</a>); <a name="l00238"></a>00238 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55babe9c1bcf366cd905b79148ba91b34756">STATUS_NOMATRIX</a>); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(13);} <a name="l00239"></a>00239 <span class="comment">/* Copy subheader information */</span> <a name="l00240"></a>00240 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <a name="l00241"></a>00241 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=polmap_header.<a class="code" href="structecat7__polmapheader.html#a85514ffcdb6dc106fe8d742bcb248947">data_type</a>; <a name="l00242"></a>00242 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=polmap_header.<a class="code" href="structecat7__polmapheader.html#ac7757667731f12beb6c6e8a584dd6682">frame_start_time</a>/1000.; <a name="l00243"></a>00243 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+polmap_header.<a class="code" href="structecat7__polmapheader.html#af2c0109195bbcc833521aed329d2bd83">frame_duration</a>/1000.; <a name="l00244"></a>00244 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00245"></a>00245 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=0.001*polmap_header.<a class="code" href="structecat7__polmapheader.html#a4a7a70570769b6b97bf67f6358a61f45">pixel_size</a>; <a name="l00246"></a>00246 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00247"></a>00247 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=image_header.<a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>; <a name="l00248"></a>00248 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>/1000.; <a name="l00249"></a>00249 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>/1000.; <a name="l00250"></a>00250 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00251"></a>00251 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>>1.0) { <a name="l00252"></a>00252 img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[fi]=image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>; <a name="l00253"></a>00253 img-><a class="code" href="structIMG.html#a6ce801dea67ec8224e8cfc9aebb8a909">decayCorrected</a>=1; <a name="l00254"></a>00254 } <a name="l00255"></a>00255 img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>=image_header.<a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>; <a name="l00256"></a>00256 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>; <a name="l00257"></a>00257 img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>; <a name="l00258"></a>00258 img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>; <a name="l00259"></a>00259 img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>; <a name="l00260"></a>00260 img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>; <a name="l00261"></a>00261 img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>; <a name="l00262"></a>00262 } <span class="keywordflow">else</span> { <a name="l00263"></a>00263 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=scan_header.<a class="code" href="structecat7__scanheader.html#ac1dfbebf9227256db4dd3ec96a95277f">data_type</a>; <a name="l00264"></a>00264 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=scan_header.<a class="code" href="structecat7__scanheader.html#a73b5c4aae33a122d91703ce6a3330f89">frame_start_time</a>/1000.; <a name="l00265"></a>00265 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>/1000.; <a name="l00266"></a>00266 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00267"></a>00267 <span class="keywordflow">if</span>(scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>>0.0) <a name="l00268"></a>00268 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>; <a name="l00269"></a>00269 <span class="keywordflow">else</span> <a name="l00270"></a>00270 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>; <a name="l00271"></a>00271 <span class="comment">/* also, correct for dead-time */</span> <a name="l00272"></a>00272 <span class="keywordflow">if</span>(scan_header.<a class="code" href="structecat7__scanheader.html#a97b2c1a33ab3c42a21aa9f1d3d9e21e7">deadtime_correction_factor</a>>0.0) <a name="l00273"></a>00273 <span class="keywordflow">for</span>(i=0, fptr=fdata; i<dimz*pxlNr; i++, fptr++) <a name="l00274"></a>00274 *fptr*=scan_header.<a class="code" href="structecat7__scanheader.html#a97b2c1a33ab3c42a21aa9f1d3d9e21e7">deadtime_correction_factor</a>; <a name="l00275"></a>00275 img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[fi]=(<span class="keywordtype">float</span>)scan_header.<a class="code" href="structecat7__scanheader.html#a421bb8924e8aed2ef38ecc673b71a574">prompts</a>; <a name="l00276"></a>00276 img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[fi]=scan_header.<a class="code" href="structecat7__scanheader.html#a8f67a369e6ef599551b8271c08a8b5d7">delayed</a>; <a name="l00277"></a>00277 } <a name="l00278"></a>00278 <span class="comment">/* Copy matrix data through volume planes */</span> <a name="l00279"></a>00279 <span class="keywordflow">for</span>(pi=0; pi<dimz; pi++) { <a name="l00280"></a>00280 <span class="keywordflow">for</span>(yi=0, fptr=fdata+pi*pxlNr; yi<dimy; yi++) <span class="keywordflow">for</span>(xi=0; xi<dimx; xi++) <a name="l00281"></a>00281 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]= *fptr++; <a name="l00282"></a>00282 } <a name="l00283"></a>00283 free(fdata); fi++; <a name="l00284"></a>00284 } <span class="comment">/* next matrix */</span> <a name="l00285"></a>00285 <span class="comment">/* Set plane numbers */</span> <a name="l00286"></a>00286 <span class="keywordflow">for</span>(pi=0; pi<dimz; pi++) img-><a class="code" href="structIMG.html#a78e3164d578cf4a570e930dceb10fb51">planeNumber</a>[pi]=pi+1; <a name="l00287"></a>00287 } <span class="keywordflow">else</span> { <a name="l00288"></a>00288 <span class="comment">/* Read separate matrices */</span> <a name="l00289"></a>00289 prev_plane=plane=-1; prev_frame=frame=-1; pi=fi=-1; <a name="l00290"></a>00290 <span class="keywordflow">for</span>(m=0; m<mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a>; m++) { <a name="l00291"></a>00291 <a class="code" href="ecat7ml_8c.html#a4cf0dc3b586a1c62d177f21b5e8e2328">ecat7_id_to_val</a>(mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a496411c7ccf25471dd7e7af220160ffd">id</a>, &matval); plane=matval.<a class="code" href="structECAT7__Matval.html#a041cdbab82513cac692f52c4e7364093">plane</a>; <a name="l00292"></a>00292 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>>=main_header.<a class="code" href="structecat7__mainheader.html#a45cd434d5473194ffdbb27c99d9d7e6a">num_gates</a>) frame=matval.<a class="code" href="structECAT7__Matval.html#afc531f65c0b1b58cbcffb947df62400b">frame</a>; <a name="l00293"></a>00293 <span class="keywordflow">else</span> frame=matval.<a class="code" href="structECAT7__Matval.html#a0f094bb9f2d880fa875ecc6110ace13b">gate</a>; <a name="l00294"></a>00294 <span class="keywordflow">if</span>(plane!=prev_plane) {fi=0; pi++;} <span class="keywordflow">else</span> fi++; <a name="l00295"></a>00295 <span class="comment">/* Read subheader and data */</span> <a name="l00296"></a>00296 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) <a name="l00297"></a>00297 ret=<a class="code" href="ecat7r_8c.html#aa07f0b9089fda6bc1f5e8ce179f62686">ecat7ReadPolarmapMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l00298"></a>00298 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &polmap_header, &fdata); <a name="l00299"></a>00299 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) <a name="l00300"></a>00300 ret=<a class="code" href="ecat7r_8c.html#ac62693d7c451818000deb09e2f59cc68">ecat7ReadImageMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l00301"></a>00301 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &image_header, &fdata); <a name="l00302"></a>00302 <span class="keywordflow">else</span> <a name="l00303"></a>00303 ret=<a class="code" href="ecat7r_8c.html#a2cdc756d0ec7d7b4d22f7d6c8b73fd7b">ecat7Read2DScanMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l00304"></a>00304 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &scan2d_header, &fdata); <a name="l00305"></a>00305 <span class="keywordflow">if</span>(ret || fdata==NULL) { <a name="l00306"></a>00306 fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55babe9c1bcf366cd905b79148ba91b34756">STATUS_NOMATRIX</a>); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span>(13);} <a name="l00307"></a>00307 <span class="comment">/* Copy subheader information */</span> <a name="l00308"></a>00308 <span class="keywordflow">if</span>(fi==0) img-><a class="code" href="structIMG.html#a78e3164d578cf4a570e930dceb10fb51">planeNumber</a>[pi]=plane; <a name="l00309"></a>00309 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <a name="l00310"></a>00310 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=polmap_header.<a class="code" href="structecat7__polmapheader.html#a85514ffcdb6dc106fe8d742bcb248947">data_type</a>; <a name="l00311"></a>00311 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=polmap_header.<a class="code" href="structecat7__polmapheader.html#ac7757667731f12beb6c6e8a584dd6682">frame_start_time</a>/1000.; <a name="l00312"></a>00312 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+polmap_header.<a class="code" href="structecat7__polmapheader.html#af2c0109195bbcc833521aed329d2bd83">frame_duration</a>/1000.; <a name="l00313"></a>00313 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00314"></a>00314 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=0.001*polmap_header.<a class="code" href="structecat7__polmapheader.html#a4a7a70570769b6b97bf67f6358a61f45">pixel_size</a>; <a name="l00315"></a>00315 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00316"></a>00316 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=image_header.<a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>; <a name="l00317"></a>00317 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>/1000.; <a name="l00318"></a>00318 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>/1000.; <a name="l00319"></a>00319 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00320"></a>00320 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>>1.0) { <a name="l00321"></a>00321 img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[fi]=image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>; <a name="l00322"></a>00322 img-><a class="code" href="structIMG.html#a6ce801dea67ec8224e8cfc9aebb8a909">decayCorrected</a>=1; <a name="l00323"></a>00323 } <a name="l00324"></a>00324 img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>=image_header.<a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>; <a name="l00325"></a>00325 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>; <a name="l00326"></a>00326 img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>; <a name="l00327"></a>00327 img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>; <a name="l00328"></a>00328 img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>; <a name="l00329"></a>00329 img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>; <a name="l00330"></a>00330 img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>; <a name="l00331"></a>00331 } <span class="keywordflow">else</span> { <a name="l00332"></a>00332 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#aa13b8697f5c56f7e31e942cafb91bddc">data_type</a>; <a name="l00333"></a>00333 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8930d980328907f75c2518b36e67b36f">frame_start_time</a>/1000.; <a name="l00334"></a>00334 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>/1000.; <a name="l00335"></a>00335 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[fi]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]); <a name="l00336"></a>00336 <span class="keywordflow">if</span>(scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>>0.0) <a name="l00337"></a>00337 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>; <a name="l00338"></a>00338 <span class="keywordflow">else</span> <a name="l00339"></a>00339 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>; <a name="l00340"></a>00340 <span class="comment">/* also, correct for dead-time */</span> <a name="l00341"></a>00341 <span class="keywordflow">if</span>(scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8788db06847593186cbeaef45e03b838">deadtime_correction_factor</a>>0.0) <a name="l00342"></a>00342 <span class="keywordflow">for</span>(i=0, fptr=fdata; i<pxlNr; i++, fptr++) <a name="l00343"></a>00343 *fptr*=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8788db06847593186cbeaef45e03b838">deadtime_correction_factor</a>; <a name="l00344"></a>00344 img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[fi]=(<span class="keywordtype">float</span>)scan_header.<a class="code" href="structecat7__scanheader.html#a421bb8924e8aed2ef38ecc673b71a574">prompts</a>; <a name="l00345"></a>00345 img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[fi]=scan_header.<a class="code" href="structecat7__scanheader.html#a8f67a369e6ef599551b8271c08a8b5d7">delayed</a>; <a name="l00346"></a>00346 } <a name="l00347"></a>00347 <span class="comment">/* Copy matrix data */</span> <a name="l00348"></a>00348 <span class="keywordflow">for</span>(yi=0, fptr=fdata; yi<dimy; yi++) <span class="keywordflow">for</span>(xi=0; xi<dimx; xi++) <a name="l00349"></a>00349 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]= *fptr++; <a name="l00350"></a>00350 free(fdata); <a name="l00351"></a>00351 <span class="comment">/* prepare for the next matrix */</span> <a name="l00352"></a>00352 prev_plane=plane; prev_frame=frame; <a name="l00353"></a>00353 } <span class="comment">/* next matrix */</span> <a name="l00354"></a>00354 } <a name="l00355"></a>00355 fclose(fp); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <a name="l00356"></a>00356 <a name="l00357"></a>00357 <span class="comment">/* Calibrate */</span> <a name="l00358"></a>00358 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#ad5be044d585696c1f35bb8b63c26fec9">ecat_calibration_factor</a>>0.0) <a name="l00359"></a>00359 <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) <a name="l00360"></a>00360 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l00361"></a>00361 <span class="keywordflow">for</span>(fi=0; fi<img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>; fi++) <a name="l00362"></a>00362 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]*=main_header.<a class="code" href="structecat7__mainheader.html#ad5be044d585696c1f35bb8b63c26fec9">ecat_calibration_factor</a>; <a name="l00363"></a>00363 <a name="l00364"></a>00364 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00365"></a>00365 <span class="keywordflow">return</span>(0); <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <span class="comment">/*****************************************************************************/</span> <a name="l00368"></a>00368 <a name="l00369"></a>00369 <span class="comment">/*****************************************************************************/</span> <a name="l00380"></a><a class="code" href="imgfile_8h.html#a16fee12c445b0de04d5252f28fe48ae6">00380</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a16fee12c445b0de04d5252f28fe48ae6">imgWriteEcat7</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l00381"></a>00381 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l00382"></a>00382 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l00383"></a>00383 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> scan_header; <a name="l00384"></a>00384 FILE *fp; <a name="l00385"></a>00385 <span class="keywordtype">int</span> fi, pi, xi, yi, pxlNr, matrixId, ret; <a name="l00386"></a>00386 <span class="keywordtype">float</span> *fdata, *fptr; <a name="l00387"></a>00387 <a name="l00388"></a>00388 <a name="l00389"></a>00389 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"imgWriteEcat7(%s, *img)\n"</span>, fname); <a name="l00390"></a>00390 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>1 && <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>==0) <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>=1; <a name="l00391"></a>00391 <span class="comment">/* Check the arguments */</span> <a name="l00392"></a>00392 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span>(1); <a name="l00393"></a>00393 <span class="keywordflow">if</span>(img==NULL || img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) { <a name="l00394"></a>00394 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00395"></a>00395 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>!=<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a> && img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>!=<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00396"></a>00396 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00397"></a>00397 <a name="l00398"></a>00398 <span class="comment">/* Initiate headers */</span> <a name="l00399"></a>00399 memset(&main_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a>)); <a name="l00400"></a>00400 memset(&image_header,0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a>)); <a name="l00401"></a>00401 memset(&scan_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a>)); <a name="l00402"></a>00402 <a name="l00403"></a>00403 <span class="comment">/* Set main header */</span> <a name="l00404"></a>00404 <a class="code" href="img__e7_8c.html#ae0290e8d66a3ce7013405b344cca52f5">imgSetEcat7MHeader</a>(img, &main_header); <a name="l00405"></a>00405 main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l00406"></a>00406 <a name="l00407"></a>00407 <span class="comment">/* Allocate memory for matrix float data */</span> <a name="l00408"></a>00408 pxlNr=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>*img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l00409"></a>00409 fdata=(<span class="keywordtype">float</span>*)malloc(pxlNr*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>)); <a name="l00410"></a>00410 <span class="keywordflow">if</span>(fdata==NULL) {<a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>); <span class="keywordflow">return</span>(3);} <a name="l00411"></a>00411 <a name="l00412"></a>00412 <span class="comment">/* Open file, write main header and initiate matrix list */</span> <a name="l00413"></a>00413 fp=<a class="code" href="ecat7w_8c.html#a85ec2c6c7070a4170b8807e13623b04d">ecat7Create</a>(fname, &main_header); <a name="l00414"></a>00414 <span class="keywordflow">if</span>(fp==NULL) {free(fdata); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>); <span class="keywordflow">return</span>(6);} <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="comment">/* Set (most of) subheader contents */</span> <a name="l00417"></a>00417 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l00418"></a>00418 scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l00419"></a>00419 scan_header.<a class="code" href="structecat7__scanheader.html#a4b4361b122c74cfd1c7171357615a2a4">num_dimensions</a>=4; <a name="l00420"></a>00420 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>==239) { <a name="l00421"></a>00421 scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[0]=63; <a name="l00422"></a>00422 scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[1]=106; <a name="l00423"></a>00423 scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[2]=70; <a name="l00424"></a>00424 } <span class="keywordflow">else</span> { <a name="l00425"></a>00425 scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[0]=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l00426"></a>00426 } <a name="l00427"></a>00427 scan_header.<a class="code" href="structecat7__scanheader.html#af0fcf4af875d58acf97d1b412d0299b5">storage_order</a>=1; <a name="l00428"></a>00428 scan_header.<a class="code" href="structecat7__scanheader.html#ac1dfbebf9227256db4dd3ec96a95277f">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l00429"></a>00429 scan_header.<a class="code" href="structecat7__scanheader.html#aee3fd0c2360973b3d53ad1adf6225d7d">num_r_elements</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l00430"></a>00430 scan_header.<a class="code" href="structecat7__scanheader.html#a4f58fe54c66427d34390f6530a12f8ed">num_angles</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l00431"></a>00431 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00432"></a>00432 image_header.<a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>=3; <a name="l00433"></a>00433 image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l00434"></a>00434 image_header.<a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l00435"></a>00435 image_header.<a class="code" href="structecat7__imageheader.html#a37550f6ce6a114de12aa0d038f573230">x_dimension</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l00436"></a>00436 image_header.<a class="code" href="structecat7__imageheader.html#a217d17f8b1f921fad128ce923fa21c35">y_dimension</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l00437"></a>00437 image_header.<a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>=img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>; <a name="l00438"></a>00438 image_header.<a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; <a name="l00439"></a>00439 image_header.<a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>; <a name="l00440"></a>00440 image_header.<a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>; <a name="l00441"></a>00441 image_header.<a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>; <a name="l00442"></a>00442 image_header.<a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>; <a name="l00443"></a>00443 image_header.<a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>=0.1*img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>; <a name="l00444"></a>00444 } <a name="l00445"></a>00445 <a name="l00446"></a>00446 <span class="comment">/* Write each matrix */</span> <a name="l00447"></a>00447 <span class="keywordflow">for</span>(fi=0; fi<img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>; fi++) { <a name="l00448"></a>00448 <a name="l00449"></a>00449 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l00450"></a>00450 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(fi+1, 1, 1, 0, 0); <a name="l00451"></a>00451 <a name="l00452"></a>00452 <span class="comment">/* Copy matrix pixel values to fdata */</span> <a name="l00453"></a>00453 fptr=fdata; <a name="l00454"></a>00454 <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) <a name="l00455"></a>00455 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l00456"></a>00456 *fptr++=img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]; <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="comment">/* Write subheader and data */</span> <a name="l00459"></a>00459 fptr=fdata; <a name="l00460"></a>00460 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l00461"></a>00461 scan_header.<a class="code" href="structecat7__scanheader.html#a73b5c4aae33a122d91703ce6a3330f89">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]); <a name="l00462"></a>00462 scan_header.<a class="code" href="structecat7__scanheader.html#ae7eafb4bf000a8404407489dbd6b54ac">frame_duration</a>=(int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi])); <a name="l00463"></a>00463 scan_header.<a class="code" href="structecat7__scanheader.html#a421bb8924e8aed2ef38ecc673b71a574">prompts</a>=temp_roundf(img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[fi]); <a name="l00464"></a>00464 scan_header.<a class="code" href="structecat7__scanheader.html#a8f67a369e6ef599551b8271c08a8b5d7">delayed</a>=temp_roundf(img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[fi]); <a name="l00465"></a>00465 <span class="comment">/*ecat7PrintScanheader(&scan_header, stdout);*/</span> <a name="l00466"></a>00466 ret=<a class="code" href="ecat7w_8c.html#a33c96bd0bbc96506cb27794fadd6abcf">ecat7WriteScanMatrix</a>(fp, matrixId, &scan_header, fptr); <a name="l00467"></a>00467 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00468"></a>00468 image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]); <a name="l00469"></a>00469 image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>=(int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi])); <a name="l00470"></a>00470 image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>=img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[fi]; <a name="l00471"></a>00471 <span class="comment">/*ecat7PrintImageheader(&image_header, stdout);*/</span> <a name="l00472"></a>00472 ret=<a class="code" href="ecat7w_8c.html#a1806f5f5cc75a6446a4d85fa29e4228b">ecat7WriteImageMatrix</a>(fp, matrixId, &image_header, fptr); <a name="l00473"></a>00473 } <span class="keywordflow">else</span> {free(fdata); fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>); <span class="keywordflow">return</span>(8);} <a name="l00474"></a>00474 <span class="keywordflow">if</span>(ret) { <a name="l00475"></a>00475 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) {printf(<span class="stringliteral">"matrixId=%d ret=%d\n"</span>, matrixId, ret);} <a name="l00476"></a>00476 free(fdata); fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba8500261907803b2afa1f761991a22679">STATUS_DISKFULL</a>); <span class="keywordflow">return</span>(7); <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <a name="l00479"></a>00479 } <span class="comment">/* next matrix */</span> <a name="l00480"></a>00480 free(fdata); fclose(fp); <a name="l00481"></a>00481 <a name="l00482"></a>00482 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00483"></a>00483 <span class="keywordflow">return</span>(0); <a name="l00484"></a>00484 } <a name="l00485"></a>00485 <span class="comment">/*****************************************************************************/</span> <a name="l00486"></a>00486 <a name="l00487"></a>00487 <span class="comment">/*****************************************************************************/</span> <a name="l00498"></a><a class="code" href="imgfile_8h.html#a0e91bf23b5a578c06992c27f6e65e460">00498</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a0e91bf23b5a578c06992c27f6e65e460">imgWrite2DEcat7</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l00499"></a>00499 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l00500"></a>00500 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l00501"></a>00501 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> scan2d_header; <a name="l00502"></a>00502 FILE *fp; <a name="l00503"></a>00503 <span class="keywordtype">int</span> fi, pi, xi, yi, pxlNr, matrixId, ret; <a name="l00504"></a>00504 <span class="keywordtype">float</span> *fdata, *fptr; <a name="l00505"></a>00505 <a name="l00506"></a>00506 <a name="l00507"></a>00507 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"imgWrite2DEcat7(%s, *img)\n"</span>, fname); <a name="l00508"></a>00508 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>1 && <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>==0) <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>=1; <a name="l00509"></a>00509 <span class="comment">/* Check the arguments */</span> <a name="l00510"></a>00510 <span class="keywordflow">if</span>(fname==NULL) {<span class="keywordflow">return</span>(1);} <a name="l00511"></a>00511 <span class="keywordflow">if</span>(img==NULL || img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) { <a name="l00512"></a>00512 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00513"></a>00513 <a name="l00514"></a>00514 <span class="comment">/* Initiate headers */</span> <a name="l00515"></a>00515 memset(&main_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a>)); <a name="l00516"></a>00516 memset(&image_header,0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a>)); <a name="l00517"></a>00517 memset(&scan2d_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a>)); <a name="l00518"></a>00518 <a name="l00519"></a>00519 <span class="comment">/* Set main header */</span> <a name="l00520"></a>00520 <a class="code" href="img__e7_8c.html#ae0290e8d66a3ce7013405b344cca52f5">imgSetEcat7MHeader</a>(img, &main_header); <a name="l00521"></a>00521 main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l00522"></a>00522 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>; <a name="l00523"></a>00523 <span class="keywordflow">else</span> main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>; <a name="l00524"></a>00524 main_header.<a class="code" href="structecat7__mainheader.html#aacea3a6d9b88add8710823f1c17acc37">num_planes</a>=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l00525"></a>00525 <a name="l00526"></a>00526 <span class="comment">/* Allocate memory for matrix float data */</span> <a name="l00527"></a>00527 pxlNr=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l00528"></a>00528 fdata=(<span class="keywordtype">float</span>*)malloc(pxlNr*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>)); <a name="l00529"></a>00529 <span class="keywordflow">if</span>(fdata==NULL) {<a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>); <span class="keywordflow">return</span>(3);} <a name="l00530"></a>00530 <a name="l00531"></a>00531 <span class="comment">/* Open file, write main header and initiate matrix list */</span> <a name="l00532"></a>00532 fp=<a class="code" href="ecat7w_8c.html#a85ec2c6c7070a4170b8807e13623b04d">ecat7Create</a>(fname, &main_header); <a name="l00533"></a>00533 <span class="keywordflow">if</span>(fp==NULL) {free(fdata); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>); <span class="keywordflow">return</span>(6);} <a name="l00534"></a>00534 <a name="l00535"></a>00535 <span class="comment">/* Set (most of) subheader contents */</span> <a name="l00536"></a>00536 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l00537"></a>00537 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a592447ad964ba95e2a29a7d3d2284576">num_dimensions</a>=2; <a name="l00538"></a>00538 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>=1; <a name="l00539"></a>00539 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#aa13b8697f5c56f7e31e942cafb91bddc">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l00540"></a>00540 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#adfe07cff44e3145ca65c234079ff255a">num_r_elements</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l00541"></a>00541 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ad0d1958b231f10aa68d60c653ec30627">num_angles</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l00542"></a>00542 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00543"></a>00543 image_header.<a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>=2; <a name="l00544"></a>00544 image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>=1; <a name="l00545"></a>00545 image_header.<a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l00546"></a>00546 image_header.<a class="code" href="structecat7__imageheader.html#a37550f6ce6a114de12aa0d038f573230">x_dimension</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l00547"></a>00547 image_header.<a class="code" href="structecat7__imageheader.html#a217d17f8b1f921fad128ce923fa21c35">y_dimension</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l00548"></a>00548 image_header.<a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>=img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>; <a name="l00549"></a>00549 image_header.<a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; <a name="l00550"></a>00550 image_header.<a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>; <a name="l00551"></a>00551 image_header.<a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>; <a name="l00552"></a>00552 image_header.<a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>; <a name="l00553"></a>00553 image_header.<a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>; <a name="l00554"></a>00554 image_header.<a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>=0.1*img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>; <a name="l00555"></a>00555 } <a name="l00556"></a>00556 <a name="l00557"></a>00557 <span class="comment">/* Write each matrix */</span> <a name="l00558"></a>00558 <span class="keywordflow">for</span>(fi=0; fi<img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>; fi++) <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) { <a name="l00559"></a>00559 <a name="l00560"></a>00560 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l00561"></a>00561 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(fi+1, img-><a class="code" href="structIMG.html#a78e3164d578cf4a570e930dceb10fb51">planeNumber</a>[pi], 1, 0, 0); <a name="l00562"></a>00562 <a name="l00563"></a>00563 <span class="comment">/* Copy matrix pixel values to fdata */</span> <a name="l00564"></a>00564 fptr=fdata; <a name="l00565"></a>00565 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l00566"></a>00566 *fptr++=img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]; <a name="l00567"></a>00567 <a name="l00568"></a>00568 <span class="comment">/* Write subheader and data */</span> <a name="l00569"></a>00569 fptr=fdata; <a name="l00570"></a>00570 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l00571"></a>00571 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8930d980328907f75c2518b36e67b36f">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]); <a name="l00572"></a>00572 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>=(int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi])); <a name="l00573"></a>00573 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ac4abf37f9a786b4133fe6526cf29463c">prompts</a>=temp_roundf(img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[fi]); <a name="l00574"></a>00574 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a01d95cfc32cb38a15067f6f2b6835176">delayed</a>=temp_roundf(img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[fi]); <a name="l00575"></a>00575 ret=<a class="code" href="ecat7w_8c.html#aa94815cb1caa7fe0fdb4223edafd6f57">ecat7Write2DScanMatrix</a>(fp, matrixId, &scan2d_header, fptr); <a name="l00576"></a>00576 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l00577"></a>00577 image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]); <a name="l00578"></a>00578 image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>=(int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi])); <a name="l00579"></a>00579 image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>=img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[fi]; <a name="l00580"></a>00580 ret=<a class="code" href="ecat7w_8c.html#a1806f5f5cc75a6446a4d85fa29e4228b">ecat7WriteImageMatrix</a>(fp, matrixId, &image_header, fptr); <a name="l00581"></a>00581 } <span class="keywordflow">else</span> {free(fdata); fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>); <span class="keywordflow">return</span>(8);} <a name="l00582"></a>00582 <span class="keywordflow">if</span>(ret) { <a name="l00583"></a>00583 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) {printf(<span class="stringliteral">"matrixId=%d ret=%d\n"</span>, matrixId, ret);} <a name="l00584"></a>00584 free(fdata); fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba8500261907803b2afa1f761991a22679">STATUS_DISKFULL</a>); <span class="keywordflow">return</span>(7); <a name="l00585"></a>00585 } <a name="l00586"></a>00586 <a name="l00587"></a>00587 } <span class="comment">/* next matrix */</span> <a name="l00588"></a>00588 free(fdata); fclose(fp); <a name="l00589"></a>00589 <a name="l00590"></a>00590 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00591"></a>00591 <span class="keywordflow">return</span>(0); <a name="l00592"></a>00592 } <a name="l00593"></a>00593 <span class="comment">/*****************************************************************************/</span> <a name="l00594"></a>00594 <a name="l00595"></a>00595 <span class="comment">/*****************************************************************************/</span> <a name="l00606"></a><a class="code" href="imgfile_8h.html#aabd4fa9a9594482278362ff653d92a5c">00606</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#aabd4fa9a9594482278362ff653d92a5c">imgWritePolarmap</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l00607"></a>00607 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l00608"></a>00608 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> polmap_header; <a name="l00609"></a>00609 FILE *fp; <a name="l00610"></a>00610 <span class="keywordtype">int</span> fi, pi, xi, yi, pxlNr, matrixId, ret; <a name="l00611"></a>00611 <span class="keywordtype">float</span> *fdata, *fptr; <a name="l00612"></a>00612 <a name="l00613"></a>00613 <a name="l00614"></a>00614 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"imgWritePolarmap(%s, *img)\n"</span>, fname); <a name="l00615"></a>00615 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>1 && <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>==0) <a class="code" href="ecat7_8h.html#aeba6b1646ad1dd69809d9ba3a8732939">ECAT7_TEST</a>=1; <a name="l00616"></a>00616 <span class="comment">/* Check the arguments */</span> <a name="l00617"></a>00617 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span>(1); <a name="l00618"></a>00618 <span class="keywordflow">if</span>(img==NULL || img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) { <a name="l00619"></a>00619 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00620"></a>00620 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>!=<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <a name="l00621"></a>00621 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <span class="keywordflow">return</span>(2);} <a name="l00622"></a>00622 <a name="l00623"></a>00623 <span class="comment">/* Initiate headers */</span> <a name="l00624"></a>00624 memset(&main_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a>)); <a name="l00625"></a>00625 memset(&polmap_header,0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a>)); <a name="l00626"></a>00626 <a name="l00627"></a>00627 <span class="comment">/* Set main header */</span> <a name="l00628"></a>00628 <a class="code" href="img__e7_8c.html#ae0290e8d66a3ce7013405b344cca52f5">imgSetEcat7MHeader</a>(img, &main_header); <a name="l00629"></a>00629 main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l00630"></a>00630 <a name="l00631"></a>00631 <span class="comment">/* Allocate memory for matrix float data */</span> <a name="l00632"></a>00632 pxlNr=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>*img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l00633"></a>00633 fdata=(<span class="keywordtype">float</span>*)malloc(pxlNr*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>)); <a name="l00634"></a>00634 <span class="keywordflow">if</span>(fdata==NULL) {<a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>); <span class="keywordflow">return</span>(3);} <a name="l00635"></a>00635 <a name="l00636"></a>00636 <span class="comment">/* Open file, write main header and initiate matrix list */</span> <a name="l00637"></a>00637 fp=<a class="code" href="ecat7w_8c.html#a85ec2c6c7070a4170b8807e13623b04d">ecat7Create</a>(fname, &main_header); <a name="l00638"></a>00638 <span class="keywordflow">if</span>(fp==NULL) {free(fdata); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>); <span class="keywordflow">return</span>(6);} <a name="l00639"></a>00639 <a name="l00640"></a>00640 <span class="comment">/* Set (most of) subheader contents */</span> <a name="l00641"></a>00641 <a class="code" href="img__e7_8c.html#ae81e49b5bd72ebac0112b9d8c2f1afc8">imgSetEcat7SHeader</a>(img, &polmap_header); <a name="l00642"></a>00642 <a name="l00643"></a>00643 <span class="comment">/* Write each matrix */</span> <a name="l00644"></a>00644 <span class="keywordflow">for</span>(fi=0; fi<img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>; fi++) { <a name="l00645"></a>00645 <a name="l00646"></a>00646 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l00647"></a>00647 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(fi+1, 1, 1, 0, 0); <a name="l00648"></a>00648 <a name="l00649"></a>00649 <span class="comment">/* Copy matrix pixel values to fdata */</span> <a name="l00650"></a>00650 fptr=fdata; <a name="l00651"></a>00651 <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) <a name="l00652"></a>00652 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l00653"></a>00653 *fptr++=img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][fi]; <a name="l00654"></a>00654 <a name="l00655"></a>00655 <span class="comment">/* Write subheader and data */</span> <a name="l00656"></a>00656 fptr=fdata; <a name="l00657"></a>00657 polmap_header.<a class="code" href="structecat7__polmapheader.html#ac7757667731f12beb6c6e8a584dd6682">frame_start_time</a>=(<span class="keywordtype">int</span>)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi]); <a name="l00658"></a>00658 polmap_header.<a class="code" href="structecat7__polmapheader.html#af2c0109195bbcc833521aed329d2bd83">frame_duration</a>=(int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[fi]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[fi])); <a name="l00659"></a>00659 <span class="comment">/*ecat7PrintImageheader(&image_header, stdout);*/</span> <a name="l00660"></a>00660 ret=<a class="code" href="ecat7w_8c.html#a5f460170ea6c75b8af960ddf5a17d0ef">ecat7WritePolarmapMatrix</a>(fp, matrixId, &polmap_header, fptr); <a name="l00661"></a>00661 <span class="keywordflow">if</span>(ret) { <a name="l00662"></a>00662 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) {printf(<span class="stringliteral">"matrixId=%d ret=%d\n"</span>, matrixId, ret);} <a name="l00663"></a>00663 free(fdata); fclose(fp); <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba8500261907803b2afa1f761991a22679">STATUS_DISKFULL</a>); <span class="keywordflow">return</span>(7); <a name="l00664"></a>00664 } <a name="l00665"></a>00665 <a name="l00666"></a>00666 } <span class="comment">/* next matrix */</span> <a name="l00667"></a>00667 free(fdata); fclose(fp); <a name="l00668"></a>00668 <a name="l00669"></a>00669 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00670"></a>00670 <span class="keywordflow">return</span>(0); <a name="l00671"></a>00671 } <a name="l00672"></a>00672 <span class="comment">/*****************************************************************************/</span> <a name="l00673"></a>00673 <a name="l00674"></a>00674 <span class="comment">/*****************************************************************************/</span> <a name="l00681"></a><a class="code" href="imgfile_8h.html#a13c42900c44b97ed1b759d7ca6348ab6">00681</a> <span class="keywordtype">void</span> <a class="code" href="img__e7_8c.html#a13c42900c44b97ed1b759d7ca6348ab6">imgGetEcat7MHeader</a>(<a class="code" href="structIMG.html">IMG</a> *img, <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> *h) { <a name="l00682"></a>00682 <span class="preprocessor">#ifndef __STRICT_ANSI__</span> <a name="l00683"></a>00683 <span class="preprocessor"></span> <span class="keyword">struct </span>tm *scanStartTime; <a name="l00684"></a>00684 time_t lt; <a name="l00685"></a>00685 <span class="preprocessor">#endif</span> <a name="l00686"></a>00686 <span class="preprocessor"></span> <a name="l00687"></a>00687 img-><a class="code" href="structIMG.html#a7f83c746c35583a9fa323b94d7ea5fb5">scanner</a>=h-><a class="code" href="structecat7__mainheader.html#ae6537726ed92ab81d76c8985fff81244">system_type</a>; <a name="l00688"></a>00688 <a class="code" href="imgunit_8c.html#affce8dc83e60543c59d5b85678899db9">imgUnitFromEcat7</a>(img, h); <a name="l00689"></a>00689 strncpy(img-><a class="code" href="structIMG.html#ab8bcc846c896a26e5aac045b118fd5cf">radiopharmaceutical</a>, h-><a class="code" href="structecat7__mainheader.html#ab353f8a8b1166323fe7798d81004a225">radiopharmaceutical</a>, 32); <a name="l00690"></a>00690 img-><a class="code" href="structIMG.html#ac9c048a9dc8205b22518b05486d8030b">isotopeHalflife</a>=h-><a class="code" href="structecat7__mainheader.html#a9389f1b044165caf1a4b79007cb6cdfd">isotope_halflife</a>; <a name="l00691"></a>00691 img-><a class="code" href="structIMG.html#a5db78f8b423fc42b80bba42e27c7b2c3">scanStart</a>=h-><a class="code" href="structecat7__mainheader.html#a1ad956ffc4f0dc8e9bd473bfa20e6b81">scan_start_time</a>; <a name="l00692"></a>00692 <span class="preprocessor">#ifndef __STRICT_ANSI__</span> <a name="l00693"></a>00693 <span class="preprocessor"></span> <span class="comment">/* refresh timezone information (might be out of date) */</span> <a name="l00694"></a>00694 tzset(); <a name="l00695"></a>00695 <span class="comment">/* correct scan start time in hours */</span> <a name="l00696"></a>00696 lt = (time_t)img-><a class="code" href="structIMG.html#a5db78f8b423fc42b80bba42e27c7b2c3">scanStart</a>; <a name="l00697"></a>00697 scanStartTime = localtime(&lt); <a name="l00698"></a>00698 <span class="keywordflow">if</span>(scanStartTime!=NULL) { <a name="l00699"></a>00699 scanStartTime->tm_hour -= (timezone/3600); <a name="l00700"></a>00700 img-><a class="code" href="structIMG.html#a5db78f8b423fc42b80bba42e27c7b2c3">scanStart</a> = mktime(scanStartTime); <a name="l00701"></a>00701 } <a name="l00702"></a>00702 <span class="preprocessor">#endif</span> <a name="l00703"></a>00703 <span class="preprocessor"></span> img-><a class="code" href="structIMG.html#af1d9f4bd7d58988eb4aa9f660a244a64">axialFOV</a>=10.0*h-><a class="code" href="structecat7__mainheader.html#a1be6bc903aaef62d6cfac179b7b8a05b">distance_scanned</a>; <a name="l00704"></a>00704 img-><a class="code" href="structIMG.html#a4a03c16266c7e7dcd6858aca05e7599f">transaxialFOV</a>=10.0*h-><a class="code" href="structecat7__mainheader.html#a3dff6c0caf29b90298e542c6e76af2a1">transaxial_fov</a>; <a name="l00705"></a>00705 strncpy(img-><a class="code" href="structIMG.html#ad76f79021c93175ec98839613ba4dcd2">studyNr</a>, h-><a class="code" href="structecat7__mainheader.html#af24db33af652c26d6b2b8a580f3515c4">study_type</a>, MAX_STUDYNR_LEN); <a name="l00706"></a>00706 strncpy(img-><a class="code" href="structIMG.html#a29013e391052918bd5aa6974eeec811d">patientName</a>, h-><a class="code" href="structecat7__mainheader.html#a077ddc2daa174f716708c2077e9ea838">patient_name</a>, 32); <a name="l00707"></a>00707 strncpy(img-><a class="code" href="structIMG.html#a7dc9c21dbaf6b609a32e54c708e089c1">patientID</a>, h-><a class="code" href="structecat7__mainheader.html#a3ba61576ab7c202d8d9ba320ea352fe3">patient_id</a>, 16); <a name="l00708"></a>00708 img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>=10.0*h-><a class="code" href="structecat7__mainheader.html#a786937fcd3117a9d287da4636e3c0f37">plane_separation</a>; <a name="l00709"></a>00709 <span class="keywordflow">switch</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00710"></a>00710 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00711"></a>00711 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00712"></a>00712 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00713"></a>00713 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>; <span class="keywordflow">break</span>; <a name="l00714"></a>00714 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>; <span class="keywordflow">break</span>; <a name="l00715"></a>00715 <span class="keywordflow">default</span>: img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>=<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>; <a name="l00716"></a>00716 } <a name="l00717"></a>00717 img-><a class="code" href="structIMG.html#aa25ed90a08d249bc43b076a3c5a30544">orientation</a>=h-><a class="code" href="structecat7__mainheader.html#a1815f9e0d0083df1ba25af49d033d202">patient_orientation</a>; <a name="l00718"></a>00718 strncpy(img-><a class="code" href="structIMG.html#a3651200fbb19796a635502a7b7d2c2c3">studyDescription</a>, h-><a class="code" href="structecat7__mainheader.html#a08d61531e0bfce977dd5542f175925d9">study_description</a>, 32); <a name="l00719"></a>00719 strncpy(img-><a class="code" href="structIMG.html#a7743f4bab187593657c7bd4b7e99fe32">userProcessCode</a>, h-><a class="code" href="structecat7__mainheader.html#a957502542c1a109b52a59af75ebcb27e">user_process_code</a>, 10); <a name="l00720"></a>00720 img-><a class="code" href="structIMG.html#a7743f4bab187593657c7bd4b7e99fe32">userProcessCode</a>[10]=(char)0; <a name="l00721"></a>00721 <span class="comment">/* If valid study number is found in user_process_code, then take it */</span> <a name="l00722"></a>00722 <span class="keywordflow">if</span>(!img-><a class="code" href="structIMG.html#ad76f79021c93175ec98839613ba4dcd2">studyNr</a>[0] && studynr_validity_check(img-><a class="code" href="structIMG.html#a7743f4bab187593657c7bd4b7e99fe32">userProcessCode</a>)) <a name="l00723"></a>00723 strcpy(img-><a class="code" href="structIMG.html#ad76f79021c93175ec98839613ba4dcd2">studyNr</a>, img-><a class="code" href="structIMG.html#a7743f4bab187593657c7bd4b7e99fe32">userProcessCode</a>); <a name="l00724"></a>00724 } <a name="l00725"></a>00725 <span class="comment">/*****************************************************************************/</span> <a name="l00726"></a>00726 <a name="l00727"></a>00727 <span class="comment">/*****************************************************************************/</span> <a name="l00734"></a><a class="code" href="imgfile_8h.html#ae0290e8d66a3ce7013405b344cca52f5">00734</a> <span class="keywordtype">void</span> <a class="code" href="img__e7_8c.html#ae0290e8d66a3ce7013405b344cca52f5">imgSetEcat7MHeader</a>(<a class="code" href="structIMG.html">IMG</a> *img, <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> *h) { <a name="l00735"></a>00735 <span class="preprocessor">#ifndef __STRICT_ANSI__</span> <a name="l00736"></a>00736 <span class="preprocessor"></span> <span class="keyword">struct </span>tm *scanStartTime; <a name="l00737"></a>00737 time_t lt; <a name="l00738"></a>00738 <span class="preprocessor">#endif</span> <a name="l00739"></a>00739 <span class="preprocessor"></span> <a name="l00740"></a>00740 h-><a class="code" href="structecat7__mainheader.html#a413498a0395e39c969bf7bf401cf023c">sw_version</a>=72; <a name="l00741"></a>00741 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <a name="l00742"></a>00742 strcpy(h-><a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#a79ce0ec6cdde2ca6101c0bbc7c78beca">ECAT7V_MAGICNR</a>); <a name="l00743"></a>00743 h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>; <a name="l00744"></a>00744 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l00745"></a>00745 strcpy(h-><a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#aaabd0d99ccbfd3207b990740f1b781f4">ECAT7S_MAGICNR</a>); <a name="l00746"></a>00746 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>; <a name="l00747"></a>00747 <span class="keywordflow">else</span> h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>; <a name="l00748"></a>00748 } <span class="keywordflow">else</span> { <a name="l00749"></a>00749 strcpy(h-><a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#a79ce0ec6cdde2ca6101c0bbc7c78beca">ECAT7V_MAGICNR</a>); <a name="l00750"></a>00750 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>; <a name="l00751"></a>00751 <span class="keywordflow">else</span> h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>=<a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>; <a name="l00752"></a>00752 } <a name="l00753"></a>00753 h-><a class="code" href="structecat7__mainheader.html#ae6537726ed92ab81d76c8985fff81244">system_type</a>=img-><a class="code" href="structIMG.html#a7f83c746c35583a9fa323b94d7ea5fb5">scanner</a>; <a name="l00754"></a>00754 h-><a class="code" href="structecat7__mainheader.html#a1ad956ffc4f0dc8e9bd473bfa20e6b81">scan_start_time</a>=img-><a class="code" href="structIMG.html#a5db78f8b423fc42b80bba42e27c7b2c3">scanStart</a>; <a name="l00755"></a>00755 <span class="preprocessor">#ifndef __STRICT_ANSI__</span> <a name="l00756"></a>00756 <span class="preprocessor"></span> <span class="comment">/* refresh timezone information (might be out of date) */</span> <a name="l00757"></a>00757 tzset(); <a name="l00758"></a>00758 <span class="comment">/* correct scan start time in hours */</span> <a name="l00759"></a>00759 lt = (time_t)h-><a class="code" href="structecat7__mainheader.html#a1ad956ffc4f0dc8e9bd473bfa20e6b81">scan_start_time</a>; <a name="l00760"></a>00760 scanStartTime = localtime(&lt); <a name="l00761"></a>00761 <span class="keywordflow">if</span>(scanStartTime!=NULL) { <a name="l00762"></a>00762 scanStartTime->tm_hour += (timezone/3600); <a name="l00763"></a>00763 h-><a class="code" href="structecat7__mainheader.html#a1ad956ffc4f0dc8e9bd473bfa20e6b81">scan_start_time</a> = mktime(scanStartTime); <a name="l00764"></a>00764 } <a name="l00765"></a>00765 <span class="preprocessor">#endif</span> <a name="l00766"></a>00766 <span class="preprocessor"></span> h-><a class="code" href="structecat7__mainheader.html#a9389f1b044165caf1a4b79007cb6cdfd">isotope_halflife</a>=img-><a class="code" href="structIMG.html#ac9c048a9dc8205b22518b05486d8030b">isotopeHalflife</a>; <a name="l00767"></a>00767 <a class="code" href="imgunit_8c.html#ad0fec561f92cbdefe55280201ef73318">imgUnitToEcat7</a>(img, h); <a name="l00768"></a>00768 h-><a class="code" href="structecat7__mainheader.html#ad5be044d585696c1f35bb8b63c26fec9">ecat_calibration_factor</a>=1.0; <a name="l00769"></a>00769 h-><a class="code" href="structecat7__mainheader.html#a3dff6c0caf29b90298e542c6e76af2a1">transaxial_fov</a>=img-><a class="code" href="structIMG.html#a4a03c16266c7e7dcd6858aca05e7599f">transaxialFOV</a>/10.0; <a name="l00770"></a>00770 h-><a class="code" href="structecat7__mainheader.html#aacea3a6d9b88add8710823f1c17acc37">num_planes</a>=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <span class="comment">/* h->num_planes=1; */</span> <a name="l00771"></a>00771 h-><a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>=img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>; <a name="l00772"></a>00772 h-><a class="code" href="structecat7__mainheader.html#a45cd434d5473194ffdbb27c99d9d7e6a">num_gates</a>=1; <a name="l00773"></a>00773 h-><a class="code" href="structecat7__mainheader.html#acd90030d2317a4af5583431115b21a4a">num_bed_pos</a>=0; <a name="l00774"></a>00774 h-><a class="code" href="structecat7__mainheader.html#a1be6bc903aaef62d6cfac179b7b8a05b">distance_scanned</a>=img-><a class="code" href="structIMG.html#af1d9f4bd7d58988eb4aa9f660a244a64">axialFOV</a>/10.0; <a name="l00775"></a>00775 h-><a class="code" href="structecat7__mainheader.html#a786937fcd3117a9d287da4636e3c0f37">plane_separation</a>=img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>/10.0; <a name="l00776"></a>00776 strncpy(h-><a class="code" href="structecat7__mainheader.html#ab353f8a8b1166323fe7798d81004a225">radiopharmaceutical</a>, img-><a class="code" href="structIMG.html#ab8bcc846c896a26e5aac045b118fd5cf">radiopharmaceutical</a>, 32); <a name="l00777"></a>00777 strcpy(h-><a class="code" href="structecat7__mainheader.html#a1a6eea4ac705c0f84f755ac6cb12d69d">isotope_name</a>, <a class="code" href="imgdecay_8c.html#a14db419685f526306032a84343eed72c">imgIsotope</a>(img)); <a name="l00778"></a>00778 strcpy(h-><a class="code" href="structecat7__mainheader.html#af24db33af652c26d6b2b8a580f3515c4">study_type</a>, img-><a class="code" href="structIMG.html#ad76f79021c93175ec98839613ba4dcd2">studyNr</a>); <a name="l00779"></a>00779 strcpy(h-><a class="code" href="structecat7__mainheader.html#a077ddc2daa174f716708c2077e9ea838">patient_name</a>, img-><a class="code" href="structIMG.html#a29013e391052918bd5aa6974eeec811d">patientName</a>); <a name="l00780"></a>00780 strcpy(h-><a class="code" href="structecat7__mainheader.html#a3ba61576ab7c202d8d9ba320ea352fe3">patient_id</a>, img-><a class="code" href="structIMG.html#a7dc9c21dbaf6b609a32e54c708e089c1">patientID</a>); <a name="l00781"></a>00781 h-><a class="code" href="structecat7__mainheader.html#a1815f9e0d0083df1ba25af49d033d202">patient_orientation</a>=img-><a class="code" href="structIMG.html#aa25ed90a08d249bc43b076a3c5a30544">orientation</a>; <a name="l00782"></a>00782 strcpy(h-><a class="code" href="structecat7__mainheader.html#a08d61531e0bfce977dd5542f175925d9">study_description</a>, img-><a class="code" href="structIMG.html#a3651200fbb19796a635502a7b7d2c2c3">studyDescription</a>); <a name="l00783"></a>00783 strncpy(h-><a class="code" href="structecat7__mainheader.html#a957502542c1a109b52a59af75ebcb27e">user_process_code</a>, img-><a class="code" href="structIMG.html#a7743f4bab187593657c7bd4b7e99fe32">userProcessCode</a>, 10); <a name="l00784"></a>00784 } <a name="l00785"></a>00785 <span class="comment">/*****************************************************************************/</span> <a name="l00786"></a>00786 <a name="l00787"></a>00787 <span class="comment">/*****************************************************************************/</span> <a name="l00794"></a><a class="code" href="imgfile_8h.html#a99bc5e0be5b16c6a0a75454f3232634c">00794</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a99bc5e0be5b16c6a0a75454f3232634c">imgGetEcat7Fileformat</a>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> *h) { <a name="l00795"></a>00795 <span class="keywordtype">int</span> fileFormat=<a class="code" href="img_8h.html#a3aea8253aaffd2e73cf8641661f6a459">IMG_UNKNOWN</a>; <a name="l00796"></a>00796 <span class="keywordflow">switch</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00797"></a>00797 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00798"></a>00798 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00799"></a>00799 fileFormat=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>; <span class="keywordflow">break</span>; <a name="l00800"></a>00800 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00801"></a>00801 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: <a name="l00802"></a>00802 fileFormat=<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>; <span class="keywordflow">break</span>; <a name="l00803"></a>00803 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>: <a name="l00804"></a>00804 fileFormat=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>; <span class="keywordflow">break</span>; <a name="l00805"></a>00805 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>: <a name="l00806"></a>00806 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>: <a name="l00807"></a>00807 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>: <a name="l00808"></a>00808 fileFormat=<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>; <span class="keywordflow">break</span>; <a name="l00809"></a>00809 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: <a name="l00810"></a>00810 fileFormat=<a class="code" href="img_8h.html#aa0111a4761ce5db222757daff1f48dfe">IMG_POLARMAP</a>; <span class="keywordflow">break</span>; <a name="l00811"></a>00811 <span class="keywordflow">default</span>: <a name="l00812"></a>00812 fileFormat=<a class="code" href="img_8h.html#a3aea8253aaffd2e73cf8641661f6a459">IMG_UNKNOWN</a>; <span class="keywordflow">break</span>; <a name="l00813"></a>00813 } <a name="l00814"></a>00814 <span class="keywordflow">return</span> fileFormat; <a name="l00815"></a>00815 } <a name="l00816"></a>00816 <span class="comment">/*****************************************************************************/</span> <a name="l00827"></a><a class="code" href="imgfile_8h.html#a80595d5fb45da4904f58fbb0d3e7e64a">00827</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a80595d5fb45da4904f58fbb0d3e7e64a">imgReadEcat7Header</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l00828"></a>00828 FILE *fp; <a name="l00829"></a>00829 <span class="keywordtype">int</span> ret, m, i; <a name="l00830"></a>00830 <span class="keywordtype">int</span> planeNr, frameNr, blkNr=0; <a name="l00831"></a>00831 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l00832"></a>00832 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l00833"></a>00833 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> scan2d_header; <a name="l00834"></a>00834 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> scan_header; <a name="l00835"></a>00835 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> polmap_header; <a name="l00836"></a>00836 <a class="code" href="structECAT7__MATRIXLIST.html">ECAT7_MATRIXLIST</a> mlist; <a name="l00837"></a>00837 <a name="l00838"></a>00838 <a name="l00839"></a>00839 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"\nimgReadEcat7Header(%s, *img)\n"</span>, fname); <a name="l00840"></a>00840 <a name="l00841"></a>00841 <span class="comment">/* Check the arguments */</span> <a name="l00842"></a>00842 <span class="keywordflow">if</span>(img==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l00843"></a>00843 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l00844"></a>00844 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <a name="l00845"></a>00845 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l00846"></a>00846 <a name="l00847"></a>00847 <span class="comment">/* Open the file */</span> <a name="l00848"></a>00848 <span class="keywordflow">if</span>((fp=fopen(fname, <span class="stringliteral">"rb"</span>)) == NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba9f298b5339db644dbc2b9dc01ef12006">STATUS_NOFILE</a>; <a name="l00849"></a>00849 <a name="l00850"></a>00850 <span class="comment">/* Read main header */</span> <a name="l00851"></a>00851 ret=<a class="code" href="ecat7r_8c.html#a7d6241dd7a472a4f2aaf3eb16dc03dc1">ecat7ReadMainheader</a>(fp, &main_header); <a name="l00852"></a>00852 <span class="keywordflow">if</span>(ret) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafa1051360f88591f14aa0383d8087132">STATUS_NOMAINHEADER</a>;} <a name="l00853"></a>00853 <span class="comment">/* Check for magic number */</span> <a name="l00854"></a>00854 <span class="keywordflow">if</span>(strncmp(main_header.<a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#a79ce0ec6cdde2ca6101c0bbc7c78beca">ECAT7V_MAGICNR</a>, 7)!=0) { <a name="l00855"></a>00855 fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba942f7c6c65ba2a702cd9c23550843003">STATUS_UNKNOWNFORMAT</a>;} <a name="l00856"></a>00856 <span class="comment">/* Check if file_type is supported */</span> <a name="l00857"></a>00857 <span class="keywordflow">if</span>(<a class="code" href="img__e7_8c.html#a4b25c303088592c0518bf26df1d20aec">imgEcat7Supported</a>(&main_header)==0) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>;} <a name="l00858"></a>00858 <span class="comment">/* Copy main header information into IMG; sets also img.type */</span> <a name="l00859"></a>00859 <a class="code" href="img__e7_8c.html#a13c42900c44b97ed1b759d7ca6348ab6">imgGetEcat7MHeader</a>(img, &main_header); <a name="l00860"></a>00860 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>7) printf(<span class="stringliteral">"img.type := %d\n"</span>, img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>); <a name="l00861"></a>00861 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>=<a class="code" href="img__e7_8c.html#a99bc5e0be5b16c6a0a75454f3232634c">imgGetEcat7Fileformat</a>(&main_header); <a name="l00862"></a>00862 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>7) printf(<span class="stringliteral">"img._fileFormat := %d\n"</span>, img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>); <a name="l00863"></a>00863 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3aea8253aaffd2e73cf8641661f6a459">IMG_UNKNOWN</a>) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>;} <a name="l00864"></a>00864 <a name="l00865"></a>00865 <span class="comment">/* Read matrix list */</span> <a name="l00866"></a>00866 <a class="code" href="ecat7ml_8c.html#a0826a19efcf80e53e28473189d07949e">ecat7InitMatlist</a>(&mlist); <a name="l00867"></a>00867 ret=<a class="code" href="ecat7ml_8c.html#a0304c6b68597ab6fe00bb35a44c19dcb">ecat7ReadMatlist</a>(fp, &mlist); <a name="l00868"></a>00868 <span class="keywordflow">if</span>(ret || mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a><1 || <a class="code" href="ecat7ml_8c.html#ae366d8f1a8202f053debfdbe2a8c6be7">ecat7CheckMatlist</a>(&mlist)) { <a name="l00869"></a>00869 fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae2d56db7d13d44bec04369ae30c44a6c">STATUS_INVALIDMATLIST</a>;} <a name="l00870"></a>00870 <span class="comment">/* Make sure that plane and frame numbers are continuous */</span> <a name="l00871"></a>00871 <a class="code" href="ecat7ml_8c.html#ad061c624a2cc95af6b54e6fdebdfc64d">ecat7GatherMatlist</a>(&mlist, 1, 1, 1, 1); <a name="l00872"></a>00872 <span class="comment">/* Get plane and frame numbers and check that volume is full */</span> <a name="l00873"></a>00873 ret=<a class="code" href="ecat7ml_8c.html#a233c8c21f8ef8975c4cf486c6137a53d">ecat7GetPlaneAndFrameNr</a>(&mlist, &main_header, &planeNr, &frameNr); <a name="l00874"></a>00874 <span class="keywordflow">if</span>(ret) {<a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); fclose(fp); <span class="keywordflow">return</span> ret;} <a name="l00875"></a>00875 img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>=planeNr; <a name="l00876"></a>00876 img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>=frameNr; <a name="l00877"></a>00877 <span class="comment">/* Get and check the size of data matrices */</span> <a name="l00878"></a>00878 ret=<a class="code" href="ecat7ml_8c.html#a24438ca2c1691deba0e4101d8fadb1c8">ecat7GetMatrixBlockSize</a>(&mlist, &blkNr); <a name="l00879"></a>00879 <span class="keywordflow">if</span>(ret) {<a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); fclose(fp); <span class="keywordflow">return</span> ret;} <a name="l00880"></a>00880 <a name="l00881"></a>00881 <span class="comment">/* Read one subheader */</span> <a name="l00882"></a>00882 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>5) printf(<span class="stringliteral">"main_header.file_type := %d\n"</span>, main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>); <a name="l00883"></a>00883 m=0; <a name="l00884"></a>00884 <span class="keywordflow">switch</span>(main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00885"></a>00885 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00886"></a>00886 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00887"></a>00887 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00888"></a>00888 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: <a name="l00889"></a>00889 ret=<a class="code" href="ecat7r_8c.html#ac96bedc17610a5a05d95ce7742d44b5c">ecat7ReadImageheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &image_header); <a name="l00890"></a>00890 <span class="keywordflow">break</span>; <a name="l00891"></a>00891 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>: <a name="l00892"></a>00892 ret=<a class="code" href="ecat7r_8c.html#aa37d19fc4f30868ea0b062d39d9d8450">ecat7Read2DScanheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &scan2d_header); <a name="l00893"></a>00893 <span class="keywordflow">break</span>; <a name="l00894"></a>00894 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>: <a name="l00895"></a>00895 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>: <a name="l00896"></a>00896 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>: <a name="l00897"></a>00897 ret=<a class="code" href="ecat7r_8c.html#a37414b52ef395686b6a81d6229d13143">ecat7ReadScanheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &scan_header); <a name="l00898"></a>00898 <span class="keywordflow">break</span>; <a name="l00899"></a>00899 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: <a name="l00900"></a>00900 ret=<a class="code" href="ecat7r_8c.html#a498d383ca08a832895af8ead01e8c756">ecat7ReadPolmapheader</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, &polmap_header); <a name="l00901"></a>00901 <span class="keywordflow">break</span>; <a name="l00902"></a>00902 <span class="keywordflow">default</span>: ret=-1; <a name="l00903"></a>00903 } <a name="l00904"></a>00904 <span class="comment">/* Free locally allocated memory and close the file */</span> <a name="l00905"></a>00905 <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); fclose(fp); <a name="l00906"></a>00906 <span class="comment">/* Check whether subheader was read */</span> <a name="l00907"></a>00907 <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae6ad5f97cf86fa7686fd12961e4ccdf4">STATUS_NOSUBHEADER</a>; <a name="l00908"></a>00908 <a name="l00909"></a>00909 <span class="comment">/* Get the following information in the subheader:</span> <a name="l00910"></a>00910 <span class="comment"> dimensions x, y and z; datatype;</span> <a name="l00911"></a>00911 <span class="comment"> image decay correction on/off, zoom, pixel size and resolution;</span> <a name="l00912"></a>00912 <span class="comment"> sinogram sample distance.</span> <a name="l00913"></a>00913 <span class="comment"> */</span> <a name="l00914"></a>00914 <span class="keywordflow">switch</span>(main_header.<a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>) { <a name="l00915"></a>00915 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>: <a name="l00916"></a>00916 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>: <a name="l00917"></a>00917 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>: <a name="l00918"></a>00918 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>: <a name="l00919"></a>00919 img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>=image_header.<a class="code" href="structecat7__imageheader.html#a37550f6ce6a114de12aa0d038f573230">x_dimension</a>; img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>=image_header.<a class="code" href="structecat7__imageheader.html#a217d17f8b1f921fad128ce923fa21c35">y_dimension</a>; <a name="l00920"></a>00920 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>>2 && image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>>1) <a name="l00921"></a>00921 <span class="comment">/*planeNr=*/</span> img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>=image_header.<a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>; <a name="l00922"></a>00922 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=image_header.<a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>; <a name="l00923"></a>00923 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>>1.0) img-><a class="code" href="structIMG.html#a6ce801dea67ec8224e8cfc9aebb8a909">decayCorrected</a>=1; <a name="l00924"></a>00924 img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>=image_header.<a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>; <a name="l00925"></a>00925 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>; <a name="l00926"></a>00926 img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>; <a name="l00927"></a>00927 img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>; <a name="l00928"></a>00928 img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>; <a name="l00929"></a>00929 img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>; <a name="l00930"></a>00930 img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>=10.*image_header.<a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>; <a name="l00931"></a>00931 <span class="keywordflow">break</span>; <a name="l00932"></a>00932 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>: <a name="l00933"></a>00933 img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#adfe07cff44e3145ca65c234079ff255a">num_r_elements</a>; img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ad0d1958b231f10aa68d60c653ec30627">num_angles</a>; <a name="l00934"></a>00934 <span class="keywordflow">if</span>(scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a592447ad964ba95e2a29a7d3d2284576">num_dimensions</a>>2 && scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>>1) <a name="l00935"></a>00935 planeNr=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>; <a name="l00936"></a>00936 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#aa13b8697f5c56f7e31e942cafb91bddc">data_type</a>; <a name="l00937"></a>00937 <span class="keywordflow">if</span>(scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a77e48781a4d1eda3cd828fdc2c3b1a62">x_resolution</a>>0.0) <a name="l00938"></a>00938 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a77e48781a4d1eda3cd828fdc2c3b1a62">x_resolution</a>; <a name="l00939"></a>00939 <span class="keywordflow">else</span> <a name="l00940"></a>00940 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>; <a name="l00941"></a>00941 <span class="keywordflow">break</span>; <a name="l00942"></a>00942 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>: <a name="l00943"></a>00943 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>: <a name="l00944"></a>00944 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>: <a name="l00945"></a>00945 img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>=scan_header.<a class="code" href="structecat7__scanheader.html#aee3fd0c2360973b3d53ad1adf6225d7d">num_r_elements</a>; img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>=scan_header.<a class="code" href="structecat7__scanheader.html#a4f58fe54c66427d34390f6530a12f8ed">num_angles</a>; <a name="l00946"></a>00946 <span class="keywordflow">for</span>(i=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>=0; i<64; i++) img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>+=scan_header.<a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[i]; <a name="l00947"></a>00947 <span class="comment">/* planeNr=img->dimz; */</span> <a name="l00948"></a>00948 img-><a class="code" href="structIMG.html#a780bf2ffdee9e977a3a51febb7696701">_dataType</a>=scan_header.<a class="code" href="structecat7__scanheader.html#ac1dfbebf9227256db4dd3ec96a95277f">data_type</a>; <a name="l00949"></a>00949 <span class="keywordflow">if</span>(scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>>0.0) <a name="l00950"></a>00950 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*scan_header.<a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>; <a name="l00951"></a>00951 <span class="keywordflow">else</span> <a name="l00952"></a>00952 img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>=10.0*main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>; <a name="l00953"></a>00953 <span class="keywordflow">break</span>; <a name="l00954"></a>00954 <span class="keywordflow">case</span> <a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>: <a name="l00955"></a>00955 img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>=1; <a name="l00956"></a>00956 img-><a class="code" href="structIMG.html#a07ae2dcb24730f7c5352f09a98967e16">polarmap_num_rings</a>=polmap_header.<a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>; <a name="l00957"></a>00957 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a07ae2dcb24730f7c5352f09a98967e16">polarmap_num_rings</a>><a class="code" href="img_8h.html#acaea665ceb89d40b45e9987366334bb8">MAX_POLARMAP_NUM_RINGS</a>) <a name="l00958"></a>00958 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba596585203b6d1a1fc5fc668f4e7f8a70">STATUS_INVALIDPOLARMAP</a>; <a name="l00959"></a>00959 <span class="keywordflow">for</span>(i=0; i<img-><a class="code" href="structIMG.html#a07ae2dcb24730f7c5352f09a98967e16">polarmap_num_rings</a>; i++) { <a name="l00960"></a>00960 img-><a class="code" href="structIMG.html#aa0cf526b49d558db6391a6e60864ec88">polarmap_sectors_per_ring</a>[i]=polmap_header.<a class="code" href="structecat7__polmapheader.html#a7888f1b2bc8adcc5bcbf918bbbb82dbb">sectors_per_ring</a>[i]; <a name="l00961"></a>00961 img-><a class="code" href="structIMG.html#afa091c63e52a3e72a674435104f8a164">polarmap_ring_position</a>[i]=polmap_header.<a class="code" href="structecat7__polmapheader.html#a1f8b29deb85540e9d4d30d9a8247c0d6">ring_position</a>[i]; <a name="l00962"></a>00962 img-><a class="code" href="structIMG.html#ad343b587b771b99bd2552f31a835cf73">polarmap_ring_angle</a>[i]=polmap_header.<a class="code" href="structecat7__polmapheader.html#af91ac7e401a999aaaaf275c8671ad0ab">ring_angle</a>[i]; <a name="l00963"></a>00963 } <a name="l00964"></a>00964 img-><a class="code" href="structIMG.html#a3cb4c538ca5fdcdbbf259adf57208ca5">polarmap_start_angle</a>=polmap_header.<a class="code" href="structecat7__polmapheader.html#ad59dd3b498ddd78aa65a6cf4425d259a">start_angle</a>; <a name="l00965"></a>00965 <span class="keywordflow">for</span>(i=0, img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>=0; i<img->polarmap_num_rings; i++) <a name="l00966"></a>00966 img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>+=img-><a class="code" href="structIMG.html#aa0cf526b49d558db6391a6e60864ec88">polarmap_sectors_per_ring</a>[i]; <a name="l00967"></a>00967 <span class="comment">/* pixel_size actually contains volume, in cubic cm */</span> <a name="l00968"></a>00968 img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>=img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>=img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>=0.001*polmap_header.<a class="code" href="structecat7__polmapheader.html#a4a7a70570769b6b97bf67f6358a61f45">pixel_size</a>; <a name="l00969"></a>00969 <span class="keywordflow">break</span>; <a name="l00970"></a>00970 } <a name="l00971"></a>00971 <a name="l00972"></a>00972 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l00973"></a>00973 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l00974"></a>00974 } <a name="l00975"></a>00975 <span class="comment">/*****************************************************************************/</span> <a name="l00976"></a>00976 <a name="l00977"></a>00977 <span class="comment">/*****************************************************************************/</span> <a name="l00984"></a><a class="code" href="imgfile_8h.html#a4b25c303088592c0518bf26df1d20aec">00984</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a4b25c303088592c0518bf26df1d20aec">imgEcat7Supported</a>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> *h) { <a name="l00985"></a>00985 <span class="keywordflow">if</span>(h==NULL) <span class="keywordflow">return</span>(0); <a name="l00986"></a>00986 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a0ea1caf9e41509e4d119d229d9636445">ECAT7_VOLUME8</a>) <span class="keywordflow">return</span>(1); <a name="l00987"></a>00987 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a6e003b3310c339d2cdac5b64cbdca3f1">ECAT7_VOLUME16</a>) <span class="keywordflow">return</span>(1); <a name="l00988"></a>00988 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a89d13a863bef6b8ba3be45dd7ae179ae">ECAT7_IMAGE8</a>) <span class="keywordflow">return</span>(1); <a name="l00989"></a>00989 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a65f66a0950e8acad3f17e8943f8fffe5">ECAT7_IMAGE16</a>) <span class="keywordflow">return</span>(1); <a name="l00990"></a>00990 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#af9e3bc8017c230f899191645d98bdeec">ECAT7_2DSCAN</a>) <span class="keywordflow">return</span>(1); <a name="l00991"></a>00991 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a432546d341581f2754964e808b368116">ECAT7_3DSCAN</a>) <span class="keywordflow">return</span>(1); <a name="l00992"></a>00992 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a4b13fe4c981f8d1ebf6f99baceb3730d">ECAT7_3DSCAN8</a>) <span class="keywordflow">return</span>(1); <a name="l00993"></a>00993 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#a6c8af4dc922ee29e79c8490da33eea76">ECAT7_3DSCANFIT</a>) <span class="keywordflow">return</span>(1); <a name="l00994"></a>00994 <span class="keywordflow">if</span>(h-><a class="code" href="structecat7__mainheader.html#a1914b3a0ebf3077d090752d6ef66c757">file_type</a>==<a class="code" href="ecat7_8h.html#ad0af87a185fd38674939656d33c410cc">ECAT7_POLARMAP</a>) <span class="keywordflow">return</span>(1); <a name="l00995"></a>00995 <span class="keywordflow">return</span>(0); <a name="l00996"></a>00996 } <a name="l00997"></a>00997 <span class="comment">/*****************************************************************************/</span> <a name="l00998"></a>00998 <a name="l00999"></a>00999 <span class="comment">/*****************************************************************************/</span> <a name="l01008"></a><a class="code" href="imgfile_8h.html#a58a522d08abfe14a1477448c9dd6786a">01008</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a58a522d08abfe14a1477448c9dd6786a">imgReadEcat7FirstFrame</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <a class="code" href="structIMG.html">IMG</a> *img) { <a name="l01009"></a>01009 <span class="keywordtype">int</span> ret=0; <a name="l01010"></a>01010 <a name="l01011"></a>01011 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"\nimgReadEcat7FirstFrame(%s, *img)\n"</span>, fname); <a name="l01012"></a>01012 <span class="comment">/* Check the input */</span> <a name="l01013"></a>01013 <span class="keywordflow">if</span>(img==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01014"></a>01014 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a7aeab2fb426b858c78ec515aaa8f0a67">IMG_STATUS_INITIALIZED</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01015"></a>01015 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>); <a name="l01016"></a>01016 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01017"></a>01017 <a name="l01018"></a>01018 <span class="comment">/* Read header information from file */</span> <a name="l01019"></a>01019 ret=<a class="code" href="img__e7_8c.html#a80595d5fb45da4904f58fbb0d3e7e64a">imgReadEcat7Header</a>(fname, img); <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span>(ret); <a name="l01020"></a>01020 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>3) <a class="code" href="img_8c.html#a32edd1b78039f6cc22b7bbe413aa3a56">imgInfo</a>(img); <a name="l01021"></a>01021 <a name="l01022"></a>01022 <span class="comment">/* Allocate memory for one frame */</span> <a name="l01023"></a>01023 img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>=1; <a name="l01024"></a>01024 ret=<a class="code" href="img_8c.html#a9b2670da9c7685e6d53058cdf1db1199">imgAllocate</a>(img, img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>, img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>, img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>, img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>); <a name="l01025"></a>01025 <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>; <a name="l01026"></a>01026 <a name="l01027"></a>01027 <span class="comment">/* Read the first frame */</span> <a name="l01028"></a>01028 ret=<a class="code" href="img__e7_8c.html#a295fc06d4e06f7b6bbd094dbce7be8c7">imgReadEcat7Frame</a>(fname, 1, img, 0); <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span>(ret); <a name="l01029"></a>01029 <a name="l01030"></a>01030 <span class="comment">/* All went well */</span> <a name="l01031"></a>01031 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l01032"></a>01032 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l01033"></a>01033 } <a name="l01034"></a>01034 <span class="comment">/*****************************************************************************/</span> <a name="l01035"></a>01035 <a name="l01036"></a>01036 <span class="comment">/*****************************************************************************/</span> <a name="l01051"></a><a class="code" href="imgfile_8h.html#a295fc06d4e06f7b6bbd094dbce7be8c7">01051</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#a295fc06d4e06f7b6bbd094dbce7be8c7">imgReadEcat7Frame</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keywordtype">int</span> frame_to_read, <a class="code" href="structIMG.html">IMG</a> *img, <span class="keywordtype">int</span> frame_index) { <a name="l01052"></a>01052 FILE *fp; <a name="l01053"></a>01053 <span class="keywordtype">int</span> ret, m, i, pi, xi, yi, frame, plane, seqplane, pxlNr; <a name="l01054"></a>01054 <span class="comment">/* int blkNr=0; */</span> <a name="l01055"></a>01055 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l01056"></a>01056 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l01057"></a>01057 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> scan2d_header; <a name="l01058"></a>01058 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> scan_header; <a name="l01059"></a>01059 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> polmap_header; <a name="l01060"></a>01060 <a class="code" href="structECAT7__MATRIXLIST.html">ECAT7_MATRIXLIST</a> mlist; <a name="l01061"></a>01061 <a class="code" href="structECAT7__Matval.html">ECAT7_Matval</a> matval; <a name="l01062"></a>01062 <span class="keywordtype">float</span> *fdata=NULL, *fptr; <a name="l01063"></a>01063 <a name="l01064"></a>01064 <a name="l01065"></a>01065 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"\nimgReadEcat7Frame(%s, %d, *img, %d)\n"</span>, <a name="l01066"></a>01066 fname, frame_to_read, frame_index); <a name="l01067"></a>01067 <a name="l01068"></a>01068 <span class="comment">/* Check the input */</span> <a name="l01069"></a>01069 <span class="keywordflow">if</span>(img==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01070"></a>01070 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01071"></a>01071 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01072"></a>01072 <span class="keywordflow">if</span>(frame_index<0 || frame_index>img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>-1) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01073"></a>01073 <span class="keywordflow">if</span>(frame_to_read<1) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01074"></a>01074 <a name="l01075"></a>01075 <span class="comment">/* Open file for read */</span> <a name="l01076"></a>01076 <span class="keywordflow">if</span>((fp=fopen(fname, <span class="stringliteral">"rb"</span>)) == NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba9f298b5339db644dbc2b9dc01ef12006">STATUS_NOFILE</a>; <a name="l01077"></a>01077 <a name="l01078"></a>01078 <span class="comment">/* Read main header */</span> <a name="l01079"></a>01079 ret=<a class="code" href="ecat7r_8c.html#a7d6241dd7a472a4f2aaf3eb16dc03dc1">ecat7ReadMainheader</a>(fp, &main_header); <a name="l01080"></a>01080 <span class="keywordflow">if</span>(ret) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafa1051360f88591f14aa0383d8087132">STATUS_NOMAINHEADER</a>;} <a name="l01081"></a>01081 <span class="comment">/* Check for magic number */</span> <a name="l01082"></a>01082 <span class="keywordflow">if</span>(strncmp(main_header.<a class="code" href="structecat7__mainheader.html#a71cb64edce706f383f3e68b9548b9ec3">magic_number</a>, <a class="code" href="ecat7_8h.html#a79ce0ec6cdde2ca6101c0bbc7c78beca">ECAT7V_MAGICNR</a>, 7)!=0) { <a name="l01083"></a>01083 fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba942f7c6c65ba2a702cd9c23550843003">STATUS_UNKNOWNFORMAT</a>;} <a name="l01084"></a>01084 <span class="comment">/* Check if file_type is supported */</span> <a name="l01085"></a>01085 <span class="keywordflow">if</span>(<a class="code" href="img__e7_8c.html#a4b25c303088592c0518bf26df1d20aec">imgEcat7Supported</a>(&main_header)==0) { <a name="l01086"></a>01086 fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baef2b214bb9b6ccc009f27c76e81b3fef">STATUS_UNSUPPORTED</a>;} <a name="l01087"></a>01087 <span class="comment">/* Read matrix list and nr and sort it */</span> <a name="l01088"></a>01088 <a class="code" href="ecat7ml_8c.html#a0826a19efcf80e53e28473189d07949e">ecat7InitMatlist</a>(&mlist); <a name="l01089"></a>01089 ret=<a class="code" href="ecat7ml_8c.html#a0304c6b68597ab6fe00bb35a44c19dcb">ecat7ReadMatlist</a>(fp, &mlist); <a name="l01090"></a>01090 <span class="keywordflow">if</span>(ret) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba5b6084734072653f2466e29481713c4b">STATUS_NOMATLIST</a>;} <a name="l01091"></a>01091 <span class="keywordflow">if</span>(mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a><=0 || <a class="code" href="ecat7ml_8c.html#ae366d8f1a8202f053debfdbe2a8c6be7">ecat7CheckMatlist</a>(&mlist)) { <a name="l01092"></a>01092 fclose(fp); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae2d56db7d13d44bec04369ae30c44a6c">STATUS_INVALIDMATLIST</a>;} <a name="l01093"></a>01093 <span class="comment">/* Make sure that plane and frame numbers are continuous */</span> <a name="l01094"></a>01094 <a class="code" href="ecat7ml_8c.html#ad061c624a2cc95af6b54e6fdebdfc64d">ecat7GatherMatlist</a>(&mlist, 1, 1, 1, 1); <a name="l01095"></a>01095 <a class="code" href="ecat7ml_8c.html#a1005274d31eb31ae483b5740dae6af1e">ecat7SortMatlistByFrame</a>(&mlist); <span class="comment">/* printf("matlist sorted\n"); */</span> <a name="l01096"></a>01096 <span class="comment">/* Calculate and check the size of one data matrix */</span> <a name="l01097"></a>01097 <span class="comment">/*ret=ecat7GetMatrixBlockSize(&mlist, &blkNr); if(ret) {fclose(fp); return ret;}*/</span> <a name="l01098"></a>01098 <a name="l01099"></a>01099 <span class="comment">/* Read all matrices that belong to the required frame */</span> <a name="l01100"></a>01100 <span class="comment">/*blkNr=-1;*/</span> <a name="l01101"></a>01101 ret=0; seqplane=-1; pxlNr=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l01102"></a>01102 <span class="keywordflow">for</span>(m=0; m<mlist.<a class="code" href="structECAT7__MATRIXLIST.html#af3e725f10fb1d8e7768330b26cd37691">matrixNr</a>; m++) { <a name="l01103"></a>01103 <span class="comment">/* get frame and plane */</span> <a name="l01104"></a>01104 <a class="code" href="ecat7ml_8c.html#a4cf0dc3b586a1c62d177f21b5e8e2328">ecat7_id_to_val</a>(mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a496411c7ccf25471dd7e7af220160ffd">id</a>, &matval); plane=matval.<a class="code" href="structECAT7__Matval.html#a041cdbab82513cac692f52c4e7364093">plane</a>; <a name="l01105"></a>01105 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>>=main_header.<a class="code" href="structecat7__mainheader.html#a45cd434d5473194ffdbb27c99d9d7e6a">num_gates</a>) frame=matval.<a class="code" href="structECAT7__Matval.html#afc531f65c0b1b58cbcffb947df62400b">frame</a>; <a name="l01106"></a>01106 <span class="keywordflow">else</span> frame=matval.<a class="code" href="structECAT7__Matval.html#a0f094bb9f2d880fa875ecc6110ace13b">gate</a>; <span class="comment">/* printf("frame=%d plane=%d\n", frame, plane); */</span> <a name="l01107"></a>01107 <span class="keywordflow">if</span>(frame!=frame_to_read) <span class="keywordflow">continue</span>; <span class="comment">/* do not process other frames */</span> <a name="l01108"></a>01108 <span class="comment">/*if(img->dimz>1) seqplane++; else seqplane=plane-1; */</span> <a name="l01109"></a>01109 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) seqplane=plane-1; <span class="keywordflow">else</span> seqplane++; <a name="l01110"></a>01110 <a name="l01111"></a>01111 <span class="comment">/* Read subheader and data */</span> <a name="l01112"></a>01112 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>4) printf(<span class="stringliteral">"reading matrix %d,%d\n"</span>, frame, plane); <a name="l01113"></a>01113 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <span class="comment">/* 2D or 3D image */</span> <a name="l01114"></a>01114 ret=<a class="code" href="ecat7r_8c.html#ac62693d7c451818000deb09e2f59cc68">ecat7ReadImageMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l01115"></a>01115 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &image_header, &fdata); <a name="l01116"></a>01116 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <span class="comment">/* polarmap */</span> <a name="l01117"></a>01117 ret=<a class="code" href="ecat7r_8c.html#aa07f0b9089fda6bc1f5e8ce179f62686">ecat7ReadPolarmapMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l01118"></a>01118 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &polmap_header, &fdata); <a name="l01119"></a>01119 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>>1) { <span class="comment">/* 3D sinogram */</span> <a name="l01120"></a>01120 ret=<a class="code" href="ecat7r_8c.html#aeed5aa16cd7ac3d07994e039ede3142d">ecat7ReadScanMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l01121"></a>01121 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &scan_header, &fdata); <a name="l01122"></a>01122 } <span class="keywordflow">else</span> { <span class="comment">/* 2D sinogram */</span> <a name="l01123"></a>01123 ret=<a class="code" href="ecat7r_8c.html#a2cdc756d0ec7d7b4d22f7d6c8b73fd7b">ecat7Read2DScanMatrix</a>(fp, mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#a599cd12bfc8ff972afaef41a2cb57aa8">strtblk</a>, <a name="l01124"></a>01124 mlist.<a class="code" href="structECAT7__MATRIXLIST.html#a691b0a0862d05c2eb983930022a908a7">matdir</a>[m].<a class="code" href="structECAT7__MatDir.html#aed143081e768d276a1eaf275e116b259">endblk</a>, &scan2d_header, &fdata); <a name="l01125"></a>01125 } <a name="l01126"></a>01126 <span class="keywordflow">if</span>(ret || fdata==NULL) { <a name="l01127"></a>01127 fclose(fp); <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55babe9c1bcf366cd905b79148ba91b34756">STATUS_NOMATRIX</a>;} <a name="l01128"></a>01128 <a name="l01129"></a>01129 <span class="comment">/* Copy information concerning this frame and make correction to data */</span> <a name="l01130"></a>01130 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#ae8b5bb16b84adcbcd2bba3e10a36d62d">IMG_TYPE_IMAGE</a>) { <a name="l01131"></a>01131 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]=image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>/1000.; <a name="l01132"></a>01132 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>/1000.; <a name="l01133"></a>01133 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[frame_index]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]); <a name="l01134"></a>01134 <span class="keywordflow">if</span>(image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>>1.0) { <a name="l01135"></a>01135 img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[frame_index]=image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>;} <a name="l01136"></a>01136 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <span class="comment">/* polarmap */</span> <a name="l01137"></a>01137 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]=polmap_header.<a class="code" href="structecat7__polmapheader.html#ac7757667731f12beb6c6e8a584dd6682">frame_start_time</a>/1000.; <a name="l01138"></a>01138 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+polmap_header.<a class="code" href="structecat7__polmapheader.html#af2c0109195bbcc833521aed329d2bd83">frame_duration</a>/1000.; <a name="l01139"></a>01139 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[frame_index]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]); <a name="l01140"></a>01140 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>>1) { <a name="l01141"></a>01141 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]=scan_header.<a class="code" href="structecat7__scanheader.html#a73b5c4aae33a122d91703ce6a3330f89">frame_start_time</a>/1000.; <a name="l01142"></a>01142 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>/1000.; <a name="l01143"></a>01143 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[frame_index]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]); <a name="l01144"></a>01144 <span class="comment">/* also, correct for dead-time */</span> <a name="l01145"></a>01145 <span class="keywordflow">if</span>(scan_header.<a class="code" href="structecat7__scanheader.html#a97b2c1a33ab3c42a21aa9f1d3d9e21e7">deadtime_correction_factor</a>>0.0) <a name="l01146"></a>01146 <span class="keywordflow">for</span>(i=0, fptr=fdata; i<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>*pxlNr; i++, fptr++) <a name="l01147"></a>01147 *fptr*=scan_header.<a class="code" href="structecat7__scanheader.html#a97b2c1a33ab3c42a21aa9f1d3d9e21e7">deadtime_correction_factor</a>; <a name="l01148"></a>01148 img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[frame_index]=(<span class="keywordtype">float</span>)scan_header.<a class="code" href="structecat7__scanheader.html#a421bb8924e8aed2ef38ecc673b71a574">prompts</a>; <a name="l01149"></a>01149 img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[frame_index]=scan_header.<a class="code" href="structecat7__scanheader.html#a8f67a369e6ef599551b8271c08a8b5d7">delayed</a>; <a name="l01150"></a>01150 } <span class="keywordflow">else</span> { <a name="l01151"></a>01151 img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8930d980328907f75c2518b36e67b36f">frame_start_time</a>/1000.; <a name="l01152"></a>01152 img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]=img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>/1000.; <a name="l01153"></a>01153 img-><a class="code" href="structIMG.html#af7c69142be89fac081e7f8bc354b14c8">mid</a>[frame_index]=0.5*(img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]+img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]); <a name="l01154"></a>01154 <span class="comment">/* also, correct for dead-time */</span> <a name="l01155"></a>01155 <span class="keywordflow">if</span>(scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8788db06847593186cbeaef45e03b838">deadtime_correction_factor</a>>0.0) <a name="l01156"></a>01156 <span class="keywordflow">for</span>(i=0, fptr=fdata; i<pxlNr; i++, fptr++) <a name="l01157"></a>01157 *fptr*=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8788db06847593186cbeaef45e03b838">deadtime_correction_factor</a>; <a name="l01158"></a>01158 img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[frame_index]=(<span class="keywordtype">float</span>)scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ac4abf37f9a786b4133fe6526cf29463c">prompts</a>; <a name="l01159"></a>01159 img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[frame_index]=scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a01d95cfc32cb38a15067f6f2b6835176">delayed</a>; <a name="l01160"></a>01160 } <a name="l01161"></a>01161 <span class="comment">/* Copy matrix data through volume planes */</span> <a name="l01162"></a>01162 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>!=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) { <a name="l01163"></a>01163 <span class="comment">/* if(img->dimz>1) { */</span> <a name="l01164"></a>01164 <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) { <a name="l01165"></a>01165 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>5) printf(<span class="stringliteral">" putting data into m[%d][][][%d]\n"</span>, pi, frame_index); <a name="l01166"></a>01166 <span class="keywordflow">for</span>(yi=0, fptr=fdata+pi*pxlNr; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <a name="l01167"></a>01167 <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l01168"></a>01168 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][frame_index]= *fptr++; <a name="l01169"></a>01169 } <a name="l01170"></a>01170 } <span class="keywordflow">else</span> { <a name="l01171"></a>01171 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>5) printf(<span class="stringliteral">" putting data into m[%d][][][%d]\n"</span>, seqplane, frame_index); <a name="l01172"></a>01172 <span class="keywordflow">for</span>(yi=0, fptr=fdata; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <a name="l01173"></a>01173 <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l01174"></a>01174 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[seqplane][yi][xi][frame_index]= *fptr++; <a name="l01175"></a>01175 img-><a class="code" href="structIMG.html#a78e3164d578cf4a570e930dceb10fb51">planeNumber</a>[seqplane]=plane; <a name="l01176"></a>01176 } <a name="l01177"></a>01177 free(fdata); <a name="l01178"></a>01178 <span class="comment">/* Calibrate */</span> <a name="l01179"></a>01179 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#ad5be044d585696c1f35bb8b63c26fec9">ecat_calibration_factor</a>>0.0) <a name="l01180"></a>01180 <span class="keywordflow">for</span>(pi=0; pi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; pi++) <a name="l01181"></a>01181 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l01182"></a>01182 img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[pi][yi][xi][frame_index]*=main_header.<a class="code" href="structecat7__mainheader.html#ad5be044d585696c1f35bb8b63c26fec9">ecat_calibration_factor</a>; <a name="l01183"></a>01183 } <span class="comment">/* next matrix */</span> <a name="l01184"></a>01184 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>3) printf(<span class="stringliteral">"end of matrices.\n"</span>); <a name="l01185"></a>01185 <a class="code" href="ecat7ml_8c.html#a570804c248c25f15c172568043a8f0a5">ecat7EmptyMatlist</a>(&mlist); <a name="l01186"></a>01186 fclose(fp); <a name="l01187"></a>01187 <a name="l01188"></a>01188 <span class="comment">/* seqplane is <0 only if this frame did not exist at all; return -1 */</span> <a name="l01189"></a>01189 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>4) printf(<span class="stringliteral">"last_seqplane := %d.\n"</span>, seqplane); <a name="l01190"></a>01190 <span class="keywordflow">if</span>(seqplane<0) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55babe9c1bcf366cd905b79148ba91b34756">STATUS_NOMATRIX</a>; <a name="l01191"></a>01191 <a name="l01192"></a>01192 <span class="comment">/* check that correct number of planes was read */</span> <a name="l01193"></a>01193 <span class="keywordflow">if</span>(seqplane>0 && (seqplane+1 != img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>)) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bad6498890650ae8d01e69f43514eb4fed">STATUS_MISSINGMATRIX</a>; <a name="l01194"></a>01194 <a name="l01195"></a>01195 <span class="comment">/* All went well */</span> <a name="l01196"></a>01196 <a class="code" href="img_8c.html#ad124d2d496934d677156cc8779a1e567">imgSetStatus</a>(img, <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>); <a name="l01197"></a>01197 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l01198"></a>01198 } <a name="l01199"></a>01199 <span class="comment">/*****************************************************************************/</span> <a name="l01200"></a>01200 <a name="l01201"></a>01201 <span class="comment">/*****************************************************************************/</span> <a name="l01222"></a><a class="code" href="imgfile_8h.html#aa4cebb077c1ca5e7fb6291e4f76f100c">01222</a> <span class="keywordtype">int</span> <a class="code" href="img__e7_8c.html#aa4cebb077c1ca5e7fb6291e4f76f100c">imgWriteEcat7Frame</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *fname, <span class="keywordtype">int</span> frame_to_write, <a class="code" href="structIMG.html">IMG</a> *img, <span class="keywordtype">int</span> frame_index) { <a name="l01223"></a>01223 <a class="code" href="structIMG.html">IMG</a> test_img; <a name="l01224"></a>01224 <span class="keywordtype">int</span> ret=0, pxlNr, zi, xi, yi, matrixId; <a name="l01225"></a>01225 <a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a> main_header; <a name="l01226"></a>01226 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> image_header; <a name="l01227"></a>01227 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> scan_header; <a name="l01228"></a>01228 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> scan2d_header; <a name="l01229"></a>01229 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> polmap_header; <a name="l01230"></a>01230 <span class="keywordtype">void</span> *sub_header=NULL; <a name="l01231"></a>01231 FILE *fp; <a name="l01232"></a>01232 <span class="keywordtype">float</span> *fdata=NULL, *fptr; <a name="l01233"></a>01233 <a name="l01234"></a>01234 <a name="l01235"></a>01235 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>) printf(<span class="stringliteral">"\nimgWriteEcat7Frame(%s, %d, *img, %d)\n"</span>, <a name="l01236"></a>01236 fname, frame_to_write, frame_index); <a name="l01237"></a>01237 <a name="l01238"></a>01238 <span class="comment">/*</span> <a name="l01239"></a>01239 <span class="comment"> * Check the input </span> <a name="l01240"></a>01240 <span class="comment"> */</span> <a name="l01241"></a>01241 <span class="keywordflow">if</span>(fname==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01242"></a>01242 <span class="keywordflow">if</span>(img==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01243"></a>01243 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5b8bdc61088df4a3c3f89c31895b14a4">status</a>!=<a class="code" href="img_8h.html#a3117b1b0649d3761dcda1395202129e5">IMG_STATUS_OCCUPIED</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01244"></a>01244 <span class="keywordflow">if</span>(frame_to_write<0) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01245"></a>01245 <span class="keywordflow">if</span>(frame_index<0 || frame_index>=img-><a class="code" href="structIMG.html#a77605d4aa64b86294590c79e9a761b15">dimt</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01246"></a>01246 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>!=<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a> && <a name="l01247"></a>01247 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>!=<a class="code" href="img_8h.html#aa0111a4761ce5db222757daff1f48dfe">IMG_POLARMAP</a> && <a name="l01248"></a>01248 img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>!=<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>; <a name="l01249"></a>01249 <a name="l01250"></a>01250 <span class="comment">/* Initiate headers */</span> <a name="l01251"></a>01251 memset(&main_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__mainheader.html">ECAT7_mainheader</a>)); <a name="l01252"></a>01252 memset(&image_header,0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a>)); <a name="l01253"></a>01253 memset(&scan_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a>)); <a name="l01254"></a>01254 memset(&scan2d_header, 0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a>)); <a name="l01255"></a>01255 memset(&polmap_header,0, <span class="keyword">sizeof</span>(<a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a>)); <a name="l01256"></a>01256 <a class="code" href="img_8c.html#af95041292a0f9e4a82a10b49a074a95c">imgInit</a>(&test_img); <a name="l01257"></a>01257 <a name="l01258"></a>01258 <a name="l01259"></a>01259 <span class="comment">/*</span> <a name="l01260"></a>01260 <span class="comment"> * If file does not exist, then create it with new mainheader,</span> <a name="l01261"></a>01261 <span class="comment"> * and if it does exist, then read and check header information.</span> <a name="l01262"></a>01262 <span class="comment"> * Create or edit mainheader to contain correct frame nr. </span> <a name="l01263"></a>01263 <span class="comment"> * In any case, leave file pointer open for write. </span> <a name="l01264"></a>01264 <span class="comment"> */</span> <a name="l01265"></a>01265 <span class="keywordflow">if</span>(access(fname, 0) == -1) { <span class="comment">/* file does not exist */</span> <a name="l01266"></a>01266 <a name="l01267"></a>01267 <span class="comment">/* Set main header */</span> <a name="l01268"></a>01268 <a class="code" href="img__e7_8c.html#ae0290e8d66a3ce7013405b344cca52f5">imgSetEcat7MHeader</a>(img, &main_header); <a name="l01269"></a>01269 main_header.<a class="code" href="structecat7__mainheader.html#abc625a3c1c4052d87e502bfca8599b8f">bin_size</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l01270"></a>01270 <span class="keywordflow">if</span>(frame_to_write==0) frame_to_write=1; <a name="l01271"></a>01271 main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>=frame_to_write; <a name="l01272"></a>01272 <a name="l01273"></a>01273 <span class="comment">/* Open file, write main header and initiate matrix list */</span> <a name="l01274"></a>01274 fp=<a class="code" href="ecat7w_8c.html#a85ec2c6c7070a4170b8807e13623b04d">ecat7Create</a>(fname, &main_header); <span class="keywordflow">if</span>(fp==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>; <a name="l01275"></a>01275 <a name="l01276"></a>01276 } <span class="keywordflow">else</span> { <span class="comment">/* file exists */</span> <a name="l01277"></a>01277 <a name="l01278"></a>01278 <span class="comment">/* Read header information for checking */</span> <a name="l01279"></a>01279 ret=<a class="code" href="img__e7_8c.html#a80595d5fb45da4904f58fbb0d3e7e64a">imgReadEcat7Header</a>(fname, &test_img); <span class="keywordflow">if</span>(ret!=0) <span class="keywordflow">return</span> ret; <a name="l01280"></a>01280 <span class="comment">/* Check that file format is the same */</span> <a name="l01281"></a>01281 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>!=test_img.<a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a> || img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>!=test_img.<a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>) <a name="l01282"></a>01282 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba8860e85936fb99f4d0f248a9ca7fd4f7">STATUS_WRONGFILETYPE</a>; <a name="l01283"></a>01283 <span class="comment">/* Check that matrix sizes are the same */</span> <a name="l01284"></a>01284 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>!=test_img.<a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a> || img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>!=test_img.<a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a> || <a name="l01285"></a>01285 img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>!=test_img.<a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>) <a name="l01286"></a>01286 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bae8ce9dbf165d2c5fdb9c4609c01d94e5">STATUS_VARMATSIZE</a>; <a name="l01287"></a>01287 <a class="code" href="img_8c.html#ada573d4b40da77be4455bb9fab9a3033">imgEmpty</a>(&test_img); <a name="l01288"></a>01288 <a name="l01289"></a>01289 <span class="comment">/* Open the file for read and write */</span> <a name="l01290"></a>01290 <span class="keywordflow">if</span>((fp=fopen(fname, <span class="stringliteral">"r+b"</span>))==NULL) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>; <a name="l01291"></a>01291 <a name="l01292"></a>01292 <span class="comment">/* Read the mainheader, set new frame number, and write it back */</span> <a name="l01293"></a>01293 <span class="keywordflow">if</span>((ret=<a class="code" href="ecat7r_8c.html#a7d6241dd7a472a4f2aaf3eb16dc03dc1">ecat7ReadMainheader</a>(fp, &main_header))!=0) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafa1051360f88591f14aa0383d8087132">STATUS_NOMAINHEADER</a>; <a name="l01294"></a>01294 <span class="keywordflow">if</span>(frame_to_write==0) frame_to_write=main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>+1; <a name="l01295"></a>01295 <span class="keywordflow">if</span>(main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a><frame_to_write) <a name="l01296"></a>01296 main_header.<a class="code" href="structecat7__mainheader.html#a7df83de0bdabd7ebf190e1a58bfc2e20">num_frames</a>=frame_to_write; <a name="l01297"></a>01297 <span class="keywordflow">if</span>((ret=<a class="code" href="ecat7w_8c.html#ae4ee4bf17962633b914d5c731ac7c321">ecat7WriteMainheader</a>(fp, &main_header))!=0) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba89d8cfdc7190aa78887b412e66e292e4">STATUS_NOWRITEPERM</a>; <a name="l01298"></a>01298 <a name="l01299"></a>01299 } <a name="l01300"></a>01300 <span class="keywordflow">if</span>(<a class="code" href="img_8h.html#a0d66ed136e5992b7b00ce6f43bad1439">IMG_TEST</a>>2) { <a name="l01301"></a>01301 printf(<span class="stringliteral">"frame_to_write := %d\n"</span>, frame_to_write); <a name="l01302"></a>01302 } <a name="l01303"></a>01303 <a name="l01304"></a>01304 <span class="comment">/* Allocate memory for matrix float data */</span> <a name="l01305"></a>01305 pxlNr=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>*img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <span class="comment">/* for 2D too! */</span> <a name="l01306"></a>01306 fdata=(<span class="keywordtype">float</span>*)malloc(pxlNr*<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>)); <a name="l01307"></a>01307 <span class="keywordflow">if</span>(fdata==NULL) {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55bafbe470f6663c748e405bf509d2bb57bb">STATUS_NOMEMORY</a>;} <a name="l01308"></a>01308 <a name="l01309"></a>01309 <span class="comment">/* Set matrix subheader */</span> <a name="l01310"></a>01310 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>) { <a name="l01311"></a>01311 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) sub_header=(<span class="keywordtype">void</span>*)&scan_header; <a name="l01312"></a>01312 <span class="keywordflow">else</span> sub_header=&image_header; <a name="l01313"></a>01313 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) { <a name="l01314"></a>01314 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) sub_header=(<span class="keywordtype">void</span>*)&scan_header; <a name="l01315"></a>01315 <span class="keywordflow">else</span> sub_header=(<span class="keywordtype">void</span>*)&image_header; <a name="l01316"></a>01316 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#aa0111a4761ce5db222757daff1f48dfe">IMG_POLARMAP</a>) { <a name="l01317"></a>01317 sub_header=(<span class="keywordtype">void</span>*)&polmap_header; <a name="l01318"></a>01318 } <span class="keywordflow">else</span> {fclose(fp); <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55baf8f3d89c25483639f6cbce4f6b08c1f8">STATUS_FAULT</a>;} <a name="l01319"></a>01319 <a class="code" href="img__e7_8c.html#ae81e49b5bd72ebac0112b9d8c2f1afc8">imgSetEcat7SHeader</a>(img, sub_header); <a name="l01320"></a>01320 <a name="l01321"></a>01321 <span class="comment">/* Copy matrix pixel values to fdata */</span> <a name="l01322"></a>01322 fptr=fdata; <a name="l01323"></a>01323 <span class="keywordflow">for</span>(zi=0; zi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; zi++) <a name="l01324"></a>01324 <span class="keywordflow">for</span>(yi=0; yi<img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; yi++) <span class="keywordflow">for</span>(xi=0; xi<img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; xi++) <a name="l01325"></a>01325 *fptr++=img-><a class="code" href="structIMG.html#a43e2c98dc0728731601a76abd51bb935">m</a>[zi][yi][xi][frame_index]; <a name="l01326"></a>01326 <a name="l01327"></a>01327 <span class="comment">/* Write subheader and data, and set the rest of subheader contents */</span> <a name="l01328"></a>01328 fptr=fdata; ret=-1; <a name="l01329"></a>01329 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a12597eb3c08c3aa66f06d4b15294a644">IMG_E7</a>) { <a name="l01330"></a>01330 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l01331"></a>01331 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(frame_to_write, 1, 1, 0, 0); <a name="l01332"></a>01332 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l01333"></a>01333 scan_header.<a class="code" href="structecat7__scanheader.html#a73b5c4aae33a122d91703ce6a3330f89">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]); <a name="l01334"></a>01334 scan_header.<a class="code" href="structecat7__scanheader.html#ae7eafb4bf000a8404407489dbd6b54ac">frame_duration</a>= <a name="l01335"></a>01335 (int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index])); <a name="l01336"></a>01336 scan_header.<a class="code" href="structecat7__scanheader.html#a421bb8924e8aed2ef38ecc673b71a574">prompts</a>=temp_roundf(img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[frame_index]); <a name="l01337"></a>01337 scan_header.<a class="code" href="structecat7__scanheader.html#a8f67a369e6ef599551b8271c08a8b5d7">delayed</a>=temp_roundf(img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[frame_index]); <a name="l01338"></a>01338 ret=<a class="code" href="ecat7w_8c.html#a33c96bd0bbc96506cb27794fadd6abcf">ecat7WriteScanMatrix</a>(fp, matrixId, &scan_header, fptr); <a name="l01339"></a>01339 } <span class="keywordflow">else</span> { <a name="l01340"></a>01340 image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]); <a name="l01341"></a>01341 image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>= <a name="l01342"></a>01342 (int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index])); <a name="l01343"></a>01343 image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>=img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[frame_index]; <a name="l01344"></a>01344 <span class="comment">/*ecat7PrintImageheader(&image_header, stdout);*/</span> <a name="l01345"></a>01345 ret=<a class="code" href="ecat7w_8c.html#a1806f5f5cc75a6446a4d85fa29e4228b">ecat7WriteImageMatrix</a>(fp, matrixId, &image_header, fptr); <a name="l01346"></a>01346 } <a name="l01347"></a>01347 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) { <a name="l01348"></a>01348 <span class="keywordflow">for</span>(zi=0; zi<img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; zi++, fptr+=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>*img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>) { <a name="l01349"></a>01349 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l01350"></a>01350 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(frame_to_write, img-><a class="code" href="structIMG.html#a78e3164d578cf4a570e930dceb10fb51">planeNumber</a>[zi], 1, 0, 0); <a name="l01351"></a>01351 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l01352"></a>01352 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a8930d980328907f75c2518b36e67b36f">frame_start_time</a>= <a name="l01353"></a>01353 (int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]); <a name="l01354"></a>01354 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#afe892b507d85054ad72ce5ac289b3b05">frame_duration</a>= <a name="l01355"></a>01355 (int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index])); <a name="l01356"></a>01356 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#ac4abf37f9a786b4133fe6526cf29463c">prompts</a>=temp_roundf(img-><a class="code" href="structIMG.html#a76d63a001b8569d9f80ccb325e064be1">prompts</a>[frame_index]); <a name="l01357"></a>01357 scan2d_header.<a class="code" href="structecat7__2Dscanheader.html#a01d95cfc32cb38a15067f6f2b6835176">delayed</a>=temp_roundf(img-><a class="code" href="structIMG.html#ae47ebbbdc0c308f473fec801a2df513d">randoms</a>[frame_index]); <a name="l01358"></a>01358 ret=<a class="code" href="ecat7w_8c.html#aa94815cb1caa7fe0fdb4223edafd6f57">ecat7Write2DScanMatrix</a>(fp, matrixId, &scan2d_header, fptr); <a name="l01359"></a>01359 } <span class="keywordflow">else</span> { <a name="l01360"></a>01360 image_header.<a class="code" href="structecat7__imageheader.html#a5fb0b8e2eec4391ed600f0efa4666631">frame_start_time</a>= <a name="l01361"></a>01361 (int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]); <a name="l01362"></a>01362 image_header.<a class="code" href="structecat7__imageheader.html#ae75244f1e5532bb257095e7583ef79a3">frame_duration</a>= <a name="l01363"></a>01363 (int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index])); <a name="l01364"></a>01364 image_header.<a class="code" href="structecat7__imageheader.html#a753cec72803431b0b3ecf130b2fee645">decay_corr_fctr</a>=img-><a class="code" href="structIMG.html#abf0ad6e681d08c3248dbd9837afa9973">decayCorrFactor</a>[frame_index]; <a name="l01365"></a>01365 ret=<a class="code" href="ecat7w_8c.html#a1806f5f5cc75a6446a4d85fa29e4228b">ecat7WriteImageMatrix</a>(fp, matrixId, &image_header, fptr); <a name="l01366"></a>01366 } <a name="l01367"></a>01367 <span class="keywordflow">if</span>(ret!=0) <span class="keywordflow">break</span>; <a name="l01368"></a>01368 } <span class="comment">/* next plane */</span> <a name="l01369"></a>01369 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#aa0111a4761ce5db222757daff1f48dfe">IMG_POLARMAP</a>) { <a name="l01370"></a>01370 <span class="comment">/* Create new matrix id (i.e. matnum) */</span> <a name="l01371"></a>01371 matrixId=<a class="code" href="ecat7ml_8c.html#acad3263ebf24cf2e10d7c43491810481">ecat7_val_to_id</a>(frame_to_write, 1, 1, 0, 0); <a name="l01372"></a>01372 polmap_header.<a class="code" href="structecat7__polmapheader.html#ac7757667731f12beb6c6e8a584dd6682">frame_start_time</a>=(int)temp_roundf(1000.*img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index]); <a name="l01373"></a>01373 polmap_header.<a class="code" href="structecat7__polmapheader.html#af2c0109195bbcc833521aed329d2bd83">frame_duration</a>= <a name="l01374"></a>01374 (int)temp_roundf(1000.*(img-><a class="code" href="structIMG.html#aa2b629a51ca62bcafad0a66d32e1ca8b">end</a>[frame_index]-img-><a class="code" href="structIMG.html#a8ff22fc209b6f44ad14341c8644788d2">start</a>[frame_index])); <a name="l01375"></a>01375 ret=<a class="code" href="ecat7w_8c.html#a5f460170ea6c75b8af960ddf5a17d0ef">ecat7WritePolarmapMatrix</a>(fp, matrixId, &polmap_header, fptr); <a name="l01376"></a>01376 } <a name="l01377"></a>01377 free(fdata); fclose(fp); <a name="l01378"></a>01378 <span class="keywordflow">if</span>(ret) <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba8500261907803b2afa1f761991a22679">STATUS_DISKFULL</a>; <a name="l01379"></a>01379 <a name="l01380"></a>01380 <span class="keywordflow">return</span> <a class="code" href="img_8h.html#a06fc87d81c62e9abb8790b6e5713c55ba7e4a42e3b6dd63708c64cf3db6f69566">STATUS_OK</a>; <a name="l01381"></a>01381 } <a name="l01382"></a>01382 <span class="comment">/*****************************************************************************/</span> <a name="l01383"></a>01383 <a name="l01384"></a>01384 <span class="comment">/*****************************************************************************/</span> <a name="l01391"></a><a class="code" href="imgfile_8h.html#ae81e49b5bd72ebac0112b9d8c2f1afc8">01391</a> <span class="keywordtype">void</span> <a class="code" href="img__e7_8c.html#ae81e49b5bd72ebac0112b9d8c2f1afc8">imgSetEcat7SHeader</a>(<a class="code" href="structIMG.html">IMG</a> *img, <span class="keywordtype">void</span> *h) { <a name="l01392"></a>01392 <a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a> *image_header; <a name="l01393"></a>01393 <a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a> *scan_header; <a name="l01394"></a>01394 <a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a> *scan2d_header; <a name="l01395"></a>01395 <a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a> *polmap_header; <a name="l01396"></a>01396 <span class="keywordtype">int</span> i; <a name="l01397"></a>01397 <a name="l01398"></a>01398 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a5f0d986b4c5b2b48d37ad25afdd20c77">IMG_TYPE_POLARMAP</a>) { <a name="l01399"></a>01399 polmap_header=(<a class="code" href="structecat7__polmapheader.html">ECAT7_polmapheader</a>*)h; <a name="l01400"></a>01400 polmap_header-><a class="code" href="structecat7__polmapheader.html#a85514ffcdb6dc106fe8d742bcb248947">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l01401"></a>01401 polmap_header-><a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>=img-><a class="code" href="structIMG.html#a07ae2dcb24730f7c5352f09a98967e16">polarmap_num_rings</a>; <a name="l01402"></a>01402 <span class="keywordflow">if</span>(polmap_header-><a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>>32) polmap_header-><a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>=32; <a name="l01403"></a>01403 <span class="keywordflow">for</span>(i=0; i<polmap_header-><a class="code" href="structecat7__polmapheader.html#a503caad4ac64580ff3508463ae8e2342">num_rings</a>; i++) { <a name="l01404"></a>01404 polmap_header-><a class="code" href="structecat7__polmapheader.html#a7888f1b2bc8adcc5bcbf918bbbb82dbb">sectors_per_ring</a>[i]=img-><a class="code" href="structIMG.html#aa0cf526b49d558db6391a6e60864ec88">polarmap_sectors_per_ring</a>[i]; <a name="l01405"></a>01405 polmap_header-><a class="code" href="structecat7__polmapheader.html#a1f8b29deb85540e9d4d30d9a8247c0d6">ring_position</a>[i]=img-><a class="code" href="structIMG.html#afa091c63e52a3e72a674435104f8a164">polarmap_ring_position</a>[i]; <a name="l01406"></a>01406 polmap_header-><a class="code" href="structecat7__polmapheader.html#af91ac7e401a999aaaaf275c8671ad0ab">ring_angle</a>[i]=img-><a class="code" href="structIMG.html#ad343b587b771b99bd2552f31a835cf73">polarmap_ring_angle</a>[i]; <a name="l01407"></a>01407 } <a name="l01408"></a>01408 polmap_header-><a class="code" href="structecat7__polmapheader.html#ad59dd3b498ddd78aa65a6cf4425d259a">start_angle</a>=258; <a name="l01409"></a>01409 polmap_header-><a class="code" href="structecat7__polmapheader.html#a4a7a70570769b6b97bf67f6358a61f45">pixel_size</a>=1000.0*img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; <a name="l01410"></a>01410 polmap_header-><a class="code" href="structecat7__polmapheader.html#aa4b2dda11a8f10a58a77307ffbf28805">quant_units</a>=0; <span class="comment">/* default, see main header */</span> <a name="l01411"></a>01411 } <span class="keywordflow">else</span> <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a0d9199e1c3c4bd94d56eb30e421b309c">type</a>==<a class="code" href="img_8h.html#a04e835f7aec92fcc1d4ecf37e0dd2e9c">IMG_TYPE_RAW</a>) { <a name="l01412"></a>01412 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) { <a name="l01413"></a>01413 scan2d_header=(<a class="code" href="structecat7__2Dscanheader.html">ECAT7_2Dscanheader</a>*)h; <a name="l01414"></a>01414 scan2d_header-><a class="code" href="structecat7__2Dscanheader.html#a592447ad964ba95e2a29a7d3d2284576">num_dimensions</a>=2; <a name="l01415"></a>01415 scan2d_header-><a class="code" href="structecat7__2Dscanheader.html#a697bb7a95d88bce42bf80e2d6bd69037">num_z_elements</a>=1; <a name="l01416"></a>01416 scan2d_header-><a class="code" href="structecat7__2Dscanheader.html#aa13b8697f5c56f7e31e942cafb91bddc">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l01417"></a>01417 scan2d_header-><a class="code" href="structecat7__2Dscanheader.html#adfe07cff44e3145ca65c234079ff255a">num_r_elements</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l01418"></a>01418 scan2d_header-><a class="code" href="structecat7__2Dscanheader.html#ad0d1958b231f10aa68d60c653ec30627">num_angles</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l01419"></a>01419 } <span class="keywordflow">else</span> { <a name="l01420"></a>01420 scan_header=(<a class="code" href="structecat7__scanheader.html">ECAT7_scanheader</a>*)h; <a name="l01421"></a>01421 scan_header-><a class="code" href="structecat7__scanheader.html#a3b20e770bbcc8bc038190aab1d777199">x_resolution</a>=img-><a class="code" href="structIMG.html#a399dae5b27dda8d5e1b0e96c885513e4">sampleDistance</a>/10.0; <a name="l01422"></a>01422 scan_header-><a class="code" href="structecat7__scanheader.html#a4b4361b122c74cfd1c7171357615a2a4">num_dimensions</a>=4; <a name="l01423"></a>01423 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>==239) { <a name="l01424"></a>01424 scan_header-><a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[0]=63; <a name="l01425"></a>01425 scan_header-><a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[1]=106; <a name="l01426"></a>01426 scan_header-><a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[2]=70; <a name="l01427"></a>01427 } <span class="keywordflow">else</span> { <a name="l01428"></a>01428 scan_header-><a class="code" href="structecat7__scanheader.html#a714bae4e56b451926ceeb0de19222ad7">num_z_elements</a>[0]=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l01429"></a>01429 } <a name="l01430"></a>01430 scan_header-><a class="code" href="structecat7__scanheader.html#af0fcf4af875d58acf97d1b412d0299b5">storage_order</a>=1; <a name="l01431"></a>01431 scan_header-><a class="code" href="structecat7__scanheader.html#ac1dfbebf9227256db4dd3ec96a95277f">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l01432"></a>01432 scan_header-><a class="code" href="structecat7__scanheader.html#aee3fd0c2360973b3d53ad1adf6225d7d">num_r_elements</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l01433"></a>01433 scan_header-><a class="code" href="structecat7__scanheader.html#a4f58fe54c66427d34390f6530a12f8ed">num_angles</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l01434"></a>01434 } <a name="l01435"></a>01435 } <span class="keywordflow">else</span> { <a name="l01436"></a>01436 image_header=(<a class="code" href="structecat7__imageheader.html">ECAT7_imageheader</a>*)h; <a name="l01437"></a>01437 image_header-><a class="code" href="structecat7__imageheader.html#a9b90dc8511beaf487a57afc61044d09a">data_type</a>=<a class="code" href="ecat7_8h.html#aee0f2ad8e2d9d538fda30aec053a642a">ECAT7_SUNI2</a>; <a name="l01438"></a>01438 image_header-><a class="code" href="structecat7__imageheader.html#a37550f6ce6a114de12aa0d038f573230">x_dimension</a>=img-><a class="code" href="structIMG.html#a0818b82059710627a94282a793ff7030">dimx</a>; <a name="l01439"></a>01439 image_header-><a class="code" href="structecat7__imageheader.html#a217d17f8b1f921fad128ce923fa21c35">y_dimension</a>=img-><a class="code" href="structIMG.html#aa17e87812503d3c142f31c08abcbf79d">dimy</a>; <a name="l01440"></a>01440 image_header-><a class="code" href="structecat7__imageheader.html#a7290c1acb6f8263f85492e3b5c44cdc9">recon_zoom</a>=img-><a class="code" href="structIMG.html#ab23da0c2295967727c6d33d0fbdc8c88">zoom</a>; <a name="l01441"></a>01441 image_header-><a class="code" href="structecat7__imageheader.html#a3f2c13786fd5e912c31f481f1b48cff3">x_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a02cc239e917e7ebf85e34f21448ff080">sizex</a>; <a name="l01442"></a>01442 image_header-><a class="code" href="structecat7__imageheader.html#aefd3bbd592bedba8d68dbec20d855586">y_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#a80b0609c63f33934bf6e6678c6121cb3">sizey</a>; <a name="l01443"></a>01443 image_header-><a class="code" href="structecat7__imageheader.html#a404d5327064305a7a9dfe75831b29581">z_pixel_size</a>=0.1*img-><a class="code" href="structIMG.html#afc2a1d2417a8a3afe2c500173a05c472">sizez</a>; <a name="l01444"></a>01444 image_header-><a class="code" href="structecat7__imageheader.html#a94c84cc00c6100c166167eaf0d4d34c9">x_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a0e4475f6d2bd9da2f4e35e4eb142ff71">resolutionx</a>; <a name="l01445"></a>01445 image_header-><a class="code" href="structecat7__imageheader.html#a88478cdda647f217f81ba4fe753f8602">y_resolution</a>=0.1*img-><a class="code" href="structIMG.html#a2fa9952c5c950ea93ec64eb8588f7088">resolutiony</a>; <a name="l01446"></a>01446 image_header-><a class="code" href="structecat7__imageheader.html#aa0599cfeedd3708b353ef027f281657d">z_resolution</a>=0.1*img-><a class="code" href="structIMG.html#afe2b3d97e63341cbb408ee64aa20202e">resolutionz</a>; <a name="l01447"></a>01447 <span class="keywordflow">if</span>(img-><a class="code" href="structIMG.html#a5e25c84c23270f974f1eb7c32a01bac7">_fileFormat</a>==<a class="code" href="img_8h.html#a3c7938cecd0e773de01ce1cb6dfaf4f3">IMG_E7_2D</a>) { <a name="l01448"></a>01448 image_header-><a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>=2; <a name="l01449"></a>01449 image_header-><a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>=1; <a name="l01450"></a>01450 } <span class="keywordflow">else</span> { <a name="l01451"></a>01451 image_header-><a class="code" href="structecat7__imageheader.html#acabca0e942a462b769c59804250b9a1c">num_dimensions</a>=3; <a name="l01452"></a>01452 image_header-><a class="code" href="structecat7__imageheader.html#a7d4bc496c4aa5581d41dff3e5b40a231">z_dimension</a>=img-><a class="code" href="structIMG.html#a9c04780b47e6a627a2b700b76352c3fc">dimz</a>; <a name="l01453"></a>01453 } <a name="l01454"></a>01454 <span class="keywordflow">for</span>(i=0; i<49; i++) image_header-><a class="code" href="structecat7__imageheader.html#ac7858af3c6aeab6ee47867cba833e0a9">fill_user</a>[i]=0; <a name="l01455"></a>01455 } <a name="l01456"></a>01456 } <a name="l01457"></a>01457 <span class="comment">/*****************************************************************************/</span> <a name="l01458"></a>01458 <a name="l01459"></a>01459 <span class="comment">/*****************************************************************************/</span> </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Mon Aug 8 2011 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>