There is no need to calculate the quaternion, it is sufficient to set the attitude in the state interface directly from the rotation matrix.
If the eulers are really needed for adding roll/pitch neutrals or mag offset, you can calc the eulers directly from the rmat without calculating the quaternion and then set it from eulers... but beware of the singularities.