Tracts in obj format with FA colors

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Tracts in obj format with FA colors

Gonzalo Rojas Costa
Hi:

How can I get the tracts saved in obj file format with FA colors ?

Sincerely,


Gonzalo Rojas Costa
Laboratory of Advanced Medical Imaging
Department  Radiology
Clinica las Condes
Santiago
Chile

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

inorton
Hi Gonzalo,

Slicer/VTK obj export support appears to be limited (needs whole render pipeline; doesn't handle scalars correctly). But I was able to get a nice result by exporting to ply, loading in meshlab [1], and re-exporting as obj.

Here is an example Python script to do the export with colors (default FA, will use whichever property is chosen for the object in Tractography Display). It is updated based on [2] for recent VTK changes:

plyFilePath = "/tmp/foo/fibers.ply"

lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")

tuber = vtk.vtkTubeFilter()
tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
tuber.Update()

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

triangles = vtk.vtkTriangleFilter()
triangles.SetInputData(tubes)
triangles.Update()

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

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

plyWriter.SetFileName(plyFilePath)
plyWriter.Write()

Hope this helps.

Best,
Isaiah



On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa <[hidden email]> wrote:
Hi:

How can I get the tracts saved in obj file format with FA colors ?

Sincerely,


Gonzalo Rojas Costa
Laboratory of Advanced Medical Imaging
Department  Radiology
Clinica las Condes
Santiago
Chile

_______________________________________________
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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Gonzalo Rojas Costa
In reply to this post by Gonzalo Rojas Costa
Hi Isaiah:

  I used your python script, and I got the ply file, and then I
convert it to obj with FA colors... But I need an OBJ with an MTL
file... How can I got that type of file ?...

  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
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ


On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]> wrote:

