The part that boggles my mind is that the rotations are X degrees counter clockwise around the X-axis, then Y degress clockwise about the Y-axis, and then Z degrees clockwise about the Z-axis. When I first saw that I said, huh, must be a left handed system, not a right handed system. Then I looked at the layer information, and there in the comp window are the three axes of rotation, and yup, it's CCW about the X, CW about the Y and CW about Z.
So after spending about an hour screwing up the derivation of the quaternion conversion to the After Effects Orientation format on paper, I finally sat down with IDLE and brute forced a derivation. That is taking each component of the rotation matrix that represents a given quaternion and applying arc sines, arc cosines and arc tangents to various combinations of the matrix elements until I got the orientation back that I used to generate the quaternion.
It's a hack, but it works. At least out to the square root of epsilon of a double for all the inputs I've tried so far, which is good enough for me.