Install FreeSurfer 6 on Mac M1 Chip?

Hi all, I’m trying to install a Freesurfer 6 on my M1 chip Mac, but everything just does not work well.
Actually Freesurfer 7 works well, but some pipelines (HCP mininal, fMRIPrep, etc) are using FreeSurfer 6, that’s why I’m turning to 6.

When I run recon-all, errors:

Fri Oct 14 11:00:51 CST 2022
mri_nu_correct.mni done
\n talairach_avi --i orig_nu.mgz --xfm transforms/talairach.auto.xfm \n
talairach_avi log file is transforms/talairach_avi.log...
Started at Fri Oct 14 11:00:51 CST 2022
Ended   at Fri Oct 14 11:01:22 CST 2022
talairach_avi done
\n cp transforms/talairach.auto.xfm transforms/talairach.xfm \n
#--------------------------------------------
#@# Talairach Failure Detection Fri Oct 14 11:01:24 CST 2022
/Applications/freesurfer/subjects/seg/mri
\n talairach_afd -T 0.005 -xfm transforms/talairach.xfm \n
talairach_afd: Talairach Transform: transforms/talairach.xfm OK (p=0.6010, pval=0.2817 >= threshold=0.0050)
\n awk -f /Applications/freesurfer/bin/extract_talairach_avi_QA.awk /Applications/freesurfer/subjects/seg/mri/transforms/talairach_avi.log \n
\n tal_QC_AZS /Applications/freesurfer/subjects/seg/mri/transforms/talairach_avi.log \n
ERROR: awk -f /Applications/freesurfer/bin/extract_talairach_avi_QA.awk /Applications/freesurfer/subjects/seg/mri/transforms/talairach_avi.log failed!  See logfile /Applications/freesurfer/subjects/seg/mri/transforms/talairach_avi_QA.log
Darwin RunjiadeMacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64


recon-all -s seg exited with ERRORS at Fri Oct 14 11:01:24 CST 2022

When I run freeview, it yields

2022-10-14 11:24:20.865 Freeview[66988:16153343] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
QColor::setNamedColor: Unknown color name '@Variant('
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC ERROR: or try http://valgrind.org on linux or man libgmalloc on Apple to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Signal received!
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 13, Thu May 15 17:29:26 CDT 2008 HG revision: 4466c6289a0922df26e20626fd4a0b4dd03c8124
[0]PETSC ERROR: See docs/changes/index.html for recent updates.
[0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
[0]PETSC ERROR: See docs/index.html for manual pages.
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Unknown Name on a darwin12. named RunjiadeMacBook-Pro.local by runjia Fri Oct 14 11:24:17 2022
[0]PETSC ERROR: Libraries linked from /usr/pubsw/packages/petsc/2.3.3-p13-64b/src/petsc-2.3.3-p13/lib/darwin12.2.0-c-opt
[0]PETSC ERROR: Configure run at Mon Dec 17 15:29:35 2012
[0]PETSC ERROR: Configure options --with-debugging=no --with-cc=gcc --with-fc=0 --download-f-blas-lapack=0 --download-mpich=1 --with-mpi=1 --with-x=0 --with-gnu-copyright-code=0 --with-shared=0 COPTFLAGS=-O3 CXXOPTFLAGS=-O3 FOPTFLAGS=-O3
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file
[unset]: aborting job:
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0

Thank you in advance!

Hi,

Have you considered running these pipelines via Docker? That might help with software compatibility.

Best,
Steven

1 Like

Are you compiling/running native ARM versions, or working with emulated x86-64 code? You can find this out by using file, so for my example dcm2niix is a universal executable that will be run as arm64 on a M1:

file /usr/local/bin/dcm2niix
/usr/local/bin/dcm2niix: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/usr/local/bin/dcm2niix (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/local/bin/dcm2niix (for architecture arm64):	Mach-O 64-bit executable arm64

For emulating x86_64 code with the M1 CPU, note that AVX instructions are not supported (though SSE instructions are). There are patches to allow you to recompile. For compiling natively to ARM you could use sse2neon. You may want to see this thread.

2 Likes

Hi Steven, many thanks for your reply!

Docker is for sure a good idea for running these pipelines.
However, I’m building my own pipeline so I need to borrow some code from existing pipelines.

Best,
Runjia

Hi, thank you for your reply!

I think I’m running x86-64 code, this is what I get when I do file $FREESUEFERHOME/bin/3dvolreg.afni and many other files that end with .fs :

/Applications/freesurfer/bin/3dvolreg.afni: Mach-O 64-bit executable x86_64
/Applications/freesurfer/bin/gdcmconv.fs: Mach-O 64-bit executable x86_64

So I should use this patch to recompile freesurfer, right?
But still, I have no idea how I should use the patch for recompiling specifically, could you please share more details?

Thank you!

Update:

I just reinstalled FreeSurfer 6, now recon-all works fine, but freeview still not working (abort immediatly),
similar issues were also proposed on the official FS mailing list, I didn’t see a solution so far. :smiling_face_with_tear: