The concatenation of the various transformations is a tricky business. It's complicated by the fact that different programs output source to base (as you might expect) or base to source directions (actually more useful). align_epi_anat.py can potentially concatenate obliquity, motion correction, anatomical alignment and alignment to a standard template, so it can get fairly complicated. 3dAllineate (like 3dWarpDrive and 3dvolreg) creates base to source affine transformation matrices and expects the same when it is asked to apply a transformation. Adding nonlinear transformations and chained transformations among spaces is even more complicated. You can use whereami's calc_chain option together with some space and transformation definitions to try some toy examples if you're really interested in all this.