Export DTI as Ply rotational error


I’m still trying to figure out the full capabilities of Slicer, and just recently started using the DMRI extension. I tried to export a tract as PLY using the “Export tractography to PLY (mesh)” tool but every time I export it I notice it has been rotated 180 degrees about the Z axis when I open it in another 3D program such as Blender. Is there a step I’m missing or something I’m not taking to account?

Thanks in advance,

That code snippet exports the tracts as they are in the scene, in RAS coordinate system. If you need the mesh in LPS coordinate system then you can invert the sign of the first two coordinate components. I’ve updated the example here.

Thanks for the reply, but I don’t know how to follow the instructions on that link. I found the “TractographyExportPLY.py” is this something I need to modify on that file?

@yuanci -the feature in SlicerDMRI was implemented based on the script example that @lassoan pointed to. He updated the example, but to update the module the same change needs to be made here in the SlicerDMRI source code. Is there any chance you could make the change, test it, and submit a pull request to SlicerDMRI? If that’s not something you are familiar with probably someone else can easily do it.

Note the LPS/RAS distinction is described here.

Figured it out! Thank you so much for the input

I defined the global variable after the imports

outputCoordinateSystem = “LPS”

Then I replaced line 206 of the “TractographyExportPLY.py”



if outputCoordinateSystem == “RAS”:
elif outputCoordinateSystem == “LPS”:
transformRasToLps = vtk.vtkTransformPolyDataFilter()
rasToLps = vtk.vtkTransform()
rasToLps.Scale(-1, -1, 1)
raise RuntimeError(“Invalid output coordinate system”)

Could you please add a outputCoordinateSystem == "RAS" argument to exportFiberBundleToPLYPath, test if it all works well, and then send a pull request with the change? You can create a pull request very easily by editing the .py file directly in github and answering yes to when you are asked if you want to fork the repository, create a branch, and submit a pull request.

It does work! It doesn’t allow me to edit the .py file on github, but I have the .py file here: Dropbox - TractographyExportPLY.py - Simplify your life

Thank you. I’ve polished it a bit (use None as default to prevent overwriting default; write coordinate system information to image header) and created a pull request:

1 Like