Mrregister: [ERROR] centre of mass initialisation not possible for empty image

Dear Mrtrix experts,
I am trying to run a population template and I get the following error.

population_template: [  0%] Performing initial rigid registration to template... population_template: [ERROR] Command failed: mrregister /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif average_header.mif -mask1 /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -rigid_scale 1  -rigid_niter 0  -type rigid  -noreorientation  -rigid_init_translation mass  -datatype float32 -rigid linear_transforms_initial/sub01.txt (population_template:492)
population_template: Output of failed command:
                     mrregister: [ERROR] centre of mass initialisation not possible for empty image
population_template: Script failed while executing the command: mrregister /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif average_header.mif -mask1 /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -rigid_scale 1  -rigid_niter 0  -type rigid  -noreorientation  -rigid_init_translation mass  -datatype float32 -rigid linear_transforms_initial/sub01.txt
population_template: For debugging, inspect contents of temporary directory: /Users/adminuser/population_template-tmp-P0ZPV4/

I run other population templates in the past and never had any problem…I also checked that by mrtrix version is updated.

Any ideas on what might be going on? In the temporary folder I checked and the linear_transforms_initial folder is empty. Could this be the reason?

Thank you for your help,

Hello Ane,

I suspect either your image is zero or the corresponding ROI has no values >0.5 where the image has non-zero values.

What is the output of

mrstats /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif
mrstats /Users/adminuser/population_template-tmp-BJCMZR/average_header.mif
mrstats /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -ignorezero
mrcalc /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -mul - | mrstats - -ignorezero

?

Thanks for the quick response!

$ mrstats /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif

volume       mean     median      stdev        min        max      count
       [ 0 ]          0          0          0          0          0    5017600
       [ 1 ]          0          0          0          0          0    5017600
       [ 2 ]          0          0          0          0          0    5017600
       [ 3 ]          0          0          0          0          0    5017600
       [ 4 ]          0          0          0          0          0    5017600
       [ 5 ]          0          0          0          0          0    5017600
       [ 6 ]          0          0          0          0          0    5017600
       [ 7 ]          0          0          0          0          0    5017600
       [ 8 ]          0          0          0          0          0    5017600
       [ 9 ]          0          0          0          0          0    5017600
      [ 10 ]          0          0          0          0          0    5017600
      [ 11 ]          0          0          0          0          0    5017600
      [ 12 ]          0          0          0          0          0    5017600
      [ 13 ]          0          0          0          0          0    5017600
      [ 14 ]          0          0          0          0          0    5017600
      [ 15 ]          0          0          0          0          0    5017600
      [ 16 ]          0          0          0          0          0    5017600
      [ 17 ]          0          0          0          0          0    5017600
      [ 18 ]          0          0          0          0          0    5017600
      [ 19 ]          0          0          0          0          0    5017600
      [ 20 ]          0          0          0          0          0    5017600
      [ 21 ]          0          0          0          0          0    5017600
      [ 22 ]          0          0          0          0          0    5017600
      [ 23 ]          0          0          0          0          0    5017600
      [ 24 ]          0          0          0          0          0    5017600
      [ 25 ]          0          0          0          0          0    5017600
      [ 26 ]          0          0          0          0          0    5017600
      [ 27 ]          0          0          0          0          0    5017600

$ mrstats /Users/adminuser/population_template-tmp-P0ZPV4/average_header.mif

volume       mean     median      stdev        min        max      count
       [ 0 ]          1          1          0          1          1    3098940
       [ 1 ]          0          0          0          0          0    3098940
       [ 2 ]          0          0          0          0          0    3098940
       [ 3 ]          0          0          0          0          0    3098940
       [ 4 ]          0          0          0          0          0    3098940
       [ 5 ]          0          0          0          0          0    3098940
       [ 6 ]          0          0          0          0          0    3098940
       [ 7 ]          0          0          0          0          0    3098940
       [ 8 ]          0          0          0          0          0    3098940
       [ 9 ]          0          0          0          0          0    3098940
      [ 10 ]          0          0          0          0          0    3098940
      [ 11 ]          0          0          0          0          0    3098940
      [ 12 ]          0          0          0          0          0    3098940
      [ 13 ]          0          0          0          0          0    3098940
      [ 14 ]          0          0          0          0          0    3098940
      [ 15 ]          0          0          0          0          0    3098940
      [ 16 ]          0          0          0          0          0    3098940
      [ 17 ]          0          0          0          0          0    3098940
      [ 18 ]          0          0          0          0          0    3098940
      [ 19 ]          0          0          0          0          0    3098940
      [ 20 ]          0          0          0          0          0    3098940
      [ 21 ]          0          0          0          0          0    3098940
      [ 22 ]          0          0          0          0          0    3098940
      [ 23 ]          0          0          0          0          0    3098940
      [ 24 ]          0          0          0          0          0    3098940
      [ 25 ]          0          0          0          0          0    3098940
      [ 26 ]          0          0          0          0          0    3098940
      [ 27 ]          0          0          0          0          0    3098940

