Automatic assessment of the goodness of many alignments

“The goodness of the alignment should always be assessed visually” !

With this sentence keeping in mind, I am wondering if there is an AFNI method conveniently available in assisting this assessment, particularly with a relatively “big” sample size. For example, I received data from several hundreds of subjects with their alignments of “anat2epi” already completed (done by someone else in the past with align_epi_anat.py), so each subject has a file pair of “epi+orig” and “anat_al+orig”. Now I want to check the goodness of these previous alignments, but it is going to be time comsuming considering that each subject also has multiple scanning sessions. In this situation, I am wondering if I can simply skip the alignment procedure in align_epi_anat.py or 3dAllineate but just run their cost functions; something like:


for each subjects
        3dAllineate -skip_alignment -base epi+orig -input anat_al+orig -cost lpa >> cost_file.1D

This would allow me to collect the “cost” values of each subject in the “cost_file.1D”; then I may just visually inspect individuals with a high, say the top 10%, cost value; and if those top costs (worst alignments) can pass my visual inspections, I can reasonably assume that all alignments are fine.

Am I correct? What can I do to realize the option of “-skip_alignment”?

I think you want

3dAllineate -allcostX1D IDENTITY allcosts.1D

This will show all available cost functions. Just be advised, the costs will vary depending on the data. Different data will give different costs, and each cost function is different. That makes it difficult to compare across differing pairs of data.

Thank you Daniel!
I understand the potential difficulty of comparing cost values across subjects. However, since the “goodness” of an alignment is ultimated determined by visual inspections with an user label of “pass” vs. “fail”, do you think that align_epi_anat.py could be improved by a machine learning based classifier? For example, we can have 3dAllineate to output a bunch of local cost values from different brain regions, then use these cost values as features to train a classifier. Once this classifier is obtained, it can be included in AFNI distributions for providing users an warning if the classifier thinks the alignment is bad.

I’ve long been a proponent of site-wise distributions for metrics like this, but I think one has to limit this to extreme outliers. Whether one has to subdivide to be sure various brain regions are included or whole brain, I’ll leave that up to you. You can help with the comparisons by using 3dUnifize to make datasets as similar as possible. Doing the comparison in standard space with a specific template will help too. Resampling to similar resolution may be useful. Like you, we receive and analyze data from many different sources, and there is certainly a lot of variety in FMRI data. So including partial coverage EPI datasets will be much more difficult. Please let me know if you have any more questions or concerns.

Thank you Daniel!
I actually don’t think the 3dUnifize being necessary as “feature normalization” and “batch normalization” are typically used in most machine learning algorithms.
I guess that partial coverage may not be a big issue either, because sparse features are often seen in literature. I may be able to give it a shot if there is a convenient way to extract local costs from a buch of ROIs (filling zero for those without coverage) in the standard space.

I would probably still trust the 3dUnifize feature, which varies over the volume, more than a machine learning algorithm normalization.

For each ROI, you can use the -source_mask or -weight for an ROI over that region.