-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marching Cubes: invalid triangle #12
Comments
I am unable to replicate. Perhaps you can share a dataset and specific method to troubleshoot. Here is a recipe that worked for me using the mni152.nii.gz image from NiiVue: $ git clone [email protected]:neurolabusc/nii2mesh.git
$ cd nii2mesh/src
$ make
$ ./nii2mesh -v
nii2mesh v1.0.20211220 Clang14.0.3 ARM
...
$ ./nii2mesh ../../mni152.nii.gz -r 0.1 -v 2 mni152.mz3
load from disk: 36 ms
pre-smooth: 57 ms
intensity range 0..88.8585, isolevel 31.5005
voxel clustering (largest cluster, bubbles): 253 ms
marching cubes (207x256x215): 112 ms
Unify vertices found no shared vertices
remove degenerate triangles 580258 -> 580211: 4 ms
iteration 0 - triangles 580211 threshold 2.187e-06
iteration 5 - triangles 288579 threshold 0.00209715
iteration 10 - triangles 95748 threshold 0.0627485
simplify vertices 290191->29039 triangles 580211->58020 (r = 0.0999981): 217 ms
save to disk: 61 ms If your NIfTI file is a T1-weighted image of the human head, you can try brain2print.org. Alternatively, for CT and other MRI scans, you can try ct2print.org |
Hello Chris, Thank you for your quick reply. I am using the segmentations of a model (in .nii format, with intensity values between 0 and 1) for converting them into .obj files. The previous model input is a CT scan (in dicom). I tried to do the following command I get an error that is given above. I tried using the options commands but that did not affect much I believe. Please find a sample files attached here which do not work with the code version of nii2mesh but work with the web based nii2mesh given in the link: https://rordenlab.github.io/nii2meshWeb/. Am I missing something here in the code? Thank you |
I am unable to replicate. Everything runs fine on my machine. ./nii2mesh ~/Downloads/segmentations/segmentation_1.nii output1.obj
./nii2mesh ~/Downloads/segmentations/segmentation_2.nii output2.obj
./nii2mesh ~/Downloads/segmentations/segmentation_2.nii output3.obj I can not help you if I can not replicate. Can I suggest you follow the recipe in my previous post, where I compile from source and run the program twice:
|
Hello Chris, I am using Linux (Google Colab) to run the code. Here is the code that I have used for the same Code starts hereimport os if not os.path.exists('nii2mesh'): %cd nii2mesh/src input_nifti = '/content/segmentation_3.nii' output_directory = os.path.dirname(output_mesh) command = f'./nii2mesh/src/nii2mesh {input_nifti} {output_mesh}' if exit_code != 0 or not os.path.exists(output_mesh): Code ends hereI get the following error: Reading package lists... Done Is there anything wrong I am trying to do?? I get a similar output for each of the files. |
I am not familiar with this tool chain - you may want to consult someone with Google colab expertise. Can you please see if the code below works. Also, are you sure that the input file exists and has read permissions, and the output location has write permissions with sufficient space.
|
Yes I am sure the input file exists and has read permissions as well as there is sufficient space for the file to store... I initially thought there is an error with the dataset but if its running well at your end and hence it should run on my end as well... The above code gave me the following output: Reading package lists... Done nii2mesh v1.0.20211220 GCC11.4.0 x86-64 load from disk: 18 ms |
For the segmentation file that I have sent you gives me the following error: load from disk: 190 ms |
Can you recompile the latest commit (it will report |
Hii Chris, Thank you for your help. Previously I had many files which did not convert to .obj, it has reduced significantly.
The run stops at something like:
The issue is I believe for some files the operation does not save the files. |
I am unable to replicate. Can you share a file that exhibits this behavior? |
I used the script
which gives the output
Please find the attached nifit file that exhibits this behavior. |
This is a limitation with your segmentation, not the software. nii2mesh returns an error code that you can detect, for example from the command line with $ ./nii2mesh segment.nii -r 0.25 -v 2 segment.obj
nii2mesh v1.0.20240904 Clang14.0.3 ARM
load from disk: 46 ms
pre-smooth: 1521 ms
intensity range 0..0.773125, isolevel 0.25098
voxel clustering (largest cluster, bubbles): 616 ms25098
$ echo $?
1 I have made a commit that now explicitly provides text describing the error: marching cubes failed to identify triangles with an isolevel of 0.25098 The only non-zero images in this image are in the very top slice. Marching cubes expects voxels above the isosurface value to be surrounded by voxels below this threshold. |
Okay. I understand now.. Thank you for your help.. |
Hello experts,
This is a very cool tool to convert the nifti (.nii) files to mesh (.obj).
But I am encountering an error like below:
load from disk: 154 ms
pre-smooth: 1604 ms
intensity range 0..1, isolevel 0.25098
voxel clustering (largest cluster, bubbles): 2578 ms
Marching Cubes: invalid triangle 15733
-0.250980 -0.250980 -0.250980 -0.250980 -0.250980 -nan 131071.750000 21941997487060864704716311175242973184.000000
When I try to run the file using the online web server it works fine..
But with the code there is an error. What am I doing wrong??
Can anyone help me resolve this??
The text was updated successfully, but these errors were encountered: