align CT to a T1-MRI template using animal_warper?

Dear AFNI team,

I have used animal_warper and successfully aligned the marmoset MRI with a T1-MRI template.
I wonder whether I can align a micro-CT scan align to T1 template as well. The CT image below shows clear brain boundaries, but the brightest part in micro-CT is the darkest part in T1-MRI.

do you think based on the logic in animal_warper I can (maybe do some preprocess on CT? i need to fix the orientation first for sure, maybe cut extra slices as well?) align the micro-CT to T1 template?

here is the micro-CT image

(I can't put a second image on this post...)

Thank you!
Yibei

While the viewer is not AFNI's, it appears the orientation of the CT is not correct, so that will need to be fixed first. Many animal scan, including marmosets, are often acquired in a sphinx position, so this program can adjust for that.

desphinxify                                \
        -orient_mid  RIP                        \
        -input       sub-001_T1w.nii.gz         \
        -prefix      sub-001_T1w_DSPH.nii.gz

animal_warper can align between T1w (the desphinxified version) and CT datasets for the same subject, often by using a rigid body alignment with the option -align_type rigid. Additionally, the nmi cost function will often be a good choice for this kind of alignment with -cost nmi.

You may also want to invert the MRI so that the skull that often appears as an irregular dark band in a T1 image is bright instead and more easily matches the bright skull of the CT.

set max = `3dBrickStat -max anat_amd+orig`
3dcalc -a anat_amd+orig. -expr "step(a)*(${max}-a)" -prefix anat_amd_rev
1 Like

Thank you! ah, the sphinx position yes... i kept forgetting it.
The viewer was MRIcroGL.
But I have to do what you suggested on a T1 template (inverting MRI) rather than on the same subject MRI. We don't have the same subject MRI :(
Our case is quite complicated. Our ultimate goal is to align functional ultrasound (fUS) image to an altas (MRI based). fUS image is vessel signal only, so originally, I did 9T MRI (subject) to MRI template. And this 9T MRI is clear enough for me to do manual landmark registration for fUS and MRI.
But it's hard to get a 9 T MRI every time. So I'm thinking of aligning the subject CT to the MRI template, segmenting the CT to get vessel signals, and then aligning the same subject fUS with the segmented aligned CT.
Sounds too idealistic?

That will be tougher. Marmosets are enough alike that it might work. You will have to try. You could try with just a cost function of nmi in animal_warper, but I expect there will be lots of distortion in the nonlinear step. You can try affine only for the align_type. Inverting the template in the same way above might help here too.

Another way is to use the Tagalign plugin, marking fiducial markers in your own specific order and then repeating that for the template. You will need at least 12 points marked. Then use the program, 3dTagalign to compute and apply an affine transformation based on the supplied coordinates.

you were right; everything is horrible, I can't even see any shape out of the aligned image. sad

i did desphinxified, inverted t1w template brightness, animal_warper (both rigid and affine)
see this link. if you search "animal warper (affine)" you can see the result.

at the end of the jupyter notebook, I inverted CT brightness. I wanted to align the inverted CT to the original MRI template. It's too noisy. I should probably do some thresholding there.

But there is one more problem. The CT file has spacing (1, 1, 1) and image size (163, 212, 232), while the T1 MRI template has spacing (0.2, 0.2, 0.2) and image size (147, 200, 135). If I resample CT to T1 MRI resolution, I'll get CT size (815, 1060, 1160)—crazy. So, in my animal_warper, I used the original CT shape.

regarding the second approach, "Tagalign plugin," sounds like a landmark registration? 12 points in order is quite challenging...

here is CT metadata

Spacing [1, 1, 1]
 Origin [0, 0, 0]
 Direction
1 0 0
0 1 0
0 0 1

 Size : 163 212  232

  Image Dimensions   : [163, 212, 232]
  Bounding Box       : {[0 0 0], [163 212 232]}
  Voxel Spacing      : [1, 1, 1]
  Intensity Range    : [0, 255]
  Mean Intensity     : 16.6623
  Direction Cos Mtx. :
1 0 0
0 1 0
0 0 1

  Voxel->RAS x-form  :
  Image Metadata:
    ITK_original_direction of unsupported type N3itk6MatrixIdLj3ELj3EEE
    ITK_original_spacing of unsupported type NSt3__16vectorIdNS_9allocatorIdEEEE
    ITK_sform_corrected = NO
    bitpix = 8
    cal_max = 0
    cal_min = 0
    datatype = 2
    dim[0] = 3
    dim[1] = 163
    dim[2] = 212
    dim[3] = 232
    dim[4] = 1
    dim[5] = 1
    dim[6] = 1
    dim[7] = 1
    dim_info = 0
    intent_code = 0
    intent_p1 = 0
    intent_p2 = 0
    intent_p3 = 0
    nifti_type = 1
    pixdim[0] = 0
    pixdim[1] = 1
    pixdim[2] = 1
    pixdim[3] = 1
    pixdim[4] = 0
    pixdim[5] = 0
    pixdim[6] = 0
    pixdim[7] = 0
    qfac = 1
    qform_code = 1
    qform_code_name = NIFTI_XFORM_SCANNER_ANAT
    qoffset_x = -0
    qoffset_y = -0
    qoffset_z = 0
    qto_xyz of unsupported type N3itk6MatrixIfLj4ELj4EEE
    quatern_b = 0
    quatern_c = 0
    quatern_d = 1
    scl_inter = 0
    scl_slope = 1
    sform_code = 1
    sform_code_name = NIFTI_XFORM_SCANNER_ANAT
    slice_code = 0
    slice_duration = 0
    slice_end = 0
    slice_start = 0
    srow_x = -1 0 0 -0
    srow_y = 0 -1 0 -0
    srow_z = 0 0 1 0
    toffset = 0
    vox_offset = 352
    xyzt_units = 2

here is T1 MRI template meta data:

 Spacing [0.2, 0.2, 0.2]
 Origin [14.6, 14.4, -3.6]
 Direction
-1 0 0
0 -1 0
0 0 1

 Size : 147 200  135

  Image Dimensions   : [147, 200, 135]
  Bounding Box       : {[14.6 14.4 -3.6], [44 54.4 23.4]}
  Voxel Spacing      : [0.2, 0.2, 0.2]
  Intensity Range    : [-5.25192e-05, 5.32487]
  Mean Intensity     : 0.999127
  Direction Cos Mtx. :
-1 0 0
0 -1 0
0 0 1

  Voxel->RAS x-form  :
  Image Metadata:
    ITK_original_direction of unsupported type N3itk6MatrixIdLj3ELj3EEE
    ITK_original_spacing of unsupported type NSt3__16vectorIdNS_9allocatorIdEEEE
    ITK_sform_corrected = NO
    bitpix = 32
    cal_max = 0
    cal_min = 0
    datatype = 16
    dim[0] = 3
    dim[1] = 147
    dim[2] = 200
    dim[3] = 135
    dim[4] = 1
    dim[5] = 1
    dim[6] = 1
    dim[7] = 1
    dim_info = 0
    intent_code = 0
    intent_p1 = 0
    intent_p2 = 0
    intent_p3 = 0
    nifti_type = 1
    pixdim[0] = 0
    pixdim[1] = 0.2
    pixdim[2] = 0.2
    pixdim[3] = 0.2
    pixdim[4] = 0
    pixdim[5] = 0
    pixdim[6] = 0
    pixdim[7] = 0
    qfac = 1
    qform_code = 1
    qform_code_name = NIFTI_XFORM_SCANNER_ANAT
    qoffset_x = -14.6
    qoffset_y = -14.4
    qoffset_z = -3.6
    qto_xyz of unsupported type N3itk6MatrixIfLj4ELj4EEE
    quatern_b = 0
    quatern_c = 0
    quatern_d = 0
    scl_inter = 0
    scl_slope = 1
    sform_code = 0
    sform_code_name = NIFTI_XFORM_UNKNOWN
    slice_code = 0
    slice_duration = 0
    slice_end = 0
    slice_start = 0
    srow_x = 0 0 0 0
    srow_y = 0 0 0 0
    srow_z = 0 0 0 0
    toffset = 0
    vox_offset = 352
    xyzt_units = 2