> Hi Gonzalo,
>
> Slicer/VTK obj export support appears to be limited (needs whole render
> pipeline; doesn't handle scalars correctly). But I was able to get a nice
> result by exporting to ply, loading in meshlab [1], and re-exporting as obj.
>
> Here is an example Python script to do the export with colors (default FA,
> will use whichever property is chosen for the object in Tractography
> Display). It is updated based on [2] for recent VTK changes:
>
> plyFilePath = "/tmp/foo/fibers.ply"
>
> lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>
> tuber = vtk.vtkTubeFilter()
> tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
> tuber.Update()
>
> tubes = tuber.GetOutput()
> scalars = tubes.GetPointData().GetArray(0)
> scalars.SetName("scalars")
>
> triangles = vtk.vtkTriangleFilter()
> triangles.SetInputData(tubes)
> triangles.Update()
>
> colorNode = lineDisplayNode.GetColorNode()
> lookupTable = vtk.vtkLookupTable()
> lookupTable.DeepCopy(colorNode.GetLookupTable())
> lookupTable.SetTableRange(0,1)
>
> plyWriter = vtk.vtkPLYWriter()
> plyWriter.SetInputData(triangles.GetOutput())
> plyWriter.SetLookupTable(lookupTable)
> plyWriter.SetArrayName("scalars")
>
> plyWriter.SetFileName(plyFilePath)
> plyWriter.Write()
>
>
> Hope this helps.
>
> Best,
> Isaiah
>
> [1] http://www.meshlab.net/
> [2]
> http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>
>
> On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi:
>>
>> How can I get the tracts saved in obj file format with FA colors ?
>>
>> Sincerely,
>>
>>
>> Gonzalo Rojas Costa
>> Laboratory of Advanced Medical Imaging
>> Department  Radiology
>> Clinica las Condes
>> Santiago
>> Chile
>>
>> _______________________________________________
>> 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
>
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Steve Pieper-2
Hi Gonzalo - 

If you have the PLY exported from Slicer with that script it will have FA colors.  You can use something like Blender to export to OBJ with MTL.

-Steve

On Mon, Apr 24, 2017 at 4:19 PM, Gonzalo Rojas Costa <[hidden email]> wrote:
Hi Isaiah:

  I used your python script, and I got the ply file, and then I
convert it to obj with FA colors... But I need an OBJ with an MTL
file... How can I got that type of file ?...

  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: <a href="tel:56-2-2105170" value="&#43;15622105170">56-2-2105170
Cel: 56-9-97771785
www.clc.cl
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ


On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]> wrote:
> Hi Gonzalo,
>
> Slicer/VTK obj export support appears to be limited (needs whole render
> pipeline; doesn't handle scalars correctly). But I was able to get a nice
> result by exporting to ply, loading in meshlab [1], and re-exporting as obj.
>
> Here is an example Python script to do the export with colors (default FA,
> will use whichever property is chosen for the object in Tractography
> Display). It is updated based on [2] for recent VTK changes:
>
> plyFilePath = "/tmp/foo/fibers.ply"
>
> lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>
> tuber = vtk.vtkTubeFilter()
> tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
> tuber.Update()
>
> tubes = tuber.GetOutput()
> scalars = tubes.GetPointData().GetArray(0)
> scalars.SetName("scalars")
>
> triangles = vtk.vtkTriangleFilter()
> triangles.SetInputData(tubes)
> triangles.Update()
>
> colorNode = lineDisplayNode.GetColorNode()
> lookupTable = vtk.vtkLookupTable()
> lookupTable.DeepCopy(colorNode.GetLookupTable())
> lookupTable.SetTableRange(0,1)
>
> plyWriter = vtk.vtkPLYWriter()
> plyWriter.SetInputData(triangles.GetOutput())
> plyWriter.SetLookupTable(lookupTable)
> plyWriter.SetArrayName("scalars")
>
> plyWriter.SetFileName(plyFilePath)
> plyWriter.Write()
>
>
> Hope this helps.
>
> Best,
> Isaiah
>
> [1] http://www.meshlab.net/
> [2]
> http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>
>
> On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi:
>>
>> How can I get the tracts saved in obj file format with FA colors ?
>>
>> Sincerely,
>>
>>
>> Gonzalo Rojas Costa
>> Laboratory of Advanced Medical Imaging
>> Department  Radiology
>> Clinica las Condes
>> Santiago
>> Chile
>>
>> _______________________________________________
>> 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
>
>
_______________________________________________
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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Mohamed Atef
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Steve Pieper-2
In reply to this post by Steve Pieper-2
Hi Mohamed -

That code is just an example - it can be pasted into the python console of slicer but might need to be tweaked to work with your system or the data you have loaded.

if there's a general need for exporting tracts with color overlays then developing an appropriate extension could be a good project for someone learning Slicer/python.

Best,
Steve

On Tue, Apr 25, 2017 at 1:30 AM, Mohamed Atef <[hidden email]> wrote:
Hi all,
Is that code shall be imported into slicer as a separate Example? or it should be added to something else?

Regards,
Mohamed


On Tue, Apr 25, 2017 at 5:27 AM, Steve Pieper <[hidden email]> wrote:
Hi Gonzalo - 

If you have the PLY exported from Slicer with that script it will have FA colors.  You can use something like Blender to export to OBJ with MTL.

-Steve

On Mon, Apr 24, 2017 at 4:19 PM, Gonzalo Rojas Costa <[hidden email]> wrote:
Hi Isaiah:

  I used your python script, and I got the ply file, and then I
convert it to obj with FA colors... But I need an OBJ with an MTL
file... How can I got that type of file ?...

  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: <a href="tel:56-2-2105170" value="&#43;15622105170" target="_blank">56-2-2105170
Cel: 56-9-97771785
www.clc.cl
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ


On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]> wrote:
> Hi Gonzalo,
>
> Slicer/VTK obj export support appears to be limited (needs whole render
> pipeline; doesn't handle scalars correctly). But I was able to get a nice
> result by exporting to ply, loading in meshlab [1], and re-exporting as obj.
>
> Here is an example Python script to do the export with colors (default FA,
> will use whichever property is chosen for the object in Tractography
> Display). It is updated based on [2] for recent VTK changes:
>
> plyFilePath = "/tmp/foo/fibers.ply"
>
> lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>
> tuber = vtk.vtkTubeFilter()
> tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
> tuber.Update()
>
> tubes = tuber.GetOutput()
> scalars = tubes.GetPointData().GetArray(0)
> scalars.SetName("scalars")
>
> triangles = vtk.vtkTriangleFilter()
> triangles.SetInputData(tubes)
> triangles.Update()
>
> colorNode = lineDisplayNode.GetColorNode()
> lookupTable = vtk.vtkLookupTable()
> lookupTable.DeepCopy(colorNode.GetLookupTable())
> lookupTable.SetTableRange(0,1)
>
> plyWriter = vtk.vtkPLYWriter()
> plyWriter.SetInputData(triangles.GetOutput())
> plyWriter.SetLookupTable(lookupTable)
> plyWriter.SetArrayName("scalars")
>
> plyWriter.SetFileName(plyFilePath)
> plyWriter.Write()
>
>
> Hope this helps.
>
> Best,
> Isaiah
>
> [1] http://www.meshlab.net/
> [2]
> http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>
>
> On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi:
>>
>> How can I get the tracts saved in obj file format with FA colors ?
>>
>> Sincerely,
>>
>>
>> Gonzalo Rojas Costa
>> Laboratory of Advanced Medical Imaging
>> Department  Radiology
>> Clinica las Condes
>> Santiago
>> Chile
>>
>> _______________________________________________
>> 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
>
>
_______________________________________________
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


_______________________________________________
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



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Gonzalo Rojas Costa
In reply to this post by Gonzalo Rojas Costa
Hi Steve:

  I tried to convert the PLY file to OBJ using Blender and 3DsMax, but
it doesn't works... Both software only shows the tracts in greyscale
color palette, and the saved OBJ has the MTL file but with grayscale
only...

  Also, I tried with meshlab... It shows the tracts in color from PLY
file, I saved it to an OBJ file... If I read the obj with meshlab the
tracts appeared in color, but that obj didn't have an MTL file (and I
need that type of OBJ file)...

  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
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ


