class_docstr: Convenience class to encapsulate TCK file format.
  
  Notes
  -----
  MRtrix (so its file format: TCK) considers streamlines coordinates
  to be in world space (RAS+ and mm space). MRtrix refers to that space
  as the "real" or "scanner" space [#]_.
  
  Moreover, when streamlines are mapped back to voxel space [#]_, a
  streamline point located at an integer coordinate (i,j,k) is considered
  to be at the center of the corresponding voxel. This is in contrast with
  TRK's internal convention where it would have referred to a corner.
  
  NiBabel's streamlines internal representation follows the same
  convention as MRtrix.
  
  .. [#] http://www.nitrc.org/pipermail/mrtrix-discussion/2014-January/000859.html
  .. [#] http://nipy.org/nibabel/coordinate_systems.html#voxel-coordinates-are-in-voxel-space
class_docstr_tok: ["Convenience","class","to","encapsulate","TCK","file","format",".","Notes","--","--","-","MRtrix","(","so","its","file","format",":","TCK",")","considers","streamlines","coordinates","to","be","in","world","space","(","RAS+","and","mm","space",")",".","MRtrix","refers","to","that","space","as","the","``","real","''","or","``","scanner","''","space","[","#","]","_",".","Moreover",",","when","streamlines","are","mapped","back","to","voxel","space","[","#","]","_",",","a","streamline","point","located","at","an","integer","coordinate","(","i",",","j",",","k",")","is","considered","to","be","at","the","center","of","the","corresponding","voxel",".","This","is","in","contrast","with","TRK","'s","internal","convention","where","it","would","have","referred","to","a","corner",".","NiBabel","'s","streamlines","internal","representation","follows","the","same","convention","as","MRtrix",".","..","[","#","]","http",":","\/\/www.nitrc.org\/pipermail\/mrtrix-discussion\/2014-January\/000859.html","..","[","#","]","http",":","\/\/nipy.org\/nibabel\/coordinate_systems.html","#","voxel-coordinates-are-in-voxel-space"]
docstr: Loads streamlines from a filename or file-like object.
  
  Parameters
  ----------
  fileobj : string or file-like object
      If string, a filename; otherwise an open file-like object in
      binary mode pointing to TCK file (and ready to read from the
      beginning of the TCK header). Note that calling this function
      does not change the file position.
  lazy_load : {False, True}, optional
      If True, load streamlines in a lazy manner i.e. they will not be
      kept in memory. Otherwise, load all streamlines in memory.
  
  Returns
  -------
  tck_file : :class:`TckFile` object
      Returns an object containing tractogram data and header
      information.
  
  Notes
  -----
  Streamlines of the tractogram are assumed to be in *RAS+* and *mm*
  space. It is also assumed that when streamlines are mapped back to
  voxel space, a streamline point located at an integer coordinate
  (i,j,k) is considered to be at the center of the corresponding voxel.
  This is in contrast with TRK's internal convention where it would
  have referred to a corner.
docstr_tok: ["Loads","streamlines","from","a","filename","or","file-like","object",".","Parameters","--","--","--","--","--","fileobj",":","string","or","file-like","object","If","string",",","a","filename",";","otherwise","an","open","file-like","object","in","binary","mode","pointing","to","TCK","file","(","and","ready","to","read","from","the","beginning","of","the","TCK","header",")",".","Note","that","calling","this","function","does","not","change","the","file","position",".","lazy_load",":","{","False",",","True","}",",","optional","If","True",",","load","streamlines","in","a","lazy","manner","i.e",".","they","will","not","be","kept","in","memory",".","Otherwise",",","load","all","streamlines","in","memory",".","Returns","--","--","--","-","tck_file",":",":","class",":","`","TckFile","`","object","Returns","an","object","containing","tractogram","data","and","header","information",".","Notes","--","--","-","Streamlines","of","the","tractogram","are","assumed","to","be","in","*","RAS+","*","and","*","mm","*","space",".","It","is","also","assumed","that","when","streamlines","are","mapped","back","to","voxel","space",",","a","streamline","point","located","at","an","integer","coordinate","(","i",",","j",",","k",")","is","considered","to","be","at","the","center","of","the","corresponding","voxel",".","This","is","in","contrast","with","TRK","'s","internal","convention","where","it","would","have","referred","to","a","corner","."]
code: def load(cls, fileobj, lazy_load=False):
      """Loads streamlines from a filename or file-like object.
  
      Parameters
      ----------
      fileobj : string or file-like object
          If string, a filename; otherwise an open file-like object in
          binary mode pointing to TCK file (and ready to read from the
          beginning of the TCK header). Note that calling this function
          does not change the file position.
      lazy_load : {False, True}, optional
          If True, load streamlines in a lazy manner i.e. they will not be
          kept in memory. Otherwise, load all streamlines in memory.
  
      Returns
      -------
      tck_file : :class:`TckFile` object
          Returns an object containing tractogram data and header
          information.
  
      Notes
      -----
      Streamlines of the tractogram are assumed to be in *RAS+* and *mm*
      space. It is also assumed that when streamlines are mapped back to
      voxel space, a streamline point located at an integer coordinate
      (i,j,k) is considered to be at the center of the corresponding voxel.
      This is in contrast with TRK's internal convention where it would
      have referred to a corner.
      """
      hdr = cls._read_header(fileobj)
  
      if lazy_load:
  
          def _read():
              for pts in cls._read(fileobj, hdr):
                  yield TractogramItem(pts, {}, {})
  
          tractogram = LazyTractogram.from_data_func(_read)
  
      else:
          tck_reader = cls._read(fileobj, hdr)
          streamlines = ArraySequence(tck_reader)
          tractogram = Tractogram(streamlines)
  
      # By definition.
      tractogram.affine_to_rasmm = np.eye(4)
      hdr[Field.VOXEL_TO_RASMM] = np.eye(4)
  
      return cls(tractogram, header=hdr)
  
imports: import os
  import warnings
  from contextlib import suppress
  import numpy
  from nibabel.openers import Opener
  from .array_sequence import ArraySequence
  from .header import Field
  from .tractogram import LazyTractogram, Tractogram, TractogramItem
  from .tractogram_file import DataError, DataWarning, HeaderError, HeaderWarning, TractogramFile
  from .utils import peek_next
label_desc: Use image node_id 4 for calling the TckFile obj's underlying member method code with example usage: obj.load(cls, fileobj, lazy_load) and returns: cls