EthoVision XT 19 - Dependent Variables Reference (Continued)
Last updated: Jul 29, 2026
GetViewDirection
Returns the current value of the Head direction variable for:
- The subject in a single-subject experiment.
- The focal subject in a multi-subject experiment. Here "focal" refers to the subject for which the statistics are calculated.
It is expressed in radians. Note that the Head direction dependent variable provided by EthoVision XT is expressed in degrees. To convert your JavaScript variable to degrees, see the example below.
Syntax
GetViewDirection()
Example
The following example retrieves the head direction and converts it to degrees:
var dir = GetViewDirection();
If you want to extract the head direction in degrees, convert the value of head direction to degrees with the following formula:
function toDegrees(angle)
{
return angle * (180 / Math.PI);
}
(...)
var dir = GetViewDirection();
angle = toDegrees(dir);
Notes
GetViewDirection is not available when using Deep learning with two subjects per arena, because this method does not record the subjects' head direction.
GetSubjectViewDirection
Returns the value of the Head direction of a specified subject in a multi-subject experiment, for the current sample. The value is given in radians. Note that the Head direction dependent variable provided by EthoVision XT is expressed in degrees. To convert your JavaScript variable to degrees, see the example in GetViewDirection.
Syntax
GetSubjectViewDirection("subject name")
where Subject name is the name of the subject specified in the Experiment settings.
Example
The following for loop extracts the Head direction in radians for a number of subjects:
// This for loop extracts the Head direction in radians for a number of subjects
for (i = 0; i < g_aSubjects.length; ++i)
{
var HDirSubj = GetSubjectViewDirection(g_aSubjects[i]);
...
}
Notes
GetSubjectViewDirection is not available when using Deep learning with two subjects per arena, because this method does not record the subjects' head direction.
GetSampleTime
Returns the sample time (in seconds) of the sample currently processed. You can use this function to calculate the latency of an event that you cannot obtain through the other dependent variables.
Note: The sample time in this function is the track time, that is, the time elapsed from the start of the track (the first sample), not the start of the trial.
Syntax
GetSampleTime()
Example
The following example outputs the value of the current sample time. If it is not found, a missing value is assigned with the SetOutputMissing command:
function Process()
{
var st = GetSampleTime();
if (st != null)
{
SetOutput(st);
}
else
{
SetOutputMissing();
}
}
GetPixelChange
Returns the current proportion of pixels in the arena that have changed intensity above the specified Activity threshold from the previous video frame. This proportion can be between 0 (no pixel in the arena has changed intensity value above the threshold) and 1 (all pixels in the arena have changed intensity value above the threshold). A pixel change value of 0.156 (expressed as proportion) corresponds to a Body angle value without smoothing of 15.6%.
To use this variable, you must select Activity analysis in the Experiment Settings and define the threshold value in Activity settings in the Detection settings. For information on the pixel change, see Body angle.
Syntax
GetPixelChange()
Example
var a = GetPixelChange();
GetDistanceToZone
Returns the distance of a (body) point from a zone. The distance is zero if the body point is within the zone. Distances are expressed in internal units (mm), independent of the units selected in the Experiment Settings.
Syntax
GetDistanceToZone(Zone, Point)
Arguments
- Zone: The name of the zone as it appears in the Arena Settings; e.g.
"Platform". - Point: The name of the point; usually a body point.
Example
const g_strZone = "Object";
(...)
function Process()
{
var ptNose = GetNose();
var dist = GetDistanceToZone(g_strZone, ptNose);
}
GetDistanceToPoi
This is similar to GetDistanceToZone; it returns the distance from the specified point of interest. Distances are expressed in internal units (mm), independent of the units selected in the Experiment Settings.
Syntax
GetDistanceToPoi(Point of interest, Point)
Arguments
- Point of interest: The name of the point of interest as it is defined in the Arena Settings.
- Point: The name of the point to which distance is determined; usually a body point.
GetBehaviorEvent
This command returns the value of an event scored manually using the Manual Scoring function. If you work with Live Mouse Tracker, this command also works with the events listed under Raw Live Mouse Tracker data in the Analysis profile.
Syntax
GetBehaviorEvent(behavior)
GetBehaviorEvent(behavior, receiver)
Arguments
- Behavior: The name of the behavior as in the Manual Scoring Settings or listed under Raw Live Mouse Tracker data in the Analysis profile.
- Receiver (optional): The name of the receiver, in case of multi-subject tracking.
Return Values
undefined: No behavior event.1: Start of a state event.2: Stop.4: Point event.
Example
The following code gets the values of the behavior Sleep that was scored. The function UpdateState at the top copies the values of Sleep, 1 or 2, to a new state variable g_bState with values true or false, respectively:
var g_bState = false;
function UpdateState(evt)
{
if (evt != undefined)
{
if (evt == 1)
{
g_bState = true;
}
else if (evt == 2)
{
g_bState = false;
}
}
}
function Process()
{
var evt = GetBehaviorEvent("Sleep");
UpdateState(evt);
SetOutput(g_bState);
}
GetCommand
Returns the event that represents a command to a hardware device.
Syntax
GetCommand(Device name, Command name)
Arguments
- Device name: The name of the device specified in EthoVision XT. For example,
"Device A". To find the device name, in the Arena Settings click the Arena-Hardware Mapping button, under Device name click the cell of the device you require and press Ctrl+C. Paste the text into the JavaScript code as Device name. - Command name: The name of the command used in the Trial Control Settings. For example,
"Drop pellet". To find the command name, open the Trial Control Settings, locate the Action box that contains that command and click Settings. Take note of the text near Action to perform. Enter this text in the JavaScript code as Command name.
Example
In the following example, JavaScript reads the command "Drop pellet" of a Pellet dispenser with name Device A and outputs the value for each sample of the track (1 = drop a pellet; missing value = no pellets dropped):
function Process()
{
var DropPellet = GetCommand("Device A", "Drop pellet");
SetOutput(DropPellet);
}
Source: EthoVision XT 19 Help, Noldus Information Technology