How to Rotate Mouse Brain MRI for quick AFNI Registration

Dear experts,

The orientation of the MRI structural images I have acquired for the mice differs from that of the standard brain, making it challenging to perform registration. If any of you have experience or knowledge in rotating image orientation within AFNI, I would be grateful for any insights, sample code, or pointers to relevant documentation to resolve this issue.

The template and AFNI images of individual mouse are as follows:


Access link to .nii format file:
https://drive.google.com/drive/folders/1_B1msrkPYfj_4ftO1h0r_6_y7U57_roi?usp=sharing

Thank you for your time and support, and I look forward to valuable discussions with the community.

Best wishes,
Peng

Hi, Peng-

It is pretty common for animal scans to be acquired with animal anatomical oriented along difference field-of-view (FOV) axes than if a human had been scanned, even though animal template brains are typically oriented as if it were a human who had been scanned (i.e., anatomical left-right oriented along FOV left-right, nose-visual cortex axis along the FOV AP, etc.), as here. Often, animals are acquired in "sphinx" orientation, and we can use 3drefit to update/change the header information.

In the past, I have done this with a brute-force method of trying all possible refittings of the header orientation, and then narrowing down which 2 look reasonable (for placement of nose, neck, etc.). We are left with 2 options this way, because left-right symmetry in most brains make a visual check impossible to distinguish. If one has additional information like a marker, distinguishing characteristic, or other information to break the symmetry, then one can reduce the re-orienting options down to one rule, which should hopefully be consistent across an acquisition.

Thanks for sharing the data; I am a bit surprised that the raw data doesn't appear to be exactly in sphinx orientation to start with. From the header, I see you have resampled+refit it a few times already. Is it possible to have a non-refit dataset to start with? (And, will you also have some information about what is left and what is right for this dataset?)

thanks,
pt

Dear Prof. Taylor,

Great thanks for your reply, I have uploaded the raw structural imaging 'dicom' files (DICOM format - EnIm1) as well as NIfTI (.nii) format files (obtained from the EnIm1.dcm file using the 'dcm2niix_afni' tool). Furthermore, I apologize for not having information about the left and right orientation for this dataset.

File url: share - Google Drive
File annotations:
dicom_T2_TurboRARE_20230607141101_20001.nii: the individual original structural mouse brain copied from anat.zip
Template_C57Bl6_n30_brain.nii: mouse brain template copied from the C57B16.zip
anat.zip: files for both DICOM and NIFTI structural original files
C57Bl6.zip: files related to a mouse template, and it is hoped that they will be helpful to you.

Best wishes,
Peng

Hi, Peng-

Thanks, I ran the following script for your just dcm2niix_afni-converted dataset:

#!/bin/tcsh

# Potential script to change a dataset acquired in sphinx orientation (e.g., 
# like many animal scan acquisitions) to human-like orientation.
#
# NB: we have to check whether RSP or LSP is more appropriate, to know
# that left/right ends up being correct
#
# This script does not overwrite files, so please move or remove tmp*
# files before running, if they exist already
#
# ---------------------------------------------------------------------------

# input dataset, presumably just after raw file conversion
set dset_in = dicom_T2_TurboRARE_20230607141101_20001.nii

# What is the appropriate orientation for refitting, from RAI orient?
# NB: for most sphinx-to-human acquisitions, I would typically expect
# to use either RSP or LSP for the final orientation here.
set new_ori = RIP      # could also be LIP: check with external information

# ---------------------------------------------------------------------------

# First, check for presence of obliquity

set is_obl = `3dinfo -is_oblique "${dset_in}"`

if ( ${is_obl} ) then
    echo "+* WARNING: input dataset ${dset_in} is oblique."
    echo "            Obliquity will *not* be preserved here"
else
    echo "++ Processing (non-oblique) dataset: ${dset_in}"
endif

# check for pre-existing run
if ( -f tmp_00_RAI.nii.gz || -f tmp_01_${new_ori}.nii.gz ) then
    echo '** ERROR: pre-existing tmp_0*.nii.gz files.  Will not overwrite.'
    echo '          Please move or remove them before running.'
    exit 1
endif

# Things are easiest starting from a standard RAI orientation---this 
# step updates both data and header information, so no "corrective" action
# occurs here (but any obliquity will not be preserved here)
3dresample                      \
    -orient RAI                 \
    -input  "${dset_in}"        \
    -prefix tmp_00_RAI.nii.gz

# Copy the data before refitting, because refitting changes the header 
# in place
3dcopy                          \
    tmp_00_RAI.nii.gz           \
    tmp_01_${new_ori}.nii.gz

# ... and update the header information, effectively reorienting the 
# dataset
3drefit                         \
    -orient ${new_ori}          \
    tmp_01_${new_ori}.nii.gz

echo "++ DONE.  Please visually verify results for final dataset:"
echo "            tmp_01_${new_ori}.nii.gz"
echo "          Please take extra caution to verify left/right correctness."

The output looked reasonable for reorientating. NB: In most sphinx-to-humanlike reorienting, I am used to refitting RAI to RSP or to LSP; in this case, I had to convert it to RIP or LIP, because the brain looked upside down otherwise. This might be due to the particular scan setup, but I just wanted to note it for future uses of this script. Also note that that script removes obliquity information from the header as it goes; if that is important to preserve, we could discuss how to do so, but it is more complicated.

Also, I think you will have to still verify left/right correctness somehow. For example, do you know how the animal was placed in the scanner to start with, so you can tell what is the animal's physiological left side in the original acquisition? For example, here is an image of your original data as underlay, with the three panels in axial (left=left), sagittal (left=anterior) and coronal (left=left) orientation, and the overlay is a copy of the dataset with have of the FOV zeroed out:


After running the script as written above on each of those datasets, the results look like:

Now, the question is, in the original dataset, can you tell whether the zeroed-out half is the anatomical left or right? If the original zeroed out half is the anatomical left, then things appear to be correct currently; otherwise, you would want to change the value of new_ori in the script to LIP.

--pt

Dear Prof. Taylor,
I am deeply thankful for your guidance in rotating the structural images of my mouse. Your insights into the technique of image rotation have significantly enhanced my research.

I have been diligently working on further processing the rotated images by performing skull stripping (01_T2_stripped.nii) and subsequent linear registration to a template (Template_C57Bl6_n30_brain.nii). Given that my upcoming research involves VBM analysis, I have prioritized linear registration. However, despite my best efforts, I have encountered challenges and have not been successful in achieving the desired results.

Considering your vast experience and expertise in the field, I am reaching out to seek your guidance and assistance. I believe that your insights and advice could greatly help me overcome the hurdles I am facing in achieving successful linear registration after skull stripping.

  • File url:
  1. share - Google 云端硬盘
  2. sharing - Google 云端硬盘
  • File annotations:
    Template_C57Bl6_n30_brain.nii: mouse brain template copied from the C57B16.zip (File url 1)
    tmp_01_RIP.nii.gz: mouse structure image after rotation according to your method (File url 2)
    01_T2_stripped.nii: Image obtained from tmp_01_RIP.nii.gz after stripping skull (File url 2)

Thank you once again for your unwavering support and dedication.
Wishing you all the best and looking forward to your response.

Sincerely,
Peng

[quote="fz1002rp, post:5, topic:6403"]
Dear Prof. Taylor,
I sincerely apologize for reaching out to you once again and for any inconvenience my inquiries might cause.
Specifically, I have been working on the problem of registering a structural image (01_T2_stripped.nii or tmp_01_RIP.nii.gz) to a mouse template image (Template_C57Bl6_n30_brain.nii). Despite my efforts, I have encountered difficulties in achieving successful registration using the methods I have attempted so far. The size of these two images seems to be different, and the result of 3dresample is also very terrible. I also tried adding parameters to 3dresample, such as -bound_type SLAB, but the result was still bad.

  1. 3dresample -master 01_T2_stripped.nii -inset Template_C57Bl6_n30_brain.nii -prefix Resampled_Mouse_Image1.nii.gz
  2. 3dresample -master Template_C57Bl6_n30_brain.nii -inset 01_T2_stripped.nii -prefix Resampled_Mouse_Image2.nii.gz

