Issue with mne.transforms.compute_volume_registration

Hello all :smiley:

  • MNE version: 1.3.1
  • operating system: macOS Ventura 13.3

I’m doing the “Aligning the CT to the MR” using the data of one subject, following the tutorial https://mne.tools/stable/auto_tutorials/clinical/10_ieeg_localize.html#

As the alignment failure occurred, I did a pre-alignment in freeview (use the rotation and translation slide bars to align the CT to the MR) and got the Ita file ‘sub01_CT_aligned_manual.mgz.lta’.

Then did the alignment:

import os.path as op
import numpy as np
import nibabel as nib
import mne

subjects_dir = '/Users/ye/freesurfer_recon' 
subject = 'sub01' 

T1 = nib.load(subjects_dir +'/' + subject +'/mri' +'/T1.mgz')
CT_orig = nib.load('/Users/ye/SEEG/sub01/eleCT/sub01_CT.nii') 

manual_reg_affine_vox = mne.read_lta(op.join('/Users/ye/SEEG/sub01/sub01_CT_aligned_manual.mgz.lta')) 
manual_reg_affine = \
    CT_orig.affine @ np.linalg.inv(manual_reg_affine_vox) \
    @ np.linalg.inv(CT_orig.affine)
reg_affine, _ = mne.transforms.compute_volume_registration(CT_orig, T1, pipeline=['rigid'],starting_affine=manual_reg_affine)
CT_aligned = mne.transforms.apply_volume_registration(CT_orig, T1, reg_affine, cval='1%')

But, when I run mne.transforms.compute_volume_registration, an error occurred as follow:

  File "/Applications/MNE-Python/.mne-python/lib/python3.10/site-packages/mne/transforms.py", line 1226, in _one_rot_to_quat
    raise ValueError('Matrix is not a pure rotation, got determinant != 1')

ValueError: Matrix is not a pure rotation, got determinant != 1

How to solve this error?

BR,
Ye

Can you try with the development version?

Hi Alex, I have got the reg_affine without errors using the development version. Thanks for your help! :smile:

1 Like