Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

What's the correct method for outputting a CARTO mesh to a .VTK file? #68

Open
Jsalas424 opened this issue Jul 24, 2022 · 8 comments
Open

Comments

@Jsalas424
Copy link

Jsalas424 commented Jul 24, 2022

Hello Dr. Williams,

I've been putting in some questions so I figured I'd explain that I'm with the University of Pennsylvania's translational EP research group and we're trying to get some CARTO data processed using your platform. We are very impressed and excited about this tool!

I'm now trying to export the CARTO mesh to a VTK file for some post-processing in 3d Slicer but am struggling with the correct method. I've attempted to use the cartoMesh2VTK api with no luck.

>> tr = openEP2VTK('datatype', 'lat')
Dot indexing is not supported for variables of this type.

Error in openEP2VTK (line 97)
                pointdata = userdata.surface.act_bip(:,1);

This is attempted with an imported RV Paced LAT map. The userdata.surface.act_bip() array is indeed empty. Can you please advise the correct way to get a VTK file out?

I do have userdata.triRep.X and userdata.triRep.triangulation data available as well.

@Jsalas424
Copy link
Author

Jsalas424 commented Jul 24, 2022

I have seemingly come up with a side answer, but would still be interested to know what the endorsed method is using the openep toolkit and your thoughts on this method. I still have to experiment with the data output to make sure it's consistent as I move between Matlab-OpenEP and 3D Slicer v5.0.3

The following solution will be how to generate VTK’s from OpenEP using vtkwrite in Matlab

x = userdata.surface.triRep.X(1:end,1);
y = userdata.surface.triRep.X(1:end,2);
z = userdata.surface.triRep.X(1:end,3);
vtkwrite('mesh.vtk','polydata','triangle',x,y,z,userdata.surface.triRep.Triangulation);

https://www.mathworks.com/matlabcentral/fileexchange/47814-vtkwrite-exports-various-2d-3d-data-to-paraview-in-vtk-file-format

Edit: It should be noted that this method has "precision" issues - i.e., it rounds the decimals and the option to change the precision of the output files doesn't work. I have since moved to the trimesh python library which works very well.

@Jsalas424
Copy link
Author

Sorry, didn't meant to close the issue. Still open.

@Jsalas424 Jsalas424 reopened this Jul 24, 2022
@p-j-smith
Copy link

Hello, are you using the cartoMesh2VTK function or 'openEP2VTK'? If it's openEP2VTK, does it work if you set a different datatype (one that is present), e.g.

openEP2VTK('datatype', 'uni')

Or set no datatype:

openEP2VTK('datatype', 'none')

@Jsalas424
Copy link
Author

HI @p-j-smith thanks for responding!

None work sadly:

>> openEP2VTK('datatype', 'none')
Dot indexing is not supported for variables of this type.

Error in openEP2VTK (line 97)
                pointdata = userdata.surface.act_bip(:,1);
 
>> openEP2VTK('datatype', 'uni')
Dot indexing is not supported for variables of this type.

Error in openEP2VTK (line 97)
                pointdata = userdata.surface.act_bip(:,1);
 
>> openEP2VTK('datatype', 'bip')
Dot indexing is not supported for variables of this type.

Error in openEP2VTK (line 97)
                pointdata = userdata.surface.act_bip(:,1);
 
>> openEP2VTK('datatype', 'lat')
Dot indexing is not supported for variables of this type.

Error in openEP2VTK (line 97)
                pointdata = userdata.surface.act_bip(:,1);

This is a paced map and there's definitely LAT data in there as evidenced by my ability to calculate conduction velocities and make those maps:

image

@p-j-smith
Copy link

Hmm, that's strange, is there any chance you could share this openep dataset too?

@Jsalas424
Copy link
Author

Absolutely! We tend to to run into issues because we generally run the latest/development version of CARTO in our lab, BWI tends to change up the text file organization every couple of iterations.

@p-j-smith
Copy link

Hi, sorry for not getting back to you sooner. I just had a look at your dataset and in doing so realised that the way you were calling the function was not quite right. The first argument should be the userdata you would like to export:

tr = openEP2VTK(userdata, 'datatype', 'none')

Hopefully that works for you!

@Jsalas424
Copy link
Author

Hi Paul,

I tried this on 2 datasets (including the one I sent you) but still no luck:

>> tr = openEP2VTK(userdata, 'datatype', 'none')
Unrecognized function or variable 'pointdata'.

Error in openEP2VTK (line 104)
writeTriRep2VTK(getMesh(userdata), pointdata, 'outputfile', path2VTKfile);
 
>> 

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants