# Segmentation Fault in population template (mrregister)

**URL:** <https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552>\
**Category:** Uncategorized\
**Created:** [November 3, 2016, 10:36am UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552 "2016-11-03T10:36:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jose\_Angel\_Pineda](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Jose\_Angel\_Pineda](https://community.mrtrix.org/u/Jose_Angel_Pineda)\
**Post date:** [November 3, 2016, 10:36am UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/1 "2016-11-03T10:36:45Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [November 3, 2016, 11:50am UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/2 "2016-11-03T11:50:47Z")

</div>

Hello Jose,

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

```auto
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
```

---

<div class="post-metadata">

**Author:** ![Jose\_Angel\_Pineda](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Jose\_Angel\_Pineda](https://community.mrtrix.org/u/Jose_Angel_Pineda)\
**Post date:** [November 3, 2016, 12:22pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/3 "2016-11-03T12:22:47Z")

</div>

Hello Max and thanks for your answer!

these are the outputs:

```auto
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é

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [November 3, 2016, 1:26pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/4 "2016-11-03T13:26:36Z")

</div>

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

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

[Here](https://community.mrtrix.org/t/mrview-segmentationfault-core-dump-ubuntu-16-04/185/26?u=maxpietsch) 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?

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

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![Jose\_Angel\_Pineda](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Jose\_Angel\_Pineda](https://community.mrtrix.org/u/Jose_Angel_Pineda)\
**Post date:** [November 3, 2016, 1:44pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/5 "2016-11-03T13:44:58Z")

</div>

This is the version Im using

- Checking for Eigen 3 library: 3.2.2

You can download the zipped folder under:

> **[Dropbox - Link not found](https://www.dropbox.com/s/tqnpfqnydsr3egp/population_template-tmp-AXFS97.tar.gz?dl=0)**
>
> Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!

Thanks!!

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [November 3, 2016, 2:16pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/6 "2016-11-03T14:16:30Z")

</div>

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

```auto
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](http://mrtrix.readthedocs.io/en/latest/installation/linux_install.html#keeping-mrtrix3-up-to-date).

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.

---

<div class="post-metadata">

**Author:** ![Jose\_Angel\_Pineda](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Jose\_Angel\_Pineda](https://community.mrtrix.org/u/Jose_Angel_Pineda)\
**Post date:** [November 3, 2016, 4:18pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/7 "2016-11-03T16:18:16Z")

</div>

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é

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [November 3, 2016, 4:48pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/8 "2016-11-03T16:48:37Z")

</div>

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](http://mrtrix.readthedocs.io/en/latest/workflows/fixel_based_analysis.html?highlight=population_template#upsampling-dw-images) recommend upsampling if you want to do fixel based analysis. @Dave might have more insight on the effects this has on downstream analysis.

---

<div class="post-metadata">

**Author:** ![Dave](https://community.mrtrix.org/user_avatar/community.mrtrix.org/dave/32/7_2.png) [@Dave](https://community.mrtrix.org/u/Dave)\
**Post date:** [November 3, 2016, 9:16pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/9 "2016-11-03T21:16:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dave](https://community.mrtrix.org/user_avatar/community.mrtrix.org/dave/32/7_2.png) [@Dave](https://community.mrtrix.org/u/Dave)\
**Post date:** [November 3, 2016, 9:27pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/10 "2016-11-03T21:27:04Z")

</div>

Jose,  
In regards to up-sampling, check out [this paper](http://www.sciencedirect.com/science/article/pii/S1053811914007472).

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](https://www.ncbi.nlm.nih.gov/pubmed/26004503), 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

---

<div class="post-metadata">

**Author:** ![maxpietsch](https://community.mrtrix.org/user_avatar/community.mrtrix.org/maxpietsch/32/25_2.png) [@maxpietsch](https://community.mrtrix.org/u/maxpietsch)\
**Post date:** [November 3, 2016, 9:43pm UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/11 "2016-11-03T21:43:43Z")

</div>

Thanks Dave!

> [@Dave](#):
>
> 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.

Sounds good to me!

---

<div class="post-metadata">

**Author:** ![Jose\_Angel\_Pineda](https://community.mrtrix.org/letter_avatar_proxy/v4/letter/j/ea666f/32.png) [@Jose\_Angel\_Pineda](https://community.mrtrix.org/u/Jose_Angel_Pineda)\
**Post date:** [November 7, 2016, 11:01am UTC](https://community.mrtrix.org/t/segmentation-fault-in-population-template-mrregister/552/12 "2016-11-07T11:01:27Z")

</div>

Thanks everyone for your recommendations.

cheers

José