On Mon, Apr 24, 2017 at 5:27 PM, Steve Pieper <[hidden email]> wrote:

> Hi Gonzalo -
>
> If you have the PLY exported from Slicer with that script it will have FA
> colors.  You can use something like Blender to export to OBJ with MTL.
>
> -Steve
>
> On Mon, Apr 24, 2017 at 4:19 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi Isaiah:
>>
>>   I used your python script, and I got the ply file, and then I
>> convert it to obj with FA colors... But I need an OBJ with an MTL
>> file... How can I got that type of file ?...
>>
>>   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
>> https://scholar.google.com/citations?user=LO7LZ3oAAAAJ
>>
>>
>> On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]>
>> wrote:
>> > Hi Gonzalo,
>> >
>> > Slicer/VTK obj export support appears to be limited (needs whole render
>> > pipeline; doesn't handle scalars correctly). But I was able to get a
>> > nice
>> > result by exporting to ply, loading in meshlab [1], and re-exporting as
>> > obj.
>> >
>> > Here is an example Python script to do the export with colors (default
>> > FA,
>> > will use whichever property is chosen for the object in Tractography
>> > Display). It is updated based on [2] for recent VTK changes:
>> >
>> > plyFilePath = "/tmp/foo/fibers.ply"
>> >
>> > lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>> >
>> > tuber = vtk.vtkTubeFilter()
>> > tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
>> > tuber.Update()
>> >
>> > tubes = tuber.GetOutput()
>> > scalars = tubes.GetPointData().GetArray(0)
>> > scalars.SetName("scalars")
>> >
>> > triangles = vtk.vtkTriangleFilter()
>> > triangles.SetInputData(tubes)
>> > triangles.Update()
>> >
>> > colorNode = lineDisplayNode.GetColorNode()
>> > lookupTable = vtk.vtkLookupTable()
>> > lookupTable.DeepCopy(colorNode.GetLookupTable())
>> > lookupTable.SetTableRange(0,1)
>> >
>> > plyWriter = vtk.vtkPLYWriter()
>> > plyWriter.SetInputData(triangles.GetOutput())
>> > plyWriter.SetLookupTable(lookupTable)
>> > plyWriter.SetArrayName("scalars")
>> >
>> > plyWriter.SetFileName(plyFilePath)
>> > plyWriter.Write()
>> >
>> >
>> > Hope this helps.
>> >
>> > Best,
>> > Isaiah
>> >
>> > [1] http://www.meshlab.net/
>> > [2]
>> >
>> > http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>> >
>> >
>> > On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
>> > <[hidden email]> wrote:
>> >>
>> >> Hi:
>> >>
>> >> How can I get the tracts saved in obj file format with FA colors ?
>> >>
>> >> Sincerely,
>> >>
>> >>
>> >> Gonzalo Rojas Costa
>> >> Laboratory of Advanced Medical Imaging
>> >> Department  Radiology
>> >> Clinica las Condes
>> >> Santiago
>> >> Chile
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> >
>> _______________________________________________
>> 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
>
>
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Steve Pieper-2
In reply to this post by Gonzalo Rojas Costa
Hi Gonzalo -

I'm not an active user of the other packages so I can't say how best to proceed.  I know that in the past I was able to get the FA colors to display in blender by tweaking some internal settings after reading the ply file (the gui in the linked screen shot should have some clues).  Maybe once you get that display in blender you can export the obj/mtl files.


Best,
Steve

On Tue, Apr 25, 2017 at 2:59 PM, Gonzalo Rojas Costa <[hidden email]> wrote:
Hi Steve:

  I tried to convert the PLY file to OBJ using Blender and 3DsMax, but
it doesn't works... Both software only shows the tracts in greyscale
color palette, and the saved OBJ has the MTL file but with grayscale
only...

  Also, I tried with meshlab... It shows the tracts in color from PLY
file, I saved it to an OBJ file... If I read the obj with meshlab the
tracts appeared in color, but that obj didn't have an MTL file (and I
need that type of OBJ file)...

  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: <a href="tel:56-2-2105170" value="&#43;15622105170">56-2-2105170
