Skip to content
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

update iso2mesh version for ARM #727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Edouard2laire
Copy link
Contributor

@Edouard2laire Edouard2laire commented Jul 23, 2024

Hello,
Iso2mesh was updated to support ARM: https://x.com/FangQ/status/1801795041867776036

This now download iso2mesh directly from github to get this updated version.

Also, it doesnt work if i keep:

    % PlugDesc(end).DeleteFiles    = {'doc', 'tools', '.git_filters', 'sample', ...
    %                                 'bin/cgalmesh.exe', 'bin/cgalmesh.mexglx', 'bin/cgalmesh.mexmaci', ...
    %                                 'bin/cgalpoly.exe', 'bin/cgalpoly.mexglx', 'bin/cgalpoly.mexmaci', 'bin/cgalpoly.mexa64', 'bin/cgalpoly.mexmaci64', 'bin/cgalpoly_x86-64.exe', ...   % Removing cgalpoly completely (not used)
    %                                 'bin/cgalsurf.exe', 'bin/cgalsurf.mexglx', 'bin/cgalsurf.mexmaci', ...
    %                                 'bin/cork.exe', ...
    %                                 'bin/gtsrefine.mexglx', 'bin/gtsrefine.mexmaci', 'bin/gtsrefine.mexarmhf', 'bin/gtsrefine.exe', 'bin/gtsrefine.mexmaci64', ...  % Removing gtsrefine completely (not used)
    %                                 'bin/jmeshlib.exe', 'bin/jmeshlib.mexglx', 'bin/jmeshlib.mexmaci', 'bin/jmeshlib.mexmac', 'bin/jmeshlib.mexarmhf', ...
    %                                 'bin/meshfix.exe', 'bin/meshfix.mexglx', 'bin/meshfix.mexmaci', 'bin/meshfix.mexarmhf', ...
    %                                 'bin/tetgen.mexglx', 'bin/tetgen.mexmac', 'bin/tetgen.mexarmhf', ...
    %                                 'bin/tetgen1.5.mexglx'};
    % PlugDesc(end).DeleteFilesBin = {'bin/tetgen.exe', 'bin/tetgen.mexa64', 'bin/tetgen.mexmaci', 'bin/tetgen.mexmaci64', 'bin/tetgen_x86-64.exe', ...    % Removing older tetgen completely (very sparsely used)
    %                                 'bin/tetgen1.5.exe'};

i get an error with tetgen. But if i dont delete any file, then it works great:
image

cc: @fangq

@fangq
Copy link

fangq commented Jul 24, 2024

how does brainstorm unzip the zip file? using regular unzip, the x permission looks fine.
there is also a possibility of needing xattr -r -d com.apple.quarantine?

~/Downloads$ wget https://github.com/fangq/iso2mesh/archive/refs/heads/master.zip
--2024-07-24 11:51:30--  https://github.com/fangq/iso2mesh/archive/refs/heads/master.zip
Resolving github.com (github.com)... 140.82.112.4
...
~/Downloads$ unzip master.zip 
Archive:  master.zip
aa78f3a1c9ffdc9dfd41b1ae290161d3233110a5
...
~/Downloads/iso2mesh-master/bin$ ls -lt *mexmaca64
-rwxr-xr-x  1 fangq  staff  12766848 Jun 14 16:42 cgalmesh.mexmaca64
-rwxr-xr-x  1 fangq  staff   3353160 Jun 14 16:42 cgalsurf.mexmaca64
-rwxr-xr-x  1 fangq  staff    488696 Jun 14 16:42 cork.mexmaca64
-rwxr-xr-x  1 fangq  staff    324672 Jun 14 16:42 jmeshlib.mexmaca64
-rwxr-xr-x  1 fangq  staff    791096 Jun 14 16:42 meshfix.mexmaca64
-rwxr-xr-x  1 fangq  staff    810632 Jun 14 16:42 tetgen.mexmaca64
-rwxr-xr-x  1 fangq  staff    706776 Jun 14 16:42 tetgen1.5.mexmaca64

