Tractography export by color

I’ve got a Tractography file in slicer with numerous colors. I’d like to export the curves with color or export the curves based on a color threshold. The idea with the latter is that I can export numerous files and bring them into another modeling program and assign the files to different layers based on color. Any ideas how to make this work?

Please try the Export tractography to PLY (mesh) module, available in the SlicerDMRI extension in nightly builds (since early April).

Note that we use PLY specifically because it supports color.

Most software with STL import also supports PLY, but if you specifically need OBJ (supports color) or STL (no color) you can convert in MeshLab.

Thank you. This is good to know but I’m need to keep these as curves and lines because we will be voxel printing. So to be more specific, is there a way to export curves and lines with color and/or segment these curves based on color?

What format are you looking for? I don’t know if STL support polylines, but at least VTK’s STL export does not seem to support that (the output is just a point cloud, I think; that’s why we apply a tube filter before export).

If you save as a PLY, then the colors will be stored per-vertex. If you save as VTK then the colors will be stored in an associated cell array.

Feel free to have a look at the code here. It is Python so you can modify as-needed in a downloaded Slicer build without compiling yourself.

I should also mention that, as far as I understand, a number of people have used exactly this export process for 3D printing of tractography. The original export script is from @pieper, and we made it into a module recently because this request comes up several times a month.

And the process you mention and code is for the meshing ply?

It sounds like I might be able to export the vtk polylines and the color ply point cloud and color the lines by association.

Any format that exports with polylines in color works. We can work with a lot of different line based files. But the lines allow us to bitmap print or voxel print and keep file size low. Whereas the meshing is often way to big of a file.

The process I mentioned applies a tube filter to the streamlines, by default creating a 6-sided tube for each streamline, so memory usage goes up roughly 6x. # sides and radius are configurable. Each ring vertex is given the same color as the corresponding point had in Slicer’s viewer.

VTK does support polylines and is the most flexible option.

Thanks I think I will export a vtk to rhino and then sort by direction. Then create seperate layers based on those directions.

A related option is to convert to voxels in Slicer using Tractography to Mask Image module. This upsamples along fibers to best fill in the intersected voxels, but it does not currently export colors. It could be helpful to take a look at the code.

It looks like we need to update the documentation for this module, as it seems to still be under the old name here: