It sounds like you have 2 stages of alignment (conceptually: MNI → anat; anat → EPI). You will want to concatenate these alignments, so that you have one (MNI → EPI). Each of these alignments appears to be affine, so the concatenation can be done with cat_matvec (and any inversion, if necessary, can be done on one or more component matrices in this program), and then the result will also be affine, you you would use 3dAllineate to apply it.
Note that we talk about “aligning A to B”, so we conceptualize taking a point in A’s space and figuring out where to send it in B’s space. The way AFNI warps/alignments are actually calculated are sitting at a grid point in B and figuring out where to pull data from in A. This matters in terms of order of concatenating: think about starting in your “end” space (here, EPI) and ordering your warps by which successive pulling of data (so, would be the “anat->EPI” warp, then “MNI->anat” warp).
Second note: we often use affine registration between the EPI and anatomical data from the same subject. However, when aligning data between different subjects’ anatomicals (which includes a subject brain to a standard space template), then we would typically recommend using nonlinear alignment (e.g., 3dQwarp or @SSwarper—which combines skullstripping (ss) with nonlinear warping, or @animal_warper for non-human data). That is something for you to consider. The nonlinear warps and affine transforms can still be concatenated and applied, just using different programs (actually, the 3dNwarpApply that you were using).
For the present data, you could do the following:
mat_MNI_to_anat.aff12.1D mat_anat_to_EPI.aff12.1D > mat_MNI_to_EPI.aff12.1D
and, if above you actually had mat_anat_to_MNI.aff12.1D, say, you could use the following to invert that:
mat_anat_to_MNI.aff12.1D -I mat_anat_to_EPI.aff12.1D > mat_MNI_to_EPI.aff12.1D
… and I think the “-ONELINE” is useful for formatting the output dset to use later.
Then, use 3dAllineate:
-1Dmatrix_apply mat_MNI_to_EPI.aff12.1D \
-source DSET_ATLAS_in_MNI \
-prefix DSET_ATLAS_in_EPI \
-final NN \
… where “-master DSET_EPI” sets the appropriate grid for the output dset, and “-final NN” tells the program to use nearest neighbor interpolation for the final output creation, so that integers stay integer.
Furthermore, if there is a labeltable associated with the dset, you can run the following to copy its header info along (while also telling AFNI to use an ROI-based colorbar when overlaying it in the GUI):
3drefit -copytables DSET_ATLAS_in_MNI DSET_ATLAS_in_EPI
3drefit -cmap INT_CMAP DSET_ATLAS_in_EPI
Please let me know how that goes, esp. verifying in the GUI that I have put things in the correct order here…