Skip to content

TMI Neuroimaging File Format

trislett edited this page Aug 31, 2017 · 10 revisions

The TMI (TFCE_mediation Image) File Format

Basic Description and Motivation:

TMI (TFCE_mediation Image) is a neuroimaging file format. It designed for group level and multimodal analyses using voxel based images (e.g. Nifti), and surface based images (e.g., Freesurfer MGH). The TMI file format is a very fast, space conscious, and expandable (i.e., other object/properties could be incorporated such as graph metrics). It is similar to the PLY (file format). Currently, a variety of object/properties can be incorporated into a single file including:

(1) Voxel or Vertex data, (2) Masks, (3) Affines, (4) Triangular meshes / surfaces , (5) Adjacency sets, and (6) Subject/contrast names.

Importantly, the objects are kept in same standard space regardless of the object type. Furthermore, TMI files record history of any action on the files so any manipulation or analyses are date stamped and the file can be 'rolled-back' to an earlier data if necessary. They also has an easily accessible header regardless of the file is in binarized (default) or in ascii format.

The file format

Files are organised as a header, that specifies the elements (data_array, mask, affine, vertex array, face array, adjacency sets) and their sizes and types, followed by the list of elements itself.

The header of both ASCII and binary files is ASCII text. Only the numerical data that follows the header is different between the two versions. The header always starts with a magic number a line containing

tmi

that identifies the file as a TMI file. The second line indicates which variation of the TMI format this is. It should be one of:

format ascii 1.0

format binary_little_endian 1.0

format binary_big_endian 1.0

Comments may be placed in the header.

The 'element' keyword introduces a description of how some particular data element is stored. TMI currently supports the following elements:

data_array: The masked data for all modalities time the number of subjects

element data_array
dtype float32
nbytes n
datashape n (data length) X n (subjects/contrasts)

masking_array: The masks denoting non-zero data for all modalities

element masking_array
dtype uint8 # for binarized masks
nbytes n
nmasked n 
maskshape X Y Z

affine: The 4x4 affine arrays for all the masks

element affine
dtype float32
nbytes n
affineshape X Y

vertex: Nx3 array of vertices

element vertex
dtype float32
nbytes n
vertexshape X Y

face: Nx3 array of faces

element face
dtype uint32
nbytes n
faceshape X Y

adjacency_object: adjacency set for each mask (pickle object)

element adjacency_object 
dtype python_object # these are pickle objects
nbytes n
adjlength n

column_id: list of subjects or contrasts contained in the TMI file

element column_id
dtype str
nbytes n
listlength n

At the end of the header, there must always be the line:

end_header

followed by the binary or ascii formatted data.

ASCII or binary format

In the ASCII version of the format, the array are written out by white space (note, adjacency sets are not support in ASCII formate). In the binary version, the data is simply packed closely together at the 'endianness' specified in the header and with the data types given in the 'property' records of the header.

TMI I/O for python

See tfce_medation/tm_io.py