External Email - Use Caution        

Dear Freesurfer experts,

I’m trying to run recon-all on "T1-like” data (it is actually a quantitative MRI map with a contrast very similar to T1). 
I managed to put it through recon-all’s autorecon1 stage without any major tricks or modifications (watershed is failing but I managed to work around it using FSL’s BET combined with mri_convert to create the brainmask.mgz file).

Now I’m running into a segmentation fault error in mri_em_register.  
Here’s the relevant portion of the log file:

#@# EM Registration Fri Dec 13 10:55:07 GMT 2019
/data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/subjects/PM1/mri

 mri_em_register -rusage /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/subjects/PM1/touch/rusage.mri_em_register.dat -uns 3 -mask brainmask.mgz nu.mgz /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/average/RB_all_2016-05-10.vc700.gca transforms/talairach.lta 

setting unknown_nbr_spacing = 3
using MR volume brainmask.mgz to mask input volume...

== Number of threads available to mri_em_register for OpenMP = 1 == 
reading 1 input volumes...
logging results to talairach.log
reading '/data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/average/RB_all_2016-05-10.vc700.gca'...
average std = 7.3   using min determinant for regularization = 5.3
0 singular and 841 ill-conditioned covariance matrices regularized
reading 'nu.mgz'...
INFO: MRImask() using MRImaskDifferentGeometry()
INFO: MRImask() using MRImaskDifferentGeometry()
INFO: MRImask() using MRImaskDifferentGeometry()
INFO: MRImask() using MRImaskDifferentGeometry()
INFO: MRImask() using MRImaskDifferentGeometry()
freeing gibbs priors...done.
accounting for voxel sizes in initial transform
bounding unknown intensity as < 6.3 or > 503.7 
total sample mean = 78.8 (1011 zeros)
************************************************
spacing=8, using 2830 sample points, tol=1.00e-05...
************************************************
register_mri: find_optimal_transform
find_optimal_transform: nsamples 2830, passno 0, spacing 8
Segmentation fault (core dumped)
Linux btupc09 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

recon-all -s PM1 exited with ERRORS at Fri Dec 13 10:55:35 GMT 2019


I’m also sending you the log from the skull striping step, in case the two errors might be connected:
 
#@# Skull Stripping Fri Dec 13 10:23:26 GMT 2019
/data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/subjects/PM1/mri

 mri_em_register -rusage /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/subjects/PM1/touch/rusage.mri_em_register.skull.dat -skull nu.mgz /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/average/RB_all_withskull_2016-05-10.vc700.gca transforms/talairach_with_skull.lta 

aligning to atlas containing skull, setting unknown_nbr_spacing = 5

== Number of threads available to mri_em_register for OpenMP = 1 == 
reading 1 input volumes...
logging results to talairach_with_skull.log
reading '/data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/average/RB_all_withskull_2016-05-10.vc700.gca'...
average std = 22.9   using min determinant for regularization = 52.6
0 singular and 9002 ill-conditioned covariance matrices regularized
reading 'nu.mgz'...
freeing gibbs priors...done.
accounting for voxel sizes in initial transform
bounding unknown intensity as < 8.7 or > 569.1 
total sample mean = 77.6 (1399 zeros)
************************************************
spacing=8, using 3243 sample points, tol=1.00e-05...
************************************************
register_mri: find_optimal_transform
find_optimal_transform: nsamples 3243, passno 0, spacing 8
resetting wm mean[0]: 100 --> 108
resetting gm mean[0]: 61 --> 61
input volume #1 is the most T1-like
using real data threshold=25.1
skull bounding box = (67, 34, 13) --> (199, 162, 201)
using (111, 77, 107) as brain centroid...
mean wm in atlas = 108, using box (95,61,84) --> (127, 92,130) to find MRI wm
before smoothing, mri peak at 106
robust fit to distribution - 107 +- 5.6
after smoothing, mri peak at 106, scaling input intensities by 1.019
scaling channel 0 by 1.01887
initial log_p = -4.775
************************************************
First Search limited to translation only.
************************************************
max log p =    -4.469154 @ (-9.091, 27.273, 9.091)
max log p =    -4.310065 @ (4.545, -4.545, -4.545)
max log p =    -4.294819 @ (-2.273, 2.273, -2.273)
max log p =    -4.269301 @ (1.136, -1.136, -1.136)
max log p =    -4.255560 @ (-0.568, 0.568, 0.568)
max log p =    -4.255560 @ (0.000, 0.000, 0.000)
Found translation: (-6.3, 24.4, 1.7): log p = -4.256
****************************************
Nine parameter search.  iteration 0 nscales = 0 ...
****************************************
Result so far: scale 1.000: max_log_p=-4.200, old_max_log_p =-4.256 (thresh=-4.3)
 1.07500   0.00000   0.00000  -16.08441;
 0.00000   1.05465   0.12074   4.81056;
 0.00000  -0.15011   0.99144   20.31265;
 0.00000   0.00000   0.00000   1.00000;
