simnibs / simnibs

Simulation of Non-Invasive Brain Stimulation
http://www.simnibs.org
GNU General Public License v3.0
124 stars 41 forks source link

headreco: Gmsh failed meshing #71

Closed legendleaf closed 1 year ago

legendleaf commented 2 years ago

Dear SimNIBS experts,

Thank you for providing such powerful software! I have some problems when using the command "headreco". I performed headreco -all sampleYX YX_T1.nii YX_T2.nii sampleYX is the ID of the current subject. The next two are T1 and T2. The reported bugs are as follows: Gmsh exit code: 2

Gmsh failed meshing one or more surfaces. Trying Delaunay meshing

Gmsh exit code: 2 Traceback (most recent call last): File "/Users/feng/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/cli/headreco.py", line 13, in main() File "/Users/feng/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/cli/headreco.py", line 10, in main headmodel(sys.argv) File "/Users/feng/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/msh/headreco.py", line 693, in headmodel vmsh = make_volume_mesh(args.subject_id, surfaces, subject_dir, args.keep_air) File "/Users/feng/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/msh/headreco.py", line 1941, in make_volume_mesh raise RuntimeError("Gmsh failed meshing one or more surfaces in {} attempts.".format(attempts)) RuntimeError: Gmsh failed meshing one or more surfaces in 3 attempts. (base) FengdeMacBook-Pro:sampleYX feng$

In addition, I also tried it with ernie data and got the same error. Referring to the question answered in the previous issue question, I tried headreco all -v 1 sampleYX YX_T1.nii YX_T2.nii, and got the same above error.

I have sent a screenshot of the bug report to support@simnibs.org Thank you for any help! Zaki Feng

Bug_reportwith_headreco
legendleaf commented 2 years ago

In addition, I just want the head model information but not the surface or deep cerebral cortex information. Can I use the following code to extract it?

%% Get a head model without cortical information clear all; close all; clc; fn = 'ernie.msh'; m=mesh_load_gmsh4(fn); trep = triangulation(double(m.tetrahedra), m.nodes(:,1),m.nodes(:,2),m.nodes(:,3)); m.triangles=freeBoundary(trep); m.triangle_regions=1002*ones(length(m.triangles),1); fn = 'headwithoutsurface_ernie.msh'; mesh_save_gmsh4(m, fn)

Thank you for any help! Zaki Feng

ulloaa commented 2 years ago

Hi,

We are also getting this same error using headreco on the ernie dataset (see error below). Is this a bug, and if so, is there a workaround?


GENERATING VOLUME MESH

Creating .geo file Creating volume mesh using Gmsh Gmsh exit code: 1

Gmsh failed meshing one or more surfaces. Doing uniform remeshing and retrying Remeshing wm.stl Remeshing gm.stl Remeshing csf.stl Remeshing bone.stl Remeshing skin.stl Remeshing eyes.stl Remeshing cavities.stl Remeshing air_outer_decoupled.stl Remeshing ventricles.stl Decoupling Decoupling ventricles from GM Decoupling WM from ventricles Decoupling GM from WM

Gmsh exit code: 1

Gmsh failed meshing one or more surfaces. Trying Delaunay meshing

Gmsh exit code: 1 Traceback (most recent call last): File "/bin/headreco", line 8, in sys.exit(main()) File "/python3.7/site-packages/simnibs/cli/headreco.py", line 10, in main headmodel(sys.argv) File "/python3.7/site-packages/simnibs/msh/headreco.py", line 693, in headmodel vmsh = make_volume_mesh(args.subject_id, surfaces, subject_dir, args.keep_air) File "/python3.7/site-packages/simnibs/msh/headreco.py", line 1941, in make_volume_mesh raise RuntimeError("Gmsh failed meshing one or more surfaces in {} attempts.".format(attempts)) RuntimeError: Gmsh failed meshing one or more surfaces in 3 attempts.

legendleaf commented 2 years ago

Not yet. I tried flag -v or --no-cat. The same error returned. Another macOS re-installed SimNIBS returned the same error.

sdsmet commented 2 years ago

Hi all,

Experiencing the same issues here with the Ernie example dataset;

======================= GENERATING VOLUME MESH

Creating .geo file Creating volume mesh using Gmsh

Gmsh exit code: 2

Gmsh failed meshing one or more surfaces. Doing uniform remeshing and retrying Remeshing wm.stl Remeshing gm.stl Remeshing csf.stl Remeshing bone.stl Remeshing skin.stl Remeshing eyes.stl Remeshing cavities.stl Remeshing air_outer_decoupled.stl Remeshing ventricles.stl Decoupling Decoupling ventricles from GM Decoupling WM from ventricles Decoupling GM from WM

Gmsh exit code: 2

Gmsh failed meshing one or more surfaces. Trying Delaunay meshing

Gmsh exit code: 2 Traceback (most recent call last): File "/Users/stefaniedesmet/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/cli/headreco.py", line 13, in main() File "/Users/stefaniedesmet/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/cli/headreco.py", line 10, in main headmodel(sys.argv) File "/Users/stefaniedesmet/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/msh/headreco.py", line 693, in headmodel vmsh = make_volume_mesh(args.subject_id, surfaces, subject_dir, args.keep_air) File "/Users/stefaniedesmet/Applications/SimNIBS-3.2/simnibs_env/lib/python3.7/site-packages/simnibs/msh/headreco.py", line 1941, in make_volume_mesh raise RuntimeError("Gmsh failed meshing one or more surfaces in {} attempts.".format(attempts)) RuntimeError: Gmsh failed meshing one or more surfaces in 3 attempts.

I am running this on a MacBook Pro (M1 chip) macOS Monterey. Tried running it yesterday on a friend her Dell XPS - windows 10 and no error.. Are you also running SIMNIBS on Macs with M1 chips?

see also this comment from the Changelog 3.2.2; "SimNIBS is so far not tested on Macs with Apple Silicon, and is likely to give errors on those machines"

ulloaa commented 2 years ago

We are getting the error on Linux using version 3.2.5.

ulloaa commented 2 years ago

We tried every single version prior to 3.2.5 and got the same error in each version except with 3.0

oulap commented 2 years ago

Hi,

Sorry have completely missed this one. We haven't tested SimNIBS on the new M1 macs yet, so no guarantees there as the website states.

I tried re-running ernie with the latest SimNIBS version on Ubuntu 20.04 and the seems to work.

Please send your headreco_log.htmls to support@simnibs.org, so we can have a closer look.

legendleaf commented 2 years ago

Dear experts,

Sorry for the late reply. My current SimNIBS version is 3.2.5. I uploaded the headreco_log.htmls.

Thank you for any help! Zaki

------------------ 原始邮件 ------------------ 发件人: "simnibs/simnibs" @.>; 发送时间: 2022年2月9日(星期三) 晚上9:53 @.>; 抄送: "子健 @.**@.>; 主题: Re: [simnibs/simnibs] headreco: Gmsh failed meshing (Issue #71)

Hi,

Sorry have completely missed this one. We haven't tested SimNIBS on the new M1 macs yet, so no guarantees there as the website states.

I tried re-running ernie with the latest SimNIBS version on Ubuntu 20.04 and the seems to work.

Please send your headreco_log.htmls to @.***, so we can have a closer look.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

oulap commented 2 years ago

Thanks, we're looking into this but seems like a gmsh issue. We have now also a M1 mac so we can test on that as well.

legendleaf commented 2 years ago

Thank you!Looking forward to your good news. Best, Zaki

---Original--- From: @.> Date: Fri, Feb 18, 2022 19:39 PM To: @.>; Cc: @.**@.>; Subject: Re: [simnibs/simnibs] headreco: Gmsh failed meshing (Issue #71)

Thanks, we're looking into this but seems like a gmsh issue. We have now also a M1 mac so we can test on that as well.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

oulap commented 2 years ago

The problem with gmsh on Macs should be fixed in the new release. Give it try and let us know if it works.

jacorvar commented 2 years ago

This issue still persists on CentOS 7.9 with Simnibs 3.2.6. I've tried downloading the installer and also using conda.

jacorvar commented 2 years ago

I installed latest version (3.2.6) on a singularity container (Ubuntu 20.04) and keeps failing with the same error when running it on CentOS 7.9 with singularity 3.7.0.

This is the container recipe I'm using (I tried with both Ubuntu 20.04 and 21.10):

BootStrap: docker
From: ubuntu:21.10

%runscript
    echo "This is what happens when you run the container..."

%post
    echo "Hello from inside the container"
    apt -y update
    apt -y install wget vim libgl1-mesa-glx
    wget https://repo.anaconda.com/miniconda/Miniconda3-py38_4.11.0-Linux-x86_64.sh
    /bin/bash /Miniconda3-py38_4.11.0-Linux-x86_64.sh -p /opt/miniconda3 -b -f
    export PATH="/opt/miniconda3/bin:$PATH"
    wget https://github.com/simnibs/simnibs/releases/latest/download/environment_linux.yml
    conda env create -f environment_linux.yml
    echo ". /opt/miniconda3/etc/profile.d/conda.sh" >> $SINGULARITY_ENVIRONMENT
    echo "conda activate simnibs_env" >> $SINGULARITY_ENVIRONMENT
    . $SINGULARITY_ENVIRONMENT
    pip install -f https://github.com/simnibs/simnibs/releases/latest simnibs
oulap commented 1 year ago

I think we managed to fix this in headreco (hopefully). In version 4 this should not be an issue as the meshing was completely changed.