# Path: sensbiotk/io/iofox.py
# def load_foxcsvfile(filename):
#     """ Load IMU HikoB Fox Node data from a CSV file version 2\n
#     id    t    dt    ax    ay    az    mx    my    mz    gx    gy    gz\n
#     columns are separated by a tab
# 
#     Parameters
#     ----------
#     filename : str
#     Name of the CSV file containing inertial data
# 
#     Return
#     -------
#     time : numpy.array
#     accx : numpy.array
#     accy : numpy.array
#     accz : numpy.array
#     magx : numpy.array
#     magy : numpy.array
#     magz : numpy.array
#     gyrx : numpy.array
#     gyry : numpy.array
#     gyrz : numpy.array
#     """
# 
#     data = np.loadtxt(filename, delimiter='\t')
# 
#     time = data[:, 1]
#     accx = data[:, 3]
#     accy = data[:, 4]
#     accz = data[:, 5]
#     magx = data[:, 6]
#     magy = data[:, 7]
#     magz = data[:, 8]
#     gyrx = data[:, 9]
#     gyry = data[:, 10]
#     gyrz = data[:, 11]
# 
#     return [time, accx, accy, accz, magx, magy, magz, gyrx, gyry, gyrz]
# 
# Path: sensbiotk/transforms3d/eulerangles.py
# def quat2euler(q):
#     ''' Return Euler angles corresponding to quaternion `q`
# 
#     Parameters
#     ----------
#     q : 4 element sequence
#        w, x, y, z of quaternion
# 
#     Returns
#     -------
#     z : scalar
#        Rotation angle in radians around z-axis (performed first)
#     y : scalar
#        Rotation angle in radians around y-axis
#     x : scalar
#        Rotation angle in radians around x-axis (performed last)
# 
#     Notes
#     -----
#     It's possible to reduce the amount of calculation a little, by
#     combining parts of the ``quat2mat`` and ``mat2euler`` functions, but
#     the reduction in computation is small, and the code repetition is
#     large.
#     '''
#     # delayed import to avoid cyclic dependencies
#     import sensbiotk.transforms3d.quaternions as nq
#     return mat2euler(nq.quat2mat(q))


import numpy as np 
import matplotlib.pyplot as plt
import sensbiotk.calib.calib_geom as calib_geom
import sensbiotk.algorithms.martin_ahrs as martin
import sensbiotk.calib.calib as calib
import sensbiotk.algorithms.goniometer as goniometer
import sensbiotk.transforms3d.quaternions as nq
import scipy.io as sio
from sensbiotk.io.iofox import load_foxcsvfile
from sensbiotk.transforms3d.eulerangles import quat2euler
    scale_mag_right_shank = params_mag_right_shank[1:4,:]
    bias_mag_right_shank = params_mag_right_shank[0,:]    
    
    scale_mag_left_thigh = params_mag_left_thigh[1:4,:]
    bias_mag_left_thigh = params_mag_left_thigh[0,:]
    
    scale_mag_left_shank = params_mag_left_shank[1:4,:]
    bias_mag_left_shank = params_mag_left_shank[0,:]    
    
    scale_mag_trunk = params_mag_left_shank[1:4,:]
    bias_mag_trunk = params_mag_left_shank[0,:]        

    ######################################################
    # Load trials data
    ######################################################   
    # right thigh
    [time_imu_right_thigh, accx_right_thigh, accy_right_thigh, accz_right_thigh, \
    mx_right_thigh, my_right_thigh, mz_right_thigh, gyrx_right_thigh, gyry_right_thigh, gyrz_right_thigh] = \
            load_foxcsvfile(trial_file_thigh_right)        
    # left thigh
    [time_imu_left_thigh, accx_left_thigh, accy_left_thigh, accz_left_thigh, \
    mx_left_thigh, my_left_thigh, mz_left_thigh, gyrx_left_thigh, gyry_left_thigh, gyrz_left_thigh] = \
            load_foxcsvfile(trial_file_thigh_left)
    # right shank
    [time_imu_right_shank, accx_right_shank, accy_right_shank, accz_right_shank, \
    mx_right_shank, my_right_shank, mz_right_shank, gyrx_right_shank, gyry_right_shank, gyrz_right_shank] = \
            load_foxcsvfile(trial_file_shank_right)
    # left shank
    [time_imu_left_shank, accx_left_shank, accy_left_shank, accz_left_shank, \
    mx_left_shank, my_left_shank, mz_left_shank, gyrx_left_shank, gyry_left_shank, gyrz_left_shank] = \

