Segmentation Fault in population template (mrregister)

Dear all,
Im running population_template on 10 subjects which have been upsampled x2, current resolution is 1mm3. Each FOD file is around 200MB size.
During execution I get a Segmentation Fault which belongs to the mrregister script and Im not able to find where is this error coming from.
This is the output I get from the mrregister along execution.

mrregister id013_csh.nii.gz average_header.mif -mask1 id013_bmask.nii.gz -rigid_scale 1 -rigid_niter 0 -type rigid -noreorientation -rigid_init_translation mass -datatype float32 -rigid linear_transforms_initial/id013.txt
mrregister: [100%] uncompressing image "id013_csh.nii.gz"
mrregister: [100%] preloading data for "id013_csh.nii.gz"
mrregister: [100%] preloading data for "/tmpdir/average_header.mif"
mrregister: [100%] uncompressing image "id013_bmask.nii.gz"
mrregister: running rigid registration
mrregister: initialising translation and centre of rotation using centre of mass
Segmentation Fault

Thanks!!

Hello Jose,

This should not happen… Could you please go to the temporary directory that population template created and post the output of

mrstats id013_bmask.nii.gz
mrstats average_header.mif
mrinfo  id013_csh.nii.gz average_header.mif 
mrregister id013_csh.nii.gz average_header.mif -mask1 id013_bmask.nii.gz -rigid_scale 1  -rigid_niter 0  -type rigid  -noreorientation  -rigid_init_translation mass  -datatype float32 -rigid linear_transforms_initial/id013.txt -debug -force

Hello Max and thanks for your answer!

these are the outputs:

joseapineda@neuroimagenWS:/tmp/population_template-tmp-AXFS97$ mrstats id013_bmask.nii.gz 
mrstats: [100%] uncompressing image "id013_bmask.nii.gz"
         volume         mean       median    std. dev.          min          max       count
         [ 0 ]      0.184984            0     0.388284            0            1       950272
joseapineda@neuroimagenWS:/tmp/population_template-tmp-AXFS97$ mrstats average_header.mif 
         volume         mean       median    std. dev.          min          max       count
         [ 0 ]             1            1            0            1            1      7307850
         [ 1 ]             0            0            0            0            0      7307850
         [ 2 ]             0            0            0            0            0      7307850
         [ 3 ]             0            0            0            0            0      7307850
         [ 4 ]             0            0            0            0            0      7307850
         [ 5 ]             0            0            0            0            0      7307850
         [ 6 ]             0            0            0            0            0      7307850
         [ 7 ]             0            0            0            0            0      7307850
         [ 8 ]             0            0            0            0            0      7307850
         [ 9 ]             0            0            0            0            0      7307850
        [ 10 ]             0            0            0            0            0      7307850
        [ 11 ]             0            0            0            0            0      7307850
        [ 12 ]             0            0            0            0            0      7307850
        [ 13 ]             0            0            0            0            0      7307850
        [ 14 ]             0            0            0            0            0      7307850
        [ 15 ]             0            0            0            0            0      7307850
        [ 16 ]             0            0            0            0            0      7307850
        [ 17 ]             0            0            0            0            0      7307850
        [ 18 ]             0            0            0            0            0      7307850
        [ 19 ]             0            0            0            0            0      7307850
        [ 20 ]             0            0            0            0            0      7307850
        [ 21 ]             0            0            0            0            0      7307850
        [ 22 ]             0            0            0            0            0      7307850
        [ 23 ]             0            0            0            0            0      7307850
        [ 24 ]             0            0            0            0            0      7307850
        [ 25 ]             0            0            0            0            0      7307850
        [ 26 ]             0            0            0            0            0      7307850
        [ 27 ]             0            0            0            0            0      7307850
        [ 28 ]             0            0            0            0            0      7307850
        [ 29 ]             0            0            0            0            0      7307850
        [ 30 ]             0            0            0            0            0      7307850
        [ 31 ]             0            0            0            0            0      7307850
        [ 32 ]             0            0            0            0            0      7307850
        [ 33 ]             0            0            0            0            0      7307850
        [ 34 ]             0            0            0            0            0      7307850
        [ 35 ]             0            0            0            0            0      7307850
        [ 36 ]             0            0            0            0            0      7307850
        [ 37 ]             0            0            0            0            0      7307850
        [ 38 ]             0            0            0            0            0      7307850
        [ 39 ]             0            0            0            0            0      7307850
        [ 40 ]             0            0            0            0            0      7307850
        [ 41 ]             0            0            0            0            0      7307850
        [ 42 ]             0            0            0            0            0      7307850
        [ 43 ]             0            0            0            0            0      7307850
        [ 44 ]             0            0            0            0            0      7307850
joseapineda@neuroimagenWS:/tmp/population_template-tmp-AXFS97$ mrinfo id013_csh.nii.gz average_header.mif 
************************************************
Image:               "id013_csh.nii.gz"
************************************************
  Dimensions:        188 x 256 x 256 x 45
  Voxel size:        1 x 0.999376 x 1 x 1
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9966    -0.03153    -0.07603      -90.12
                          0.03047      0.9994    -0.01518      -108.7
                          0.07646     0.01282       0.997      -148.7
  comments:          FSL5.0
  mrtrix_version:    0.3.15-308-g145b52a9
************************************************
Image:               "average_header.mif"
************************************************
  Dimensions:        165 x 215 x 206 x 45
  Voxel size:        0.998447 x 0.990084 x 0.988562 x ?
  Data strides:      [ 1 2 3 4 ]
  Format:            MRtrix
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:               0.9999     0.01303   -0.004257      -90.12
                         -0.01345      0.9925     -0.1211      -62.28
                         0.002647      0.1212      0.9926      -98.18
  mrtrix_version:    0.3.15-308-g145b52a9
joseapineda@neuroimagenWS:/tmp/population_template-tmp-AXFS97$ mrregister id013_csh.nii.gz average_header.mif -mask1 id013_bmask.nii.gz -rigid_scale 1  -rigid_niter 0  -type rigid  -noreorientation  -rigid_init_translation mass  -datatype float32 -rigid linear_transforms_initial/id013.txt -debug -force
mrregister: [WARNING] existing output files will be overwritten
mrregister: [DEBUG] No config file found at "/etc/mrtrix.conf"
mrregister: [DEBUG] No config file found at ".mrtrix.conf"
mrregister: [INFO] opening image "id013_csh.nii.gz"...
mrregister: [DEBUG] sanitising image information...
mrregister: [DEBUG] loading image "id013_csh.nii.gz"...
mrregister: [100%] uncompressing image "id013_csh.nii.gz"
mrregister: [DEBUG] image "id013_csh.nii.gz" loaded
mrregister: [DEBUG] image "id013_csh.nii.gz" initialised with strides = [ -1 188 48128 12320768 ], start = 187, using indirect IO
mrregister: [DEBUG] initialising threads...
mrregister: [DEBUG] launching 8 threads "loop threads"...
mrregister: [  0%] preloading data for "id013_csh.nii.gz"... 
mrregister: [DEBUG] waiting for completion of threads "loop threads"...
mrregister: [100%] preloading data for "id013_csh.nii.gz"... 
mrregister: [DEBUG] threads "loop threads" completed OK
mrregister: [100%] preloading data for "id013_csh.nii.gz"
mrregister: [DEBUG] image "id013_csh.nii.gz" initialised with strides = [ -45 8460 2165760 1 ], start = 8415, using direct IO
mrregister: [INFO] opening image "average_header.mif"...
mrregister: [DEBUG] reading key/value file "average_header.mif"...
mrregister: [DEBUG] sanitising image information...
mrregister: [DEBUG] memory-mapping file "average_header.mif"...
mrregister: [DEBUG] file "average_header.mif" mapped at 0x7f4f71986000, size 1315413000 (read-only)
mrregister: [DEBUG] image "average_header.mif" loaded
mrregister: [DEBUG] image "average_header.mif" initialised with strides = [ 1 165 35475 7307850 ], start = 0, using indirect IO
mrregister: [DEBUG] initialising threads...
mrregister: [DEBUG] launching 8 threads "loop threads"...
mrregister: [  0%] preloading data for "average_header.mif"... 
mrregister: [DEBUG] waiting for completion of threads "loop threads"...
mrregister: [100%] preloading data for "average_header.mif"... 
mrregister: [DEBUG] threads "loop threads" completed OK
mrregister: [100%] preloading data for "average_header.mif"
mrregister: [DEBUG] image "average_header.mif" initialised with strides = [ 45 7425 1596375 1 ], start = 0, using direct IO
mrregister: [INFO] opening image "id013_bmask.nii.gz"...
mrregister: [DEBUG] sanitising image information...
mrregister: [DEBUG] loading image "id013_bmask.nii.gz"...
mrregister: [100%] uncompressing image "id013_bmask.nii.gz"
mrregister: [DEBUG] image "id013_bmask.nii.gz" loaded
mrregister: [DEBUG] image "id013_bmask.nii.gz" initialised with strides = [ -1 128 16384 ], start = 127, using indirect IO
mrregister: running rigid registration
mrregister: initialising translation and centre of rotation using centre of mass
Segmentation Fault

bw

José

Thanks,

I can’t see any problem with the data and I can not reproduce your issue. Can I double check that you are using the latest version of mrtrix and not the beta version of eigen (<= 3.2.10)?

mrregister -version
grep Eigen  $(dirname `which mrregister`)/../config

Here is described how to use the stable version of eigen.

If you do use eigen stable and still get the error with the latest version of mrregister, could you please share your data with me?

cd /tmp/population_template-tmp-AXFS97
zip ~/files4max.zip id013_csh.nii.gz average_header.mif id013_bmask.nii.gz

Cheers,
Max

This is the version Im using

  • Checking for Eigen 3 library: 3.2.2

You can download the zipped folder under:

Thanks!!

What does mrregister -version give you? The latest version of mrregister should give you an error, not a segfault:

mrregister id013_csh.nii.gz average_header.mif -mask1 id013_bmask.nii.gz -rigid_scale 1  -rigid_niter 0  -type rigid  -noreorientation  -rigid_init_translation mass  -datatype float32 -rigid linear_transforms_initial/id013.txt -force
mrregister: [WARNING] existing output files will be overwritten
mrregister: [100%] uncompressing image "id013_csh.nii.gz"
mrregister: [100%] preloading data for "id013_csh.nii.gz"
mrregister: [100%] preloading data for "average_header.mif"
mrregister: [100%] uncompressing image "id013_bmask.nii.gz"
mrregister: [ERROR] dimension mismatch between "id013_csh.nii.gz" and "id013_bmask.nii.gz"

How to update mrtrix.

Your mask image has a non-orthonormal header (s- and q-form). You can give the mrregister debug command without the mask argument a try. I hope this works, let me know if not.

For your cohort, you might want to use dwi2mask or fsl’s bet(2). Also, your image is very large. I doubt that you need to upsample your data that much (or at all) before passing it to population_template.

Thanks Max,

you were right, it was a dimension mismatch. I was using the mask in the original DWI space 2x2x2. Now it works perfectly.

Regarding the upsampling, Im going from 2mm3 to 1mm3, following Raffelt et al 2012 guidelines. Should I run the template using the 2mm3 dataset instead?, or it is ok to continue with the upsampling?

bw

José

I personally do not upsample the data before population_template. I guess it depends what you want to do with the template. For instance, the docs recommend upsampling if you want to do fixel based analysis. @Dave might have more insight on the effects this has on downstream analysis.

Hi Guys,
Just arrived at work and read this. I noticed the issue of dimension mismatch recently and added a check for the mask dimensions in the fixel_format branch. This branch will be merged with master sometime soon.

@maxpietsch I guess there is no reason why the masks can’t be the same dimensions during registration since their values are accessed with interpolation. We would just need to modify the transform initialiser to use a reslice adapter on the mask.

Cheers,
Dave

Jose,
In regards to up-sampling, check out this paper.

In my experience registration works better, and the template has less partial voluming of neighbouring structures, compared to if I were to register with native resolution data and then up sample for comparison.

With the new fixel-based statistical analysis, I don’t think there is any major benefit.

I guess the trade off is a major hit to computation time and disk space.
Cheers,
Dave

Thanks Dave!

Sounds good to me!

Thanks everyone for your recommendations.

cheers

José