Tractography in PLY with colors to OBJ with material (MTL) conversion

How can I convert tractography saved in a PLY file with colors to a OBJ/MTL file ?

MeshLab can bake textures from point scalars, so if you need a one-off conversion then that may be the simplest. You can find instructions on the web, see for example here.

If you need to do this often or this is part of a time-constrained workflow then probably you can write a script that uses VTK filters to create texture coordinates and fill the texture image with colors taken from the PLY mesh.

Why do you need the colored model as OBJ/MTL file? For 3D printing?

If you have access to a suitable multimaterial Stratasys printer, then you may try voxel printing with SlicerFab extension. Voxel printing is not as widely available as standard colored surface printing but it is so much nicer. See for example how fiber tracts look with this technique:


I need the tract (PLY mesh) in OBJ/MTL for a virtual reality software that we are creating…

FYI, you can show Slicer scene in virtual reality with a single button click, on any OpenVR compatible headset. No need to use any third-party software or exporting or converting any data. Moreover, you are not limited to viewing some static set of fiber tracts but you can do dynamic tractography seeding, see for example this multi-user demo:

Instead of redeveloping a limited variant of this feature in a different environment, it would be so much nicer to collaborate on improving the existing implementation in Slicer. Customization and optimization of tractography visualization in virtual reality would be a good project for an upcoming Project week (in Spain in January or in Boston in June), but if you cannot come to these then we are happy to help you remotely/via this forum.