File Format

TrackVis deals with 4 types of files.

Track File. Track file (with .trk as filename extention) is the main data file TrackVis program works with. Without a track data file loaded, TrackVis can not perform any of its functionalities. Track file is created by fiber tracking routines included in the Diffusion Toolkit. TrackVis itself does not perform fiber tracking and create track data.

Track file is one single binary file, with the first 1000 bytes as the header and the rest as the body. Detailed format of the header and the body is decribed in the following table.

Content of the header
NameData typeBytes Comment
id_string[6]char6 ID string for track file. The first 5 characters must be "TRACK".
dim[3]short int6 Dimension of the image volume.
voxel_size[3]float12 Voxel size of the image volume.
origin[3]float12 Origin of the image volume. This field is not yet being used by TrackVis. That means the origin is always (0, 0, 0).
n_scalarsshort int2 Number of scalars saved at each track point (besides x, y and z coordinates).
scalar_name[10][20]char200 Name of each scalar. Can not be longer than 20 characters each. Can only store up to 10 names.
n_propertiesshort int2 Number of properties saved at each track.
property_name[10][20]char200 Name of each property. Can not be longer than 20 characters each. Can only store up to 10 names.
vox_to_ras[4][4]float64 4x4 matrix for voxel to RAS (crs to xyz) transformation. If vox_to_ras[3][3] is 0, it means the matrix is not recorded. This field is added from version 2.
reserved[444]char444 Reserved space for future version.
voxel_order[4]char4 Storing order of the original image data. Explained here.
pad2[4]char4 Paddings.
image_orientation_patient[6]float24 Image orientation of the original image. As defined in the DICOM header.
pad1[2]char2 Paddings.
invert_xunsigned char1 Inversion/rotation flags used to generate this track file. For internal use only.
invert_yunsigned char1 As above.
invert_xunsigned char1 As above.
swap_xyunsigned char1 As above.
swap_yzunsigned char1 As above.
swap_zxunsigned char1 As above.
n_countint4 Number of tracks stored in this track file. 0 means the number was NOT stored.
versionint4 Version number. Current version is 2.
hdr_sizeint4 Size of the header. Used to determine byte swap. Should be 1000.

Quick Q&A
What is the difference of scalar and property?
Scalar is associated with each track point, i.e., each point on a track has its own scalar, such as diffusivity at each point. Property is associated with a whole track, such as length, mean scalar. Scalar and property are designed for advanced and future extension of track file format. In most cases at this point, there is no scalar or property stored in the track file, i.e., n_scalars = 0 and n_properties = 0.

To better explain the format of the body, let's assume n is the total number of tracks, n_s is the number of scalars and n_p is the number of properties. The content of the body is formed as the following table.

TrackData typeBytes Comment
Track #1int4 Number of points in this track, as m.
float(3+n_s)*4 Track Point #1. Contains 3 plus n_s float numbers. First 3 float numbers are the x/y/z coordinate of this track point, followed by n_s float numbers representing each of its scalars.
float(3+n_s)*4 Track Point #2. Same as above.
...... ...
float(3+n_s)*4 Track Point #m. Same as above.
floatn_p*4 n_p float numbers representing each of the properties of this track.
Track #2    Same as above.

...    Same as above.

Track #n    Same as above.

Image File. TrackVis takes standard Nifti or ANALYZE file (with .nii, .hdr or .img as filename extention) as the image file for slice image display.

ROI File. TrackVis saves and loads hand-drawn ROI as an ROI file, also in standard Nifti or ANALYZE format.

Scene File. A scene of the render window, including every existing objects and light and camera information, can be saved in a Scene file (with .scene as filename extention). Scene file is stored as an XML text file and can be loaded back to recreate the scene. Please note, a scene file contains only the description of the scene, it does not contain the actually data. So the date files (i.e., track file, image and/or ROI files, etc) are still needed to recreate the scene.

You should not modify scene file manually unless necessary.