brainstorm3 icon indicating copy to clipboard operation
brainstorm3 copied to clipboard

update iso2mesh version for ARM

Open Edouard2laire opened this issue 1 year ago • 10 comments

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

Edouard2laire avatar Jul 23 '24 17:07 Edouard2laire

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

fangq avatar Jul 24 '24 15:07 fangq

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.

Edouard2laire avatar Jul 24 '24 16:07 Edouard2laire

@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?

rcassani avatar Jul 24 '24 19:07 rcassani

@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.

Edouard2laire avatar Jul 24 '24 19:07 Edouard2laire

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.

tmedani avatar Jul 24 '24 19:07 tmedani

@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 avatar Jul 24 '24 21:07 fangq

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

fangq avatar Jul 25 '24 18:07 fangq

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

fangq avatar Aug 18 '24 16:08 fangq

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

https://github.com/fangq/iso2mesh/issues/80

fangq avatar Aug 20 '24 19:08 fangq

thx. i will do some test later this week

Edouard2laire avatar Aug 21 '24 17:08 Edouard2laire