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
Name | Data type | Bytes |
Comment |
id_string[6] | char | 6 |
ID string for track file. The first 5 characters must be "TRACK". |
dim[3] | short int | 6 |
Dimension of the image volume. |
voxel_size[3] | float | 12 |
Voxel size of the image volume. |
origin[3] | float | 12 |
Origin of the image volume. This field is not yet being used by TrackVis. That means the origin is always (0, 0, 0). |
n_scalars | short int | 2 |
Number of scalars saved at each track point (besides x, y and z coordinates). |
scalar_name[10][20] | char | 200 |
Name of each scalar. Can not be longer than 20 characters each. Can only store up to 10 names. |
n_properties | short int | 2 |
Number of properties saved at each track. |
property_name[10][20] | char | 200 |
Name of each property. Can not be longer than 20 characters each. Can only store up to 10 names. |
vox_to_ras[4][4] | float | 64 |
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] | char | 444 |
Reserved space for future version. |
voxel_order[4] | char | 4 |
Storing order of the original image data. Explained here. |
pad2[4] | char | 4 |
Paddings. |
image_orientation_patient[6] | float | 24 |
Image orientation of the original image. As defined in the DICOM header. |
pad1[2] | char | 2 |
Paddings. |
invert_x | unsigned char | 1 |
Inversion/rotation flags used to generate this track file. For internal use only. |
invert_y | unsigned char | 1 |
As above. |
invert_x | unsigned char | 1 |
As above. |
swap_xy | unsigned char | 1 |
As above. |
swap_yz | unsigned char | 1 |
As above. |
swap_zx | unsigned char | 1 |
As above. |
n_count | int | 4 |
Number of tracks stored in this track file. 0 means the number was NOT stored. |
version | int | 4 |
Version number. Current version is 2. |
hdr_size | int | 4 |
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.
Track | Data type | Bytes |
Comment |
Track #1 | int | 4 |
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. |
float | n_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.