(nibabel error) FreeSurfer QCACHE Outputs Empty

Summary of what happened:

I am preparing a surface-based morphometry study, and am trying to get thickness values for subjects registered to fsaverage space, smoothed at 10mm FWHM. recon-all with the qcache flag completes without errors, and qcache should be registering and smoothing the subject outputs, as described here. The files look like they are there (e.g. $SUB/surf/lh.thickness.fwhm10.fsaverage.mgh) but they appear to be empty, as described in the code below.

Command used (and if a helper script was used, a link to the helper script or the command generated):

For recon-all:

singularity exec -e -B ${scratch},$scratch/license.txt:/usr/local/freesurfer/.license $IMG \
recon-all -subject $subject -i $scratch/t1.nii.gz -T2 $scratch/t2.nii.gz -T2pial -all -qcache -hires -openmp 8

For checking outputs in Python:

import nibabel as nib
path_to_morph = 'PATH/TO/FREESURFER/SUB/surf/lh.thickness.fwhm10.fsaverage.mgh'
morph_data = nib.freesurfer.io.read_morph_data(path_to_morph)


FreeSurfer 7.3.2
Nibabel 5.0.0

Environment (Docker, Singularity, custom installation):

Singularity 3.9.5 for FreeSurfer
Virtual environment for Python

Data formatted according to a validatable standard? Please provide the output of the validator:

BIDS, but that isn’t relevant here

Relevant log outputs (up to 20 lines):

No errors in any part of the process.

Screenshots / relevant information:

Of note:

  1. When I load the native space thickness file (e.g. surf/lh.thickness), I get the expected full output with all data there.
  2. When I load the QCACHE files, there are no errors in loading the file, but the data array returned is empty
  3. This is true for all subjects (not subject-specific), measurement types (e.g. area, volume, etc) and smoothing kernels.
  4. All qcache outputs are the same file size (668.6 kb), which doesn’t seem like it should be right.

How should I proceed?



It appears that this is nibabel not reading the files correctly. The following alternative method worked for me:

import nibabel as nib
morph_path = '/PATH/TO/MORPH/FILE.mgh'
morph_loaded = nib.MGHImage.from_filename(morph_path)
morph_data = morph_loaded.get_fdata()