****************************************
Nine parameter search.  iteration 1 nscales = 0 ...
****************************************
Result so far: scale 1.000: max_log_p=-4.200, old_max_log_p =-4.200 (thresh=-4.2)
 1.07500   0.00000   0.00000  -16.08441;
 0.00000   1.05465   0.12074   4.81056;
 0.00000  -0.15011   0.99144   20.31265;
 0.00000   0.00000   0.00000   1.00000;
reducing scale to 0.2500
****************************************
Nine parameter search.  iteration 2 nscales = 1 ...
****************************************
Result so far: scale 0.250: max_log_p=-4.137, old_max_log_p =-4.200 (thresh=-4.2)
 1.09382   0.00671  -0.03027  -14.36137;
-0.00004   1.06183   0.18668  -1.18705;
 0.03573  -0.20423   0.92682   27.37608;
 0.00000   0.00000   0.00000   1.00000;
****************************************
Nine parameter search.  iteration 3 nscales = 1 ...
****************************************
Result so far: scale 0.250: max_log_p=-4.137, old_max_log_p =-4.137 (thresh=-4.1)
 1.09382   0.00671  -0.03027  -14.36137;
-0.00004   1.06183   0.18668  -1.18705;
 0.03573  -0.20423   0.92682   27.37608;
 0.00000   0.00000   0.00000   1.00000;
reducing scale to 0.0625
****************************************
Nine parameter search.  iteration 4 nscales = 2 ...
****************************************
Result so far: scale 0.062: max_log_p=-4.112, old_max_log_p =-4.137 (thresh=-4.1)
 1.09811   0.01669   0.00322  -18.38501;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23036   0.92131   35.15163;
 0.00000   0.00000   0.00000   1.00000;
****************************************
Nine parameter search.  iteration 5 nscales = 2 ...
****************************************
Result so far: scale 0.062: max_log_p=-4.109, old_max_log_p =-4.112 (thresh=-4.1)
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;
min search scale 0.025000 reached
***********************************************
Computing MAP estimate using 3243 samples...
***********************************************
dt = 5.00e-06, momentum=0.80, tol=1.00e-05
l_intensity = 1.0000
Aligning input volume to GCA...
Transform matrix
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;
nsamples 3243
Quasinewton: input matrix
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;
outof QuasiNewtonEMA: 008: -log(p) =   -0.0  tol 0.000010
Resulting transform:
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;

pass 1, spacing 8: log(p) = -4.109 (old=-4.775)
transform before final EM align:
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;

**************************************************
 EM alignment process ...
 Computing final MAP estimate using 364799 samples. 
**************************************************
dt = 5.00e-06, momentum=0.80, tol=1.00e-07
l_intensity = 1.0000
Aligning input volume to GCA...
Transform matrix
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;
nsamples 364799
Quasinewton: input matrix
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;
outof QuasiNewtonEMA: 010: -log(p) =    4.6  tol 0.000000
final transform:
 1.09940   0.01671   0.00322  -18.55289;