@Edouard2laire
Copy link
Contributor Author

how does brainstorm unzip the zip file? using regular unzip, the x permission looks fine. there is also a possibility of needing xattr -r -d com.apple.quarantine?

~/Downloads$ wget https://github.com/fangq/iso2mesh/archive/refs/heads/master.zip
--2024-07-24 11:51:30--  https://github.com/fangq/iso2mesh/archive/refs/heads/master.zip
Resolving github.com (github.com)... 140.82.112.4
...
~/Downloads$ unzip master.zip 
Archive:  master.zip
aa78f3a1c9ffdc9dfd41b1ae290161d3233110a5
...
~/Downloads/iso2mesh-master/bin$ ls -lt *mexmaca64
-rwxr-xr-x  1 fangq  staff  12766848 Jun 14 16:42 cgalmesh.mexmaca64
-rwxr-xr-x  1 fangq  staff   3353160 Jun 14 16:42 cgalsurf.mexmaca64
-rwxr-xr-x  1 fangq  staff    488696 Jun 14 16:42 cork.mexmaca64
-rwxr-xr-x  1 fangq  staff    324672 Jun 14 16:42 jmeshlib.mexmaca64
-rwxr-xr-x  1 fangq  staff    791096 Jun 14 16:42 meshfix.mexmaca64
-rwxr-xr-x  1 fangq  staff    810632 Jun 14 16:42 tetgen.mexmaca64
-rwxr-xr-x  1 fangq  staff    706776 Jun 14 16:42 tetgen1.5.mexmaca64

oh actually you are right, permission are fine. Issue i got was because of the file being deleted.

@rcassani
Copy link
Member

@Edouard2laire, could you identify which removed file(s) are the culprits?

@tmedani, besides the comments in bst_plugin are you familiar with the reasons for removing some files when installing iso2mesh?

@Edouard2laire
Copy link
Contributor Author

Edouard2laire commented Jul 24, 2024

@Edouard2laire, could you identify which removed file(s) are the culprits?

i am not sure how. Seems it would require a lot of try and error.

i mainly getting this error:
image

So i tried to delete everything expet tetgen files, but i still get the same error with the following log file:


------------------------------------------------------------------------
24-Jul-2024 15:16:01 - Running job #1
------------------------------------------------------------------------
24-Jul-2024 15:16:02 - Running 'Segment'

SPM12: spm_preproc_run (v7670)                     15:16:02 - 24/07/2024
========================================================================
Segment /Users/edelaire1/.brainstorm/tmp/brain2mesh_240724_151558/sub-01T1.nii,1
Completed                               :          15:18:25 - 24/07/2024
24-Jul-2024 15:18:25 - Done    'Segment'
24-Jul-2024 15:18:25 - Done

extracting surfaces from a volume ...
region 1 centroid :	144.333333 87.666667 88.500000

processing threshold level 1...
Surface Mesh Extraction Utility (Based on CGAL 5.6.1)
(modified for iso2mesh by Qianqian Fang)
http://iso2mesh.sf.net

RNG seed 1648335518
set initial mesh size to 50
Final number of points: 37761
251 isolated nodes were removed
surface mesh generation is complete
extracting surfaces from a volume ...
region 1 centroid :	139.333333 111.666667 116.500000

processing threshold level 1...
Surface Mesh Extraction Utility (Based on CGAL 5.6.1)
(modified for iso2mesh by Qianqian Fang)
http://iso2mesh.sf.net

RNG seed 1648335518
set initial mesh size to 50
Final number of points: 43898
294 isolated nodes were removed
surface mesh generation is complete
extracting surfaces from a volume ...
region 1 centroid :	142.333333 94.666667 128.500000

processing threshold level 1...
Surface Mesh Extraction Utility (Based on CGAL 5.6.1)
(modified for iso2mesh by Qianqian Fang)
http://iso2mesh.sf.net

RNG seed 1648335518
set initial mesh size to 50
Final number of points: 4125
53 isolated nodes were removed
surface mesh generation is complete
extracting surfaces from a volume ...
region 1 centroid :	131.333333 112.666667 133.500000

