Exporting fibre vector to other softwares

diffusion

(Azam Ahmad Bakir) #1

Dear all,

I am a new user of 3D slicer, working mostly on brain MRI segmentation. So far, I’m quite happy with the tools provided in 3D slicer. I have a question regarding DT-MRI fibre bundle.

So far, I have managed to create fibre bundle (.vtk) file from DT-MRI images. I need to export the fibre vector (x,y,z components) to finite element software i.e. COMSOL. We typically need the fibre vector direction data in .csv file in order to export this. I noticed the fibre bundle can only be saved as .vtk, .vtp, .obj, .stl, and .ply. Is it possible to convert the fibre bundle into vector data in .csv or .txt.?

Thank you for all your assistance.

Best regards,
Azam

Operating system: Windows 10
Slicer version: 4.8.1
Expected behavior:
Actual behavior:


(Isaiah Norton) #2

There is a PLY export tool (Diffusion -> Import and Export -> Export Tractography to PLY (mesh)), but a quick google suggests Comsol only supports STL.

If you want an ASCII format, the simplest option is to export as either .vtk text format, or .obj. Either of those will be a list of points, followed by lists of point-ids contained in each line (each line is a cell in vtk terminology).

  • OBJ is simpler, because each point triplet is on a separate line
  • In ASCII VTK, all triplets are consecutive, read them by 3s. For ASCII .vtk, make sure to click “Show options” in the Save Data dialog, and uncheck the “Compress” button next to the .vtk file, or see here for how to do programmatically.

If you want to do something else programmatically, I just added an example of how to iterate over lines in (almost) pure NumPy: