neurolabusc / nii2mesh Goto Github PK
View Code? Open in Web Editor NEWConvert NIfTI volume to triangulated mesh using marching cubes
Home Page: https://rordenlab.github.io/nii2meshWeb/
License: Other
Convert NIfTI volume to triangulated mesh using marching cubes
Home Page: https://rordenlab.github.io/nii2meshWeb/
License: Other
The release section is empty, so I compiled it on windows. It can be tricky. Just want to share with you.
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.
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!
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:
bet.nii.gz
provided on nii2meshweb
demo.nii2mesh
:nii2mesh bet.seg.nii.gz -a 1 bet_.ply
Output bet_1.ply.zip
Green is segmentaiton visualization, yellow is model:
Happy to provide any more details that you need.
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)
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
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
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.
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?
There seems to be a copy-paste error in the help text at the top of quadric.h
:
https://github.com/neurolabusc/nii2mesh/blob/main/src/quadric.h
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.