Texture exportation

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Nicolas Wotawa

Texture exportation

Post by Nicolas Wotawa »

Hello,

I am trying to use the texture files we can export from a 3D-fusion (*.tex), but the normalization of the texture values between 0 and 1 looses the absolute texture values (for example of a T-test image projected on the GM/WM interface).
We furthermore cannot directly apply a rescaling to those values, as we don't know the actual min and max of the original texture (depending on the projection technic used and in general different from the original 3D image min/max).

Any idea to deal with this problem?

Nicolas.
User avatar
Jean-Francois Mangin
Posts: 337
Joined: Mon Mar 01, 2004 10:24 am
Location: Neurospin, CEA, France
Contact:

Post by Jean-Francois Mangin »

Hello Nicolas,
as far as I am aware, this behaviour stems from the fact that the texture has to be normalized before being given to openGL. Unfortunately, Anatomist seems to save the normalized data rather than the initial one. Unfortunately, D. Rivière is skiing somewhere in the Alpes for two weeks, and he is the only Anatomist wizard. Therefore, no solution for the moment, sorry:-)
Jeff
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Post by NicolasW »

Thank you for your quick answer :D

A solution could be to put 2 additional field min and max in the "header" of the file.

Nicolas.
Guest

Post by Guest »

I guess it may be even simpler to save the actual texture and to normalize before
feeding openGL. However, another choice has been done; therefore there may be another explanation I do not know...
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Another point around extremal values: 3d-fusion

Post by NicolasW »

Hi,

back with another problem around extrems values and mesh: when I do a 3D-fusion of the mesh and a 3D image, the maximum value in the 3D image is not displayed on the mesh, even if there should be this maximal value on different vertices of the latter.

For instance, if I want to see a 3D binary mask projected on the cortical surface, it doesn't appear (only the interpolated values out of the region edges can be seen, which is another Open-GL problem; by the way, is it solvable?).
I found a trick, putting a higher value (say 2 in my example) in one far voxel and the mask appears on the mesh.

Is there a way to avoid that without adding artificial values?

Thanks,

Nicolas.
User avatar
Jean-Francois Mangin
Posts: 337
Joined: Mon Mar 01, 2004 10:24 am
Location: Neurospin, CEA, France
Contact:

Post by Jean-Francois Mangin »

Hi Nicolas,
nobody dares to dive into that part of Anatomist here except Denis. Therefore
you will have to wait to get an answer except if you dive yourself. I know you already
had a nasty experience with this part of the code which is pretty confusing (its history
involved several people). However, nothing really complicated is done there. Hence
I bet you could maybe get the answer yourself :-)
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Post by NicolasW »

Hi Jeff,

well, as I don't know a single thing from OpenGL beyond its name, I can wait for Denis ;-). Indeed, the problem I mentionned is a technical issue I can bypass, but it could be very misleading if you ignore it, thus if it could be simply corrected in the next release, it would help new users.

However, the second point I mentionned about the interpolation around a patch of texture on a mesh is more bothering, but it is once again a pure OpenGL technical issue (some parameter, somewhere in a painting function I assume). There should be a way to deal with it, for example the SUMA software, based on Open GL, deals with it. Sorry, but no idea how...:?

Nicolas.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

I'm recoding all OpenGL/texutring stuff in Anatomist so things might be improved a bit in the next version (depending on what far I can go without spending too much time on it).
- keeping texture extrema should be possible outside openGL (when calculating textures) in most cases, it's Anatomist object structures which were incomplete. Our fault.
- the interpolation problem seems more difficult to deal with (unless I missed some options in OpenGL texturing functions documentation) because colors are directly interpolated in the palette image space. We could use 3D textures in some cases but this would not be compatible with the special value calculations (averaging along normals etc) and would need lots of texture memory (on the 3D card). I don't know if there is a good solution. We have to think...
You can perhaps trick it by moving the palette max cursor ? OK it's dirty but...

Denis
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Post by NicolasW »

Denis,

this would be great at least for the fMRI community if you could change the texture exportation function, keeping the absolute values!

About the interpolation, moving the palette max cursor doesn't change the problem, and no proper "out-of-mask" value can be chosen (NaN gives specially weird colors!). As I mentionned earlier, there seems to be a way to deal with it in Open GL, the SUMA software for instance displays a texture (saved in a comparable manner, that is a RGB triplet for each vertice) without outter interpolation. Unfortunatly, no idea how they manage to do this...

Nicolas.[/url]
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Nicolas,

Right now I only see 3 ways of doing the interpolation (see image, hand-drawn quick'n'dirty) (sorry the answer is a bit technical):

(A) texture with palette, this is the mode used right now. Values are computed for each vertex of the mesh and used as a coordinate in a texture image (1D texture palette). Interpolation is done by following a line on this palette (am I clear?)

(B) interpolation in RGB space: each vertex is assigned a RGB value and colors are continuously interpolated by their RGB values. To do this we must either use "color" properties of OpenGL rather than textures, which are not so easy to use because they completely override lighting (it will not look nice), or use 3 textures, one for each R,G,B channel (feasible but not on all 3D cards: mine for instance has only 2 tex units). This should be possible in the next Anatomist version which can use multitexturing. There might be other ways to do it: I only know of OpenGL what I have needed up to now for Anatomist...

(C) use a 3D texture (here shown in 2D). This needs quite large amounts of texture memory in 3D cards because we need to load the whole initial volume into the 3D card, and it forbids calculations like integration along the normals or on spheres. We could think about allowing it only for the special "point-to-point" case, but it would need some work just for this special case because the rendering method is completely different from what is done now.

Image

There may be other ways to map textures, but I don't have any in mind right now. What would you expect ? What does SUMA ?
If you (or someone else) find a good idea, I will be happy to program it in the next version (if it's not too much work, of course) :wink: ...

Denis
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Post by NicolasW »

Hello Denis,

Indeed, solution (B) with 3 channels or solution (C) cost too much.

SUMA seems to do the solution (B) you suggested, that is interpolating in the RGB space. There is however a difference with Anatomist's textures, only vertices with a value of interest (say different from 0 or NaN or any user specified value(s)?) are saved in the texture file, with the vertex number followed by its 3 RGB values...This might be the way to drive Open GL to avoid interpolation in a triangle with at leat one vertex at this non-interest value.
But what is the underlying Open GL rountine...?

Nicolas.
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

So what is displayed on vertices without a value ?
NicolasW
Posts: 29
Joined: Fri Mar 05, 2004 11:45 am
Location: INRIA Sophia Antipolis, France
Contact:

Post by NicolasW »

Nothing! The default texture is the surface curvature, but it can be removed. The default color (grey) of the surface then appears.
For some examples (and an overview of what is available), see the web page:
http://afni.nimh.nih.gov/ssc/ziad/SUMA/SUMA.htm

Maybe its main author, Ziad S. Saad (ziad@nih.gov), could give an idea for the Open GL functions and options...

Nicolas.[/img]
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Nicolas,

I fixed your first problem: unnormalized textures can now be exported frol 3D fusions. But of course it's done in the development branch of anatomist, which will not be avialable for a little while... But now you know one of your problems will have a solution one day...

I haven't done anything yet for the texture interpolation problem. The easiest way I see is using multitexturing. Now it just has to be programmed...

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

Post by riviere »

Hi Nicolas,

I've worked in Anatomist, and I have made a new texturing mode which uses color interpolation in RGB space (rather than the normal palette space):
Image Image
left: palette interpolation, right: RGB interpolation
Both images are the same mesh and texture, with the same palette (colors on vertices are identical).

This mode may be more suitable for "label" textures (it is rendered using 2 textures). It will be in the next version of Anatomist.
Does it look more like what you were expecting ?

Denis
Post Reply