NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.trackvis.empty_header

Next topic

nibabel.trackvis.write

This Page

Reggie -- the one

nibabel.trackvis.read

nibabel.trackvis.read(fileobj, as_generator=False, points_space=None)

Read trackvis file, return streamlines, header

Parameters :

fileobj : string or file-like object

If string, a filename; otherwise an open file-like object pointing to trackvis file (and ready to read from the beginning of the trackvis header data)

as_generator : bool, optional

Whether to return tracks as sequence (False, default) or as a generator (True).

points_space : {None, ‘voxel’, ‘rasmm’}, optional

The coordinates in which you want the points in the output streamlines expressed. If None, then return the points exactly as they are stored in the trackvis file. The points will probably be in trackviz voxmm space - see Notes for write function. If ‘voxel’, we convert the points to voxel space simply by dividing by the recorded voxel size. If ‘rasmm’ we’ll convert the points to RAS mm space (real space). For ‘rasmm’ we check if the affine is set and matches the voxel sizes and voxel order.

Returns :

streamlines : sequence or generator

Returns sequence if as_generator is False, generator if True. Value is sequence or generator of 3 element sequences with elements:

  1. points : ndarray shape (N,3) where N is the number of points
  2. scalars : None or ndarray shape (N, M) where M is the number of scalars per point
  3. properties : None or ndarray shape (P,) where P is the number of properties

hdr : structured array

structured array with trackvis header fields

Notes

The endianness of the input data can be deduced from the endianness of the returned hdr or streamlines

Points are in trackvis voxel mm. Each track has N points, each with 3 coordinates, x, y, z, where x is the floating point voxel coordinate along the first image axis, multiplied by the voxel size for that axis.