Anatomy of a BXH file

Here is a sample BXH file that is placed alongside a series of slices in DICOM format. The file is annotated below, and can be seen in its original format at dcm005_00.bxh.

This is the top of a BXH file -- everything except the comment is necessary!

<?xml version="1.0"?>
<!-- This is a BXH (BIAC XML Header) file. -->
<bxh xmlns:bxh="http://www.biac.duke.edu/bxh" xmlns="http://www.biac.duke.edu/bxh" version="1.0">
    

The datarec element describes the properties of the data itself. The type of this datarec is "image". The "orientation" field below is merely informative, and is derived from the "direction" fields, described later.

  <datarec type="image">
    <orientation>oblique axial</orientation>
    

Each "datarec" element will have one or more dimension elements which describe properties of each dimension of the data, including the type ("x" below refers to the first spatial dimension), units, size (i.e. number of values), origin (starting label for first data element/pixel), gap (unsampled space between data points), spacing (distance between [the center of] each value), and for "image" datarecs, a direction which describes the normal vector along this dimension from start to end in RAS patient coordinates.

    <dimension type="x">
      <units>mm</units>
      <size>64</size>
      <origin>120</origin>
      <gap>0</gap>
      <spacing>3.74997</spacing>
      <direction>-1 -0 0</direction>
    </dimension>
    

Further dimensions are described below. Dimensions are ordered from fastest-moving to slowest-moving. In image data, "x", "y", "z", and "t" (with more to be defined) are special and refer to spatial and temporal dimensions. By convention, "x" is the fastest-moving (first) spatial dimension. Note the values in the "direction" elements, they indicate that this image is oblique.

    <dimension type="y">
      <units>mm</units>
      <size>64</size>
      <origin>100.63</origin>
      <gap>0</gap>
      <spacing>3.75</spacing>
      <direction>-0 -0.996927 -0.078342</direction>
    </dimension>
    <dimension type="z">
      <units>mm</units>
      <size>22</size>
      <origin>55.4009</origin>
      <gap>0</gap>
      <spacing>3.8</spacing>
      <direction>0 0.0787025 -0.996898</direction>
    </dimension>
    

byteorder is either "lsbfirst" (little-endian) or "msbfirst" (big-endian). elementtype is of the form [type][bits], such as "int16", "float64", as well as other types like "ascii".

    <byteorder>lsbfirst</byteorder>
    <elementtype>int16</elementtype>
    

Here follows the list of filenames, and file offsets within each file to find the raw data. If "fileoffset" is missing, it is assumed to be 0. "filerecordsize" indicates how much data to read (if missing, read to end of the file).

    <filename>MRSCAN_005_00_00001.dcm</filename>
    <fileoffset>9512</fileoffset>
    <filerecordsize>8192</filerecordsize>
    <filename>MRSCAN_005_00_00002.dcm</filename>
    <fileoffset>9512</fileoffset>
    <filerecordsize>8192</filerecordsize>
    <filename>MRSCAN_005_00_00003.dcm</filename>
    <fileoffset>9512</fileoffset>
    <filerecordsize>8192</filerecordsize>
    ...
    <filename>MRSCAN_005_00_00021.dcm</filename>
    <fileoffset>9512</fileoffset>
    <filerecordsize>8192</filerecordsize>
    <filename>MRSCAN_005_00_00022.dcm</filename>
    <fileoffset>9512</fileoffset>
    <filerecordsize>8192</filerecordsize>
  </datarec>
    

acquisitiondata will provide scanner-related data, including acquisition parameters such as "tr", "te", "fieldofview", and also date and time.

  <acquisitiondata>
    <examnumber>XXXX</examnumber>
    <studyid>XXXXX</studyid>
    <seriesnumber>5</seriesnumber>
    <runnumber>0</runnumber>
    <institution>Duke Univ Med Ctr</institution>
    <magneticfield>1.5</magneticfield>
    <description>Head,Obl,2D,GRE</description>
    <scandate>XXXX-XX-XX</scandate>
    <scantime>09:56:22</scantime>
    <scanner>XXXXX</scanner>
    <fieldofview>240 240</fieldofview>
    <tr>1999.984000</tr>
    <te>40.000000</te>
    <operator>XX</operator>
    <flipangle>30</flipangle>
    <frequencydirection>2</frequencydirection>
    <acquisitionmatrix>64 64</acquisitionmatrix>
    <bandwidth>124</bandwidth>
  </acquisitiondata>
    

subject tells you about the subject who was scanned.

  <subject>
    <name>XXXXX</name>
    <age>0</age>
    <sex>O</sex>
    <weight>82.00</weight>
  </subject>
    

history is intended for recording the data path, such as transformations on this data, and the programs used to generate them.

  <history>
    <date>XXXX-XX-XX 16:44:58</date>
    <description>Generated on xxxx.biac.duke.edu
by 'dicom2bxh'
from DICOM file 'XXXXX'</description>
  </history>
    

This is the end.

</bxh>