# Path: sensbiotk/io/iofox.py
# def load_foxcsvfile(filename):
#     """ Load IMU HikoB Fox Node data from a CSV file version 2\n
#     id    t    dt    ax    ay    az    mx    my    mz    gx    gy    gz\n
#     columns are separated by a tab
# 
#     Parameters
#     ----------
#     filename : str
#     Name of the CSV file containing inertial data
# 
#     Return
#     -------
#     time : numpy.array
#     accx : numpy.array
#     accy : numpy.array
#     accz : numpy.array
#     magx : numpy.array
#     magy : numpy.array
#     magz : numpy.array
#     gyrx : numpy.array
#     gyry : numpy.array
#     gyrz : numpy.array
#     """
# 
#     data = np.loadtxt(filename, delimiter='\t')
# 
#     time = data[:, 1]
#     accx = data[:, 3]
#     accy = data[:, 4]
#     accz = data[:, 5]
#     magx = data[:, 6]
#     magy = data[:, 7]
#     magz = data[:, 8]
#     gyrx = data[:, 9]
#     gyry = data[:, 10]
#     gyrz = data[:, 11]
# 
#     return [time, accx, accy, accz, magx, magy, magz, gyrx, gyry, gyrz]
# 
# Path: sensbiotk/transforms3d/eulerangles.py
# def quat2euler(q):
#     ''' Return Euler angles corresponding to quaternion `q`
# 
#     Parameters
#     ----------
#     q : 4 element sequence
#        w, x, y, z of quaternion
# 
#     Returns
#     -------
#     z : scalar
#        Rotation angle in radians around z-axis (performed first)
#     y : scalar
#        Rotation angle in radians around y-axis
#     x : scalar
#        Rotation angle in radians around x-axis (performed last)
# 
#     Notes
#     -----
#     It's possible to reduce the amount of calculation a little, by
#     combining parts of the ``quat2mat`` and ``mat2euler`` functions, but
#     the reduction in computation is small, and the code repetition is
#     large.
#     '''
#     # delayed import to avoid cyclic dependencies
#     import sensbiotk.transforms3d.quaternions as nq
#     return mat2euler(nq.quat2mat(q))


# Path: examples/tug_angles/tug.py
import numpy as np 
import matplotlib.pyplot as plt
import sensbiotk.calib.calib_geom as calib_geom
import sensbiotk.algorithms.martin_ahrs as martin
import sensbiotk.calib.calib as calib
import sensbiotk.algorithms.goniometer as goniometer
import sensbiotk.transforms3d.quaternions as nq
import scipy.io as sio
from sensbiotk.io.iofox import load_foxcsvfile
from sensbiotk.transforms3d.eulerangles import quat2euler

    scale_mag_right_shank = params_mag_right_shank[1:4,:]
    bias_mag_right_shank = params_mag_right_shank[0,:]    
    
    scale_mag_left_thigh = params_mag_left_thigh[1:4,:]
    bias_mag_left_thigh = params_mag_left_thigh[0,:]
    
    scale_mag_left_shank = params_mag_left_shank[1:4,:]
    bias_mag_left_shank = params_mag_left_shank[0,:]    
    
    scale_mag_trunk = params_mag_left_shank[1:4,:]
    bias_mag_trunk = params_mag_left_shank[0,:]        

    ######################################################
    # Load trials data
    ######################################################   
    # right thigh
    [time_imu_right_thigh, accx_right_thigh, accy_right_thigh, accz_right_thigh, \
    mx_right_thigh, my_right_thigh, mz_right_thigh, gyrx_right_thigh, gyry_right_thigh, gyrz_right_thigh] = \
            load_foxcsvfile(trial_file_thigh_right)        
    # left thigh
    [time_imu_left_thigh, accx_left_thigh, accy_left_thigh, accz_left_thigh, \
    mx_left_thigh, my_left_thigh, mz_left_thigh, gyrx_left_thigh, gyry_left_thigh, gyrz_left_thigh] = \
            load_foxcsvfile(trial_file_thigh_left)
    # right shank
    [time_imu_right_shank, accx_right_shank, accy_right_shank, accz_right_shank, \
    mx_right_shank, my_right_shank, mz_right_shank, gyrx_right_shank, gyry_right_shank, gyrz_right_shank] = \
            load_foxcsvfile(trial_file_shank_right)
    # left shank
    [time_imu_left_shank, accx_left_shank, accy_left_shank, accz_left_shank, \
    mx_left_shank, my_left_shank, mz_left_shank, gyrx_left_shank, gyry_left_shank, gyrz_left_shank] = \

            load_foxcsvfile(trial_file_shank_left)