convert

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
salemhannoun
Posts: 7
Joined: Tue Mar 27, 2007 2:08 pm
Location: france

convert

Post by salemhannoun »

could we in brain visa convert the matrix file from .trm to .mat.
if we could could you please tell me how to do so?

i'll be most greatfull if you did
thank you.
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Post by Manik »

If you want to read a .trm file in matlab, you can use
m = textread('file.trm')
The .mat format can contain anything (rotation matrix + vector, quaternion), so it is impossible to understand what kind of .mat you want to get.
The .trm format, as far as I can remember is
Tx Ty Tz
R11 R12 R13
R21 R22 R23
R31 R32 R33

where T is the translation and R the matrix.
To get a quaternion, you need
R11 R12 R13 Tx
R21 R22 R23 Ty
R31 R32 R33 Tz
0 0 0 1


Maybe someone else can say whether it is possible to write a .mat file with brainvisa, but I don't think it is possible without matlab (and the format is not compatible between matlab versions...).
Manik Bhattacharjee
INSERM U836
salemhannoun
Posts: 7
Joined: Tue Mar 27, 2007 2:08 pm
Location: france

convert

Post by salemhannoun »

hi actually i'm using brainvisa just for to calculate the matrix that makes T1 images and diffusion images superpose.
for tractography i'm using MedINRIA. i want to draw the ROIs for the diffusion on the T1 then transfer them on the diffusion.
but the Program needs a matrix with its format .mat.
the first line in this matrix is diffusion image resolution and the second is the T1 image reolution.
Image sizes on the 3 axes are indicated followed by the voxel size in mm. After this resolution information, the coefficients of the transformation matrix to apply are succesively specified. Transformation is divided in a linear transform and a translation :

A =( A11 A21 A31
A12 A22 A32
A13 A23 A33)
T=( t1
t2
t3)
where A is the affine transform matrix and T the translation vector.
In the matrix file the coefficients are sorted as followed (column-wise):
A11 A12 A13 A21 A22 A23 A31 A32 A33 t1 t2 t3 (A.2)
For instance the identity transformation would be:
1 0 0 0 1 0 0 0 1 0 0 0

the matrix for example will be:
affinematrix.mat
128 128 30 1.875 1.875 4
256 256 134 0.94 0.94 1
2 0 0 0 -2 0 0 0 2 50 0 25

now the third line in the matrix is the linearisation of the matrix i get from brainvisa. how can transform it? how to get the .mat file, with what can i write it with?
thank you for ur help
User avatar
Yann Cointepas
Posts: 316
Joined: Tue Jan 20, 2004 2:56 pm
Location: Neurospin, Saint Aubin, France
Contact:

Post by Yann Cointepas »

A *.mat file can contains many different things, you should ask MedINRIA developpers what they expect in their .mat. To generate the file, you should create a Matlab script that reads and convert the trm file ; its just a text file containing the 12 values you need (3 for translation then 9 for matrix).
Post Reply