class_docstr: Convenience class to encapsulate TRK file format.
  
  Notes
  -----
  TrackVis (so its file format: TRK) considers the streamline coordinate
  (0,0,0) to be in the corner of the voxel whereas NiBabel's streamlines
  internal representation (Voxel space) assumes (0,0,0) to be in the
  center of the voxel.
  
  Thus, streamlines are shifted by half a voxel on load and are shifted
  back on save.
docstr: Gets a formatted string of the header of a TRK file.
  
  Returns
  -------
  info : string
      Header information relevant to the TRK format.
docstr_tok: ["Gets","a","formatted","string","of","the","header","of","a","TRK","file",".","Returns","--","--","--","-","info",":","string","Header","information","relevant","to","the","TRK","format","."]
code: def __str__(self):
      """Gets a formatted string of the header of a TRK file.
  
      Returns
      -------
      info : string
          Header information relevant to the TRK format.
      """
      vars = self.header.copy()
      for attr in dir(Field):
          if attr[0] in string.ascii_uppercase:
              hdr_field = getattr(Field, attr)
              if hdr_field in vars:
                  vars[attr] = vars[hdr_field]
  
      nb_scalars = self.header[Field.NB_SCALARS_PER_POINT]
      scalar_names = [
          s.decode("latin-1")
          for s in vars["scalar_name"][:nb_scalars]
          if len(s) > 0
      ]
      vars["scalar_names"] = "\n  ".join(scalar_names)
      nb_properties = self.header[Field.NB_PROPERTIES_PER_STREAMLINE]
      property_names = [
          s.decode("latin-1")
          for s in vars["property_name"][:nb_properties]
          if len(s) > 0
      ]
      vars["property_names"] = "\n  ".join(property_names)
      # Make all byte strings into strings
      # Fixes recursion error on Python 3.3
      vars = {
          k: v.decode("latin-1") if hasattr(v, "decode") else v
          for k, v in vars.items()
      }
      return """\
  MAGIC NUMBER: {MAGIC_NUMBER}
  v.{version}
  dim: {DIMENSIONS}
  voxel_sizes: {VOXEL_SIZES}
  origin: {ORIGIN}
  nb_scalars: {NB_SCALARS_PER_POINT}
  scalar_names:\n  {scalar_names}
  nb_properties: {NB_PROPERTIES_PER_STREAMLINE}
  property_names:\n  {property_names}
  vox_to_world:\n{VOXEL_TO_RASMM}
  voxel_order: {VOXEL_ORDER}
  image_orientation_patient: {image_orientation_patient}
  pad1: {pad1}
  pad2: {pad2}
  invert_x: {invert_x}
  invert_y: {invert_y}
  invert_z: {invert_z}
  swap_xy: {swap_xy}
  swap_yz: {swap_yz}
  swap_zx: {swap_zx}
  n_count: {NB_STREAMLINES}
  hdr_size: {hdr_size}""".format(
          **vars
      )
  
imports: import os
  import string
  import struct
  import warnings
  import numpy
  import nibabel
  from nibabel.openers import Opener
  from nibabel.orientations import aff2axcodes, axcodes2ornt
  from nibabel.volumeutils import endian_codes, native_code, swapped_code
  from .array_sequence import create_arraysequences_from_generator
  from .header import Field
  from .tractogram import LazyTractogram, Tractogram, TractogramItem
  from .tractogram_file import DataError, HeaderError, HeaderWarning, TractogramFile
  from .utils import peek_next
label_desc: Use image node_id 9 for calling the TrkFile obj's underlying member method code with example usage: obj.__str__() and returns: str