-0.01727   1.06003   0.21032  -0.89724;
 0.00002  -0.23009   0.92023   35.24042;
 0.00000   0.00000   0.00000   1.00000;

writing output transformation to transforms/talairach_with_skull.lta...
mri_em_register utimesec    749.584000
mri_em_register stimesec    1.268000
mri_em_register ru_maxrss   612332
mri_em_register ru_ixrss    0
mri_em_register ru_idrss    0
mri_em_register ru_isrss    0
mri_em_register ru_minflt   157470
mri_em_register ru_majflt   0
mri_em_register ru_nswap    0
mri_em_register ru_inblock  148912
mri_em_register ru_oublock  24
mri_em_register ru_msgsnd   0
mri_em_register ru_msgrcv   0
mri_em_register ru_nsignals 0
mri_em_register ru_nvcsw    28
mri_em_register ru_nivcsw   480
registration took 12 minutes and 31 seconds.

 mri_watershed -rusage /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/subjects/PM1/touch/rusage.mri_watershed.dat -T1 -brain_atlas /data/MR/mr_user/rloucao/Scriptery/freesurferCentOS/freesurfer/average/RB_all_withskull_2016-05-10.vc700.gca transforms/talairach_with_skull.lta T1.mgz brainmask.auto.mgz 


Mode:          T1 normalized volume
Mode:          Use the information of atlas (default parms, --help for details)

*********************************************************
The input file is T1.mgz
The output file is brainmask.auto.mgz
Weighting the input with atlas information before watershed

*************************WATERSHED**************************
Sorting...
      first estimation of the COG coord: x=129 y=88 z=109 r=61
      first estimation of the main basin volume: 953211 voxels
      Looking for seedpoints 
        2 found in the cerebellum 
        18 found in the rest of the brain 
      global maximum in x=114, y=83, z=83, Imax=255
      CSF=11, WM_intensity=110, WM_VARIANCE=5
      WM_MIN=110, WM_HALF_MIN=110, WM_HALF_MAX=110, WM_MAX=110 
      preflooding height equal to 10 percent
done.
Analyze...

      main basin size=9854728970 voxels, voxel volume =1.000 
                     = 9854728970 mmm3 = 9854729.216 cm3
done.
PostAnalyze...Basin Prior
 47 basins merged thanks to atlas 
      ***** 0 basin(s) merged in 1 iteration(s)
      ***** 0 voxel(s) added to the main basin
done.
Weighting the input with prior template 

****************TEMPLATE DEFORMATION****************

      second estimation of the COG coord: x=134,y=125, z=130, r=123101 iterations
^^^^^^^^ couldn't find WM with original limits - expanding ^^^^^^

   GLOBAL      CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = 45809
  RIGHT_CER    CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = -1021745081
  LEFT_CER     CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = 1107215422
 RIGHT_BRAIN   CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = 1073632535
 LEFT_BRAIN    CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = 1058569754
    OTHER      CSF_MIN=1, CSF_intensity=2, CSF_MAX=4 , nb = 1087488148
mri_watershed Error: 
 GLOBAL region of the brain empty !
Linux btupc09 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

recon-all -s PM1 exited with ERRORS at Fri Dec 13 10:36:04 GMT 2019

To report a problem, see http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting


I’m not convinced that the problem is with mri_em_register per se, since the same command in the skull striping step didn’t evoke any problems.
I also tried looking for nan’s or negative values in the nu.mgz and T1.mgz files and didn’t find any. Both these files are uchar(0), as shown by mri_info.

I’m running recon-all from Freesurfer version 6.0.0, on an Ubuntu 16.04, with 64GB of RAM. 

Any help or pointers are highly appreciated! 

Thank you for your time,
Best regards,
Ricardo


﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎
Ricardo Loução

Institute of Neuroscience and Medicine 
INM-11
Forschungszentrum Jülich GmbH
Germany

E-mail:  r.loucao@fz-juelich.de
Tel:  +49 2461 61 1907
﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊



------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Volker Rieke
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------