Viewing Tractography in Blender (save color information and lines connecting the dots)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Viewing Tractography in Blender (save color information and lines connecting the dots)

KevinL
Hello all, 

I would like to export tractography models I generated in Slicer (imported as VTK files) and import them in another mesh editor. (If possible I would like to export it as a .obj file, but .ply works as well) Is it possible to save the color information and the connecting lines from slicer when I export these files? 



Thank you,

Kevin 

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Viewing Tractography in Blender (save color information and lines connecting the dots)

arumiat
This is Steve Piepers code that he once sent to me, it should satisfy your purpose

-------------------------------------------------------------------
...
I pasted in the script below that can generate the .ply files -- as you can see it turned out to be not much code -- the 'magic' is knowing what code to write ;)  You can save it to a file and then run it in slicer using the 'execfile' command given in the comment with whatever path you have saved to.  You can also edit the plyFilePath (forward slashes!).   right now it's hard coded to handle just the first fiber bundle in the slicer scene, but this can be generalized.
...

-Steve




plyFilePath = "/tmp/fibers.ply"

lineDisplayNode = getNode("*LineDisplay*")

tuber = vtk.vtkTubeFilter()
tuber.SetInput(lineDisplayNode.GetOutputPolyData())

tubes = tuber.GetOutput()
tubes.Update()
scalars = tubes.GetPointData().GetArray(0)
scalars.SetName("scalars")

triangles = vtk.vtkTriangleFilter()
triangles.SetInput(tubes)

colorNode = lineDisplayNode.GetColorNode()
lookupTable = vtk.vtkLookupTable()
lookupTable.DeepCopy(colorNode.GetLookupTable())
lookupTable.SetTableRange(0,1)

plyWriter = vtk.vtkPLYWriter()
plyWriter.SetInput(triangles.GetOutput())
plyWriter.SetLookupTable(lookupTable)
plyWriter.SetArrayName("scalars")

plyWriter.SetFileName(plyFilePath)
plyWriter.Write()

------------------------------------
V A L A design
+ 4 4 (0) 2 0 3 6 3 7 0 0 6 2
IVALA LTD.   REG NO.7931234


On 14 December 2015 at 20:17, Kevin Liang <[hidden email]> wrote:
Hello all, 

I would like to export tractography models I generated in Slicer (imported as VTK files) and import them in another mesh editor. (If possible I would like to export it as a .obj file, but .ply works as well) Is it possible to save the color information and the connecting lines from slicer when I export these files? 



Thank you,

Kevin 

_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.



_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.
Reply | Threaded
Open this post in threaded view
|

Re: Viewing Tractography in Blender (save color information and lines connecting the dots)

Gonzalo Rojas Costa
In reply to this post by KevinL
Dear Dr. Alavi:

  The code that you sent must input in the Python Interactor window
?... To execute it, must I add an "import" command or other python
code ?...

  Sincerely,


Gonzalo Rojas Costa



--
Gonzalo Rojas Costa
Laboratory for Advanced Medical Image Processing
Department of Radiology
ClĂ­nica las Condes
Lo Fontecilla 441, Las Condes, Santiago, Chile.
Tel: 56-2-2105170
Cel: 56-9-97771785
www.clc.cl

=======================================================

Message: 50
Date: Mon, 14 Dec 2015 22:06:05 +0000
From: Taimur Alavi <[hidden email]>
Subject: Re: [slicer-users] Viewing Tractography in Blender (save
        color information and lines connecting the dots)
To: Kevin Liang <[hidden email]>
Cc: SPL Slicer Users <[hidden email]>
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="us-ascii"

This is Steve Piepers code that he once sent to me, it should satisfy
your purpose

-------------------------------------------------------------------
...
I pasted in the script below that can generate the .ply files -- as
you can see it turned out to be not much code -- the 'magic' is
knowing what code to write ;)  You can save it to a file and then run
it in slicer using the 'execfile' command given in the comment with
whatever path you have saved to.  You can also edit the plyFilePath
(forward slashes!).   right now it's hard coded to handle just the
first fiber bundle in the slicer scene, but this can be generalized.
...

-Steve




plyFilePath = "/tmp/fibers.ply"

lineDisplayNode = getNode("*LineDisplay*")

tuber = vtk.vtkTubeFilter()
tuber.SetInput(lineDisplayNode.GetOutputPolyData())

tubes = tuber.GetOutput()
tubes.Update()
scalars = tubes.GetPointData().GetArray(0)
scalars.SetName("scalars")

triangles = vtk.vtkTriangleFilter()
triangles.SetInput(tubes)

colorNode = lineDisplayNode.GetColorNode()
lookupTable = vtk.vtkLookupTable()
lookupTable.DeepCopy(colorNode.GetLookupTable())
lookupTable.SetTableRange(0,1)

plyWriter = vtk.vtkPLYWriter()
plyWriter.SetInput(triangles.GetOutput())
plyWriter.SetLookupTable(lookupTable)
plyWriter.SetArrayName("scalars")

plyWriter.SetFileName(plyFilePath)
plyWriter.Write()

------------------------------------
I V A L A design
WWW.IVALADESIGN.COM<http://www.ivaladesign.com>
[hidden email]<mailto:[hidden email]>
+ 4 4 (0) 2 0 3 6 3 7 0 0 6 2
IVALA LTD.   REG NO.7931234
uk.linkedin.com/pub/taimur-alavi/71/72/b38/<http://uk.linkedin.com/pub/taimur-alavi/71/72/b38/>

  *


On 14 December 2015 at 20:17, Kevin Liang
<[hidden email]<mailto:[hidden email]>> wrote:
Hello all,

I would like to export tractography models I generated in Slicer
(imported as VTK files) and import them in another mesh editor. (If
possible I would like to export it as a .obj file, but .ply works as
well) Is it possible to save the color information and the connecting
lines from slicer when I export these files?



Thank you,

Kevin
_______________________________________________
slicer-users mailing list
[hidden email]
http://massmail.spl.harvard.edu/mailman/listinfo/slicer-users
To unsubscribe: send email to [hidden email] with unsubscribe as the subject
http://www.slicer.org/slicerWiki/index.php/Documentation/4.3/FAQ


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.