$ mrstats /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -ignorezero

volume       mean     median      stdev        min        max      count
       [ 0 ]   0.818172 0.99999994   0.376465  -0.121695    1.13437    1306030

$ mrcalc /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif -mul - | mrstats - -ignorezero

mrcalc: [100%] computing: (/Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif * /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/mask_input/sub01.mif)
      volume       mean     median      stdev        min        max      count
       [ 0 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 1 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 2 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 3 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 4 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 5 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 6 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 7 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 8 ]        N/A        N/A        N/A        N/A        N/A          0
       [ 9 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 10 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 11 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 12 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 13 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 14 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 15 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 16 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 17 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 18 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 19 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 20 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 21 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 22 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 23 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 24 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 25 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 26 ]        N/A        N/A        N/A        N/A        N/A          0
      [ 27 ]        N/A        N/A        N/A        N/A        N/A          0

Your input image /Users/adminuser/ANE/Investigations/ROI_Analyses/template_SC/fod_input/sub01.mif appears to be empty, not much to register to I suppose?

Thank you very much!

From time to time some of my files are ‘corrupted’/damaged and I have to recompute them…Going to a previous backup and recomputing the file solved the issue.

Just in case, the error I sometimes in the damaged files is the following:

mrstats: [SYSTEM FATAL CODE: SIGBUS (10)] Bus error: Accessing invalid address (out of storage space?)

I report it but I don’t think it has anything to do with mrtrix…might be a problem with libraries, or who knows.

Thank you again for the support!

Can you provide more information about that mrstats error? It’s pretty unexpected, this is a read-only command, I’m struggling to see what could possibly have gone wrong there… Is this part of a script? Is the output of that command being redirected to file? Any chance some other process might be accessing that file concurrently…?

I’m not sure what else to describe…
It’s not something systematic.Sometime when I get errors using MRtrix commands that I used before without any problem, I realise that it must be the problem with some of the files. So I run mrstats on the file, just to see whether any error pops up, and sometimes the previous error appears. When I recompute them and the error dissapears.
I don’t know if any other process might be accessing that file concurrently…
The next time I get the error I could send you the file, but now I’m not able to reproduce it, since I recomputed it.
The last damaged file was the preprocessed dwi of a subject. mrstats owas OK with the first 9 volumes and crashed when reading the next one…

Ok, so if I understand correctly, when you come across one of these problematic files, and you run mrstats on it, you get the SIGBUS error. That sounds to me like a corrupt file, maybe something that you’d get if you run out of storage space (?).

For reference, what I think might be happening here is that the file size stored in the file metadata (i.e. on the filesystem) doesn’t match the amount of data actually stored in the file (maybe the OS intended to write a file of the size, but something interrupted the actual writing of the data, and for some reason the OS didn’t or couldn’t update the file size entry to match after the fact). This is one of the few explanations I can think of for a SIGBUS error… This shouldn’t happen with a modern journaling filesystem. I’d have a close look at where these data are stored, using what filesystem, and whether you’re tight on space on that device…

Thank you very much for the suggestions and apologies for the long post…:sweat_smile:

The computer has 1.7TB of free space, so I guess storage space is not the problem. Regarding the filesystem:

$ mount
/dev/disk2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk3s2 on /Volumes/LaCie (hfs, local, nodev, nosuid, journaled)
/dev/disk3s3 on /Volumes/Mac_HD_backup (hfs, local, nodev, nosuid, journaled, noowners)

I’m unfamiliar with this, so I don’t know whether this is a typical output…

However, I’ve been ‘lucky’ and found a new corrupted file…:sob: Fortunately, I have a non-corrupted backup of the same file.

I run md5 on the corrupted and non-corrupted files, and I get the following error in the corrupted file:

$ md5 /dir1/fod_input/sub18.mif 
md5: /dir1/fod_input/sub18.mif: Input/output error

The same command in the non-corrupted file gives this output:

$ md5 /dir2/sub18/FOD_up.mif
MD5 (/dir2/sub18/FOD_up.mif) = 0f5ebd2c4204259b2470b961cc56f71cr

So this leads to the SIGBUS error when using mrstats on the corrupted file:

$ mrstats /dir1/fod_input/sub18.mif
      volume       mean     median      stdev        min        max      count

mrstats: [SYSTEM FATAL CODE: SIGBUS (10)] Bus error: Accessing invalid address (out of storage space?)

Running mrstats on the non-corrupted file works fine:

$ mrstats /dir2/sub18/FOD_up.mif
      volume       mean     median      stdev        min        max      count
       [ 0 ]  0.0358973          0  0.0805793 -1.88519e-08    1.23226    5017600
       [ 1 ] 0.000238475          0   0.022886  -0.382126    0.36374    5017600
       [ 2 ] 0.000349817          0  0.0259572  -0.458823   0.594064    5017600
       [ 3 ] -0.000550487          0  0.0250286  -0.297521   0.603076    5017600

Any ideas?
I understand that this might be out of the scope of MRtrix, so feel free not to answer. However it is driving me crazy, so I will at least try.

