NiBabel

Access a cacophony of neuro-imaging file formats

Previous topic

nibabel.trackvis.TrackvisFile

Next topic

nibabel.eulerangles

Reggie -- the one

nibabel.trackvis.TrackvisFile

digraph inheritance456d7918c0 { rankdir=LR; ratio=compress; fontsize=14; size="6.0, 8.0"; "TrackvisFile" [shape=ellipse,URL="#nibabel.trackvis.TrackvisFile",fontname=Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans,fontsize=14,color=dodgerblue1,style=filled,height=0.75]; }

class nibabel.trackvis.TrackvisFile(streamlines, mapping=None, endianness=None, filename=None, points_space=None, affine=None)

Convenience class to encapsulate trackvis file information

Parameters :

streamlines : sequence

sequence of streamlines. This object does not accept generic iterables as input because these can be consumed and make the object unusable. Please use the function interface to work with generators / iterables

mapping : None or mapping

Mapping defining header attributes

endianness : {None, ‘<’, ‘>’}

Set here explicit endianness if required. Endianness otherwise inferred from streamlines

filename : None or str, optional

filename

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

Space in which streamline points are expressed in memory. Default (None) means streamlines contain points in trackvis voxmm space (voxel positions * voxel sizes). ‘voxel’ means points are in voxel space (and need to be multiplied by voxel size for saving in file). ‘rasmm’ mean the points are expressed in mm space according to the affine. See read and write function docstrings for more detail.

affine : None or (4,4) ndarray, optional

Affine expressing relationship of voxels in an image to mm in RAS mm space. If ‘points_space’ is not None, you can use this to give the relationship between voxels, rasmm and voxmm space (above).

classmethod from_file(klass, file_like, points_space=None)
get_affine(atleast_v2=None)

Get affine from header in object

Returns :

aff : (4,4) ndarray

affine from header

atleast_v2 : None or bool, optional

See aff_from_hdr docstring for detail. If True, require valid affine in vox_to_ras field of header.

Notes

This method currently works for trackvis version 1 headers, but we consider it unsafe for version 1 headers, and in future versions of nibabel we will raise an error for trackvis headers < version 2.

set_affine(affine, pos_vox=None, set_order=None)

Set affine affine into trackvis header

Affine is mapping from voxel space to Nifti RAS) output coordinate system convention; x: Left -> Right, y: Posterior -> Anterior, z: Inferior -> Superior. Sets affine if possible, and voxel sizes, and voxel axis ordering.

Parameters :

affine : (4,4) array-like

Affine voxel to mm transformation

pos_vos : None or bool, optional

If None, currently defaults to False - this will change in future versions of nibabel. If False, allow negative voxel sizes in header to record axis flips. Negative voxels cause problems for trackvis (the application). If True, enforce positive voxel sizes.

set_order : None or bool, optional

If None, currently defaults to False - this will change in future versions of nibabel. If False, do not set voxel_order field in trk_hdr. If True, calculcate voxel_order from affine and set into trk_hdr.

Returns :

None :

to_file(file_like)