mamoset atlas SAM integration with MBM

Hi, it's me again!

I managed to align CT brain (vascular signal only) to MRI template (MBM). Then, I wanted to use SAM (the subcortical atlas of marmoset), so I found that SAM has been integrated into MBM through SAM_T2_template.nii.gz. Then I tried to align CT brain to SAM_T2_template.nii.gz, but I was not successful.

here is init_qc_03.input_NL+base when aligning with SAM_T2_template.nii.gz

here is the same QC when aligning with MBM t2 template. (much better right?)

I guess the extra brain stem part in SAM_T2_template.nii.gz confuses the program. But maybe this problem can be solved by adding a brain mask?

The most important question I want to ask is, currently SAM_T2_template.nii.gz is 0.15x0.15x-0.15, and it has different origins than MBM templates/atlas. I want to run animal_warper once with both the cortical (MBM) and subcortical (SAM) atlases, but now they have different voxel size, shape, and origin, what's the best way to do it? I tried to resample SAM_T2_template.nii.gz/MBM template/atlas, not good.

here is the information on SAM

Template Space:  SAM_Marmoset
Dataset Type:    Anat Bucket (-abuc)
Byte Order:      LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode:    NIFTI
Storage Space:   20,870,016 (21 million) bytes
Geometry String: "MATRIX(-0.15,0,0,13.65,0,-0.15,0,27,0,0,0.15,-18.9):184,278,204"
Data Axes Tilt:  Plumb
Data Axes Orientation:
  first  (x) = Left-to-Right
  second (y) = Posterior-to-Anterior
  third  (z) = Inferior-to-Superior   [-orient LPI]
R-to-L extent:   -13.800 [R] -to-    13.650 [L] -step-     0.150 mm [184 voxels]
A-to-P extent:   -14.550 [A] -to-    27.000 [P] -step-     0.150 mm [278 voxels]
I-to-S extent:   -18.900 [I] -to-    11.550 [S] -step-     0.150 mm [204 voxels]
Number of values stored at each pixel = 1
  -- At sub-brick #0 '?' datum type is short:            0 to           976

here is the information on MBM template

Template Space:  ORIG
Dataset Type:    Anat Bucket (-abuc)
Byte Order:      LSB_FIRST {assumed} [this CPU native = LSB_FIRST]
Storage Mode:    NIFTI
Storage Space:   15,876,000 (16 million) bytes
Geometry String: "MATRIX(-0.2,0,0,14.6,0,-0.2,0,14.4,0,0,0.2,-3.6):147,200,135"
Data Axes Tilt:  Plumb
Data Axes Orientation:
  first  (x) = Left-to-Right
  second (y) = Posterior-to-Anterior
  third  (z) = Inferior-to-Superior   [-orient LPI]
R-to-L extent:   -14.600 [R] -to-    14.600 [L] -step-     0.200 mm [147 voxels]
A-to-P extent:   -25.400 [A] -to-    14.400 [P] -step-     0.200 mm [200 voxels]
I-to-S extent:    -3.600 [I] -to-    23.200 [S] -step-     0.200 mm [135 voxels]
Number of values stored at each pixel = 1
  -- At sub-brick #0 '?' datum type is float:            0 to       4.12392

Thank you!
Yibei

The CT to MRI alignment will work best with an MRI from the same animal. If you don't have that, it could still work, as you have seen, but the template will probably need a skull since the main feature in a head CT of most animals is the skull. A group template, like the MBMv3 template, has a skull,l so that's handy here. The ex-vivo template, SAM v1.0, doesn't have a skull at all.

All is not lost though, and you've hit upon the way to do it. The paper that introduced the SAM template and atlas include the alignment transformation betweeen SAM and MBM spaces. You have three choices of spaces to work in then - the native space, the MBM space or the SAM space. It's a bit easier here to work in the MBM space. That's a little less accurate than the SAM template space if you have data where you can tell the difference. CT doesn't typically. You can move the atlas from the MBM space to the CT native space in the usual way with the "-atlas" option (and probably "-ok_to_exist" to avoid rerunning the rest).

