I have an atlas and a mask in the same space. The atlas has 10 labels encoded as integers from 1 to 10.
I want to register the atlas to my subject’s functional space. I have tried both SPM co-register and AntsPy with SyN algo but they both fail to produce nice results.
One idea would be to use a template or anatomical image in the atlas space for registration to my subject’s T1/T2 space and the reslicing to the functional space. However, I do not have an anatomical image in the atlas space but only the mask and the atlas…
For registration, you may better try with a T1w version of the atlas, or any kind of image in the atlas space with a continuous contrast, if you have that available.
Do you also have a T1w image of your subject, that could be use as an intermediary target for registration?
Besides, your functional image looks to have been already smoothed, is that the case? Do you have another image less smoothed with better contrast?
Finally, did you try to look both images (functional and atlas) to see if the images are far away in world coordinates? You may use some viewers such as FSLeyes or SPM to check this.
I think there might be at least a couple ways to do this:
Talairach both the subject and the atlas data. This is the manual, stereotaxic procedure where you would select a several locations in each dataset to bring them into the Talairach space. This will be very approximate. You can use AFNI’s GUI for this.
Mark tags in each to align one to the other. AFNI has the Tagset plugin to mark locations in each dataset, and 3dTagalign to compute and apply the affine transformation. Probably better, but manual and tedious if you have lots to do.
Align with a better cost function for this, something that would reduce this problem to just an overlap computation - maybe a least squares. Changing the atlas to just a single binary mask might be helpful.
Still, as jsein suggests, this is probably not the best approach if you can get the template the atlas is based on - maybe some version of an MNI space template, for instance. Also, we tend not to align functional data directly to any template, but instead use the anatomical, structural dataset for that alignment. The functional data you have shown has little structural detail, and that will allow a fair bit of wiggle room, so an anatomical dataset generally is better. Then we align the functional data to the anatomical data and concatenate the transformations to align to a template and use related atlases. That concatenation usually involves motion correction and obliquity handling in AFNI. Inverting the whole chain of transformations allows the atlases to be used in the native space.
I got inspired by your ideas and managed to solve the problem by doing the following. I did not have any T1/T2 image in the atlas spae but I had a functional one. So I used the functional one in the altas space as the “moving” one and the functional of my subject as the “fixed” one and I applied the amazing BOLDAffine algo from antspy. This did the trick and then I applied the transformation to the label (atlas) image.