processing threshold level 1...
Surface Mesh Extraction Utility (Based on CGAL 5.6.1)
(modified for iso2mesh by Qianqian Fang)
http://iso2mesh.sf.net

RNG seed 1648335518
set initial mesh size to 50
Final number of points: 11710
375 isolated nodes were removed
surface mesh generation is complete
generating tetrahedral mesh from closed surfaces ...
creating volumetric mesh from a surface mesh ...
volume mesh generation is complete
extracting surfaces from a volume ...
region 1 centroid :	102.333333 134.666667 102.000000

processing threshold level 1...
Surface Mesh Extraction Utility (Based on CGAL 5.6.1)
(modified for iso2mesh by Qianqian Fang)
http://iso2mesh.sf.net

RNG seed 1648335518
set initial mesh size to 50
Final number of points: 108985
4593 isolated nodes were removed
surface mesh generation is complete
generating tetrahedral mesh from closed surfaces ...
creating volumetric mesh from a surface mesh ...
volume mesh generation is complete
generating tetrahedral mesh from closed surfaces ...
creating volumetric mesh from a surface mesh ...
volumetric mesh generation failed, returning the intermediate surface model onlyIdleTimeout has been reached.

Here is a more precise error of what happens here: https://github.com/fangq/brain2mesh/blob/master/brain2mesh.m#L361


Error using surf2mesh
Tetgen command failed:
Opening /Users/edelaire1/.brainstorm/tmp/post_vmesh.poly.
Delaunizing vertices...
Delaunay seconds:  1.06491
Creating surface mesh ...
Surface mesh seconds:  0.389386
Constrained Delaunay...
PLC Error:  A vertex lies in a segment.
  Vertex:  [147545] (255.919,158.723,60.1497).
  Segment: [147547, 147546] #-1 (0)
A self-intersection was detected. Program stopped.
Hint: use -d option to detect all self-intersections.



Error in s2m (line 35)
        [node,elem,face]=surf2mesh(v,f,[],[],keepratio,maxvol,regions,holes,0,method,varargin{:});

i don't understand how not deleting file could solve the issue; so identifying which file to keep is outside of my skill set.

@tmedani
Copy link
Member

tmedani commented Jul 24, 2024

Hey team,

@tmedani, besides the comments in bst_plugin are you familiar with the reasons for removing some files when installing iso2mesh?

we did some tests and selected only the dependencies required by the process_fem_mesh.m
I don't understand why this new release is not working; maybe there are some changes in the internal calls for this new release.
Is this issue specific to ARM processors?

I agree with @Edouard2laire, testing all the cases with all dependencies can be tedious. Maybe we can just remove those

'doc', 'tools', '.git_filters', 'sample'

and keep all the other files.

@fangq
Copy link

fangq commented Jul 24, 2024

@Edouard2laire, could you identify which removed file(s) are the culprits?

i am not sure how. Seems it would require a lot of try and error.

i mainly getting this error: ![image](https://private-user-images.githubusercontent.com/24530402/351847601-
...
i don't understand how not deleting file could solve the issue; so identifying which file to keep is outside of my skill set.

if you try the same input for brain2mesh on windows or Linux and they do not crash tetgen, then I think it is likely caused by the updated cgal version when the arm64 mac binaries were compiled (v5.x vs v3.x)

if you can share the matlab variables used for the brain2mesh call, I can also take a look

@fangq
Copy link

fangq commented Jul 25, 2024

@Edouard2laire, FYI, I tested both built-in examples of brain2mesh on my M2 Mac, and both worked fine.

@fangq
Copy link

fangq commented Aug 18, 2024

@Edouard2laire, are the new binaries working ok with brainstorm?

@fangq
Copy link

fangq commented Aug 20, 2024

@Edouard2laire, FYI, I added a missing cgalsimp2 binary for arm64 mac

fangq/iso2mesh#80

@Edouard2laire
Copy link
Contributor Author

thx. i will do some test later this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants