Code to reconstruct data structures from raw sensor data and calculate quaternions