Here's the link for the animal_warper output for the alignment for SAM to MBM templates with transformation of the atlas.

https://afni.nimh.nih.gov/pub/dist/atlases/marmoset/SAM_Marmoset/aw_SAM_to_MBM.tgz

1 Like

thank you! MBM space is the easiest one.

everything was perfect when i added "-atlas" option with "-ok_to_exist" (on the successful alignment with MBM t1-template) but then i got

++ Are these dsets on same grid?
     SAMv1_atlas_warp2std_in_MASK_Marmosete_brain_B_200micron_reoriented_resampled.nii.gz[0]
     MASK_Marmosete_brain_B_200micron_reoriented_resampled_mask.nii.gz
   --> True
++ Are these dsets on same grid?
     .../aw_SAM_to_MBM_brainstem_fs0.8_1/SAMv1_atlas_warp2std.nii.gz[0]
     .../template_T1w_brain.nii.gz
   --> False

** ERROR: need input dsets on same grid;
   these do not match:
     .../aw_SAM_to_MBM_brainstem_fs0.8_1/SAMv1_atlas_warp2std.nii.gz[0]
     .../template_T1w_brain.nii.gz
** ERROR: program failed (base2osh atl/seg foll, table)
   ... for dset: SAMv1_atlas_warp2std_in_MASK_Marmosete_brain_B_200micron_reoriented_resampled.nii.gz

then i checked, there is a slight difference in terms of the shape, SAMv1_atlas_warp2std.nii.gz has shape (147, 200, 185), template_T1w_brain.nii.gz has shape (147, 200, 135). it's the brainstem difference.
I know in aw_SAM_to_MBM, there is MBM_T2_brainstem_zp.nii.gz which has shape (147, 200, 185). but if i use this one, i wouldn't be able to align the cortical atlas. all MBM atlases still have shape (147, 200, 135).

That's right. To include the brainstem, you need to extend the MBM atlas a little bit; that's why the zeropadded template is there. Use that for your template instead of the original for this atlas. If you don't care about the brainstem, then you can use the original and zeropad the warped atlas to match the template where you would remove slices. Use 3dZeropad -master and provide the original template in that case.

Yes! 3dZeropad it is. Here is my overall result. It's not perfect, but there is probably not much we can do since we use a single CT brain to align to a template?

MBM cortical atlas



SAM (looks okay???)



This is indeed not bad and might be the best you can do, but I would experiment with the cost functions a bit, like nmi, for the alignment of your CT to the MBM template Another approach I often use for MRI-CT alignment is to make an inverted MRI template/dataset and use that for the alignment. In T1-weighted MRI datasets, the skull shows up as a thin dark and often noisy layer.

# make T1 real skull bright by inverting and mask
3dAutomask -apply_prefix anat_amd -dilate 3 DBS.023.anat.nii.gz
set max = `3dBrickStat -max anat_amd+orig`
3dcalc -a anat_amd+orig. -expr "step(a)*(${max}-a)" -prefix anat_amd_rev
 
# align T1 to CT
align_epi_anat.py -dset1 anat_amd_rev+orig -dset2 CT_sh_rs+orig  \
-dset1_strip None -dset2_strip None -suffix _al2ct_nmi \
-feature_size 1  -overwrite -cost nmi -giant_move 
# for within-subject CT-MRI alignment, add  "-rigid_body"

Thank you! However, there is one small note regarding the cost function.
I've encountered errors using nmi as a cost function; see the errors here (adjunct_deob_around_origin didn't work? or not really an oblique problem? - #10 by yc0181). I tried a couple of times during the weekend, using the previous MRI to T1 template and this CT data to T1 template, but I always get similar errors.
But maybe if I inverted T1 as you suggested, the nmi error would disappear?