BIC-MNI / minc-toolkit-v2

Version 2 of the minc-toolkit, uses tools based on ITK version 4.x
GNU General Public License v3.0
48 stars 21 forks source link

Can't open .obj files in meshlab #65

Closed danhps closed 4 years ago

danhps commented 5 years ago

Hi Again Everyone,

So I was able to successfully generate the .obj meshes for my collaboration. Thanks for your help on that! However, my collaborator is unable to open the meshes. She uses meshlab, which is supposed to be able to handle .obj files, but when she (or I) try to import the .obj files I created in the minc toolkit, we get errors. The error says "Error details: No vertex found". There is also a warning: "Warning: Warning: There are gl errors: invalid framebuffer operation". Does anyone know how to export .obj files from MINC so that they can be imported into mesh lab. Or convert the .obj files to another format that will work, such as .ply or .stl? Thanks again for your help!

Dan

gdevenyi commented 5 years ago

Vtk_meshconvert.py from minc-stuffs https://github.com/Mouse-Imaging-Centre/minc-stuffs

danhps commented 5 years ago

Thanks! sudo apt-get install libvtk5-dev python-vtk, the script given to for installing VTK, doesn't seem to work anymore (sudo: apt-set: command not found is the error I get). Is there a current version?

gdevenyi commented 5 years ago

Compare the command you were supposed to use: apt-get install libvtk5-dev python-vtk

and the error you got: sudo: apt-set: command not found

I see a typo.

Also notice that the instructions are from 2015, you probably need libvtk6 instead.

vfonov commented 5 years ago

There is bicobj2vtk and bicobj2oogl - in the minc-toolkit , try running that.

vfonov commented 5 years ago

https://github.com/BIC-MNI/bicpl/blob/develop/tools/bicobj2ply.c - is present in bicpl , but not compiled by default ....

danhps commented 5 years ago

Gabe: that was an autocorrect typo, I think, though I don't know why it would convert one word to another. I still get "sudo: apt-get: command not found"

Vladimir: Thanks! May I ask how do I compile bicobj2ply.c?

gdevenyi commented 5 years ago

Then you're not using debian or Ubuntu... Use the appropriate command for your system to install to install the python-vtk package

vfonov commented 5 years ago