Cel: 56-9-97771785
www.clc.cl
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ


On Mon, Apr 24, 2017 at 5:27 PM, Steve Pieper <[hidden email]> wrote:
> Hi Gonzalo -
>
> If you have the PLY exported from Slicer with that script it will have FA
> colors.  You can use something like Blender to export to OBJ with MTL.
>
> -Steve
>
> On Mon, Apr 24, 2017 at 4:19 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi Isaiah:
>>
>>   I used your python script, and I got the ply file, and then I
>> convert it to obj with FA colors... But I need an OBJ with an MTL
>> file... How can I got that type of file ?...
>>
>>   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: <a href="tel:56-2-2105170" value="&#43;15622105170">56-2-2105170
>> Cel: 56-9-97771785
>> www.clc.cl
>> https://scholar.google.com/citations?user=LO7LZ3oAAAAJ
>>
>>
>> On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]>
>> wrote:
>> > Hi Gonzalo,
>> >
>> > Slicer/VTK obj export support appears to be limited (needs whole render
>> > pipeline; doesn't handle scalars correctly). But I was able to get a
>> > nice
>> > result by exporting to ply, loading in meshlab [1], and re-exporting as
>> > obj.
>> >
>> > Here is an example Python script to do the export with colors (default
>> > FA,
>> > will use whichever property is chosen for the object in Tractography
>> > Display). It is updated based on [2] for recent VTK changes:
>> >
>> > plyFilePath = "/tmp/foo/fibers.ply"
>> >
>> > lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>> >
>> > tuber = vtk.vtkTubeFilter()
>> > tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
>> > tuber.Update()
>> >
>> > tubes = tuber.GetOutput()
>> > scalars = tubes.GetPointData().GetArray(0)
>> > scalars.SetName("scalars")
>> >
>> > triangles = vtk.vtkTriangleFilter()
>> > triangles.SetInputData(tubes)
>> > triangles.Update()
>> >
>> > colorNode = lineDisplayNode.GetColorNode()
>> > lookupTable = vtk.vtkLookupTable()
>> > lookupTable.DeepCopy(colorNode.GetLookupTable())
>> > lookupTable.SetTableRange(0,1)
>> >
>> > plyWriter = vtk.vtkPLYWriter()
>> > plyWriter.SetInputData(triangles.GetOutput())
>> > plyWriter.SetLookupTable(lookupTable)
>> > plyWriter.SetArrayName("scalars")
>> >
>> > plyWriter.SetFileName(plyFilePath)
>> > plyWriter.Write()
>> >
>> >
>> > Hope this helps.
>> >
>> > Best,
>> > Isaiah
>> >
>> > [1] http://www.meshlab.net/
>> > [2]
>> >
>> > http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>> >
>> >
>> > On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
>> > <[hidden email]> wrote:
>> >>
>> >> Hi:
>> >>
>> >> How can I get the tracts saved in obj file format with FA colors ?
>> >>
>> >> Sincerely,
>> >>
>> >>
>> >> Gonzalo Rojas Costa
>> >> Laboratory of Advanced Medical Imaging
>> >> Department  Radiology
>> >> Clinica las Condes
>> >> Santiago
>> >> Chile
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> >
>> _______________________________________________
>> 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
>
>


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Tracts in obj format with FA colors

Andras Lasso-2

If ply does not work then you can export as VRML. See details here:

http://massmail.spl.harvard.edu/public-archives/slicer-devel/2015/039129.html

 

Andras

 

From: slicer-users [mailto:[hidden email]] On Behalf Of Steve Pieper
Sent: April 25, 2017 17:58
To: Gonzalo Rojas Costa <[hidden email]>
Cc: SPL Slicer Users <[hidden email]>
Subject: Re: [slicer-users] Tracts in obj format with FA colors

 

Hi Gonzalo -

 

I'm not an active user of the other packages so I can't say how best to proceed.  I know that in the past I was able to get the FA colors to display in blender by tweaking some internal settings after reading the ply file (the gui in the linked screen shot should have some clues).  Maybe once you get that display in blender you can export the obj/mtl files.

 

 

Best,

Steve

 

On Tue, Apr 25, 2017 at 2:59 PM, Gonzalo Rojas Costa <[hidden email]> wrote:

Hi Steve:

  I tried to convert the PLY file to OBJ using Blender and 3DsMax, but
it doesn't works... Both software only shows the tracts in greyscale
color palette, and the saved OBJ has the MTL file but with grayscale
only...

  Also, I tried with meshlab... It shows the tracts in color from PLY
file, I saved it to an OBJ file... If I read the obj with meshlab the
tracts appeared in color, but that obj didn't have an MTL file (and I
need that type of OBJ file)...

  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: <a href="tel:56-2-2105170">56-2-2105170
Cel: 56-9-97771785
www.clc.cl
https://scholar.google.com/citations?user=LO7LZ3oAAAAJ

On Mon, Apr 24, 2017 at 5:27 PM, Steve Pieper <[hidden email]> wrote:
> Hi Gonzalo -
>
> If you have the PLY exported from Slicer with that script it will have FA
> colors.  You can use something like Blender to export to OBJ with MTL.
>
> -Steve
>
> On Mon, Apr 24, 2017 at 4:19 PM, Gonzalo Rojas Costa
> <[hidden email]> wrote:
>>
>> Hi Isaiah:
>>
>>   I used your python script, and I got the ply file, and then I
>> convert it to obj with FA colors... But I need an OBJ with an MTL
>> file... How can I got that type of file ?...
>>
>>   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: <a href="tel:56-2-2105170">56-2-2105170
>> Cel: 56-9-97771785
>> www.clc.cl
>> https://scholar.google.com/citations?user=LO7LZ3oAAAAJ
>>
>>
>> On Wed, Apr 5, 2017 at 12:38 PM, Isaiah Norton <[hidden email]>
>> wrote:
>> > Hi Gonzalo,
>> >
>> > Slicer/VTK obj export support appears to be limited (needs whole render
>> > pipeline; doesn't handle scalars correctly). But I was able to get a
>> > nice
>> > result by exporting to ply, loading in meshlab [1], and re-exporting as
>> > obj.
>> >
>> > Here is an example Python script to do the export with colors (default
>> > FA,
>> > will use whichever property is chosen for the object in Tractography
>> > Display). It is updated based on [2] for recent VTK changes:
>> >
>> > plyFilePath = "/tmp/foo/fibers.ply"
>> >
>> > lineDisplayNode = getNode("vtkMRMLFiberBundleLineDisplayNode1")
>> >
>> > tuber = vtk.vtkTubeFilter()
>> > tuber.SetInputData(lineDisplayNode.GetOutputPolyData())
>> > tuber.Update()
>> >
>> > tubes = tuber.GetOutput()
>> > scalars = tubes.GetPointData().GetArray(0)
>> > scalars.SetName("scalars")
>> >
>> > triangles = vtk.vtkTriangleFilter()
>> > triangles.SetInputData(tubes)
>> > triangles.Update()
>> >
>> > colorNode = lineDisplayNode.GetColorNode()
>> > lookupTable = vtk.vtkLookupTable()
>> > lookupTable.DeepCopy(colorNode.GetLookupTable())
>> > lookupTable.SetTableRange(0,1)
>> >
>> > plyWriter = vtk.vtkPLYWriter()
>> > plyWriter.SetInputData(triangles.GetOutput())
>> > plyWriter.SetLookupTable(lookupTable)
>> > plyWriter.SetArrayName("scalars")
>> >
>> > plyWriter.SetFileName(plyFilePath)
>> > plyWriter.Write()
>> >
>> >
>> > Hope this helps.
>> >
>> > Best,
>> > Isaiah
>> >
>> > [1] http://www.meshlab.net/
>> > [2]
>> >
>> > http://slicer-users.65878.n3.nabble.com/Viewing-Tractography-in-Blender-save-color-information-and-lines-connecting-the-dots-td4029734.html
>> >
>> >
>> > On Tue, Apr 4, 2017 at 11:01 PM, Gonzalo Rojas Costa
>> > <[hidden email]> wrote:
>> >>
>> >> Hi:
>> >>
>> >> How can I get the tracts saved in obj file format with FA colors ?
>> >>
>> >> Sincerely,
>> >>
>> >>
>> >> Gonzalo Rojas Costa
>> >> Laboratory of Advanced Medical Imaging
>> >> Department  Radiology
>> >> Clinica las Condes
>> >> Santiago
>> >> Chile
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> >
>> _______________________________________________
>> 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
>
>

 


_______________________________________________
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
Loading...