Incorrect lta affine from pre-alignment during MRI - CT coregistration

Hi,

I’m coregistering MRI and CT scans to localize intracranial contacts. Today I’ve hit the first instance of incorrect automatic MRI-CT coregistration:


(the red ovals show where the incorrect alignment can be best seen)

Following the adivce in the great " Locating intracranial electrode contacts" tutorial I’ve corrected the issue by aligning the CT to MRI by hand in freeview. However later, when I read the lta saved in freeview to mne using the code provided in the tutorial:

manual_reg_affine_vox = mne.read_lta(op.join(
    save_dir, 'sub-U06_ct_aligned_manual.nii.lta'))

# convert from vox->vox to ras->ras
manual_reg_affine = \
    CT_orig.affine @ np.linalg.inv(manual_reg_affine_vox) \
    @ np.linalg.inv(CT_orig.affine)

I see that applying the manual_reg_affine to CT does not give me the MRI-CT placement that I saw in freeview:

But when I apply the lta in freeview I see that it is correct:

 freeview T1.mgz sub-U06_ct_Tilt_1.nii:colormap=heat:opacity=0.6:reg=sub-U06_ct_aligned_manual.nii.lta

I get the following text (might be related):

QStandardPaths: XDG_RUNTIME_DIR points to non-existing path '/home/mmagnuski/.xdg', please create it with 0700 permissions.
WARNING: hdr.dim[4] = 0 (nframes), setting to 1
WARNING: hdr.dim[4] = 0 (nframes), setting to 1
INFO: LTA input is not RAS to RAS...converting...

and I see the correct alignment (the one I performed by hand):

I’d be thankful for any ideas on what the issue could be.

I can share the CT, MRI and lta matrix that I am using.

Additional info

  • MNE version: 1.3.0
  • operating system: Windows 10
  • I am using freesurfer 7.2.0 on WSL 2 (with Xming for freeview)
  • after aligning the scan to ACPC and running recon-all freesurfer errored due to FOV > 256, so I used -cw256 flag and then recon-all completed without problems. However, after reading the mri from freesurfer subject/mri directory in python I saw that the scan was no longer in ACPC. It might be due to cropping that freesurfer does when -cw256 is provided, but I’m not sure it is relevant here.

The issue has been resolved - it turns out that in the development version of mne the function reading freesurfers affine matrices (mne.read_lta) has been fixed.
(prealigning CT and MRI: incorrect transformation read from freesurfer .lta file · Issue #11527 · mne-tools/mne-python · GitHub)

1 Like