To compile bicobj2ply.c one have to modify CMakeFiles.txt to do that ( https://github.com/BIC-MNI/bicpl/blob/develop/tools/CMakeLists.txt )

marta-vidalgarcia commented 4 years ago

Hi, I'm just following up on this. I am batch-processing multiple meshes with the marching_cubes function. It seems to work well, but I am unable to open/load the meshes in any software other than Display. The meshes generated through marching_cubes are smaller than when I generate them through the Display menu. Another interesting thing is that I am able to open the meshes through the Display interface (e.g. 'Display test1.ply'), and when I save that mesh (without any manipulation) as a *.ply, it saves a bigger (~5-6MB bigger) mesh than the one I had loaded. I'm not sure what's wrong, but my guess would be something to do with the header? When I try to open the initial 'marching_cubes' mesh in a text editor it seems corrupted, while the one saved through the Display interface appears to be right. Any help on this issue would be much appreciated! Many thanks, Marta

gdevenyi commented 4 years ago

The object file is probably an MNI binary object instead of a MNI ASCII object, use this to convert:

> convert_object 
Toggle format of a .obj file from ASCII to BINARY, or vice-versa
Usage: convert_object input.obj output.obj
marta-vidalgarcia commented 4 years ago

Thanks! Do I have to specify binary to ASCII or can that function detect it automatically

vfonov commented 4 years ago

it should detect it automatically

marta-vidalgarcia commented 4 years ago

Thanks so much for your quick reply! I'm still having problems with this, sorry. I did it exactly as you said ($ convert_object test1.ply tes1_converted.ply) and got this message "Converting object from BINARY to ASCII...". However, I still get an error in Meshlab ("Error details: Header not found"). And when I open it in text editor I can see that the header is missing. First 15 lines of test1.ply file created with Display: ply format ascii 1.0 comment Created by Display 2.0.6 element vertex 464076 property float x property float y property float z element face 464102 property list uchar int vertex_index end_header 7.840000 7.455000 1.102500 7.840000 7.437500 1.120000 7.822500 7.455000 1.120000 7.875000 7.455000 1.102500 7.875000 7.437500 1.120000

And first 15 lines of the file I created with marching_cubes and converted from binary to ASCII with convert_object: P 0.3 0.6 0.6 30 1 464076 7.84 7.455 1.1025 7.84 7.4375 1.12 7.8225 7.455 1.12 7.875 7.455 1.1025 7.875 7.4375 1.12 7.91 7.455 1.1025 7.91 7.4375 1.12 7.9275 7.455 1.12 7.7 7.49 1.1025 7.7 7.4725 1.12 7.6825 7.49 1.12 7.735 7.49 1.1025 7.735 7.4725 1.12 7.77 7.49 1.1025

So I would be able to manipulate the file in vim to add the extra lines for most of it, but I'm missing the information on the 'Element face'. As well as issues with the header, when I copy the header from the 'Display' ply to this new file and try to import it into meshlab I get this message 'Error details: Bad vertex index in face'. And I cannot import the mesh into R either. Any help with this would me much appreciated. Am I missing something other than 'marching_cubes' and 'convert_object'? Thank you very much for all your help!

gdevenyi commented 4 years ago

Only Display can create ply files. All other minc object functions create MNI obj files. See discussion far above as to how to convert to other formats.

marta-vidalgarcia commented 4 years ago

@gdevenyi Thanks for your help! I don't necessarily need ply, I'd be happy to get obj files. I should have specified that I have exactly the same problem with .obj files. I use marching_cubes & convert_object but I cannot import that .obj file anywhere other than Display. I'm not sure what I'm missing. Thanks you very much for all your help!

gdevenyi commented 4 years ago

OBJ files are MNI OBJ files. meshlab can't load those. See above about vtk_meshconvert.py which can convert MNI OBJ to other mesh formats.

marta-vidalgarcia commented 4 years ago

Thanks, but I'm still having trouble with this. I'm running $ marching_cubes test1.mnc test1.obj; $ convert_object test1.obj test1_ascii.obj; $ vtk_meshconvert.py -i test1_ascii.obj -o test1.stl (but I have also tried with ply), and I cannot open the resulting stl or ply mesh in any software, including Display. However, I can still open the original binary and ascii *.obj files in Display. Thank you very much for your help!

gdevenyi commented 4 years ago

I just went through the same steps as you did and for meshlab 2016.12-2 the stl and ply files open as expected.

marta-vidalgarcia commented 4 years ago

@gdevenyi - I don't get any errors when I run these steps, so I'm not sure what I'm missing... I cannot open the mesh in text editor either. The only thing that occurred to me is that 'marching_cubes' might be working differently on my mnc files because they are labels? In Display I do 'Create Surface' -> 'Volume Bin-Isosurface' -> '1 1'. Could this be the issue? I have tried marching_cubes with both 1 1 at the end of the input file and output file and nothing and I seem to get the same outcome. Thanks very much! I really appreciate your fast responses and all your help trouble-shooting this! Edit - I have tried to upload this my test1.mnc file here but this file type is not supported, so I just changed the extension to txt to be able to upload it here, in case that helps. Thank you! test1.txt

gdevenyi commented 4 years ago

It should not matter at all how the obj file is generated if it displays properly it should be valid. At this point the only thing left to do is to share the files from all steps with me so I can inspect/test as it "works for me" (tm)

marta-vidalgarcia commented 4 years ago

Thanks heaps @gdevenyi! Which files do you need?

gdevenyi commented 4 years ago
marta-vidalgarcia commented 4 years ago

@gdevenyi - I was just able to run it in another computer, all good! Thanks so much for your help!

gdevenyi commented 4 years ago

Resolved, issue with meshlab install.