Skip to content

wrong minc header #712

Open
Open
@ltetrel

Description

@ltetrel

Hello all,

So I am trying to convert .mnc images to .nii with nibabel, here is my code :

import nibabel as nib

(...)

# loading the original image
nibImg = nib.load(srcFilePath)
nibAffine = np.array(nibImg.affine)
nibData = np.array(nibImg.dataobj)

# inverting the data axes and rotating the affine to match nii space
nibAffine[0:3, 0:3] = nibAffine[0:3, 0:3] @ rotZ(np.pi/2) @ rotY(np.pi) @ rotX(np.pi/2)
nibData = nibData.T
nibData = np.swapaxes(nibData, 0, 1)

# creating the nifti image
niftiImg = nib.Nifti1Image(nibData, nibAffine, nibImg.header)

The problem is that the header nib.minc2.Minc2Image.header does nto have proper TR information :

In [270]: nibImg.header.get_zooms()
Out[270]: (4.000000000000021, 4.000000000000001, 4.0, 4.0)

When it should be (using mincheader):

acquisition:repetition_time = 2. ;

I started investigated and apparently it has something to do with

zooms[:n_to_set] = vox[:n_to_set]

Thank you for your work,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions