Convert .tex file to .nii for import to TrackVis

AIMS library and commands usage

Moderators: denghien, riviere

Post Reply
robear
Posts: 1
Joined: Fri Jul 04, 2014 9:02 am

Convert .tex file to .nii for import to TrackVis

Post by robear »

Dear BrainVisa users,

I am trying to convert a .tex file from anatomist in to TrackVis.
TrackVis requires a .nii file.

I have tried the commands

Code: Select all

./AimsFileConvert -i ~/Files/example.tex -o ~/Files/example.nii
./AimsFileConvert -i ~/Files/example.tex -o ~/Files/example.nii -e 0 -f NIFTI1
but these export a file labeled example.nii.gii which i can not import.

Is it possible to convert a .tex file to .nii?

Thanks for your help,
Rob
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: Convert .tex file to .nii for import to TrackVis

Post by riviere »

Hi,
This kind of conversion seems a bit inappropriate and is not directly handled: we use .tex files for textures (information mapped on a mesh, on each vertex of a mesh), whereas NIFTI files are used to store volumic information: arrays of voxels, with specified voxels sizes and voxels coordinates. I know some people or tools do use NIFTI files for "raw arrays" but there are more appropriate format for this.
You can use the GIFTI format, which has been designed in the neuroimaging community as a kind of "brother" to the NIFTI format, for meshes and mesh texture information: AimsFileConvert supports the GIFTI format (.gii extension).
I don't exactly know what fotmats does Trackvis support: doesn't it read .gii files ?
If it really requires texture information as NIFTI, then I guess some tools in the community could convert GIFTI to NIFTI... I'm just curious how would Trackvis interpret the information in such files

Otherwise you can also convert it using a home-made script, reading the .tex or .gii data and writing a 1D NIFTI file with arbitrary voxels sizes.
In Pyaims, it would look something like:

Code: Select all

#!/usr/bin/env python

from soma import aims
import numpy as np

texture = aims.read(sys.argv[1])
image = aims.Volume(texture[0].size(), dtype=type(texture[0][0]))

np.asarray(image)[:, 0, 0, 0] = np.asarray(texture[0])

aims.write(image, sys.argv[2])
and you would call this scripy with 2 arguments: the input texture (.tex or .gii) and the output nifti file.
But also remember that NIFTI only supports 16 bits dimensions, so if the texture has more than 65535 vertices, this conversion will fail.

In any case, I'm not sure that this is really what you want to do...

Denis
Post Reply