Thank you for the constant support!

:thinking: probably… but we’re nice people :grin:

Besides, there’s a chance this may relate to MRtrix3 – what was the command that generated this file? And did anything happen at the time? Were there any errors or warnings issued by the command that generated the file?


In any case, looking at the information you provided, it seems the problematic data reside on /dev/disk2, which is formatted using the HFS+ filesystem. At least I assume that the /dir1 & /dir2 folders reside on that main / partition, not in the auto-mounted (networked?) /home folder, or any of the external volumes.

A quick Google search suggests that the HFS+ filesystem has had its day (Linus Thorvalds is clearly not a fan), and there are some reports of silent file corruption (although it’s not clear whether it’s any worse than other commonly-used filesystems).

More to the point though, it looks like HFS+ is not the recommended choice for use on solid-state drives, which I’d expect to find on any semi-recent macbook. Is your main drive an SSD? Apparently, the upgrade to High Sierra would have forced you to upgrade to their newer APFS filesystem if you have an SSD drive (although I’m guessing there may have been ways to avoid that). The main issue is that HFS+ is not designed for SSDs, and they need to be handled quite differently to maximise the life of your SSD (the blocks in your SSD will eventually fail after a few hundred thousand writes, so the filesystem needs to avoid repeatedly writing to the same parts of your drive). So if you have an SSD, and are running High Sierra or later, you’ll probably want to upgrade your main filesystem to APFS.

In your particular case, one of the benefits of using APFS is apparently that it “uses checksums for data integrity of metadata” – which from what I can tell is exactly the kind of safeguard that might have prevented this issue. It certainly looks relevant…

But this wouldn’t happen if your drive itself wasn’t already having trouble – it would have been nice if the filesystem had detected or even corrected the corruption, but it does look like there was corruption. I would look closely at the health of your drive, by checking its SMART status. There’s a chance it’s due to be replaced. And if it’s an SSD, there’s also a chance that using HFS+ on it may have contributed to hastening its demise…

Wow! :grin: Thanks for that!

The corrupted files are usually FOD’s (generated using dwiextract, dwi2fod) and I don’t receive any error/warning when computing them.

Dir1 is in /disk2, but dir2 is in an external volume (in /dev/disk3s3 = MAC_HD_backup in the image below) which also uses HFS+.

I work from an imac Retina 5K from late 2015 (High Sierra v.10.13.6) and my main drive is HDD (see below).

Drama coming…
Yesterday I made a check using Disk utility and it found filesystem errors…after that the PC died I was not able to restart it. The error it found seem to be related to filesyst:

Since I was not able to restart the PC, I erased the hard drive and recover it from the time machine. Now the smart status says ‘Verified’. However, I know that this copy is still corrupted since it came from the last backup that I took yesterday.

I thought that something might have gone wrong in one of my updates, so checked similar info in a recent imac that our lab owns. It has the same specifications as my PC: imac Retina 5K from (High Sierra v.10.13.6) with the only difference that was bought in 2017. In that PC, the filesystem is also Journaled HFS+, so a problem with an update seems unlikely. No one has reported any problem in that computer + they don’t use MRtrix.

So basically I’m left with the question of whether using Journaled HFS is that dramatic if my drive is HDD, whether it would it be convenient to switch the filesyst from HFS+ to AFPS anyway or whether the problem is something else…

Hope you had enough coffee to face this post and THANK YOU!! :grinning:

Just in case it has something to do…
I don’t get warnings when computing dwi2fod, but sometimes I get this warning (for instance with mrtheshold)
[WARNING] requested datatype (Bit) not supported - substituting with UInt8

OK, it looks like you have a fusion drive, and the recommendation in the links I posted previously was to keep using HFS+ on that kind of setup - no need to switch to APFS.

But given that there is filesystem corruption, it looks like you’ve basically figured out what the problem was. Corruption can happen from time to time, what’s worrying is that it seems to happen relatively frequently – is that right? Personally, I’d look very closely into the SMART status for both the SSD and HDD of that fusion drive (you should be able to get much more detailed information than just “verified”). I’d also look closely at your main drive: if /dir1 is on that drive, that’s the location of the corrupted file you posted earlier – so it looks like it’s also affected.

If you can recover it, and repair the filesystem, that may be all you need to do. You won’t recover the corrupt files, but hopefully you won’t encounter further corruption in the future. That depends on whether the drives are as reliable as they should be. The SMART report is a good first indicator of drive failure, but it’s not perfect. Personally, I’d consider replacing the drive at this point…

But ultimately, I reckon that’s about as much advice as I can give you on this issue. I’d start getting friendly with your local IT support staff…

No need to worry about that. This is the message you get if you’re trying to write a binary mask to a NIfTI image, which doesn’t support bitwise storage – so MRtrix3 substitutes an 8-bit (byte-wise) datatype instead. Shouldn’t make any difference otherwise.

You’re right, I will contact the IT staff and try to replace the drive
Cannot thank enough! :grinning: