Skip to content

Nifti surface files misshapen when loaded #309

Closed
@effigies

Description

@effigies

As noted in #100, FreeSurfer can put surface files into niftis. For example, on a machine that has FreeSurfer installed:

$ mri_convert $SUBJECTS_DIR/fsaverage/surf/lh.orig.avg.area.{mgh,nii}

To examine the files:

>>> fmt = os.path.join(os.environ['SUBJECTS_DIR'], 'fsaverage/surf/lh.orig.avg.area.{}').format
>>> mgh = nib.load(fmt('mgh'))
>>> nii = nib.load(fmt('nii'))

We see:

>>> mgh.shape
(163842, 1, 1)
>>> nii.shape
(27307, 1, 6)
>>> np.all(np.squeeze(mgh.get_data()) == nii.get_data().transpose().reshape(-1))
True

So the data's the same, but reshaped and has an axis rolled. I think the expected behavior would probably be a Nifti1Image with the same shape as the MGHImage.

On the plus side, nib.load(x).to_filename(x) seems to produce files that FreeSurfer tools accept without complaint (and look the same at first glance).

I could probably write up the above in test form in the next couple days, but I'm really not sure where to begin digging into Nifti1Image to fix this. It's also possible that the problem is that mri_convert is producing niis with bad headers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions