Hello neurostars!
I am trying to use mri_convert
on recon-all
outputs which were processed a few years ago (probably in 2014/2015, and I don’t know what version of Freesurfer these people used at the time) and get the following error:
〉 mri_convert aseg.mgz aseg.nii.gz
mri_convert aseg.mgz aseg.nii.gz
reading from aseg.mgz...
error: Cannot allocate memory
error: znzTAGskip: tag=1697605229, failed to calloc 1953461248 bytes!
1953461248 bytes
(= 1.8 Gbytes) indeed sounds like a lot (although it should easily fit in RAM on the machine I’m using, considering that this file is 100Ko…
I found a workaround using Python were I unzip the mgz
file and later convert it to nii.gz
:
import nibabel as nib
img = nib.load("aseg.mgz")
img.to_filename("aseg.mgh")
〉 mri_convert aseg.mgh aseg.nii.gz
mri_convert aseg.mgh aseg.nii.gz
reading from aseg.mgh...
TR=2700.00, TE=3.35, TI=850.00, flip angle=9.00
i_ras = (-1, 0, 0)
j_ras = (0, 0, -1)
k_ras = (0, 1, 0)
writing to aseg.nii.gz...
I am simply curious as to why mri_convert
doesn’t seem to work out-of-the box for these files (it worked for me on more recent outputs of recon-all
I computed on my machine). In particular, I looked at a previous topic on Neurostars which mentions a similar error message that was supposedly solved in fmriprep
1.5.4 ; I looked at the diff on github between versions 1.5.4 and 1.5.3 but couldn’t find any clue on how to solve this issue in a systematic way.
Thank you in advance for your help
NB: initially, I’m doing all this because I want to open this .mgz
file with freeview, which weirdly enough doesn’t seem to handle this format while it correctly deals with .mgh
and .nii.gz
(fsleyes does open all of these formats though).