I understand that your time is valuable, and I greatly appreciate any support you can offer.

  • File url:
  1. share - Google 云端硬盘
  2. sharing - Google 云端硬盘
  • File annotations:
    Template_C57Bl6_n30_brain.nii: mouse brain template copied from the C57B16.zip (File url 1)
    tmp_01_RIP.nii.gz: mouse structure image after rotation according to your method (File url 2)
    01_T2_stripped.nii: Image obtained from tmp_01_RIP.nii.gz after stripping skull (File url 2)

Thank you once again for your help!
Wishing you all the best and looking forward to your response.

Sincerely,
Peng

Howdy-

Sorry, this fell off my radar, after I was having a hard time finding a mousebrain template whose properties seemed most useful for this. Do you have a particular reference template you are using?

-pt

[quote="fz1002rp, post:6, topic:6403"]
Dear Prof. Taylor,
Thank you very much for your reply, and I sincerely appreciate your assistance.
I apologize for any confusion, but I must admit that I didn't fully grasp the intent behind your previous message. Specifically, I'm uncertain whether the issue lies in the accessibility of the web link I shared for the uploaded files, or if there might be concerns regarding the suitability of the mouse brain template I provided.
My Objective: To perform image registration between my mouse brain images with a recognized mouse brain template and subsequently conduct VBM analysis. The choice of mouse brain template is flexible, but it must be accompanied by corresponding tissue probability maps.
I have utilized the mouse brain template from the provided address (Template_C57Bl6): NITRC: Templates for In vivo Mouse Brain: Tool/Resource Info. In addition, my own mouse brain images "tmp_01_RIP.nii.gz," which is the mouse structure image after rotation as per your recommended method. Furthermore, I have generated the stripped version labeled "01_T2_stripped.nii" after performing skull stripping on the "tmp_01_RIP.nii.gz" image.

  • File url:
  1. share - Google 云端硬盘
  2. sharing - Google 云端硬盘
  • File annotations:
    Template_C57Bl6_n30_brain.nii: mouse brain template copied from the C57B16.zip (File url 1)
    tmp_01_RIP.nii.gz: mouse structure image after rotation according to your method (File url 2)
    01_T2_stripped.nii: Image obtained from tmp_01_RIP.nii.gz after stripping skull (File url 2)

    I would be grateful for any further clarification or guidance you could provide regarding the challenges I've encountered.
    Thank you once again for your time and support.
    Sincerely,
    Peng

There are similar problems as in the original post; the orientation of those datasets is not correct, and they are differently incorrect. By looking at this in the AFNI GUI, it becomes apparent, the sagittal, axial and coronal views are not correctly set. The solution is to "refit" the header of the dataset with the correct orientation. to3d provides one way to fix the header. By opening the dataset with the to3d GUI, the orientation can be found by looking across the image, down the image and across the slices and noting the first letter of each of the directions. We can't know left from right here, so there are just assumpltions to make this more consistent, but hopefully you will know that from some other clues in the anatomy of these particular mice.

# find dimensions in number of voxels in i,j,k with 3dinfo
3dinfo 01_T2_1_refit.nii
# use those dimensions here when starting to3d, use "View images"
# can ctrl-c to exit or exit without saving
to3d '3D:-1:0:192:192:52:01_T2_1_refit.nii'
# refit the orientation from what was found in the GUI
3drefit -orient RSA 01_T2_1_refit.nii

Similarly do that for the RARE dataset. That's slightly more complicated because it is also an oblique dataset.

3dinfo dicom_T2_TurboRARE_20230607141101_20001.nii
3drefit -orient LIP -deoblique dicom_T2_TurboRARE_20230607141101_20001.nii

These two datasets now line up with each other.

Unfortunately, the template with its 800um resolution is far too large for a mouse, but I don't know what it should be. In the meantime, you could use another template and atlas, like the Allen mouse brain here. See the previous thread here:

and here:

Depending on the size of the volumetric changes, the segmentation quality will be limited by voxel resolution, and I wouldn't expect VBM to be particularly useful. Alternative methods may work better.