# Standardize: Standardize accelerometer and magnetometer data In TrackReconstruction: Reconstruct Animal Tracks from Magnetometer, Accelerometer, Depth and Optional Speed Data

## Description

Calculates intercept and slope values with a linear model to standardize accelerometer and magnetometer data to values between -1 and +1.

## Usage

 ```1 2 3``` ```Standardize(MagOrSR, MagOrHV, MagOrSW, AccOrSR, AccOrHV, AccOrSW, magSRmin, magSRmax, magHVmin, magHVmax, magSWmin, magSWmax, accSRmin, accSRmax, accHVmin, accHVmax, accSWmin, accSWmax) ```

## Arguments

 `MagOrSR` Surge Magnetometer Orientation -1 or 1 `MagOrHV` Heave Magnetometer Orientation -1 or 1 `MagOrSW` Sway Magnetometer Orientation -1 or 1 `AccOrSR` Surge Accelerometer Orientation -1 or 1 `AccOrHV` Heave Accelerometer Orientation -1 or 1 `AccOrSW` Sway Accelerometer Orientation -1 or 1 `magSRmin` Surge Magnetometer minimum `magSRmax` Surge Magnetometer maximum `magHVmin` Heave Magnetometer minimum `magHVmax` Heave Magnetometer maximum `magSWmin` Sway Magnetometer minimum `magSWmax` Sway Magnetometer maximum `accSRmin` Surge Accelerometer minimum `accSRmax` Surge Accelerometer maximum `accHVmin` Heave Accelerometer minimum `accHVmax` Heave Accelerometer maximum `accSWmin` Sway Accelerometer minimum `accSWmax` Sway Accelerometer maximum

## Details

Standardization/Calibration/normalization/relativizing of accelerometer and magnetometer data. The right-hand-rule indicates the orientation (polarity) of the magnetometers and accelerometers required for the pseudotrack reconstruction algorithm, so that when the front, top or left side of the tag is facing the earth, the accelerometers are at the maximal reading (+1) when the tag is not moving. A similar rule applies for the magnetometers except the maximal reading for each axis will be when the front, top or left side is facing north and at the angle of inclination of the magnetic field (the angle at which the magnetic field enters the earth) at that location on the planet. If the tag sensors conform to this rule all the orientation parameters should be 1, any sensors that are opposite to this should have -1 as an orientation value. Instead of labeling the tag in X,Y and Z dimensions, the directions are labeled as Surge, Heave and Sway where Surge indicates the front (anterior) to back (posterior) axis, the Heave is the top (dorsal) to bottom (ventral) axis and the Sway is the right to left (lateral) axis.

## Value

Returns a [2,6] matrix with intercept in the first row and slope in the second row and columns in the order of the orientation parameter input. Row names are c("B0 Intercept","B1 Slope") and column names are c("MagSurge","MagHeave","MagSway","AccSurge","AccHeave","AccSway").

Brian Battaile

## Examples

 ```1 2 3``` ```betas<-Standardize(1,1,-1,1,1,1,-57.8,68.76,-61.8,64.2,-70.16,58.08,-10.1,9.55,-9.75,9.72, -9.91,9.43) betas ```

### Example output

```Loading required package: fields
Spam version 2.1-1 (2017-07-02) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following objects are masked from 'package:base':

backsolve, forwardsolve