GithubHelp home page GithubHelp logo

neurolabusc / nii2mesh Goto Github PK

View Code? Open in Web Editor NEW
132.0 5.0 15.0 4.58 MB

Convert NIfTI volume to triangulated mesh using marching cubes

Home Page: https://rordenlab.github.io/nii2meshWeb/

License: Other

Makefile 0.16% C 99.84%
mri-images medical-imaging mesh-generation mesh-simplification nifti-format 3d obj-format marching-cubes

nii2mesh's Issues

Compile on Win10

The release section is empty, so I compiled it on windows. It can be tricky. Just want to share with you.

  1. Install MinGW with C, make
  2. meshify.c line 270 change to:
double clockMsec() { //return milliseconds since midnight
#ifdef _MSC_VER
	clock_t t = clock();
	return (double)((double)t) / (CLOCKS_PER_SEC / 1000.0);
#else
    time_t seconds_since_midnight = time(NULL) % 86400;
  
    // #define CLOCK_MONOTONIC                 1
	// struct timespec _t;
	// clock_gettime(CLOCK_MONOTONIC, &_t);
	// return _t.tv_sec*1000.0 + (_t.tv_nsec/1.0e6);
    return seconds_since_midnight;
#endif

After that, you should be able to compile it.

Request for the release for Windows

Thank you for the fantastic work! The solutions for compiling are comprehensive and informative; however, it would be very helpful if the compiled version of the program for Windows could be found in the release. Thanks a lot!

Incorrect orientation of exported meshes

Hey, thank you for making and publishing nii2mesh. I'm a big fan of your works (using NiiVue for open visualization).
I've notice that the generated meshes from nii2mesh is in a different orientation comparing to the voxel orientation. I need to perform a 180 degrees rotation around the Z axis in local coordinates of the object* for correction.

I've tested and confirmed with different files having these original affine: RAS, LPS and LAI.

Example file:

  1. I created a rough segmentation using 3D Slicer for bet.nii.gz provided on nii2meshweb demo.
    You could download it here bet.seg.nii.gz
  2. Run nii2mesh:
nii2mesh bet.seg.nii.gz -a 1 bet_.ply

Output bet_1.ply.zip

  1. View with 3D Slicer:

Green is segmentaiton visualization, yellow is model:

image image

Happy to provide any more details that you need.

"double free or corruption (!prev)" in quadric_simplify_mesh

With the exemplar attached mesh (20480 faces), quadric_simplify_mesh runs successfully at reducing the number of faces from 20479 to 3750 but crashes when requesting 3749 faces (aggressiveness set to 7.0):

 iteration 0 - triangles 20480 threshold 2.187e-06
 iteration 1 - triangles 11952 threshold 1.6384e-05
 iteration 2 - triangles 7700 threshold 7.8125e-05
 iteration 3 - triangles 4790 threshold 0.000279936
 iteration 4 - triangles 3748 threshold 2.22045e-16
double free or corruption (!prev)

sphere.zip

incomplete conversion

Only half of my tooth model is left after the conversion
微信截图_20230426104702
The original nii.gz model contained both upper and lower teeth

segfault when meshing a volume with non-zero voxels on the bounding-box

while I was testing the below command as part of PR #1

cd src
make JSON=1
cd ../data
 ../src/nii2mesh digimouse.jnii -i 0.5 -v 1 test.bmsh

I got a segfault in several computers I tested. However, running valgrind with the above command completed without a problem. I traced the crash to the marchingCubes function.

The volume digimouse.jnii contains segmentation labels from 0 to 21. Setting -i 0.5, I meant to extract the exterior surface. in such case, the hi bbx corner matches the maximum z-axis (104)

marching cubes (190x496x104): lo: [8 20 4] hi: [174 466 104], isolevel: 0.500000

if I remove -i 0.5, and let nii2mesh to choose the default isolevel, the program runs without an error, it prints the below parameters, note that the bbx bounded by lo/hi are no longer align with the outer boundary

marching cubes (190x496x104): lo: [26 171 12], hi: [156 332 95], isolevel= 7.975141

so I suspected that the marchingCubes function has some robustness issues when processing surfaces along the exterior bbx of the volume.

do you know what is the expected behavior for the marching-cubes module in such case? as I mentioned, when running valgrind, it did output a valid mesh, see below

segfault_digimouse

digimouse_i0 5

Missing releases

Hi-

Would it be possible to upload a release for windows please? The readme alludes and even links to one, but no release seems to be present.

I have tried compiling myself (although admittedly I can only get the 'cl' compile to run.) - it appears to compile without error, but whenever I execute from the cmd line the program does not seem to create an output file. Perhaps this is the compatibility issue described in the readme.md

Cheers-
Oli

Scope of functions defined in quadric.c

Would it be OK to add a static keyword to all functions in quadric.c apart from quadric_simplify_mesh, laplacian_smoothHC and laplacian_smooth (and perhaps expose laplacian_smooth in quadric.h)?

It also seems that time.h does not need to be included.

Demo does not support this data type (solution: use niimath)

Hello, I met a problem when using nii2mesh.
./nii2mesh $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala_mask-in-rawavg.nii.gz -p 1 -l 0 -s 100 $SUBJECTS_DIR/sub-OAS30001_ses-d0129_T1w/mri/lh.amygdala.p1l0s100.stl
Demo does not support this data type (solution: use niimath)

I don't know why this error rises even when the input format is NIFTI. And after this, I tried to solve this by installing niimath but nothing changed.
So what's wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.