<!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>nifti1_io: /builddir/build/BUILD/nifticlib-2.0.0/niftilib/nifti1.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body onload='searchBox.OnSelectItem(0);'> <!-- Generated by Doxygen 1.7.4 --> <script type="text/javascript"><!-- var searchBox = new SearchBox("searchBox", "search",false,'Search'); --></script> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">nifti1_io</div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li id="searchli"> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </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>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">/builddir/build/BUILD/nifticlib-2.0.0/niftilib/nifti1.h</div> </div> </div> <div class="contents"> <a href="nifti1_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00012"></a>00012 <span class="preprocessor">#ifndef _NIFTI_HEADER_</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define _NIFTI_HEADER_</span> <a name="l00014"></a>00014 <span class="preprocessor"></span> <a name="l00015"></a>00015 <span class="comment">/*****************************************************************************</span> <a name="l00016"></a>00016 <span class="comment"> ** This file defines the "NIFTI-1" header format. **</span> <a name="l00017"></a>00017 <span class="comment"> ** It is derived from 2 meetings at the NIH (31 Mar 2003 and **</span> <a name="l00018"></a>00018 <span class="comment"> ** 02 Sep 2003) of the Data Format Working Group (DFWG), **</span> <a name="l00019"></a>00019 <span class="comment"> ** chartered by the NIfTI (Neuroimaging Informatics Technology **</span> <a name="l00020"></a>00020 <span class="comment"> ** Initiative) at the National Institutes of Health (NIH). **</span> <a name="l00021"></a>00021 <span class="comment"> **--------------------------------------------------------------**</span> <a name="l00022"></a>00022 <span class="comment"> ** Neither the National Institutes of Health (NIH), the DFWG, **</span> <a name="l00023"></a>00023 <span class="comment"> ** nor any of the members or employees of these institutions **</span> <a name="l00024"></a>00024 <span class="comment"> ** imply any warranty of usefulness of this material for any **</span> <a name="l00025"></a>00025 <span class="comment"> ** purpose, and do not assume any liability for damages, **</span> <a name="l00026"></a>00026 <span class="comment"> ** incidental or otherwise, caused by any use of this document. **</span> <a name="l00027"></a>00027 <span class="comment"> ** If these conditions are not acceptable, do not use this! **</span> <a name="l00028"></a>00028 <span class="comment"> **--------------------------------------------------------------**</span> <a name="l00029"></a>00029 <span class="comment"> ** Author: Robert W Cox (NIMH, Bethesda) **</span> <a name="l00030"></a>00030 <span class="comment"> ** Advisors: John Ashburner (FIL, London), **</span> <a name="l00031"></a>00031 <span class="comment"> ** Stephen Smith (FMRIB, Oxford), **</span> <a name="l00032"></a>00032 <span class="comment"> ** Mark Jenkinson (FMRIB, Oxford) **</span> <a name="l00033"></a>00033 <span class="comment">******************************************************************************/</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00036"></a>00036 <span class="comment">/* Note that the ANALYZE 7.5 file header (dbh.h) is</span> <a name="l00037"></a>00037 <span class="comment"> (c) Copyright 1986-1995</span> <a name="l00038"></a>00038 <span class="comment"> Biomedical Imaging Resource</span> <a name="l00039"></a>00039 <span class="comment"> Mayo Foundation</span> <a name="l00040"></a>00040 <span class="comment"> Incorporation of components of dbh.h are by permission of the</span> <a name="l00041"></a>00041 <span class="comment"> Mayo Foundation.</span> <a name="l00042"></a>00042 <span class="comment"></span> <a name="l00043"></a>00043 <span class="comment"> Changes from the ANALYZE 7.5 file header in this file are released to the</span> <a name="l00044"></a>00044 <span class="comment"> public domain, including the functional comments and any amusing asides.</span> <a name="l00045"></a>00045 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00115"></a>00115 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00116"></a>00116 <span class="comment">/* HEADER STRUCT DECLARATION:</span> <a name="l00117"></a>00117 <span class="comment"> -------------------------</span> <a name="l00118"></a>00118 <span class="comment"> In the comments below for each field, only NIFTI-1 specific requirements</span> <a name="l00119"></a>00119 <span class="comment"> or changes from the ANALYZE 7.5 format are described. For convenience,</span> <a name="l00120"></a>00120 <span class="comment"> the 348 byte header is described as a single struct, rather than as the</span> <a name="l00121"></a>00121 <span class="comment"> ANALYZE 7.5 group of 3 substructs.</span> <a name="l00122"></a>00122 <span class="comment"></span> <a name="l00123"></a>00123 <span class="comment"> Further comments about the interpretation of various elements of this</span> <a name="l00124"></a>00124 <span class="comment"> header are after the data type definition itself. Fields that are</span> <a name="l00125"></a>00125 <span class="comment"> marked as ++UNUSED++ have no particular interpretation in this standard.</span> <a name="l00126"></a>00126 <span class="comment"> (Also see the UNUSED FIELDS comment section, far below.)</span> <a name="l00127"></a>00127 <span class="comment"></span> <a name="l00128"></a>00128 <span class="comment"> The presumption below is that the various C types have particular sizes:</span> <a name="l00129"></a>00129 <span class="comment"> sizeof(int) = sizeof(float) = 4 ; sizeof(short) = 2</span> <a name="l00130"></a>00130 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="comment">/*=================*/</span> <a name="l00133"></a>00133 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00134"></a>00134 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { <a name="l00135"></a>00135 <span class="preprocessor">#endif</span> <a name="l00136"></a>00136 <span class="preprocessor"></span><span class="comment">/*=================*/</span> <a name="l00137"></a>00137 <a name="l00143"></a>00143 <span class="comment">/*************************/</span> <span class="comment">/************************/</span> <a name="l00144"></a><a class="code" href="structnifti__1__header.html">00144</a> <span class="keyword">struct </span><a class="code" href="structnifti__1__header.html" title="Data structure defining the fields in the nifti1 header. This binary header should be found at the be...">nifti_1_header</a> { <span class="comment">/* NIFTI-1 usage */</span> <span class="comment">/* ANALYZE 7.5 field(s) */</span> <a name="l00145"></a>00145 <span class="comment">/*************************/</span> <span class="comment">/************************/</span> <a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="comment">/*--- was header_key substruct ---*/</span> <a name="l00148"></a><a class="code" href="structnifti__1__header.html#af1d99efbd3af0180f9335cbb1b822248">00148</a> <span class="keywordtype">int</span> <a class="code" href="structnifti__1__header.html#af1d99efbd3af0180f9335cbb1b822248">sizeof_hdr</a>; <span class="comment">/* int sizeof_hdr; */</span> <a name="l00149"></a><a class="code" href="structnifti__1__header.html#a4442d6183e4dce5af7e71365d3eed1ec">00149</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a4442d6183e4dce5af7e71365d3eed1ec">data_type</a>[10]; <span class="comment">/* char data_type[10]; */</span> <a name="l00150"></a><a class="code" href="structnifti__1__header.html#a0e0cf033d74cfae329b4ce0d1b7ece8e">00150</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a0e0cf033d74cfae329b4ce0d1b7ece8e">db_name</a>[18]; <span class="comment">/* char db_name[18]; */</span> <a name="l00151"></a><a class="code" href="structnifti__1__header.html#ab37ea6af93cab84f95d97ee4fdbc3f4d">00151</a> <span class="keywordtype">int</span> <a class="code" href="structnifti__1__header.html#ab37ea6af93cab84f95d97ee4fdbc3f4d">extents</a>; <span class="comment">/* int extents; */</span> <a name="l00152"></a><a class="code" href="structnifti__1__header.html#a1011d5320abdedcb710552cae92f86db">00152</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a1011d5320abdedcb710552cae92f86db">session_error</a>; <span class="comment">/* short session_error; */</span> <a name="l00153"></a><a class="code" href="structnifti__1__header.html#acd9cfc4f9d1117a803c4a619132583d7">00153</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#acd9cfc4f9d1117a803c4a619132583d7">regular</a>; <span class="comment">/* char regular; */</span> <a name="l00154"></a><a class="code" href="structnifti__1__header.html#a7d3eb58a5415d9c65f3df444ac94fc74">00154</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a7d3eb58a5415d9c65f3df444ac94fc74">dim_info</a>; <span class="comment">/* char hkey_un0; */</span> <a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="comment">/*--- was image_dimension substruct ---*/</span> <a name="l00157"></a><a class="code" href="structnifti__1__header.html#abd0c6bb6b71a2a6d10fbcb516af52b13">00157</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#abd0c6bb6b71a2a6d10fbcb516af52b13">dim</a>[8]; <span class="comment">/* short dim[8]; */</span> <a name="l00158"></a><a class="code" href="structnifti__1__header.html#a5c875c40271c15601b3389450fba85b3">00158</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a5c875c40271c15601b3389450fba85b3">intent_p1</a> ; <span class="comment">/* short unused8; */</span> <a name="l00159"></a>00159 <span class="comment">/* short unused9; */</span> <a name="l00160"></a><a class="code" href="structnifti__1__header.html#ab39ee04eb345e95dd4e5183e0f84c02b">00160</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#ab39ee04eb345e95dd4e5183e0f84c02b">intent_p2</a> ; <span class="comment">/* short unused10; */</span> <a name="l00161"></a>00161 <span class="comment">/* short unused11; */</span> <a name="l00162"></a><a class="code" href="structnifti__1__header.html#aa1eeee8a4cd325b413c5d368ec8fc534">00162</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#aa1eeee8a4cd325b413c5d368ec8fc534">intent_p3</a> ; <span class="comment">/* short unused12; */</span> <a name="l00163"></a>00163 <span class="comment">/* short unused13; */</span> <a name="l00164"></a><a class="code" href="structnifti__1__header.html#a017e9d430b66386e569c6b9cd11059ed">00164</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a017e9d430b66386e569c6b9cd11059ed">intent_code</a> ; <span class="comment">/* short unused14; */</span> <a name="l00165"></a><a class="code" href="structnifti__1__header.html#ad5f8888fcc5fde14d3e387653721e270">00165</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#ad5f8888fcc5fde14d3e387653721e270">datatype</a>; <span class="comment">/* short datatype; */</span> <a name="l00166"></a><a class="code" href="structnifti__1__header.html#a60fc36ed5afd638fd7da425ad7ecae94">00166</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a60fc36ed5afd638fd7da425ad7ecae94">bitpix</a>; <span class="comment">/* short bitpix; */</span> <a name="l00167"></a><a class="code" href="structnifti__1__header.html#adc0e937b2b556da163772b20da729778">00167</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#adc0e937b2b556da163772b20da729778">slice_start</a>; <span class="comment">/* short dim_un0; */</span> <a name="l00168"></a><a class="code" href="structnifti__1__header.html#af3b966e2936cc174b43fedadbbd933dc">00168</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#af3b966e2936cc174b43fedadbbd933dc">pixdim</a>[8]; <span class="comment">/* float pixdim[8]; */</span> <a name="l00169"></a><a class="code" href="structnifti__1__header.html#aa3a09932cda88dd765a438c9b9c46503">00169</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#aa3a09932cda88dd765a438c9b9c46503">vox_offset</a>; <span class="comment">/* float vox_offset; */</span> <a name="l00170"></a><a class="code" href="structnifti__1__header.html#a45a97dd330a77ab680ef91c47a761c29">00170</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a45a97dd330a77ab680ef91c47a761c29">scl_slope</a> ; <span class="comment">/* float funused1; */</span> <a name="l00171"></a><a class="code" href="structnifti__1__header.html#aca24a8965851296a63d13da6c7cc3456">00171</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#aca24a8965851296a63d13da6c7cc3456">scl_inter</a> ; <span class="comment">/* float funused2; */</span> <a name="l00172"></a><a class="code" href="structnifti__1__header.html#a260d55840377fe1bcfb49bda5f85b76c">00172</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a260d55840377fe1bcfb49bda5f85b76c">slice_end</a>; <span class="comment">/* float funused3; */</span> <a name="l00173"></a><a class="code" href="structnifti__1__header.html#af25a6170a90128800e3986b68fc79e4d">00173</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#af25a6170a90128800e3986b68fc79e4d">slice_code</a> ; <a name="l00174"></a><a class="code" href="structnifti__1__header.html#a6b95dab630916801b716f52513305e93">00174</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a6b95dab630916801b716f52513305e93">xyzt_units</a> ; <a name="l00175"></a><a class="code" href="structnifti__1__header.html#af415db2201f47d61354766245c3f2520">00175</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#af415db2201f47d61354766245c3f2520">cal_max</a>; <span class="comment">/* float cal_max; */</span> <a name="l00176"></a><a class="code" href="structnifti__1__header.html#a600fb5b0c533454bbbc61b2e0696c9a8">00176</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a600fb5b0c533454bbbc61b2e0696c9a8">cal_min</a>; <span class="comment">/* float cal_min; */</span> <a name="l00177"></a><a class="code" href="structnifti__1__header.html#a70400549d1f42d7f777915273576549b">00177</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a70400549d1f42d7f777915273576549b">slice_duration</a>; <span class="comment">/* float compressed; */</span> <a name="l00178"></a><a class="code" href="structnifti__1__header.html#a0d2b669f776a2b7fb84807ea2f7b4231">00178</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a0d2b669f776a2b7fb84807ea2f7b4231">toffset</a>; <span class="comment">/* float verified; */</span> <a name="l00179"></a><a class="code" href="structnifti__1__header.html#a07e91b15b45a914b71ff41f93fe64e56">00179</a> <span class="keywordtype">int</span> <a class="code" href="structnifti__1__header.html#a07e91b15b45a914b71ff41f93fe64e56">glmax</a>; <span class="comment">/* int glmax; */</span> <a name="l00180"></a><a class="code" href="structnifti__1__header.html#acc037ae9773f9e79333f0927ed3a38ce">00180</a> <span class="keywordtype">int</span> <a class="code" href="structnifti__1__header.html#acc037ae9773f9e79333f0927ed3a38ce">glmin</a>; <span class="comment">/* int glmin; */</span> <a name="l00181"></a>00181 <a name="l00182"></a>00182 <span class="comment">/*--- was data_history substruct ---*/</span> <a name="l00183"></a><a class="code" href="structnifti__1__header.html#a8725b5f9e0ef6882200bfeb89b11eb3a">00183</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a8725b5f9e0ef6882200bfeb89b11eb3a">descrip</a>[80]; <span class="comment">/* char descrip[80]; */</span> <a name="l00184"></a><a class="code" href="structnifti__1__header.html#a93e288bd39c44188304677f6bdc96a6b">00184</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a93e288bd39c44188304677f6bdc96a6b">aux_file</a>[24]; <span class="comment">/* char aux_file[24]; */</span> <a name="l00185"></a>00185 <a name="l00186"></a><a class="code" href="structnifti__1__header.html#a95ae85e5e0bba57c4b3cbd8a0b32168b">00186</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a95ae85e5e0bba57c4b3cbd8a0b32168b">qform_code</a> ; <span class="comment">/*-- all ANALYZE 7.5 ---*/</span> <a name="l00187"></a><a class="code" href="structnifti__1__header.html#a48d14671528f3dfe0593320006877a8a">00187</a> <span class="keywordtype">short</span> <a class="code" href="structnifti__1__header.html#a48d14671528f3dfe0593320006877a8a">sform_code</a> ; <span class="comment">/* fields below here */</span> <a name="l00188"></a>00188 <span class="comment">/* are replaced */</span> <a name="l00189"></a><a class="code" href="structnifti__1__header.html#a530588bf405af52255dc064a6f451c71">00189</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a530588bf405af52255dc064a6f451c71">quatern_b</a> ; <a name="l00190"></a><a class="code" href="structnifti__1__header.html#a3ade0b01649a3d990ee1dfdef8c452c4">00190</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a3ade0b01649a3d990ee1dfdef8c452c4">quatern_c</a> ; <a name="l00191"></a><a class="code" href="structnifti__1__header.html#af47d0d4ae23f57441edcef9594fd1495">00191</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#af47d0d4ae23f57441edcef9594fd1495">quatern_d</a> ; <a name="l00192"></a><a class="code" href="structnifti__1__header.html#a6fbfa89133238e59e6220e0b778c93ef">00192</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a6fbfa89133238e59e6220e0b778c93ef">qoffset_x</a> ; <a name="l00193"></a><a class="code" href="structnifti__1__header.html#a5cfb257cbd7a4b7dde2350877cd126c5">00193</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a5cfb257cbd7a4b7dde2350877cd126c5">qoffset_y</a> ; <a name="l00194"></a><a class="code" href="structnifti__1__header.html#a962002307f10b359788cea98ebcb40b6">00194</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a962002307f10b359788cea98ebcb40b6">qoffset_z</a> ; <a name="l00196"></a><a class="code" href="structnifti__1__header.html#ad88e17b7ec9a5e198bf13d82e167e643">00196</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#ad88e17b7ec9a5e198bf13d82e167e643">srow_x</a>[4] ; <a name="l00197"></a><a class="code" href="structnifti__1__header.html#a07b0ec3e66e4dd72db3f0910cfab4c46">00197</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#a07b0ec3e66e4dd72db3f0910cfab4c46">srow_y</a>[4] ; <a name="l00198"></a><a class="code" href="structnifti__1__header.html#aea26ff366fcf2fdde19efd4e4f5b9d98">00198</a> <span class="keywordtype">float</span> <a class="code" href="structnifti__1__header.html#aea26ff366fcf2fdde19efd4e4f5b9d98">srow_z</a>[4] ; <a name="l00200"></a><a class="code" href="structnifti__1__header.html#ae3d911b886703c6f0976e308d83a3495">00200</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#ae3d911b886703c6f0976e308d83a3495">intent_name</a>[16]; <a name="l00202"></a><a class="code" href="structnifti__1__header.html#a5c7eff0d659a6a1f69f576d40cf4d3ed">00202</a> <span class="keywordtype">char</span> <a class="code" href="structnifti__1__header.html#a5c7eff0d659a6a1f69f576d40cf4d3ed">magic</a>[4] ; <a name="l00204"></a>00204 } ; <span class="comment">/**** 348 bytes total ****/</span> <a name="l00205"></a>00205 <a name="l00206"></a>00206 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structnifti__1__header.html" title="Data structure defining the fields in the nifti1 header. This binary header should be found at the be...">nifti_1_header</a> <a class="code" href="structnifti__1__header.html" title="Data structure defining the fields in the nifti1 header. This binary header should be found at the be...">nifti_1_header</a> ; <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00209"></a>00209 <span class="comment">/* HEADER EXTENSIONS:</span> <a name="l00210"></a>00210 <span class="comment"> -----------------</span> <a name="l00211"></a>00211 <span class="comment"> After the end of the 348 byte header (e.g., after the magic field),</span> <a name="l00212"></a>00212 <span class="comment"> the next 4 bytes are a char array field named "extension". By default,</span> <a name="l00213"></a>00213 <span class="comment"> all 4 bytes of this array should be set to zero. In a .nii file, these</span> <a name="l00214"></a>00214 <span class="comment"> 4 bytes will always be present, since the earliest start point for</span> <a name="l00215"></a>00215 <span class="comment"> the image data is byte #352. In a separate .hdr file, these bytes may</span> <a name="l00216"></a>00216 <span class="comment"> or may not be present. If not present (i.e., if the length of the .hdr</span> <a name="l00217"></a>00217 <span class="comment"> file is 348 bytes), then a NIfTI-1 compliant program should use the</span> <a name="l00218"></a>00218 <span class="comment"> default value of extension={0,0,0,0}. The first byte (extension[0])</span> <a name="l00219"></a>00219 <span class="comment"> is the only value of this array that is specified at present. The other</span> <a name="l00220"></a>00220 <span class="comment"> 3 bytes are reserved for future use.</span> <a name="l00221"></a>00221 <span class="comment"></span> <a name="l00222"></a>00222 <span class="comment"> If extension[0] is nonzero, it indicates that extended header information</span> <a name="l00223"></a>00223 <span class="comment"> is present in the bytes following the extension array. In a .nii file,</span> <a name="l00224"></a>00224 <span class="comment"> this extended header data is before the image data (and vox_offset</span> <a name="l00225"></a>00225 <span class="comment"> must be set correctly to allow for this). In a .hdr file, this extended</span> <a name="l00226"></a>00226 <span class="comment"> data follows extension and proceeds (potentially) to the end of the file.</span> <a name="l00227"></a>00227 <span class="comment"></span> <a name="l00228"></a>00228 <span class="comment"> The format of extended header data is weakly specified. Each extension</span> <a name="l00229"></a>00229 <span class="comment"> must be an integer multiple of 16 bytes long. The first 8 bytes of each</span> <a name="l00230"></a>00230 <span class="comment"> extension comprise 2 integers:</span> <a name="l00231"></a>00231 <span class="comment"> int esize , ecode ;</span> <a name="l00232"></a>00232 <span class="comment"> These values may need to be byte-swapped, as indicated by dim[0] for</span> <a name="l00233"></a>00233 <span class="comment"> the rest of the header.</span> <a name="l00234"></a>00234 <span class="comment"> * esize is the number of bytes that form the extended header data</span> <a name="l00235"></a>00235 <span class="comment"> + esize must be a positive integral multiple of 16</span> <a name="l00236"></a>00236 <span class="comment"> + this length includes the 8 bytes of esize and ecode themselves</span> <a name="l00237"></a>00237 <span class="comment"> * ecode is a non-negative integer that indicates the format of the</span> <a name="l00238"></a>00238 <span class="comment"> extended header data that follows</span> <a name="l00239"></a>00239 <span class="comment"> + different ecode values are assigned to different developer groups</span> <a name="l00240"></a>00240 <span class="comment"> + at present, the "registered" values for code are</span> <a name="l00241"></a>00241 <span class="comment"> = 0 = unknown private format (not recommended!)</span> <a name="l00242"></a>00242 <span class="comment"> = 2 = DICOM format (i.e., attribute tags and values)</span> <a name="l00243"></a>00243 <span class="comment"> = 4 = AFNI group (i.e., ASCII XML-ish elements)</span> <a name="l00244"></a>00244 <span class="comment"> In the interests of interoperability (a primary rationale for NIfTI),</span> <a name="l00245"></a>00245 <span class="comment"> groups developing software that uses this extension mechanism are</span> <a name="l00246"></a>00246 <span class="comment"> encouraged to document and publicize the format of their extensions.</span> <a name="l00247"></a>00247 <span class="comment"> To this end, the NIfTI DFWG will assign even numbered codes upon request</span> <a name="l00248"></a>00248 <span class="comment"> to groups submitting at least rudimentary documentation for the format</span> <a name="l00249"></a>00249 <span class="comment"> of their extension; at present, the contact is mailto:rwcox@nih.gov.</span> <a name="l00250"></a>00250 <span class="comment"> The assigned codes and documentation will be posted on the NIfTI</span> <a name="l00251"></a>00251 <span class="comment"> website. All odd values of ecode (and 0) will remain unassigned;</span> <a name="l00252"></a>00252 <span class="comment"> at least, until the even ones are used up, when we get to 2,147,483,646.</span> <a name="l00253"></a>00253 <span class="comment"></span> <a name="l00254"></a>00254 <span class="comment"> Note that the other contents of the extended header data section are</span> <a name="l00255"></a>00255 <span class="comment"> totally unspecified by the NIfTI-1 standard. In particular, if binary</span> <a name="l00256"></a>00256 <span class="comment"> data is stored in such a section, its byte order is not necessarily</span> <a name="l00257"></a>00257 <span class="comment"> the same as that given by examining dim[0]; it is incumbent on the</span> <a name="l00258"></a>00258 <span class="comment"> programs dealing with such data to determine the byte order of binary</span> <a name="l00259"></a>00259 <span class="comment"> extended header data.</span> <a name="l00260"></a>00260 <span class="comment"></span> <a name="l00261"></a>00261 <span class="comment"> Multiple extended header sections are allowed, each starting with an</span> <a name="l00262"></a>00262 <span class="comment"> esize,ecode value pair. The first esize value, as described above,</span> <a name="l00263"></a>00263 <span class="comment"> is at bytes #352-355 in the .hdr or .nii file (files start at byte #0).</span> <a name="l00264"></a>00264 <span class="comment"> If this value is positive, then the second (esize2) will be found</span> <a name="l00265"></a>00265 <span class="comment"> starting at byte #352+esize1 , the third (esize3) at byte #352+esize1+esize2,</span> <a name="l00266"></a>00266 <span class="comment"> et cetera. Of course, in a .nii file, the value of vox_offset must</span> <a name="l00267"></a>00267 <span class="comment"> be compatible with these extensions. If a malformed file indicates</span> <a name="l00268"></a>00268 <span class="comment"> that an extended header data section would run past vox_offset, then</span> <a name="l00269"></a>00269 <span class="comment"> the entire extended header section should be ignored. In a .hdr file,</span> <a name="l00270"></a>00270 <span class="comment"> if an extended header data section would run past the end-of-file,</span> <a name="l00271"></a>00271 <span class="comment"> that extended header data should also be ignored.</span> <a name="l00272"></a>00272 <span class="comment"></span> <a name="l00273"></a>00273 <span class="comment"> With the above scheme, a program can successively examine the esize</span> <a name="l00274"></a>00274 <span class="comment"> and ecode values, and skip over each extended header section if the</span> <a name="l00275"></a>00275 <span class="comment"> program doesn't know how to interpret the data within. Of course, any</span> <a name="l00276"></a>00276 <span class="comment"> program can simply ignore all extended header sections simply by jumping</span> <a name="l00277"></a>00277 <span class="comment"> straight to the image data using vox_offset.</span> <a name="l00278"></a>00278 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00279"></a>00279 <a name="l00287"></a><a class="code" href="structnifti1__extender.html">00287</a> <span class="keyword">struct </span><a class="code" href="structnifti1__extender.html" title="This structure represents a 4-byte string that should follow the binary nifti_1_header data in a NIFT...">nifti1_extender</a> { <span class="keywordtype">char</span> extension[4] ; } ; <a name="l00288"></a>00288 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structnifti1__extender.html" title="This structure represents a 4-byte string that should follow the binary nifti_1_header data in a NIFT...">nifti1_extender</a> <a class="code" href="structnifti1__extender.html" title="This structure represents a 4-byte string that should follow the binary nifti_1_header data in a NIFT...">nifti1_extender</a> ; <a name="l00289"></a>00289 <a name="l00293"></a><a class="code" href="structnifti1__extension.html">00293</a> <span class="keyword">struct </span><a class="code" href="structnifti1__extension.html" title="Data structure defining the fields of a header extension.">nifti1_extension</a> { <a name="l00294"></a><a class="code" href="structnifti1__extension.html#ab28de104ee23ab3703a07312b45b3edc">00294</a> <span class="keywordtype">int</span> <a class="code" href="structnifti1__extension.html#ab28de104ee23ab3703a07312b45b3edc">esize</a> ; <a name="l00295"></a><a class="code" href="structnifti1__extension.html#ab2fd473ee53f5e91706e8a9f03be7ad7">00295</a> <span class="keywordtype">int</span> <a class="code" href="structnifti1__extension.html#ab2fd473ee53f5e91706e8a9f03be7ad7">ecode</a> ; <a name="l00296"></a><a class="code" href="structnifti1__extension.html#a598c33c1b45d45c22645d40762803ceb">00296</a> <span class="keywordtype">char</span> * <a class="code" href="structnifti1__extension.html#a598c33c1b45d45c22645d40762803ceb">edata</a> ; <a name="l00297"></a>00297 } ; <a name="l00298"></a>00298 <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structnifti1__extension.html" title="Data structure defining the fields of a header extension.">nifti1_extension</a> <a class="code" href="structnifti1__extension.html" title="Data structure defining the fields of a header extension.">nifti1_extension</a> ; <a name="l00299"></a>00299 <a name="l00300"></a>00300 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00301"></a>00301 <span class="comment">/* DATA DIMENSIONALITY (as in ANALYZE 7.5):</span> <a name="l00302"></a>00302 <span class="comment"> ---------------------------------------</span> <a name="l00303"></a>00303 <span class="comment"> dim[0] = number of dimensions;</span> <a name="l00304"></a>00304 <span class="comment"> - if dim[0] is outside range 1..7, then the header information</span> <a name="l00305"></a>00305 <span class="comment"> needs to be byte swapped appropriately</span> <a name="l00306"></a>00306 <span class="comment"> - ANALYZE supports dim[0] up to 7, but NIFTI-1 reserves</span> <a name="l00307"></a>00307 <span class="comment"> dimensions 1,2,3 for space (x,y,z), 4 for time (t), and</span> <a name="l00308"></a>00308 <span class="comment"> 5,6,7 for anything else needed.</span> <a name="l00309"></a>00309 <span class="comment"></span> <a name="l00310"></a>00310 <span class="comment"> dim[i] = length of dimension #i, for i=1..dim[0] (must be positive)</span> <a name="l00311"></a>00311 <span class="comment"> - also see the discussion of intent_code, far below</span> <a name="l00312"></a>00312 <span class="comment"></span> <a name="l00313"></a>00313 <span class="comment"> pixdim[i] = voxel width along dimension #i, i=1..dim[0] (positive)</span> <a name="l00314"></a>00314 <span class="comment"> - cf. ORIENTATION section below for use of pixdim[0]</span> <a name="l00315"></a>00315 <span class="comment"> - the units of pixdim can be specified with the xyzt_units</span> <a name="l00316"></a>00316 <span class="comment"> field (also described far below).</span> <a name="l00317"></a>00317 <span class="comment"></span> <a name="l00318"></a>00318 <span class="comment"> Number of bits per voxel value is in bitpix, which MUST correspond with</span> <a name="l00319"></a>00319 <span class="comment"> the datatype field. The total number of bytes in the image data is</span> <a name="l00320"></a>00320 <span class="comment"> dim[1] * ... * dim[dim[0]] * bitpix / 8</span> <a name="l00321"></a>00321 <span class="comment"></span> <a name="l00322"></a>00322 <span class="comment"> In NIFTI-1 files, dimensions 1,2,3 are for space, dimension 4 is for time,</span> <a name="l00323"></a>00323 <span class="comment"> and dimension 5 is for storing multiple values at each spatiotemporal</span> <a name="l00324"></a>00324 <span class="comment"> voxel. Some examples:</span> <a name="l00325"></a>00325 <span class="comment"> - A typical whole-brain FMRI experiment's time series:</span> <a name="l00326"></a>00326 <span class="comment"> - dim[0] = 4</span> <a name="l00327"></a>00327 <span class="comment"> - dim[1] = 64 pixdim[1] = 3.75 xyzt_units = NIFTI_UNITS_MM</span> <a name="l00328"></a>00328 <span class="comment"> - dim[2] = 64 pixdim[2] = 3.75 | NIFTI_UNITS_SEC</span> <a name="l00329"></a>00329 <span class="comment"> - dim[3] = 20 pixdim[3] = 5.0</span> <a name="l00330"></a>00330 <span class="comment"> - dim[4] = 120 pixdim[4] = 2.0</span> <a name="l00331"></a>00331 <span class="comment"> - A typical T1-weighted anatomical volume:</span> <a name="l00332"></a>00332 <span class="comment"> - dim[0] = 3</span> <a name="l00333"></a>00333 <span class="comment"> - dim[1] = 256 pixdim[1] = 1.0 xyzt_units = NIFTI_UNITS_MM</span> <a name="l00334"></a>00334 <span class="comment"> - dim[2] = 256 pixdim[2] = 1.0</span> <a name="l00335"></a>00335 <span class="comment"> - dim[3] = 128 pixdim[3] = 1.1</span> <a name="l00336"></a>00336 <span class="comment"> - A single slice EPI time series:</span> <a name="l00337"></a>00337 <span class="comment"> - dim[0] = 4</span> <a name="l00338"></a>00338 <span class="comment"> - dim[1] = 64 pixdim[1] = 3.75 xyzt_units = NIFTI_UNITS_MM</span> <a name="l00339"></a>00339 <span class="comment"> - dim[2] = 64 pixdim[2] = 3.75 | NIFTI_UNITS_SEC</span> <a name="l00340"></a>00340 <span class="comment"> - dim[3] = 1 pixdim[3] = 5.0</span> <a name="l00341"></a>00341 <span class="comment"> - dim[4] = 1200 pixdim[4] = 0.2</span> <a name="l00342"></a>00342 <span class="comment"> - A 3-vector stored at each point in a 3D volume:</span> <a name="l00343"></a>00343 <span class="comment"> - dim[0] = 5</span> <a name="l00344"></a>00344 <span class="comment"> - dim[1] = 256 pixdim[1] = 1.0 xyzt_units = NIFTI_UNITS_MM</span> <a name="l00345"></a>00345 <span class="comment"> - dim[2] = 256 pixdim[2] = 1.0</span> <a name="l00346"></a>00346 <span class="comment"> - dim[3] = 128 pixdim[3] = 1.1</span> <a name="l00347"></a>00347 <span class="comment"> - dim[4] = 1 pixdim[4] = 0.0</span> <a name="l00348"></a>00348 <span class="comment"> - dim[5] = 3 intent_code = NIFTI_INTENT_VECTOR</span> <a name="l00349"></a>00349 <span class="comment"> - A single time series with a 3x3 matrix at each point:</span> <a name="l00350"></a>00350 <span class="comment"> - dim[0] = 5</span> <a name="l00351"></a>00351 <span class="comment"> - dim[1] = 1 xyzt_units = NIFTI_UNITS_SEC</span> <a name="l00352"></a>00352 <span class="comment"> - dim[2] = 1</span> <a name="l00353"></a>00353 <span class="comment"> - dim[3] = 1</span> <a name="l00354"></a>00354 <span class="comment"> - dim[4] = 1200 pixdim[4] = 0.2</span> <a name="l00355"></a>00355 <span class="comment"> - dim[5] = 9 intent_code = NIFTI_INTENT_GENMATRIX</span> <a name="l00356"></a>00356 <span class="comment"> - intent_p1 = intent_p2 = 3.0 (indicates matrix dimensions)</span> <a name="l00357"></a>00357 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00358"></a>00358 <a name="l00359"></a>00359 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00360"></a>00360 <span class="comment">/* DATA STORAGE:</span> <a name="l00361"></a>00361 <span class="comment"> ------------</span> <a name="l00362"></a>00362 <span class="comment"> If the magic field is "n+1", then the voxel data is stored in the</span> <a name="l00363"></a>00363 <span class="comment"> same file as the header. In this case, the voxel data starts at offset</span> <a name="l00364"></a>00364 <span class="comment"> (int)vox_offset into the header file. Thus, vox_offset=352.0 means that</span> <a name="l00365"></a>00365 <span class="comment"> the data starts immediately after the NIFTI-1 header. If vox_offset is</span> <a name="l00366"></a>00366 <span class="comment"> greater than 352, the NIFTI-1 format does not say much about the</span> <a name="l00367"></a>00367 <span class="comment"> contents of the dataset file between the end of the header and the</span> <a name="l00368"></a>00368 <span class="comment"> start of the data.</span> <a name="l00369"></a>00369 <span class="comment"></span> <a name="l00370"></a>00370 <span class="comment"> FILES:</span> <a name="l00371"></a>00371 <span class="comment"> -----</span> <a name="l00372"></a>00372 <span class="comment"> If the magic field is "ni1", then the voxel data is stored in the</span> <a name="l00373"></a>00373 <span class="comment"> associated ".img" file, starting at offset 0 (i.e., vox_offset is not</span> <a name="l00374"></a>00374 <span class="comment"> used in this case, and should be set to 0.0).</span> <a name="l00375"></a>00375 <span class="comment"></span> <a name="l00376"></a>00376 <span class="comment"> When storing NIFTI-1 datasets in pairs of files, it is customary to name</span> <a name="l00377"></a>00377 <span class="comment"> the files in the pattern "name.hdr" and "name.img", as in ANALYZE 7.5.</span> <a name="l00378"></a>00378 <span class="comment"> When storing in a single file ("n+1"), the file name should be in</span> <a name="l00379"></a>00379 <span class="comment"> the form "name.nii" (the ".nft" and ".nif" suffixes are already taken;</span> <a name="l00380"></a>00380 <span class="comment"> cf. http://www.icdatamaster.com/n.html ).</span> <a name="l00381"></a>00381 <span class="comment"></span> <a name="l00382"></a>00382 <span class="comment"> BYTE ORDERING:</span> <a name="l00383"></a>00383 <span class="comment"> -------------</span> <a name="l00384"></a>00384 <span class="comment"> The byte order of the data arrays is presumed to be the same as the byte</span> <a name="l00385"></a>00385 <span class="comment"> order of the header (which is determined by examining dim[0]).</span> <a name="l00386"></a>00386 <span class="comment"></span> <a name="l00387"></a>00387 <span class="comment"> Floating point types are presumed to be stored in IEEE-754 format.</span> <a name="l00388"></a>00388 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00389"></a>00389 <a name="l00390"></a>00390 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00391"></a>00391 <span class="comment">/* DETAILS ABOUT vox_offset:</span> <a name="l00392"></a>00392 <span class="comment"> ------------------------</span> <a name="l00393"></a>00393 <span class="comment"> In a .nii file, the vox_offset field value is interpreted as the start</span> <a name="l00394"></a>00394 <span class="comment"> location of the image data bytes in that file. In a .hdr/.img file pair,</span> <a name="l00395"></a>00395 <span class="comment"> the vox_offset field value is the start location of the image data</span> <a name="l00396"></a>00396 <span class="comment"> bytes in the .img file.</span> <a name="l00397"></a>00397 <span class="comment"> * If vox_offset is less than 352 in a .nii file, it is equivalent</span> <a name="l00398"></a>00398 <span class="comment"> to 352 (i.e., image data never starts before byte #352 in a .nii file).</span> <a name="l00399"></a>00399 <span class="comment"> * The default value for vox_offset in a .nii file is 352.</span> <a name="l00400"></a>00400 <span class="comment"> * In a .hdr file, the default value for vox_offset is 0.</span> <a name="l00401"></a>00401 <span class="comment"> * vox_offset should be an integer multiple of 16; otherwise, some</span> <a name="l00402"></a>00402 <span class="comment"> programs may not work properly (e.g., SPM). This is to allow</span> <a name="l00403"></a>00403 <span class="comment"> memory-mapped input to be properly byte-aligned.</span> <a name="l00404"></a>00404 <span class="comment"> Note that since vox_offset is an IEEE-754 32 bit float (for compatibility</span> <a name="l00405"></a>00405 <span class="comment"> with the ANALYZE-7.5 format), it effectively has a 24 bit mantissa. All</span> <a name="l00406"></a>00406 <span class="comment"> integers from 0 to 2^24 can be represented exactly in this format, but not</span> <a name="l00407"></a>00407 <span class="comment"> all larger integers are exactly storable as IEEE-754 32 bit floats. However,</span> <a name="l00408"></a>00408 <span class="comment"> unless you plan to have vox_offset be potentially larger than 16 MB, this</span> <a name="l00409"></a>00409 <span class="comment"> should not be an issue. (Actually, any integral multiple of 16 up to 2^27</span> <a name="l00410"></a>00410 <span class="comment"> can be represented exactly in this format, which allows for up to 128 MB</span> <a name="l00411"></a>00411 <span class="comment"> of random information before the image data. If that isn't enough, then</span> <a name="l00412"></a>00412 <span class="comment"> perhaps this format isn't right for you.)</span> <a name="l00413"></a>00413 <span class="comment"></span> <a name="l00414"></a>00414 <span class="comment"> In a .img file (i.e., image data stored separately from the NIfTI-1</span> <a name="l00415"></a>00415 <span class="comment"> header), data bytes between #0 and #vox_offset-1 (inclusive) are completely</span> <a name="l00416"></a>00416 <span class="comment"> undefined and unregulated by the NIfTI-1 standard. One potential use of</span> <a name="l00417"></a>00417 <span class="comment"> having vox_offset > 0 in the .hdr/.img file pair storage method is to make</span> <a name="l00418"></a>00418 <span class="comment"> the .img file be a copy of (or link to) a pre-existing image file in some</span> <a name="l00419"></a>00419 <span class="comment"> other format, such as DICOM; then vox_offset would be set to the offset of</span> <a name="l00420"></a>00420 <span class="comment"> the image data in this file. (It may not be possible to follow the</span> <a name="l00421"></a>00421 <span class="comment"> "multiple-of-16 rule" with an arbitrary external file; using the NIfTI-1</span> <a name="l00422"></a>00422 <span class="comment"> format in such a case may lead to a file that is incompatible with software</span> <a name="l00423"></a>00423 <span class="comment"> that relies on vox_offset being a multiple of 16.)</span> <a name="l00424"></a>00424 <span class="comment"></span> <a name="l00425"></a>00425 <span class="comment"> In a .nii file, data bytes between #348 and #vox_offset-1 (inclusive) may</span> <a name="l00426"></a>00426 <span class="comment"> be used to store user-defined extra information; similarly, in a .hdr file,</span> <a name="l00427"></a>00427 <span class="comment"> any data bytes after byte #347 are available for user-defined extra</span> <a name="l00428"></a>00428 <span class="comment"> information. The (very weak) regulation of this extra header data is</span> <a name="l00429"></a>00429 <span class="comment"> described elsewhere.</span> <a name="l00430"></a>00430 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00431"></a>00431 <a name="l00432"></a>00432 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00433"></a>00433 <span class="comment">/* DATA SCALING:</span> <a name="l00434"></a>00434 <span class="comment"> ------------</span> <a name="l00435"></a>00435 <span class="comment"> If the scl_slope field is nonzero, then each voxel value in the dataset</span> <a name="l00436"></a>00436 <span class="comment"> should be scaled as</span> <a name="l00437"></a>00437 <span class="comment"> y = scl_slope * x + scl_inter</span> <a name="l00438"></a>00438 <span class="comment"> where x = voxel value stored</span> <a name="l00439"></a>00439 <span class="comment"> y = "true" voxel value</span> <a name="l00440"></a>00440 <span class="comment"> Normally, we would expect this scaling to be used to store "true" floating</span> <a name="l00441"></a>00441 <span class="comment"> values in a smaller integer datatype, but that is not required. That is,</span> <a name="l00442"></a>00442 <span class="comment"> it is legal to use scaling even if the datatype is a float type (crazy,</span> <a name="l00443"></a>00443 <span class="comment"> perhaps, but legal).</span> <a name="l00444"></a>00444 <span class="comment"> - However, the scaling is to be ignored if datatype is DT_RGB24.</span> <a name="l00445"></a>00445 <span class="comment"> - If datatype is a complex type, then the scaling is to be</span> <a name="l00446"></a>00446 <span class="comment"> applied to both the real and imaginary parts.</span> <a name="l00447"></a>00447 <span class="comment"></span> <a name="l00448"></a>00448 <span class="comment"> The cal_min and cal_max fields (if nonzero) are used for mapping (possibly</span> <a name="l00449"></a>00449 <span class="comment"> scaled) dataset values to display colors:</span> <a name="l00450"></a>00450 <span class="comment"> - Minimum display intensity (black) corresponds to dataset value cal_min.</span> <a name="l00451"></a>00451 <span class="comment"> - Maximum display intensity (white) corresponds to dataset value cal_max.</span> <a name="l00452"></a>00452 <span class="comment"> - Dataset values below cal_min should display as black also, and values</span> <a name="l00453"></a>00453 <span class="comment"> above cal_max as white.</span> <a name="l00454"></a>00454 <span class="comment"> - Colors "black" and "white", of course, may refer to any scalar display</span> <a name="l00455"></a>00455 <span class="comment"> scheme (e.g., a color lookup table specified via aux_file).</span> <a name="l00456"></a>00456 <span class="comment"> - cal_min and cal_max only make sense when applied to scalar-valued</span> <a name="l00457"></a>00457 <span class="comment"> datasets (i.e., dim[0] < 5 or dim[5] = 1).</span> <a name="l00458"></a>00458 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00459"></a>00459 <a name="l00460"></a>00460 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00461"></a>00461 <span class="comment">/* TYPE OF DATA (acceptable values for datatype field):</span> <a name="l00462"></a>00462 <span class="comment"> ---------------------------------------------------</span> <a name="l00463"></a>00463 <span class="comment"> Values of datatype smaller than 256 are ANALYZE 7.5 compatible.</span> <a name="l00464"></a>00464 <span class="comment"> Larger values are NIFTI-1 additions. These are all multiples of 256, so</span> <a name="l00465"></a>00465 <span class="comment"> that no bits below position 8 are set in datatype. But there is no need</span> <a name="l00466"></a>00466 <span class="comment"> to use only powers-of-2, as the original ANALYZE 7.5 datatype codes do.</span> <a name="l00467"></a>00467 <span class="comment"></span> <a name="l00468"></a>00468 <span class="comment"> The additional codes are intended to include a complete list of basic</span> <a name="l00469"></a>00469 <span class="comment"> scalar types, including signed and unsigned integers from 8 to 64 bits,</span> <a name="l00470"></a>00470 <span class="comment"> floats from 32 to 128 bits, and complex (float pairs) from 64 to 256 bits.</span> <a name="l00471"></a>00471 <span class="comment"></span> <a name="l00472"></a>00472 <span class="comment"> Note that most programs will support only a few of these datatypes!</span> <a name="l00473"></a>00473 <span class="comment"> A NIFTI-1 program should fail gracefully (e.g., print a warning message)</span> <a name="l00474"></a>00474 <span class="comment"> when it encounters a dataset with a type it doesn't like.</span> <a name="l00475"></a>00475 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00476"></a>00476 <a name="l00477"></a>00477 <span class="preprocessor">#undef DT_UNKNOWN </span><span class="comment">/* defined in dirent.h on some Unix systems */</span> <a name="l00478"></a>00478 <a name="l00483"></a>00483 <span class="comment">/*--- the original ANALYZE 7.5 type codes ---*/</span> <a name="l00484"></a>00484 <span class="preprocessor">#define DT_NONE 0</span> <a name="l00485"></a>00485 <span class="preprocessor"></span><span class="preprocessor">#define DT_UNKNOWN 0 </span><span class="comment">/* what it says, dude */</span> <a name="l00486"></a>00486 <span class="preprocessor">#define DT_BINARY 1 </span><span class="comment">/* binary (1 bit/voxel) */</span> <a name="l00487"></a>00487 <span class="preprocessor">#define DT_UNSIGNED_CHAR 2 </span><span class="comment">/* unsigned char (8 bits/voxel) */</span> <a name="l00488"></a>00488 <span class="preprocessor">#define DT_SIGNED_SHORT 4 </span><span class="comment">/* signed short (16 bits/voxel) */</span> <a name="l00489"></a>00489 <span class="preprocessor">#define DT_SIGNED_INT 8 </span><span class="comment">/* signed int (32 bits/voxel) */</span> <a name="l00490"></a>00490 <span class="preprocessor">#define DT_FLOAT 16 </span><span class="comment">/* float (32 bits/voxel) */</span> <a name="l00491"></a>00491 <span class="preprocessor">#define DT_COMPLEX 32 </span><span class="comment">/* complex (64 bits/voxel) */</span> <a name="l00492"></a>00492 <span class="preprocessor">#define DT_DOUBLE 64 </span><span class="comment">/* double (64 bits/voxel) */</span> <a name="l00493"></a>00493 <span class="preprocessor">#define DT_RGB 128 </span><span class="comment">/* RGB triple (24 bits/voxel) */</span> <a name="l00494"></a>00494 <span class="preprocessor">#define DT_ALL 255 </span><span class="comment">/* not very useful (?) */</span> <a name="l00495"></a>00495 <a name="l00496"></a>00496 <span class="comment">/*----- another set of names for the same ---*/</span> <a name="l00497"></a>00497 <span class="preprocessor">#define DT_UINT8 2</span> <a name="l00498"></a>00498 <span class="preprocessor"></span><span class="preprocessor">#define DT_INT16 4</span> <a name="l00499"></a>00499 <span class="preprocessor"></span><span class="preprocessor">#define DT_INT32 8</span> <a name="l00500"></a>00500 <span class="preprocessor"></span><span class="preprocessor">#define DT_FLOAT32 16</span> <a name="l00501"></a>00501 <span class="preprocessor"></span><span class="preprocessor">#define DT_COMPLEX64 32</span> <a name="l00502"></a>00502 <span class="preprocessor"></span><span class="preprocessor">#define DT_FLOAT64 64</span> <a name="l00503"></a>00503 <span class="preprocessor"></span><span class="preprocessor">#define DT_RGB24 128</span> <a name="l00504"></a>00504 <span class="preprocessor"></span> <a name="l00505"></a>00505 <span class="comment">/*------------------- new codes for NIFTI ---*/</span> <a name="l00506"></a>00506 <span class="preprocessor">#define DT_INT8 256 </span><span class="comment">/* signed char (8 bits) */</span> <a name="l00507"></a>00507 <span class="preprocessor">#define DT_UINT16 512 </span><span class="comment">/* unsigned short (16 bits) */</span> <a name="l00508"></a>00508 <span class="preprocessor">#define DT_UINT32 768 </span><span class="comment">/* unsigned int (32 bits) */</span> <a name="l00509"></a>00509 <span class="preprocessor">#define DT_INT64 1024 </span><span class="comment">/* long long (64 bits) */</span> <a name="l00510"></a>00510 <span class="preprocessor">#define DT_UINT64 1280 </span><span class="comment">/* unsigned long long (64 bits) */</span> <a name="l00511"></a>00511 <span class="preprocessor">#define DT_FLOAT128 1536 </span><span class="comment">/* long double (128 bits) */</span> <a name="l00512"></a>00512 <span class="preprocessor">#define DT_COMPLEX128 1792 </span><span class="comment">/* double pair (128 bits) */</span> <a name="l00513"></a>00513 <span class="preprocessor">#define DT_COMPLEX256 2048 </span><span class="comment">/* long double pair (256 bits) */</span> <a name="l00514"></a>00514 <span class="preprocessor">#define DT_RGBA32 2304 </span><span class="comment">/* 4 byte RGBA (32 bits/voxel) */</span> <a name="l00515"></a>00515 <span class="comment">/* @} */</span> <a name="l00516"></a>00516 <a name="l00517"></a>00517 <a name="l00518"></a>00518 <span class="comment">/*------- aliases for all the above codes ---*/</span> <a name="l00519"></a>00519 <a name="l00525"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga1ef0dc17948c65b6a7311fe96ddfc441">00525</a> <span class="preprocessor">#define NIFTI_TYPE_UINT8 2</span> <a name="l00526"></a>00526 <span class="preprocessor"></span> <a name="l00527"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga746b4eba0eaaac6366b232b46f590f48">00527</a> <span class="preprocessor">#define NIFTI_TYPE_INT16 4</span> <a name="l00528"></a>00528 <span class="preprocessor"></span> <a name="l00529"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga9bf4e01d93f73a1eaf8966f387e65999">00529</a> <span class="preprocessor">#define NIFTI_TYPE_INT32 8</span> <a name="l00530"></a>00530 <span class="preprocessor"></span> <a name="l00531"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga8220ccec425b9387abf3d2b71ac0be7e">00531</a> <span class="preprocessor">#define NIFTI_TYPE_FLOAT32 16</span> <a name="l00532"></a>00532 <span class="preprocessor"></span> <a name="l00533"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga9ae010c2ff48380fcb611c06048956c5">00533</a> <span class="preprocessor">#define NIFTI_TYPE_COMPLEX64 32</span> <a name="l00534"></a>00534 <span class="preprocessor"></span> <a name="l00535"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga1253a2540a68b4dd7a5d78bc8c4c2a4d">00535</a> <span class="preprocessor">#define NIFTI_TYPE_FLOAT64 64</span> <a name="l00536"></a>00536 <span class="preprocessor"></span> <a name="l00537"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#gabad329a29f5f3b65c1e4de114d7bb06b">00537</a> <span class="preprocessor">#define NIFTI_TYPE_RGB24 128</span> <a name="l00538"></a>00538 <span class="preprocessor"></span> <a name="l00539"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga7ed8fda7096e3ff6d4051cd73d708688">00539</a> <span class="preprocessor">#define NIFTI_TYPE_INT8 256</span> <a name="l00540"></a>00540 <span class="preprocessor"></span> <a name="l00541"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga253e4b750f2aa75a3efdac232663b85c">00541</a> <span class="preprocessor">#define NIFTI_TYPE_UINT16 512</span> <a name="l00542"></a>00542 <span class="preprocessor"></span> <a name="l00543"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga75125d71779526934b59d4d402b5fe10">00543</a> <span class="preprocessor">#define NIFTI_TYPE_UINT32 768</span> <a name="l00544"></a>00544 <span class="preprocessor"></span> <a name="l00545"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga68fa86838cb29705b5a8ffc9ac158419">00545</a> <span class="preprocessor">#define NIFTI_TYPE_INT64 1024</span> <a name="l00546"></a>00546 <span class="preprocessor"></span> <a name="l00547"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#gab8a45494d65119cdd94df359ee18b94b">00547</a> <span class="preprocessor">#define NIFTI_TYPE_UINT64 1280</span> <a name="l00548"></a>00548 <span class="preprocessor"></span> <a name="l00549"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga33274f22307e976a90c24917467e6c56">00549</a> <span class="preprocessor">#define NIFTI_TYPE_FLOAT128 1536</span> <a name="l00550"></a>00550 <span class="preprocessor"></span> <a name="l00551"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga65e61452b861209be2eb1a5a96556ca9">00551</a> <span class="preprocessor">#define NIFTI_TYPE_COMPLEX128 1792</span> <a name="l00552"></a>00552 <span class="preprocessor"></span> <a name="l00553"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga08c3af37cce4c1dd34703d1fbbdf9129">00553</a> <span class="preprocessor">#define NIFTI_TYPE_COMPLEX256 2048</span> <a name="l00554"></a>00554 <span class="preprocessor"></span> <a name="l00555"></a><a class="code" href="group__NIFTI1__DATATYPE__ALIASES.html#ga6ee4807e271d77790cdc6c0dd3220fcb">00555</a> <span class="preprocessor">#define NIFTI_TYPE_RGBA32 2304</span> <a name="l00556"></a>00556 <span class="preprocessor"></span><span class="comment">/* @} */</span> <a name="l00557"></a>00557 <a name="l00558"></a>00558 <span class="comment">/*-------- sample typedefs for complicated types ---*/</span> <a name="l00559"></a>00559 <span class="preprocessor">#if 0</span> <a name="l00560"></a>00560 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="keywordtype">float</span> r,i; } complex_float ; <a name="l00561"></a>00561 <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="keywordtype">double</span> r,i; } complex_double ; <a name="l00562"></a>00562 <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="keywordtype">long</span> <span class="keywordtype">double</span> r,i; } complex_longdouble ; <a name="l00563"></a>00563 <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> r,g,b; } rgb_byte ; <a name="l00564"></a>00564 <span class="preprocessor">#endif</span> <a name="l00565"></a>00565 <span class="preprocessor"></span> <a name="l00566"></a>00566 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00567"></a>00567 <span class="comment">/* INTERPRETATION OF VOXEL DATA:</span> <a name="l00568"></a>00568 <span class="comment"> ----------------------------</span> <a name="l00569"></a>00569 <span class="comment"> The intent_code field can be used to indicate that the voxel data has</span> <a name="l00570"></a>00570 <span class="comment"> some particular meaning. In particular, a large number of codes is</span> <a name="l00571"></a>00571 <span class="comment"> given to indicate that the the voxel data should be interpreted as</span> <a name="l00572"></a>00572 <span class="comment"> being drawn from a given probability distribution.</span> <a name="l00573"></a>00573 <span class="comment"></span> <a name="l00574"></a>00574 <span class="comment"> VECTOR-VALUED DATASETS:</span> <a name="l00575"></a>00575 <span class="comment"> ----------------------</span> <a name="l00576"></a>00576 <span class="comment"> The 5th dimension of the dataset, if present (i.e., dim[0]=5 and</span> <a name="l00577"></a>00577 <span class="comment"> dim[5] > 1), contains multiple values (e.g., a vector) to be stored</span> <a name="l00578"></a>00578 <span class="comment"> at each spatiotemporal location. For example, the header values</span> <a name="l00579"></a>00579 <span class="comment"> - dim[0] = 5</span> <a name="l00580"></a>00580 <span class="comment"> - dim[1] = 64</span> <a name="l00581"></a>00581 <span class="comment"> - dim[2] = 64</span> <a name="l00582"></a>00582 <span class="comment"> - dim[3] = 20</span> <a name="l00583"></a>00583 <span class="comment"> - dim[4] = 1 (indicates no time axis)</span> <a name="l00584"></a>00584 <span class="comment"> - dim[5] = 3</span> <a name="l00585"></a>00585 <span class="comment"> - datatype = DT_FLOAT</span> <a name="l00586"></a>00586 <span class="comment"> - intent_code = NIFTI_INTENT_VECTOR</span> <a name="l00587"></a>00587 <span class="comment"> mean that this dataset should be interpreted as a 3D volume (64x64x20),</span> <a name="l00588"></a>00588 <span class="comment"> with a 3-vector of floats defined at each point in the 3D grid.</span> <a name="l00589"></a>00589 <span class="comment"></span> <a name="l00590"></a>00590 <span class="comment"> A program reading a dataset with a 5th dimension may want to reformat</span> <a name="l00591"></a>00591 <span class="comment"> the image data to store each voxels' set of values together in a struct</span> <a name="l00592"></a>00592 <span class="comment"> or array. This programming detail, however, is beyond the scope of the</span> <a name="l00593"></a>00593 <span class="comment"> NIFTI-1 file specification! Uses of dimensions 6 and 7 are also not</span> <a name="l00594"></a>00594 <span class="comment"> specified here.</span> <a name="l00595"></a>00595 <span class="comment"></span> <a name="l00596"></a>00596 <span class="comment"> STATISTICAL PARAMETRIC DATASETS (i.e., SPMs):</span> <a name="l00597"></a>00597 <span class="comment"> --------------------------------------------</span> <a name="l00598"></a>00598 <span class="comment"> Values of intent_code from NIFTI_FIRST_STATCODE to NIFTI_LAST_STATCODE</span> <a name="l00599"></a>00599 <span class="comment"> (inclusive) indicate that the numbers in the dataset should be interpreted</span> <a name="l00600"></a>00600 <span class="comment"> as being drawn from a given distribution. Most such distributions have</span> <a name="l00601"></a>00601 <span class="comment"> auxiliary parameters (e.g., NIFTI_INTENT_TTEST has 1 DOF parameter).</span> <a name="l00602"></a>00602 <span class="comment"></span> <a name="l00603"></a>00603 <span class="comment"> If the dataset DOES NOT have a 5th dimension, then the auxiliary parameters</span> <a name="l00604"></a>00604 <span class="comment"> are the same for each voxel, and are given in header fields intent_p1,</span> <a name="l00605"></a>00605 <span class="comment"> intent_p2, and intent_p3.</span> <a name="l00606"></a>00606 <span class="comment"></span> <a name="l00607"></a>00607 <span class="comment"> If the dataset DOES have a 5th dimension, then the auxiliary parameters</span> <a name="l00608"></a>00608 <span class="comment"> are different for each voxel. For example, the header values</span> <a name="l00609"></a>00609 <span class="comment"> - dim[0] = 5</span> <a name="l00610"></a>00610 <span class="comment"> - dim[1] = 128</span> <a name="l00611"></a>00611 <span class="comment"> - dim[2] = 128</span> <a name="l00612"></a>00612 <span class="comment"> - dim[3] = 1 (indicates a single slice)</span> <a name="l00613"></a>00613 <span class="comment"> - dim[4] = 1 (indicates no time axis)</span> <a name="l00614"></a>00614 <span class="comment"> - dim[5] = 2</span> <a name="l00615"></a>00615 <span class="comment"> - datatype = DT_FLOAT</span> <a name="l00616"></a>00616 <span class="comment"> - intent_code = NIFTI_INTENT_TTEST</span> <a name="l00617"></a>00617 <span class="comment"> mean that this is a 2D dataset (128x128) of t-statistics, with the</span> <a name="l00618"></a>00618 <span class="comment"> t-statistic being in the first "plane" of data and the degrees-of-freedom</span> <a name="l00619"></a>00619 <span class="comment"> parameter being in the second "plane" of data.</span> <a name="l00620"></a>00620 <span class="comment"></span> <a name="l00621"></a>00621 <span class="comment"> If the dataset 5th dimension is used to store the voxel-wise statistical</span> <a name="l00622"></a>00622 <span class="comment"> parameters, then dim[5] must be 1 plus the number of parameters required</span> <a name="l00623"></a>00623 <span class="comment"> by that distribution (e.g., intent_code=NIFTI_INTENT_TTEST implies dim[5]</span> <a name="l00624"></a>00624 <span class="comment"> must be 2, as in the example just above).</span> <a name="l00625"></a>00625 <span class="comment"></span> <a name="l00626"></a>00626 <span class="comment"> Note: intent_code values 2..10 are compatible with AFNI 1.5x (which is</span> <a name="l00627"></a>00627 <span class="comment"> why there is no code with value=1, which is obsolescent in AFNI).</span> <a name="l00628"></a>00628 <span class="comment"></span> <a name="l00629"></a>00629 <span class="comment"> OTHER INTENTIONS:</span> <a name="l00630"></a>00630 <span class="comment"> ----------------</span> <a name="l00631"></a>00631 <span class="comment"> The purpose of the intent_* fields is to help interpret the values</span> <a name="l00632"></a>00632 <span class="comment"> stored in the dataset. Some non-statistical values for intent_code</span> <a name="l00633"></a>00633 <span class="comment"> and conventions are provided for storing other complex data types.</span> <a name="l00634"></a>00634 <span class="comment"></span> <a name="l00635"></a>00635 <span class="comment"> The intent_name field provides space for a 15 character (plus 0 byte)</span> <a name="l00636"></a>00636 <span class="comment"> 'name' string for the type of data stored. Examples:</span> <a name="l00637"></a>00637 <span class="comment"> - intent_code = NIFTI_INTENT_ESTIMATE; intent_name = "T1";</span> <a name="l00638"></a>00638 <span class="comment"> could be used to signify that the voxel values are estimates of the</span> <a name="l00639"></a>00639 <span class="comment"> NMR parameter T1.</span> <a name="l00640"></a>00640 <span class="comment"> - intent_code = NIFTI_INTENT_TTEST; intent_name = "House";</span> <a name="l00641"></a>00641 <span class="comment"> could be used to signify that the voxel values are t-statistics</span> <a name="l00642"></a>00642 <span class="comment"> for the significance of 'activation' response to a House stimulus.</span> <a name="l00643"></a>00643 <span class="comment"> - intent_code = NIFTI_INTENT_DISPVECT; intent_name = "ToMNI152";</span> <a name="l00644"></a>00644 <span class="comment"> could be used to signify that the voxel values are a displacement</span> <a name="l00645"></a>00645 <span class="comment"> vector that transforms each voxel (x,y,z) location to the</span> <a name="l00646"></a>00646 <span class="comment"> corresponding location in the MNI152 standard brain.</span> <a name="l00647"></a>00647 <span class="comment"> - intent_code = NIFTI_INTENT_SYMMATRIX; intent_name = "DTI";</span> <a name="l00648"></a>00648 <span class="comment"> could be used to signify that the voxel values comprise a diffusion</span> <a name="l00649"></a>00649 <span class="comment"> tensor image.</span> <a name="l00650"></a>00650 <span class="comment"></span> <a name="l00651"></a>00651 <span class="comment"> If no data name is implied or needed, intent_name[0] should be set to 0.</span> <a name="l00652"></a>00652 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l00653"></a>00653 <a name="l00656"></a><a class="code" href="nifti1_8h.html#acf25def6deaff31270b422f1c56c1b35">00656</a> <span class="preprocessor">#define NIFTI_INTENT_NONE 0</span> <a name="l00657"></a>00657 <span class="preprocessor"></span> <a name="l00658"></a>00658 <span class="comment">/*-------- These codes are for probability distributions ---------------*/</span> <a name="l00659"></a>00659 <span class="comment">/* Most distributions have a number of parameters,</span> <a name="l00660"></a>00660 <span class="comment"> below denoted by p1, p2, and p3, and stored in</span> <a name="l00661"></a>00661 <span class="comment"> - intent_p1, intent_p2, intent_p3 if dataset doesn't have 5th dimension</span> <a name="l00662"></a>00662 <span class="comment"> - image data array if dataset does have 5th dimension</span> <a name="l00663"></a>00663 <span class="comment"></span> <a name="l00664"></a>00664 <span class="comment"> Functions to compute with many of the distributions below can be found</span> <a name="l00665"></a>00665 <span class="comment"> in the CDF library from U Texas.</span> <a name="l00666"></a>00666 <span class="comment"></span> <a name="l00667"></a>00667 <span class="comment"> Formulas for and discussions of these distributions can be found in the</span> <a name="l00668"></a>00668 <span class="comment"> following books:</span> <a name="l00669"></a>00669 <span class="comment"></span> <a name="l00670"></a>00670 <span class="comment"> [U] Univariate Discrete Distributions,</span> <a name="l00671"></a>00671 <span class="comment"> NL Johnson, S Kotz, AW Kemp.</span> <a name="l00672"></a>00672 <span class="comment"></span> <a name="l00673"></a>00673 <span class="comment"> [C1] Continuous Univariate Distributions, vol. 1,</span> <a name="l00674"></a>00674 <span class="comment"> NL Johnson, S Kotz, N Balakrishnan.</span> <a name="l00675"></a>00675 <span class="comment"></span> <a name="l00676"></a>00676 <span class="comment"> [C2] Continuous Univariate Distributions, vol. 2,</span> <a name="l00677"></a>00677 <span class="comment"> NL Johnson, S Kotz, N Balakrishnan. */</span> <a name="l00678"></a>00678 <span class="comment">/*----------------------------------------------------------------------*/</span> <a name="l00679"></a>00679 <a name="l00688"></a>00688 <span class="preprocessor">#define NIFTI_INTENT_CORREL 2</span> <a name="l00689"></a>00689 <span class="preprocessor"></span> <a name="l00692"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga84ab612e611c71c52848c7aea27581fd">00692</a> <span class="preprocessor">#define NIFTI_INTENT_TTEST 3</span> <a name="l00693"></a>00693 <span class="preprocessor"></span> <a name="l00697"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gab744c9d5e8891ef4d73913454a80d4cd">00697</a> <span class="preprocessor">#define NIFTI_INTENT_FTEST 4</span> <a name="l00698"></a>00698 <span class="preprocessor"></span> <a name="l00701"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gae7c23a0c9b8d1819054b1b3e81da70a1">00701</a> <span class="preprocessor">#define NIFTI_INTENT_ZSCORE 5</span> <a name="l00702"></a>00702 <span class="preprocessor"></span> <a name="l00706"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga982823fd732a1c5c145eb762b0b28c77">00706</a> <span class="preprocessor">#define NIFTI_INTENT_CHISQ 6</span> <a name="l00707"></a>00707 <span class="preprocessor"></span> <a name="l00711"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gaf118b42c87a475affe1cb7ff39b2e4bb">00711</a> <span class="preprocessor">#define NIFTI_INTENT_BETA 7</span> <a name="l00712"></a>00712 <span class="preprocessor"></span> <a name="l00717"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga67a03c21e9077ed568b06ee1f2ec75a3">00717</a> <span class="preprocessor">#define NIFTI_INTENT_BINOM 8</span> <a name="l00718"></a>00718 <span class="preprocessor"></span> <a name="l00723"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga4f6b973488f64f3e6fda7ddbcd09d83e">00723</a> <span class="preprocessor">#define NIFTI_INTENT_GAMMA 9</span> <a name="l00724"></a>00724 <span class="preprocessor"></span> <a name="l00728"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga1e8492dbe60e4ce358cd49d4bfd0b3c6">00728</a> <span class="preprocessor">#define NIFTI_INTENT_POISSON 10</span> <a name="l00729"></a>00729 <span class="preprocessor"></span> <a name="l00733"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gae185e35ddb509fdae6802fc6140838fa">00733</a> <span class="preprocessor">#define NIFTI_INTENT_NORMAL 11</span> <a name="l00734"></a>00734 <span class="preprocessor"></span> <a name="l00739"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga808f36bb918469fa2c8f5b1e86e6a322">00739</a> <span class="preprocessor">#define NIFTI_INTENT_FTEST_NONC 12</span> <a name="l00740"></a>00740 <span class="preprocessor"></span> <a name="l00744"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga27bd29bf806c73caf0fe055157d93695">00744</a> <span class="preprocessor">#define NIFTI_INTENT_CHISQ_NONC 13</span> <a name="l00745"></a>00745 <span class="preprocessor"></span> <a name="l00750"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga08101b266ebd17fbb746b10ad7686e95">00750</a> <span class="preprocessor">#define NIFTI_INTENT_LOGISTIC 14</span> <a name="l00751"></a>00751 <span class="preprocessor"></span> <a name="l00756"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga1897f1fd2c7c083e5dbe3056c93742e9">00756</a> <span class="preprocessor">#define NIFTI_INTENT_LAPLACE 15</span> <a name="l00757"></a>00757 <span class="preprocessor"></span> <a name="l00760"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga876d2d65a04c636b69048cdc4acaa697">00760</a> <span class="preprocessor">#define NIFTI_INTENT_UNIFORM 16</span> <a name="l00761"></a>00761 <span class="preprocessor"></span> <a name="l00765"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gaef337ad2c0ea0d698d0d13c92532501c">00765</a> <span class="preprocessor">#define NIFTI_INTENT_TTEST_NONC 17</span> <a name="l00766"></a>00766 <span class="preprocessor"></span> <a name="l00772"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga2c5885d5e6d7a98039455f8358923991">00772</a> <span class="preprocessor">#define NIFTI_INTENT_WEIBULL 18</span> <a name="l00773"></a>00773 <span class="preprocessor"></span> <a name="l00780"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga927bc217e6332cc414736be447c3e8d2">00780</a> <span class="preprocessor">#define NIFTI_INTENT_CHI 19</span> <a name="l00781"></a>00781 <span class="preprocessor"></span> <a name="l00787"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gae40fc7f839a4e3f41387b1d55d6eb5a0">00787</a> <span class="preprocessor">#define NIFTI_INTENT_INVGAUSS 20</span> <a name="l00788"></a>00788 <span class="preprocessor"></span> <a name="l00793"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga29705d289bf7e8847716fdf6ee0bfa7d">00793</a> <span class="preprocessor">#define NIFTI_INTENT_EXTVAL 21</span> <a name="l00794"></a>00794 <span class="preprocessor"></span> <a name="l00797"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga111364b2f83b48a64f2d49d4541d1a4b">00797</a> <span class="preprocessor">#define NIFTI_INTENT_PVAL 22</span> <a name="l00798"></a>00798 <span class="preprocessor"></span> <a name="l00805"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gaab09a5d0db8d2c1a4479638c8c0661ce">00805</a> <span class="preprocessor">#define NIFTI_INTENT_LOGPVAL 23</span> <a name="l00806"></a>00806 <span class="preprocessor"></span> <a name="l00812"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga4d2f0e4f4c62772506b48fea9ec5fdec">00812</a> <span class="preprocessor">#define NIFTI_INTENT_LOG10PVAL 24</span> <a name="l00813"></a>00813 <span class="preprocessor"></span> <a name="l00816"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gaabc78cf5797171dcb13b8095892a6433">00816</a> <span class="preprocessor">#define NIFTI_FIRST_STATCODE 2</span> <a name="l00817"></a>00817 <span class="preprocessor"></span> <a name="l00820"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga513536b4a3669cae83a0f0a7acfbc6dd">00820</a> <span class="preprocessor">#define NIFTI_LAST_STATCODE 24</span> <a name="l00821"></a>00821 <span class="preprocessor"></span> <a name="l00822"></a>00822 <span class="comment">/*---------- these values for intent_code aren't for statistics ----------*/</span> <a name="l00823"></a>00823 <a name="l00828"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gaef336dc28dadfce293aadda671264a93">00828</a> <span class="preprocessor">#define NIFTI_INTENT_ESTIMATE 1001</span> <a name="l00829"></a>00829 <span class="preprocessor"></span> <a name="l00834"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gace230337cfafd74b741509d3665b5777">00834</a> <span class="preprocessor">#define NIFTI_INTENT_LABEL 1002</span> <a name="l00835"></a>00835 <span class="preprocessor"></span> <a name="l00839"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga25ee86d92c9e62308efaa6ce9aa8cd51">00839</a> <span class="preprocessor">#define NIFTI_INTENT_NEURONAME 1003</span> <a name="l00840"></a>00840 <span class="preprocessor"></span> <a name="l00853"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga8e3cfdd7e1be9fd0bb801fa225435db8">00853</a> <span class="preprocessor">#define NIFTI_INTENT_GENMATRIX 1004</span> <a name="l00854"></a>00854 <span class="preprocessor"></span> <a name="l00866"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gab6cd5413095cde3e72ee216a38f60178">00866</a> <span class="preprocessor">#define NIFTI_INTENT_SYMMATRIX 1005</span> <a name="l00867"></a>00867 <span class="preprocessor"></span> <a name="l00875"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gafbbc9936500b51461f7c8bd4ff96ed43">00875</a> <span class="preprocessor">#define NIFTI_INTENT_DISPVECT 1006 </span><span class="comment">/* specifically for displacements */</span> <a name="l00876"></a>00876 <span class="preprocessor">#define NIFTI_INTENT_VECTOR 1007 </span><span class="comment">/* for any other type of vector */</span> <a name="l00877"></a>00877 <a name="l00889"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga124259beb28b9b08b279ec9b5196f90e">00889</a> <span class="preprocessor">#define NIFTI_INTENT_POINTSET 1008</span> <a name="l00890"></a>00890 <span class="preprocessor"></span> <a name="l00902"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gae34eb51c5984233c4d1c30ae5f5d309f">00902</a> <span class="preprocessor">#define NIFTI_INTENT_TRIANGLE 1009</span> <a name="l00903"></a>00903 <span class="preprocessor"></span> <a name="l00911"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga69746985b119af3ca3e576fbf98396fb">00911</a> <span class="preprocessor">#define NIFTI_INTENT_QUATERNION 1010</span> <a name="l00912"></a>00912 <span class="preprocessor"></span> <a name="l00916"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga5014b482ea33b66e7ed2c000282e2260">00916</a> <span class="preprocessor">#define NIFTI_INTENT_DIMLESS 1011</span> <a name="l00917"></a>00917 <span class="preprocessor"></span> <a name="l00918"></a>00918 <span class="comment">/*---------- these values apply to GIFTI datasets ----------*/</span> <a name="l00919"></a>00919 <a name="l00922"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga6f9fccc28d5accae59a279aa1830ce91">00922</a> <span class="preprocessor">#define NIFTI_INTENT_TIME_SERIES 2001</span> <a name="l00923"></a>00923 <span class="preprocessor"></span> <a name="l00927"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga5cd8e1c7d0e25958db5de64965a0b499">00927</a> <span class="preprocessor">#define NIFTI_INTENT_NODE_INDEX 2002</span> <a name="l00928"></a>00928 <span class="preprocessor"></span> <a name="l00938"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#ga24a258463206ca3d9f7af242249f993c">00938</a> <span class="preprocessor">#define NIFTI_INTENT_RGB_VECTOR 2003</span> <a name="l00939"></a>00939 <span class="preprocessor"></span> <a name="l00949"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gae5d634acc4f9386eb955a3f967faf961">00949</a> <span class="preprocessor">#define NIFTI_INTENT_RGBA_VECTOR 2004</span> <a name="l00950"></a>00950 <span class="preprocessor"></span> <a name="l00954"></a><a class="code" href="group__NIFTI1__INTENT__CODES.html#gad0df641934f6c9b30407ee8db84e47c0">00954</a> <span class="preprocessor">#define NIFTI_INTENT_SHAPE 2005</span> <a name="l00955"></a>00955 <span class="preprocessor"></span> <a name="l00956"></a>00956 <span class="comment">/* @} */</span> <a name="l00957"></a>00957 <a name="l00958"></a>00958 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l00959"></a>00959 <span class="comment">/* 3D IMAGE (VOLUME) ORIENTATION AND LOCATION IN SPACE:</span> <a name="l00960"></a>00960 <span class="comment"> ---------------------------------------------------</span> <a name="l00961"></a>00961 <span class="comment"> There are 3 different methods by which continuous coordinates can</span> <a name="l00962"></a>00962 <span class="comment"> attached to voxels. The discussion below emphasizes 3D volumes, and</span> <a name="l00963"></a>00963 <span class="comment"> the continuous coordinates are referred to as (x,y,z). The voxel</span> <a name="l00964"></a>00964 <span class="comment"> index coordinates (i.e., the array indexes) are referred to as (i,j,k),</span> <a name="l00965"></a>00965 <span class="comment"> with valid ranges:</span> <a name="l00966"></a>00966 <span class="comment"> i = 0 .. dim[1]-1</span> <a name="l00967"></a>00967 <span class="comment"> j = 0 .. dim[2]-1 (if dim[0] >= 2)</span> <a name="l00968"></a>00968 <span class="comment"> k = 0 .. dim[3]-1 (if dim[0] >= 3)</span> <a name="l00969"></a>00969 <span class="comment"> The (x,y,z) coordinates refer to the CENTER of a voxel. In methods</span> <a name="l00970"></a>00970 <span class="comment"> 2 and 3, the (x,y,z) axes refer to a subject-based coordinate system,</span> <a name="l00971"></a>00971 <span class="comment"> with</span> <a name="l00972"></a>00972 <span class="comment"> +x = Right +y = Anterior +z = Superior.</span> <a name="l00973"></a>00973 <span class="comment"> This is a right-handed coordinate system. However, the exact direction</span> <a name="l00974"></a>00974 <span class="comment"> these axes point with respect to the subject depends on qform_code</span> <a name="l00975"></a>00975 <span class="comment"> (Method 2) and sform_code (Method 3).</span> <a name="l00976"></a>00976 <span class="comment"></span> <a name="l00977"></a>00977 <span class="comment"> N.B.: The i index varies most rapidly, j index next, k index slowest.</span> <a name="l00978"></a>00978 <span class="comment"> Thus, voxel (i,j,k) is stored starting at location</span> <a name="l00979"></a>00979 <span class="comment"> (i + j*dim[1] + k*dim[1]*dim[2]) * (bitpix/8)</span> <a name="l00980"></a>00980 <span class="comment"> into the dataset array.</span> <a name="l00981"></a>00981 <span class="comment"></span> <a name="l00982"></a>00982 <span class="comment"> N.B.: The ANALYZE 7.5 coordinate system is</span> <a name="l00983"></a>00983 <span class="comment"> +x = Left +y = Anterior +z = Superior</span> <a name="l00984"></a>00984 <span class="comment"> which is a left-handed coordinate system. This backwardness is</span> <a name="l00985"></a>00985 <span class="comment"> too difficult to tolerate, so this NIFTI-1 standard specifies the</span> <a name="l00986"></a>00986 <span class="comment"> coordinate order which is most common in functional neuroimaging.</span> <a name="l00987"></a>00987 <span class="comment"></span> <a name="l00988"></a>00988 <span class="comment"> N.B.: The 3 methods below all give the locations of the voxel centers</span> <a name="l00989"></a>00989 <span class="comment"> in the (x,y,z) coordinate system. In many cases, programs will wish</span> <a name="l00990"></a>00990 <span class="comment"> to display image data on some other grid. In such a case, the program</span> <a name="l00991"></a>00991 <span class="comment"> will need to convert its desired (x,y,z) values into (i,j,k) values</span> <a name="l00992"></a>00992 <span class="comment"> in order to extract (or interpolate) the image data. This operation</span> <a name="l00993"></a>00993 <span class="comment"> would be done with the inverse transformation to those described below.</span> <a name="l00994"></a>00994 <span class="comment"></span> <a name="l00995"></a>00995 <span class="comment"> N.B.: Method 2 uses a factor 'qfac' which is either -1 or 1; qfac is</span> <a name="l00996"></a>00996 <span class="comment"> stored in the otherwise unused pixdim[0]. If pixdim[0]=0.0 (which</span> <a name="l00997"></a>00997 <span class="comment"> should not occur), we take qfac=1. Of course, pixdim[0] is only used</span> <a name="l00998"></a>00998 <span class="comment"> when reading a NIFTI-1 header, not when reading an ANALYZE 7.5 header.</span> <a name="l00999"></a>00999 <span class="comment"></span> <a name="l01000"></a>01000 <span class="comment"> N.B.: The units of (x,y,z) can be specified using the xyzt_units field.</span> <a name="l01001"></a>01001 <span class="comment"></span> <a name="l01002"></a>01002 <span class="comment"> METHOD 1 (the "old" way, used only when qform_code = 0):</span> <a name="l01003"></a>01003 <span class="comment"> -------------------------------------------------------</span> <a name="l01004"></a>01004 <span class="comment"> The coordinate mapping from (i,j,k) to (x,y,z) is the ANALYZE</span> <a name="l01005"></a>01005 <span class="comment"> 7.5 way. This is a simple scaling relationship:</span> <a name="l01006"></a>01006 <span class="comment"></span> <a name="l01007"></a>01007 <span class="comment"> x = pixdim[1] * i</span> <a name="l01008"></a>01008 <span class="comment"> y = pixdim[2] * j</span> <a name="l01009"></a>01009 <span class="comment"> z = pixdim[3] * k</span> <a name="l01010"></a>01010 <span class="comment"></span> <a name="l01011"></a>01011 <span class="comment"> No particular spatial orientation is attached to these (x,y,z)</span> <a name="l01012"></a>01012 <span class="comment"> coordinates. (NIFTI-1 does not have the ANALYZE 7.5 orient field,</span> <a name="l01013"></a>01013 <span class="comment"> which is not general and is often not set properly.) This method</span> <a name="l01014"></a>01014 <span class="comment"> is not recommended, and is present mainly for compatibility with</span> <a name="l01015"></a>01015 <span class="comment"> ANALYZE 7.5 files.</span> <a name="l01016"></a>01016 <span class="comment"></span> <a name="l01017"></a>01017 <span class="comment"> METHOD 2 (used when qform_code > 0, which should be the "normal" case):</span> <a name="l01018"></a>01018 <span class="comment"> ---------------------------------------------------------------------</span> <a name="l01019"></a>01019 <span class="comment"> The (x,y,z) coordinates are given by the pixdim[] scales, a rotation</span> <a name="l01020"></a>01020 <span class="comment"> matrix, and a shift. This method is intended to represent</span> <a name="l01021"></a>01021 <span class="comment"> "scanner-anatomical" coordinates, which are often embedded in the</span> <a name="l01022"></a>01022 <span class="comment"> image header (e.g., DICOM fields (0020,0032), (0020,0037), (0028,0030),</span> <a name="l01023"></a>01023 <span class="comment"> and (0018,0050)), and represent the nominal orientation and location of</span> <a name="l01024"></a>01024 <span class="comment"> the data. This method can also be used to represent "aligned"</span> <a name="l01025"></a>01025 <span class="comment"> coordinates, which would typically result from some post-acquisition</span> <a name="l01026"></a>01026 <span class="comment"> alignment of the volume to a standard orientation (e.g., the same</span> <a name="l01027"></a>01027 <span class="comment"> subject on another day, or a rigid rotation to true anatomical</span> <a name="l01028"></a>01028 <span class="comment"> orientation from the tilted position of the subject in the scanner).</span> <a name="l01029"></a>01029 <span class="comment"> The formula for (x,y,z) in terms of header parameters and (i,j,k) is:</span> <a name="l01030"></a>01030 <span class="comment"></span> <a name="l01031"></a>01031 <span class="comment"> [ x ] [ R11 R12 R13 ] [ pixdim[1] * i ] [ qoffset_x ]</span> <a name="l01032"></a>01032 <span class="comment"> [ y ] = [ R21 R22 R23 ] [ pixdim[2] * j ] + [ qoffset_y ]</span> <a name="l01033"></a>01033 <span class="comment"> [ z ] [ R31 R32 R33 ] [ qfac * pixdim[3] * k ] [ qoffset_z ]</span> <a name="l01034"></a>01034 <span class="comment"></span> <a name="l01035"></a>01035 <span class="comment"> The qoffset_* shifts are in the NIFTI-1 header. Note that the center</span> <a name="l01036"></a>01036 <span class="comment"> of the (i,j,k)=(0,0,0) voxel (first value in the dataset array) is</span> <a name="l01037"></a>01037 <span class="comment"> just (x,y,z)=(qoffset_x,qoffset_y,qoffset_z).</span> <a name="l01038"></a>01038 <span class="comment"></span> <a name="l01039"></a>01039 <span class="comment"> The rotation matrix R is calculated from the quatern_* parameters.</span> <a name="l01040"></a>01040 <span class="comment"> This calculation is described below.</span> <a name="l01041"></a>01041 <span class="comment"></span> <a name="l01042"></a>01042 <span class="comment"> The scaling factor qfac is either 1 or -1. The rotation matrix R</span> <a name="l01043"></a>01043 <span class="comment"> defined by the quaternion parameters is "proper" (has determinant 1).</span> <a name="l01044"></a>01044 <span class="comment"> This may not fit the needs of the data; for example, if the image</span> <a name="l01045"></a>01045 <span class="comment"> grid is</span> <a name="l01046"></a>01046 <span class="comment"> i increases from Left-to-Right</span> <a name="l01047"></a>01047 <span class="comment"> j increases from Anterior-to-Posterior</span> <a name="l01048"></a>01048 <span class="comment"> k increases from Inferior-to-Superior</span> <a name="l01049"></a>01049 <span class="comment"> Then (i,j,k) is a left-handed triple. In this example, if qfac=1,</span> <a name="l01050"></a>01050 <span class="comment"> the R matrix would have to be</span> <a name="l01051"></a>01051 <span class="comment"></span> <a name="l01052"></a>01052 <span class="comment"> [ 1 0 0 ]</span> <a name="l01053"></a>01053 <span class="comment"> [ 0 -1 0 ] which is "improper" (determinant = -1).</span> <a name="l01054"></a>01054 <span class="comment"> [ 0 0 1 ]</span> <a name="l01055"></a>01055 <span class="comment"></span> <a name="l01056"></a>01056 <span class="comment"> If we set qfac=-1, then the R matrix would be</span> <a name="l01057"></a>01057 <span class="comment"></span> <a name="l01058"></a>01058 <span class="comment"> [ 1 0 0 ]</span> <a name="l01059"></a>01059 <span class="comment"> [ 0 -1 0 ] which is proper.</span> <a name="l01060"></a>01060 <span class="comment"> [ 0 0 -1 ]</span> <a name="l01061"></a>01061 <span class="comment"></span> <a name="l01062"></a>01062 <span class="comment"> This R matrix is represented by quaternion [a,b,c,d] = [0,1,0,0]</span> <a name="l01063"></a>01063 <span class="comment"> (which encodes a 180 degree rotation about the x-axis).</span> <a name="l01064"></a>01064 <span class="comment"></span> <a name="l01065"></a>01065 <span class="comment"> METHOD 3 (used when sform_code > 0):</span> <a name="l01066"></a>01066 <span class="comment"> -----------------------------------</span> <a name="l01067"></a>01067 <span class="comment"> The (x,y,z) coordinates are given by a general affine transformation</span> <a name="l01068"></a>01068 <span class="comment"> of the (i,j,k) indexes:</span> <a name="l01069"></a>01069 <span class="comment"></span> <a name="l01070"></a>01070 <span class="comment"> x = srow_x[0] * i + srow_x[1] * j + srow_x[2] * k + srow_x[3]</span> <a name="l01071"></a>01071 <span class="comment"> y = srow_y[0] * i + srow_y[1] * j + srow_y[2] * k + srow_y[3]</span> <a name="l01072"></a>01072 <span class="comment"> z = srow_z[0] * i + srow_z[1] * j + srow_z[2] * k + srow_z[3]</span> <a name="l01073"></a>01073 <span class="comment"></span> <a name="l01074"></a>01074 <span class="comment"> The srow_* vectors are in the NIFTI_1 header. Note that no use is</span> <a name="l01075"></a>01075 <span class="comment"> made of pixdim[] in this method.</span> <a name="l01076"></a>01076 <span class="comment"></span> <a name="l01077"></a>01077 <span class="comment"> WHY 3 METHODS?</span> <a name="l01078"></a>01078 <span class="comment"> --------------</span> <a name="l01079"></a>01079 <span class="comment"> Method 1 is provided only for backwards compatibility. The intention</span> <a name="l01080"></a>01080 <span class="comment"> is that Method 2 (qform_code > 0) represents the nominal voxel locations</span> <a name="l01081"></a>01081 <span class="comment"> as reported by the scanner, or as rotated to some fiducial orientation and</span> <a name="l01082"></a>01082 <span class="comment"> location. Method 3, if present (sform_code > 0), is to be used to give</span> <a name="l01083"></a>01083 <span class="comment"> the location of the voxels in some standard space. The sform_code</span> <a name="l01084"></a>01084 <span class="comment"> indicates which standard space is present. Both methods 2 and 3 can be</span> <a name="l01085"></a>01085 <span class="comment"> present, and be useful in different contexts (method 2 for displaying the</span> <a name="l01086"></a>01086 <span class="comment"> data on its original grid; method 3 for displaying it on a standard grid).</span> <a name="l01087"></a>01087 <span class="comment"></span> <a name="l01088"></a>01088 <span class="comment"> In this scheme, a dataset would originally be set up so that the</span> <a name="l01089"></a>01089 <span class="comment"> Method 2 coordinates represent what the scanner reported. Later,</span> <a name="l01090"></a>01090 <span class="comment"> a registration to some standard space can be computed and inserted</span> <a name="l01091"></a>01091 <span class="comment"> in the header. Image display software can use either transform,</span> <a name="l01092"></a>01092 <span class="comment"> depending on its purposes and needs.</span> <a name="l01093"></a>01093 <span class="comment"></span> <a name="l01094"></a>01094 <span class="comment"> In Method 2, the origin of coordinates would generally be whatever</span> <a name="l01095"></a>01095 <span class="comment"> the scanner origin is; for example, in MRI, (0,0,0) is the center</span> <a name="l01096"></a>01096 <span class="comment"> of the gradient coil.</span> <a name="l01097"></a>01097 <span class="comment"></span> <a name="l01098"></a>01098 <span class="comment"> In Method 3, the origin of coordinates would depend on the value</span> <a name="l01099"></a>01099 <span class="comment"> of sform_code; for example, for the Talairach coordinate system,</span> <a name="l01100"></a>01100 <span class="comment"> (0,0,0) corresponds to the Anterior Commissure.</span> <a name="l01101"></a>01101 <span class="comment"></span> <a name="l01102"></a>01102 <span class="comment"> QUATERNION REPRESENTATION OF ROTATION MATRIX (METHOD 2)</span> <a name="l01103"></a>01103 <span class="comment"> -------------------------------------------------------</span> <a name="l01104"></a>01104 <span class="comment"> The orientation of the (x,y,z) axes relative to the (i,j,k) axes</span> <a name="l01105"></a>01105 <span class="comment"> in 3D space is specified using a unit quaternion [a,b,c,d], where</span> <a name="l01106"></a>01106 <span class="comment"> a*a+b*b+c*c+d*d=1. The (b,c,d) values are all that is needed, since</span> <a name="l01107"></a>01107 <span class="comment"> we require that a = sqrt(1.0-(b*b+c*c+d*d)) be nonnegative. The (b,c,d)</span> <a name="l01108"></a>01108 <span class="comment"> values are stored in the (quatern_b,quatern_c,quatern_d) fields.</span> <a name="l01109"></a>01109 <span class="comment"></span> <a name="l01110"></a>01110 <span class="comment"> The quaternion representation is chosen for its compactness in</span> <a name="l01111"></a>01111 <span class="comment"> representing rotations. The (proper) 3x3 rotation matrix that</span> <a name="l01112"></a>01112 <span class="comment"> corresponds to [a,b,c,d] is</span> <a name="l01113"></a>01113 <span class="comment"></span> <a name="l01114"></a>01114 <span class="comment"> [ a*a+b*b-c*c-d*d 2*b*c-2*a*d 2*b*d+2*a*c ]</span> <a name="l01115"></a>01115 <span class="comment"> R = [ 2*b*c+2*a*d a*a+c*c-b*b-d*d 2*c*d-2*a*b ]</span> <a name="l01116"></a>01116 <span class="comment"> [ 2*b*d-2*a*c 2*c*d+2*a*b a*a+d*d-c*c-b*b ]</span> <a name="l01117"></a>01117 <span class="comment"></span> <a name="l01118"></a>01118 <span class="comment"> [ R11 R12 R13 ]</span> <a name="l01119"></a>01119 <span class="comment"> = [ R21 R22 R23 ]</span> <a name="l01120"></a>01120 <span class="comment"> [ R31 R32 R33 ]</span> <a name="l01121"></a>01121 <span class="comment"></span> <a name="l01122"></a>01122 <span class="comment"> If (p,q,r) is a unit 3-vector, then rotation of angle h about that</span> <a name="l01123"></a>01123 <span class="comment"> direction is represented by the quaternion</span> <a name="l01124"></a>01124 <span class="comment"></span> <a name="l01125"></a>01125 <span class="comment"> [a,b,c,d] = [cos(h/2), p*sin(h/2), q*sin(h/2), r*sin(h/2)].</span> <a name="l01126"></a>01126 <span class="comment"></span> <a name="l01127"></a>01127 <span class="comment"> Requiring a >= 0 is equivalent to requiring -Pi <= h <= Pi. (Note that</span> <a name="l01128"></a>01128 <span class="comment"> [-a,-b,-c,-d] represents the same rotation as [a,b,c,d]; there are 2</span> <a name="l01129"></a>01129 <span class="comment"> quaternions that can be used to represent a given rotation matrix R.)</span> <a name="l01130"></a>01130 <span class="comment"> To rotate a 3-vector (x,y,z) using quaternions, we compute the</span> <a name="l01131"></a>01131 <span class="comment"> quaternion product</span> <a name="l01132"></a>01132 <span class="comment"></span> <a name="l01133"></a>01133 <span class="comment"> [0,x',y',z'] = [a,b,c,d] * [0,x,y,z] * [a,-b,-c,-d]</span> <a name="l01134"></a>01134 <span class="comment"></span> <a name="l01135"></a>01135 <span class="comment"> which is equivalent to the matrix-vector multiply</span> <a name="l01136"></a>01136 <span class="comment"></span> <a name="l01137"></a>01137 <span class="comment"> [ x' ] [ x ]</span> <a name="l01138"></a>01138 <span class="comment"> [ y' ] = R [ y ] (equivalence depends on a*a+b*b+c*c+d*d=1)</span> <a name="l01139"></a>01139 <span class="comment"> [ z' ] [ z ]</span> <a name="l01140"></a>01140 <span class="comment"></span> <a name="l01141"></a>01141 <span class="comment"> Multiplication of 2 quaternions is defined by the following:</span> <a name="l01142"></a>01142 <span class="comment"></span> <a name="l01143"></a>01143 <span class="comment"> [a,b,c,d] = a*1 + b*I + c*J + d*K</span> <a name="l01144"></a>01144 <span class="comment"> where</span> <a name="l01145"></a>01145 <span class="comment"> I*I = J*J = K*K = -1 (I,J,K are square roots of -1)</span> <a name="l01146"></a>01146 <span class="comment"> I*J = K J*K = I K*I = J</span> <a name="l01147"></a>01147 <span class="comment"> J*I = -K K*J = -I I*K = -J (not commutative!)</span> <a name="l01148"></a>01148 <span class="comment"> For example</span> <a name="l01149"></a>01149 <span class="comment"> [a,b,0,0] * [0,0,0,1] = [0,0,-b,a]</span> <a name="l01150"></a>01150 <span class="comment"> since this expands to</span> <a name="l01151"></a>01151 <span class="comment"> (a+b*I)*(K) = (a*K+b*I*K) = (a*K-b*J).</span> <a name="l01152"></a>01152 <span class="comment"></span> <a name="l01153"></a>01153 <span class="comment"> The above formula shows how to go from quaternion (b,c,d) to</span> <a name="l01154"></a>01154 <span class="comment"> rotation matrix and direction cosines. Conversely, given R,</span> <a name="l01155"></a>01155 <span class="comment"> we can compute the fields for the NIFTI-1 header by</span> <a name="l01156"></a>01156 <span class="comment"></span> <a name="l01157"></a>01157 <span class="comment"> a = 0.5 * sqrt(1+R11+R22+R33) (not stored)</span> <a name="l01158"></a>01158 <span class="comment"> b = 0.25 * (R32-R23) / a => quatern_b</span> <a name="l01159"></a>01159 <span class="comment"> c = 0.25 * (R13-R31) / a => quatern_c</span> <a name="l01160"></a>01160 <span class="comment"> d = 0.25 * (R21-R12) / a => quatern_d</span> <a name="l01161"></a>01161 <span class="comment"></span> <a name="l01162"></a>01162 <span class="comment"> If a=0 (a 180 degree rotation), alternative formulas are needed.</span> <a name="l01163"></a>01163 <span class="comment"> See the nifti1_io.c function mat44_to_quatern() for an implementation</span> <a name="l01164"></a>01164 <span class="comment"> of the various cases in converting R to [a,b,c,d].</span> <a name="l01165"></a>01165 <span class="comment"></span> <a name="l01166"></a>01166 <span class="comment"> Note that R-transpose (= R-inverse) would lead to the quaternion</span> <a name="l01167"></a>01167 <span class="comment"> [a,-b,-c,-d].</span> <a name="l01168"></a>01168 <span class="comment"></span> <a name="l01169"></a>01169 <span class="comment"> The choice to specify the qoffset_x (etc.) values in the final</span> <a name="l01170"></a>01170 <span class="comment"> coordinate system is partly to make it easy to convert DICOM images to</span> <a name="l01171"></a>01171 <span class="comment"> this format. The DICOM attribute "Image Position (Patient)" (0020,0032)</span> <a name="l01172"></a>01172 <span class="comment"> stores the (Xd,Yd,Zd) coordinates of the center of the first voxel.</span> <a name="l01173"></a>01173 <span class="comment"> Here, (Xd,Yd,Zd) refer to DICOM coordinates, and Xd=-x, Yd=-y, Zd=z,</span> <a name="l01174"></a>01174 <span class="comment"> where (x,y,z) refers to the NIFTI coordinate system discussed above.</span> <a name="l01175"></a>01175 <span class="comment"> (i.e., DICOM +Xd is Left, +Yd is Posterior, +Zd is Superior,</span> <a name="l01176"></a>01176 <span class="comment"> whereas +x is Right, +y is Anterior , +z is Superior. )</span> <a name="l01177"></a>01177 <span class="comment"> Thus, if the (0020,0032) DICOM attribute is extracted into (px,py,pz), then</span> <a name="l01178"></a>01178 <span class="comment"> qoffset_x = -px qoffset_y = -py qoffset_z = pz</span> <a name="l01179"></a>01179 <span class="comment"> is a reasonable setting when qform_code=NIFTI_XFORM_SCANNER_ANAT.</span> <a name="l01180"></a>01180 <span class="comment"></span> <a name="l01181"></a>01181 <span class="comment"> That is, DICOM's coordinate system is 180 degrees rotated about the z-axis</span> <a name="l01182"></a>01182 <span class="comment"> from the neuroscience/NIFTI coordinate system. To transform between DICOM</span> <a name="l01183"></a>01183 <span class="comment"> and NIFTI, you just have to negate the x- and y-coordinates.</span> <a name="l01184"></a>01184 <span class="comment"></span> <a name="l01185"></a>01185 <span class="comment"> The DICOM attribute (0020,0037) "Image Orientation (Patient)" gives the</span> <a name="l01186"></a>01186 <span class="comment"> orientation of the x- and y-axes of the image data in terms of 2 3-vectors.</span> <a name="l01187"></a>01187 <span class="comment"> The first vector is a unit vector along the x-axis, and the second is</span> <a name="l01188"></a>01188 <span class="comment"> along the y-axis. If the (0020,0037) attribute is extracted into the</span> <a name="l01189"></a>01189 <span class="comment"> value (xa,xb,xc,ya,yb,yc), then the first two columns of the R matrix</span> <a name="l01190"></a>01190 <span class="comment"> would be</span> <a name="l01191"></a>01191 <span class="comment"> [ -xa -ya ]</span> <a name="l01192"></a>01192 <span class="comment"> [ -xb -yb ]</span> <a name="l01193"></a>01193 <span class="comment"> [ xc yc ]</span> <a name="l01194"></a>01194 <span class="comment"> The negations are because DICOM's x- and y-axes are reversed relative</span> <a name="l01195"></a>01195 <span class="comment"> to NIFTI's. The third column of the R matrix gives the direction of</span> <a name="l01196"></a>01196 <span class="comment"> displacement (relative to the subject) along the slice-wise direction.</span> <a name="l01197"></a>01197 <span class="comment"> This orientation is not encoded in the DICOM standard in a simple way;</span> <a name="l01198"></a>01198 <span class="comment"> DICOM is mostly concerned with 2D images. The third column of R will be</span> <a name="l01199"></a>01199 <span class="comment"> either the cross-product of the first 2 columns or its negative. It is</span> <a name="l01200"></a>01200 <span class="comment"> possible to infer the sign of the 3rd column by examining the coordinates</span> <a name="l01201"></a>01201 <span class="comment"> in DICOM attribute (0020,0032) "Image Position (Patient)" for successive</span> <a name="l01202"></a>01202 <span class="comment"> slices. However, this method occasionally fails for reasons that I</span> <a name="l01203"></a>01203 <span class="comment"> (RW Cox) do not understand.</span> <a name="l01204"></a>01204 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l01205"></a>01205 <a name="l01206"></a>01206 <span class="comment">/* [qs]form_code value: */</span> <span class="comment">/* x,y,z coordinate system refers to: */</span> <a name="l01207"></a>01207 <span class="comment">/*-----------------------*/</span> <span class="comment">/*---------------------------------------*/</span> <a name="l01208"></a>01208 <a name="l01215"></a><a class="code" href="group__NIFTI1__XFORM__CODES.html#ga07bbf1c2d76a8d8770fc5d76b24647d1">01215</a> <span class="preprocessor">#define NIFTI_XFORM_UNKNOWN 0</span> <a name="l01216"></a>01216 <span class="preprocessor"></span> <a name="l01219"></a><a class="code" href="group__NIFTI1__XFORM__CODES.html#gaa90a1fd4f431574e7bebc2b0261ec50f">01219</a> <span class="preprocessor">#define NIFTI_XFORM_SCANNER_ANAT 1</span> <a name="l01220"></a>01220 <span class="preprocessor"></span> <a name="l01224"></a><a class="code" href="group__NIFTI1__XFORM__CODES.html#gae6c1f140dd22d735e396c2fb3b6334c6">01224</a> <span class="preprocessor">#define NIFTI_XFORM_ALIGNED_ANAT 2</span> <a name="l01225"></a>01225 <span class="preprocessor"></span> <a name="l01229"></a><a class="code" href="group__NIFTI1__XFORM__CODES.html#ga4159e2d4eb86e582c1f4b6c205b53108">01229</a> <span class="preprocessor">#define NIFTI_XFORM_TALAIRACH 3</span> <a name="l01230"></a>01230 <span class="preprocessor"></span> <a name="l01233"></a><a class="code" href="group__NIFTI1__XFORM__CODES.html#ga80292343978413b03cb8ccc1e55eb121">01233</a> <span class="preprocessor">#define NIFTI_XFORM_MNI_152 4</span> <a name="l01234"></a>01234 <span class="preprocessor"></span><span class="comment">/* @} */</span> <a name="l01235"></a>01235 <a name="l01236"></a>01236 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l01237"></a>01237 <span class="comment">/* UNITS OF SPATIAL AND TEMPORAL DIMENSIONS:</span> <a name="l01238"></a>01238 <span class="comment"> ----------------------------------------</span> <a name="l01239"></a>01239 <span class="comment"> The codes below can be used in xyzt_units to indicate the units of pixdim.</span> <a name="l01240"></a>01240 <span class="comment"> As noted earlier, dimensions 1,2,3 are for x,y,z; dimension 4 is for</span> <a name="l01241"></a>01241 <span class="comment"> time (t).</span> <a name="l01242"></a>01242 <span class="comment"> - If dim[4]=1 or dim[0] < 4, there is no time axis.</span> <a name="l01243"></a>01243 <span class="comment"> - A single time series (no space) would be specified with</span> <a name="l01244"></a>01244 <span class="comment"> - dim[0] = 4 (for scalar data) or dim[0] = 5 (for vector data)</span> <a name="l01245"></a>01245 <span class="comment"> - dim[1] = dim[2] = dim[3] = 1</span> <a name="l01246"></a>01246 <span class="comment"> - dim[4] = number of time points</span> <a name="l01247"></a>01247 <span class="comment"> - pixdim[4] = time step</span> <a name="l01248"></a>01248 <span class="comment"> - xyzt_units indicates units of pixdim[4]</span> <a name="l01249"></a>01249 <span class="comment"> - dim[5] = number of values stored at each time point</span> <a name="l01250"></a>01250 <span class="comment"></span> <a name="l01251"></a>01251 <span class="comment"> Bits 0..2 of xyzt_units specify the units of pixdim[1..3]</span> <a name="l01252"></a>01252 <span class="comment"> (e.g., spatial units are values 1..7).</span> <a name="l01253"></a>01253 <span class="comment"> Bits 3..5 of xyzt_units specify the units of pixdim[4]</span> <a name="l01254"></a>01254 <span class="comment"> (e.g., temporal units are multiples of 8).</span> <a name="l01255"></a>01255 <span class="comment"></span> <a name="l01256"></a>01256 <span class="comment"> This compression of 2 distinct concepts into 1 byte is due to the</span> <a name="l01257"></a>01257 <span class="comment"> limited space available in the 348 byte ANALYZE 7.5 header. The</span> <a name="l01258"></a>01258 <span class="comment"> macros XYZT_TO_SPACE and XYZT_TO_TIME can be used to mask off the</span> <a name="l01259"></a>01259 <span class="comment"> undesired bits from the xyzt_units fields, leaving "pure" space</span> <a name="l01260"></a>01260 <span class="comment"> and time codes. Inversely, the macro SPACE_TIME_TO_XYZT can be</span> <a name="l01261"></a>01261 <span class="comment"> used to assemble a space code (0,1,2,...,7) with a time code</span> <a name="l01262"></a>01262 <span class="comment"> (0,8,16,32,...,56) into the combined value for xyzt_units.</span> <a name="l01263"></a>01263 <span class="comment"></span> <a name="l01264"></a>01264 <span class="comment"> Note that codes are provided to indicate the "time" axis units are</span> <a name="l01265"></a>01265 <span class="comment"> actually frequency in Hertz (_HZ), in part-per-million (_PPM)</span> <a name="l01266"></a>01266 <span class="comment"> or in radians-per-second (_RADS).</span> <a name="l01267"></a>01267 <span class="comment"></span> <a name="l01268"></a>01268 <span class="comment"> The toffset field can be used to indicate a nonzero start point for</span> <a name="l01269"></a>01269 <span class="comment"> the time axis. That is, time point #m is at t=toffset+m*pixdim[4]</span> <a name="l01270"></a>01270 <span class="comment"> for m=0..dim[4]-1.</span> <a name="l01271"></a>01271 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l01272"></a>01272 <a name="l01279"></a><a class="code" href="group__NIFTI1__UNITS.html#gaab4358e3a869324c9bbd4b2d4eb5567a">01279</a> <span class="preprocessor">#define NIFTI_UNITS_UNKNOWN 0</span> <a name="l01280"></a>01280 <span class="preprocessor"></span> <a name="l01283"></a><a class="code" href="group__NIFTI1__UNITS.html#ga58b8564584f3e2cda3bfb9daebdd28d5">01283</a> <span class="preprocessor">#define NIFTI_UNITS_METER 1</span> <a name="l01284"></a>01284 <span class="preprocessor"></span> <a name="l01285"></a><a class="code" href="group__NIFTI1__UNITS.html#gae37d3c19fa7561f6ef662bc27a4af5d4">01285</a> <span class="preprocessor">#define NIFTI_UNITS_MM 2</span> <a name="l01286"></a>01286 <span class="preprocessor"></span> <a name="l01287"></a><a class="code" href="group__NIFTI1__UNITS.html#ga9ab584aac820e59dc2373581ee2c237e">01287</a> <span class="preprocessor">#define NIFTI_UNITS_MICRON 3</span> <a name="l01288"></a>01288 <span class="preprocessor"></span> <a name="l01291"></a><a class="code" href="group__NIFTI1__UNITS.html#gae1126a70acd21a99d7748c7ee9f877a8">01291</a> <span class="preprocessor">#define NIFTI_UNITS_SEC 8</span> <a name="l01292"></a>01292 <span class="preprocessor"></span> <a name="l01293"></a><a class="code" href="group__NIFTI1__UNITS.html#ga3a890f2c798b2aa7853135e4c9b03113">01293</a> <span class="preprocessor">#define NIFTI_UNITS_MSEC 16</span> <a name="l01294"></a>01294 <span class="preprocessor"></span> <a name="l01295"></a><a class="code" href="group__NIFTI1__UNITS.html#ga17714a9f67cbf27371ee9dda4a046942">01295</a> <span class="preprocessor">#define NIFTI_UNITS_USEC 24</span> <a name="l01296"></a>01296 <span class="preprocessor"></span> <a name="l01297"></a>01297 <span class="comment">/*** These units are for spectral data: ***/</span> <a name="l01299"></a><a class="code" href="group__NIFTI1__UNITS.html#ga3f82832f715abf1f8afeebe900bd2f19">01299</a> <span class="preprocessor">#define NIFTI_UNITS_HZ 32</span> <a name="l01300"></a>01300 <span class="preprocessor"></span> <a name="l01301"></a><a class="code" href="group__NIFTI1__UNITS.html#ga56bb7231fda9e33cbe20df645c6c0f13">01301</a> <span class="preprocessor">#define NIFTI_UNITS_PPM 40</span> <a name="l01302"></a>01302 <span class="preprocessor"></span> <a name="l01303"></a><a class="code" href="group__NIFTI1__UNITS.html#ga23156c7a00356dd9896d509a0b9a5c93">01303</a> <span class="preprocessor">#define NIFTI_UNITS_RADS 48</span> <a name="l01304"></a>01304 <span class="preprocessor"></span><span class="comment">/* @} */</span> <a name="l01305"></a>01305 <a name="l01306"></a>01306 <span class="preprocessor">#undef XYZT_TO_SPACE</span> <a name="l01307"></a>01307 <span class="preprocessor"></span><span class="preprocessor">#undef XYZT_TO_TIME</span> <a name="l01308"></a>01308 <span class="preprocessor"></span><span class="preprocessor">#define XYZT_TO_SPACE(xyzt) ( (xyzt) & 0x07 )</span> <a name="l01309"></a>01309 <span class="preprocessor"></span><span class="preprocessor">#define XYZT_TO_TIME(xyzt) ( (xyzt) & 0x38 )</span> <a name="l01310"></a>01310 <span class="preprocessor"></span> <a name="l01311"></a>01311 <span class="preprocessor">#undef SPACE_TIME_TO_XYZT</span> <a name="l01312"></a>01312 <span class="preprocessor"></span><span class="preprocessor">#define SPACE_TIME_TO_XYZT(ss,tt) ( (((char)(ss)) & 0x07) \</span> <a name="l01313"></a>01313 <span class="preprocessor"> | (((char)(tt)) & 0x38) )</span> <a name="l01314"></a>01314 <span class="preprocessor"></span> <a name="l01315"></a>01315 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l01316"></a>01316 <span class="comment">/* MRI-SPECIFIC SPATIAL AND TEMPORAL INFORMATION:</span> <a name="l01317"></a>01317 <span class="comment"> ---------------------------------------------</span> <a name="l01318"></a>01318 <span class="comment"> A few fields are provided to store some extra information</span> <a name="l01319"></a>01319 <span class="comment"> that is sometimes important when storing the image data</span> <a name="l01320"></a>01320 <span class="comment"> from an FMRI time series experiment. (After processing such</span> <a name="l01321"></a>01321 <span class="comment"> data into statistical images, these fields are not likely</span> <a name="l01322"></a>01322 <span class="comment"> to be useful.)</span> <a name="l01323"></a>01323 <span class="comment"></span> <a name="l01324"></a>01324 <span class="comment"> { freq_dim } = These fields encode which spatial dimension (1,2, or 3)</span> <a name="l01325"></a>01325 <span class="comment"> { phase_dim } = corresponds to which acquisition dimension for MRI data.</span> <a name="l01326"></a>01326 <span class="comment"> { slice_dim } =</span> <a name="l01327"></a>01327 <span class="comment"> Examples:</span> <a name="l01328"></a>01328 <span class="comment"> Rectangular scan multi-slice EPI:</span> <a name="l01329"></a>01329 <span class="comment"> freq_dim = 1 phase_dim = 2 slice_dim = 3 (or some permutation)</span> <a name="l01330"></a>01330 <span class="comment"> Spiral scan multi-slice EPI:</span> <a name="l01331"></a>01331 <span class="comment"> freq_dim = phase_dim = 0 slice_dim = 3</span> <a name="l01332"></a>01332 <span class="comment"> since the concepts of frequency- and phase-encoding directions</span> <a name="l01333"></a>01333 <span class="comment"> don't apply to spiral scan</span> <a name="l01334"></a>01334 <span class="comment"></span> <a name="l01335"></a>01335 <span class="comment"> slice_duration = If this is positive, AND if slice_dim is nonzero,</span> <a name="l01336"></a>01336 <span class="comment"> indicates the amount of time used to acquire 1 slice.</span> <a name="l01337"></a>01337 <span class="comment"> slice_duration*dim[slice_dim] can be less than pixdim[4]</span> <a name="l01338"></a>01338 <span class="comment"> with a clustered acquisition method, for example.</span> <a name="l01339"></a>01339 <span class="comment"></span> <a name="l01340"></a>01340 <span class="comment"> slice_code = If this is nonzero, AND if slice_dim is nonzero, AND</span> <a name="l01341"></a>01341 <span class="comment"> if slice_duration is positive, indicates the timing</span> <a name="l01342"></a>01342 <span class="comment"> pattern of the slice acquisition. The following codes</span> <a name="l01343"></a>01343 <span class="comment"> are defined:</span> <a name="l01344"></a>01344 <span class="comment"> NIFTI_SLICE_SEQ_INC == sequential increasing</span> <a name="l01345"></a>01345 <span class="comment"> NIFTI_SLICE_SEQ_DEC == sequential decreasing</span> <a name="l01346"></a>01346 <span class="comment"> NIFTI_SLICE_ALT_INC == alternating increasing</span> <a name="l01347"></a>01347 <span class="comment"> NIFTI_SLICE_ALT_DEC == alternating decreasing</span> <a name="l01348"></a>01348 <span class="comment"> NIFTI_SLICE_ALT_INC2 == alternating increasing #2</span> <a name="l01349"></a>01349 <span class="comment"> NIFTI_SLICE_ALT_DEC2 == alternating decreasing #2</span> <a name="l01350"></a>01350 <span class="comment"> { slice_start } = Indicates the start and end of the slice acquisition</span> <a name="l01351"></a>01351 <span class="comment"> { slice_end } = pattern, when slice_code is nonzero. These values</span> <a name="l01352"></a>01352 <span class="comment"> are present to allow for the possible addition of</span> <a name="l01353"></a>01353 <span class="comment"> "padded" slices at either end of the volume, which</span> <a name="l01354"></a>01354 <span class="comment"> don't fit into the slice timing pattern. If there</span> <a name="l01355"></a>01355 <span class="comment"> are no padding slices, then slice_start=0 and</span> <a name="l01356"></a>01356 <span class="comment"> slice_end=dim[slice_dim]-1 are the correct values.</span> <a name="l01357"></a>01357 <span class="comment"> For these values to be meaningful, slice_start must</span> <a name="l01358"></a>01358 <span class="comment"> be non-negative and slice_end must be greater than</span> <a name="l01359"></a>01359 <span class="comment"> slice_start. Otherwise, they should be ignored.</span> <a name="l01360"></a>01360 <span class="comment"></span> <a name="l01361"></a>01361 <span class="comment"> The following table indicates the slice timing pattern, relative to</span> <a name="l01362"></a>01362 <span class="comment"> time=0 for the first slice acquired, for some sample cases. Here,</span> <a name="l01363"></a>01363 <span class="comment"> dim[slice_dim]=7 (there are 7 slices, labeled 0..6), slice_duration=0.1,</span> <a name="l01364"></a>01364 <span class="comment"> and slice_start=1, slice_end=5 (1 padded slice on each end).</span> <a name="l01365"></a>01365 <span class="comment"></span> <a name="l01366"></a>01366 <span class="comment"> slice</span> <a name="l01367"></a>01367 <span class="comment"> index SEQ_INC SEQ_DEC ALT_INC ALT_DEC ALT_INC2 ALT_DEC2</span> <a name="l01368"></a>01368 <span class="comment"> 6 : n/a n/a n/a n/a n/a n/a n/a = not applicable</span> <a name="l01369"></a>01369 <span class="comment"> 5 : 0.4 0.0 0.2 0.0 0.4 0.2 (slice time offset</span> <a name="l01370"></a>01370 <span class="comment"> 4 : 0.3 0.1 0.4 0.3 0.1 0.0 doesn't apply to</span> <a name="l01371"></a>01371 <span class="comment"> 3 : 0.2 0.2 0.1 0.1 0.3 0.3 slices outside</span> <a name="l01372"></a>01372 <span class="comment"> 2 : 0.1 0.3 0.3 0.4 0.0 0.1 the range</span> <a name="l01373"></a>01373 <span class="comment"> 1 : 0.0 0.4 0.0 0.2 0.2 0.4 slice_start ..</span> <a name="l01374"></a>01374 <span class="comment"> 0 : n/a n/a n/a n/a n/a n/a slice_end)</span> <a name="l01375"></a>01375 <span class="comment"></span> <a name="l01376"></a>01376 <span class="comment"> The SEQ slice_codes are sequential ordering (uncommon but not unknown),</span> <a name="l01377"></a>01377 <span class="comment"> either increasing in slice number or decreasing (INC or DEC), as</span> <a name="l01378"></a>01378 <span class="comment"> illustrated above.</span> <a name="l01379"></a>01379 <span class="comment"></span> <a name="l01380"></a>01380 <span class="comment"> The ALT slice codes are alternating ordering. The 'standard' way for</span> <a name="l01381"></a>01381 <span class="comment"> these to operate (without the '2' on the end) is for the slice timing</span> <a name="l01382"></a>01382 <span class="comment"> to start at the edge of the slice_start .. slice_end group (at slice_start</span> <a name="l01383"></a>01383 <span class="comment"> for INC and at slice_end for DEC). For the 'ALT_*2' slice_codes, the</span> <a name="l01384"></a>01384 <span class="comment"> slice timing instead starts at the first slice in from the edge (at</span> <a name="l01385"></a>01385 <span class="comment"> slice_start+1 for INC2 and at slice_end-1 for DEC2). This latter</span> <a name="l01386"></a>01386 <span class="comment"> acquisition scheme is found on some Siemens scanners.</span> <a name="l01387"></a>01387 <span class="comment"></span> <a name="l01388"></a>01388 <span class="comment"> The fields freq_dim, phase_dim, slice_dim are all squished into the single</span> <a name="l01389"></a>01389 <span class="comment"> byte field dim_info (2 bits each, since the values for each field are</span> <a name="l01390"></a>01390 <span class="comment"> limited to the range 0..3). This unpleasantness is due to lack of space</span> <a name="l01391"></a>01391 <span class="comment"> in the 348 byte allowance.</span> <a name="l01392"></a>01392 <span class="comment"></span> <a name="l01393"></a>01393 <span class="comment"> The macros DIM_INFO_TO_FREQ_DIM, DIM_INFO_TO_PHASE_DIM, and</span> <a name="l01394"></a>01394 <span class="comment"> DIM_INFO_TO_SLICE_DIM can be used to extract these values from the</span> <a name="l01395"></a>01395 <span class="comment"> dim_info byte.</span> <a name="l01396"></a>01396 <span class="comment"></span> <a name="l01397"></a>01397 <span class="comment"> The macro FPS_INTO_DIM_INFO can be used to put these 3 values</span> <a name="l01398"></a>01398 <span class="comment"> into the dim_info byte.</span> <a name="l01399"></a>01399 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l01400"></a>01400 <a name="l01401"></a>01401 <span class="preprocessor">#undef DIM_INFO_TO_FREQ_DIM</span> <a name="l01402"></a>01402 <span class="preprocessor"></span><span class="preprocessor">#undef DIM_INFO_TO_PHASE_DIM</span> <a name="l01403"></a>01403 <span class="preprocessor"></span><span class="preprocessor">#undef DIM_INFO_TO_SLICE_DIM</span> <a name="l01404"></a>01404 <span class="preprocessor"></span> <a name="l01405"></a>01405 <span class="preprocessor">#define DIM_INFO_TO_FREQ_DIM(di) ( ((di) ) & 0x03 )</span> <a name="l01406"></a>01406 <span class="preprocessor"></span><span class="preprocessor">#define DIM_INFO_TO_PHASE_DIM(di) ( ((di) >> 2) & 0x03 )</span> <a name="l01407"></a>01407 <span class="preprocessor"></span><span class="preprocessor">#define DIM_INFO_TO_SLICE_DIM(di) ( ((di) >> 4) & 0x03 )</span> <a name="l01408"></a>01408 <span class="preprocessor"></span> <a name="l01409"></a>01409 <span class="preprocessor">#undef FPS_INTO_DIM_INFO</span> <a name="l01410"></a>01410 <span class="preprocessor"></span><span class="preprocessor">#define FPS_INTO_DIM_INFO(fd,pd,sd) ( ( ( ((char)(fd)) & 0x03) ) | \</span> <a name="l01411"></a>01411 <span class="preprocessor"> ( ( ((char)(pd)) & 0x03) << 2 ) | \</span> <a name="l01412"></a>01412 <span class="preprocessor"> ( ( ((char)(sd)) & 0x03) << 4 ) )</span> <a name="l01413"></a>01413 <span class="preprocessor"></span> <a name="l01419"></a>01419 <span class="preprocessor">#define NIFTI_SLICE_UNKNOWN 0</span> <a name="l01420"></a>01420 <span class="preprocessor"></span><span class="preprocessor">#define NIFTI_SLICE_SEQ_INC 1</span> <a name="l01421"></a>01421 <span class="preprocessor"></span><span class="preprocessor">#define NIFTI_SLICE_SEQ_DEC 2</span> <a name="l01422"></a>01422 <span class="preprocessor"></span><span class="preprocessor">#define NIFTI_SLICE_ALT_INC 3</span> <a name="l01423"></a>01423 <span class="preprocessor"></span><span class="preprocessor">#define NIFTI_SLICE_ALT_DEC 4</span> <a name="l01424"></a>01424 <span class="preprocessor"></span><span class="preprocessor">#define NIFTI_SLICE_ALT_INC2 5 </span><span class="comment">/* 05 May 2005: RWCox */</span> <a name="l01425"></a>01425 <span class="preprocessor">#define NIFTI_SLICE_ALT_DEC2 6 </span><span class="comment">/* 05 May 2005: RWCox */</span> <a name="l01426"></a>01426 <span class="comment">/* @} */</span> <a name="l01427"></a>01427 <a name="l01428"></a>01428 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l01429"></a>01429 <span class="comment">/* UNUSED FIELDS:</span> <a name="l01430"></a>01430 <span class="comment"> -------------</span> <a name="l01431"></a>01431 <span class="comment"> Some of the ANALYZE 7.5 fields marked as ++UNUSED++ may need to be set</span> <a name="l01432"></a>01432 <span class="comment"> to particular values for compatibility with other programs. The issue</span> <a name="l01433"></a>01433 <span class="comment"> of interoperability of ANALYZE 7.5 files is a murky one -- not all</span> <a name="l01434"></a>01434 <span class="comment"> programs require exactly the same set of fields. (Unobscuring this</span> <a name="l01435"></a>01435 <span class="comment"> murkiness is a principal motivation behind NIFTI-1.)</span> <a name="l01436"></a>01436 <span class="comment"></span> <a name="l01437"></a>01437 <span class="comment"> Some of the fields that may need to be set for other (non-NIFTI aware)</span> <a name="l01438"></a>01438 <span class="comment"> software to be happy are:</span> <a name="l01439"></a>01439 <span class="comment"></span> <a name="l01440"></a>01440 <span class="comment"> extents dbh.h says this should be 16384</span> <a name="l01441"></a>01441 <span class="comment"> regular dbh.h says this should be the character 'r'</span> <a name="l01442"></a>01442 <span class="comment"> glmin, } dbh.h says these values should be the min and max voxel</span> <a name="l01443"></a>01443 <span class="comment"> glmax } values for the entire dataset</span> <a name="l01444"></a>01444 <span class="comment"></span> <a name="l01445"></a>01445 <span class="comment"> It is best to initialize ALL fields in the NIFTI-1 header to 0</span> <a name="l01446"></a>01446 <span class="comment"> (e.g., with calloc()), then fill in what is needed.</span> <a name="l01447"></a>01447 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l01448"></a>01448 <a name="l01449"></a>01449 <span class="comment">/*---------------------------------------------------------------------------*/</span> <a name="l01450"></a>01450 <span class="comment">/* MISCELLANEOUS C MACROS</span> <a name="l01451"></a>01451 <span class="comment">-----------------------------------------------------------------------------*/</span> <a name="l01452"></a>01452 <a name="l01453"></a>01453 <span class="comment">/*.................*/</span> <a name="l01457"></a><a class="code" href="nifti1_8h.html#aab4f74084b6e622a911afd7dd637be7d">01457</a> <span class="preprocessor">#define NIFTI_VERSION(h) \</span> <a name="l01458"></a>01458 <span class="preprocessor"> ( ( (h).magic[0]=='n' && (h).magic[3]=='\0' && \</span> <a name="l01459"></a>01459 <span class="preprocessor"> ( (h).magic[1]=='i' || (h).magic[1]=='+' ) && \</span> <a name="l01460"></a>01460 <span class="preprocessor"> ( (h).magic[2]>='1' && (h).magic[2]<='9' ) ) \</span> <a name="l01461"></a>01461 <span class="preprocessor"> ? (h).magic[2]-'0' : 0 )</span> <a name="l01462"></a>01462 <span class="preprocessor"></span> <a name="l01463"></a>01463 <span class="comment">/*.................*/</span> <a name="l01468"></a><a class="code" href="nifti1_8h.html#a52a7c735335bcc8afa6bb6f096ce7cb7">01468</a> <span class="preprocessor">#define NIFTI_ONEFILE(h) ( (h).magic[1] == '+' )</span> <a name="l01469"></a>01469 <span class="preprocessor"></span> <a name="l01470"></a>01470 <span class="comment">/*.................*/</span> <a name="l01474"></a><a class="code" href="nifti1_8h.html#a12e8b5fe9240bf3db30d520a5240381f">01474</a> <span class="preprocessor">#define NIFTI_NEEDS_SWAP(h) ( (h).dim[0] < 0 || (h).dim[0] > 7 )</span> <a name="l01475"></a>01475 <span class="preprocessor"></span> <a name="l01476"></a>01476 <span class="comment">/*.................*/</span> <a name="l01480"></a><a class="code" href="nifti1_8h.html#ada727dd45bee2e85ce735d72e0f7daec">01480</a> <span class="preprocessor">#define NIFTI_5TH_DIM(h) ( ((h).dim[0]>4 && (h).dim[5]>1) ? (h).dim[5] : 0 )</span> <a name="l01481"></a>01481 <span class="preprocessor"></span> <a name="l01482"></a>01482 <span class="comment">/*****************************************************************************/</span> <a name="l01483"></a>01483 <a name="l01484"></a>01484 <span class="comment">/*=================*/</span> <a name="l01485"></a>01485 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l01486"></a>01486 <span class="preprocessor"></span>} <a name="l01487"></a>01487 <span class="preprocessor">#endif</span> <a name="l01488"></a>01488 <span class="preprocessor"></span><span class="comment">/*=================*/</span> <a name="l01489"></a>01489 <a name="l01490"></a>01490 <span class="preprocessor">#endif </span><span class="comment">/* _NIFTI_HEADER_ */</span> </pre></div></div> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Defines</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <hr class="footer"/><address class="footer"><small>Generated on Tue Jul 26 2011 for nifti1_io 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>