Applying quaternion rotations to bones

I’ve succesfully imported the positions of the armature of a gamefile into blender, the problem is that the file also has quaternion rotations in it and I’ve no idea how to apply it to the armature.

So far I’ve put the armature in pose mode, and got the quaternion data into a mathutils.Quaternion. I tried applying it by inputting it into the edit_bone’s transform(), but that just sent my bones all over the place.

Could anybody tell me what the right way to do this is?

You may want to review how the BVH importer is handling this. It comes with Blender and is located here: scripts\addons\io_anim_bvh\

I’m not certain about the right way, but a quaternion just encodes a rotation not a transformation. I would try setting the pose bone’s "rotation_quaternion’ field directly.