<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.biophysics.science.ru.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lof</id>
	<title>biophysics - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.biophysics.science.ru.nl/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Lof"/>
	<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/Special:Contributions/Lof"/>
	<updated>2026-10-06T04:04:54Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4993</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4993"/>
		<updated>2026-09-29T07:53:04Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
The [https://gitlab.science.ru.nl/marcw/biofysica/-/blob/master/experiment/EXP_programs/EXP_programs_user_manual.docx?ref_type=heads EXP_programs_use_manual.docx] can be downloaded from gitlab.&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These classes are templates for lab-specific classes which are used for building a lab-specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*An experiment file (.exp) specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each constructor. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4992</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4992"/>
		<updated>2026-09-29T07:50:48Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
A manual (EXP_programs_use_manual.docx) can be downloaded from gitlab.&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These classes are templates for lab-specific classes which are used for building a lab-specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*An experiment file (.exp) specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each constructor. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4991</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4991"/>
		<updated>2026-09-29T07:48:10Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Lab program example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These classes are templates for lab-specific classes which are used for building a lab-specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*An experiment file (.exp) specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each constructor. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4990</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4990"/>
		<updated>2026-09-29T07:46:53Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These classes are templates for lab-specific classes which are used for building a lab-specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*An experiment file (.exp) specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4989</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4989"/>
		<updated>2026-09-29T07:44:14Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main objects in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    environment&lt;br /&gt;
    hardwareSystem&lt;br /&gt;
    experiment&lt;br /&gt;
    recordingsHandler &lt;br /&gt;
    experimentPlayer&lt;br /&gt;
    guiHandler&lt;br /&gt;
    gui&lt;br /&gt;
&lt;br /&gt;
*These objects are derived from EXP_ classes which are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*An experiment file (.exp) specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4988</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4988"/>
		<updated>2026-09-29T07:42:07Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main objects in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    environment&lt;br /&gt;
    hardwareSystem&lt;br /&gt;
    experiment&lt;br /&gt;
    recordingsHandler &lt;br /&gt;
    experimentPlayer&lt;br /&gt;
    guiHandler&lt;br /&gt;
    gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4987</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4987"/>
		<updated>2026-09-16T10:57:15Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
energy   = power * time &lt;br /&gt;
x        = sin(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh   = distance_km / time_h&lt;br /&gt;
 energy_kWh  = power_kW * time_h&lt;br /&gt;
 x           = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4986</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4986"/>
		<updated>2026-09-16T10:55:54Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
energy   = power * time &lt;br /&gt;
x        = sin(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh   = distance_km / time_h&lt;br /&gt;
 energy      = 1000 * energy_kWh * hour&lt;br /&gt;
 x           = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4985</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4985"/>
		<updated>2026-09-16T10:55:27Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* SI units */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
energy   = power * time &lt;br /&gt;
x        = sin(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh   = distance_km / time_h&lt;br /&gt;
 energy      = 1000 * hour * energy_kWh&lt;br /&gt;
 x           = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4984</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4984"/>
		<updated>2026-09-16T10:54:07Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
x        = sin(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh   = distance_km / time_h&lt;br /&gt;
 energy      = 1000 * hour * energy_kWh&lt;br /&gt;
 x           = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4983</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4983"/>
		<updated>2026-09-16T10:53:48Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* SI units */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
x        = sin(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 energy = 1000 * hour * energy_kWh&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4982</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4982"/>
		<updated>2026-09-16T10:53:03Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 energy = 1000 * hour * energy_kWh&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4981</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4981"/>
		<updated>2026-09-16T10:52:26Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 energy_kWh = 1000 * hour * energy&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4980</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4980"/>
		<updated>2026-09-16T10:51:01Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 power_kW  = 1000 * power&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4979</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4979"/>
		<updated>2026-09-16T10:50:32Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 power_kW  = &lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4978</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4978"/>
		<updated>2026-09-16T10:49:14Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 presure_psi = force_pnd / area_sqi&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4977</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4977"/>
		<updated>2026-09-16T10:47:49Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* SI units */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed    = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4976</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4976"/>
		<updated>2026-09-16T10:47:35Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* SI units */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
speed = distance / time&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4975</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4975"/>
		<updated>2026-09-16T10:46:26Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4974</id>
		<title>Units in Matlab</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Units_in_Matlab&amp;diff=4974"/>
		<updated>2026-09-16T10:46:16Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Programming rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
==Introduction==&lt;br /&gt;
When working with quantities we often have to know what the units are in which the quantities are expressed. There are several ways to use variables with units in a program. &lt;br /&gt;
&lt;br /&gt;
Space probes have crashed on Mars due to invalid assumptions about units for some variables. So how can we avoid this type of disasters? We have to make it as simple and explicit as possible. But most importantly we have to have rules and stick to it!&lt;br /&gt;
&lt;br /&gt;
==SI units==&lt;br /&gt;
&lt;br /&gt;
In science we have the &#039;&#039;&#039;primary&#039;&#039;&#039; SI-units of the Franse Système international d&#039;unités:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Meter (m) - Unit of length&lt;br /&gt;
Kilogram (kg) - Unit of mass&lt;br /&gt;
Second (s) - Unit of time&lt;br /&gt;
Ampere (A) - Unit of electric current&lt;br /&gt;
Kelvin (K) - Unit of temperature&lt;br /&gt;
Mole (mol) - Unit of amount of substance&lt;br /&gt;
Candela (cd) - Unit of luminous intensity&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Combinations of these units are considered &#039;&#039;&#039;derived&#039;&#039;&#039; SI-units. These are units like m/s and units that can be expressed in terms of SI-units but have their own name, like: Newton (kg.m/s²) or Pascal (N/m²).&lt;br /&gt;
&lt;br /&gt;
SI-units with prefixes like &#039;&#039;millisecond&#039;&#039; or &#039;&#039;centimeter&#039;&#039; are &#039;&#039;&#039;not&#039;&#039;&#039; considered primary or derived SI-units. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Primary&#039;&#039; and &#039;&#039;derived&#039;&#039; SI-units will be here defined as &#039;&#039;&#039;basic SI-units&#039;&#039;&#039;. Units with prefixes do not fall under this definition.&lt;br /&gt;
&lt;br /&gt;
Some common derived SI-units are: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Joule    (energy)&lt;br /&gt;
Coulomb  (electric charge)&lt;br /&gt;
Voltage  (electric potential)&lt;br /&gt;
Ohm      (electric resistance)&lt;br /&gt;
Farad    (electric capacitance)&lt;br /&gt;
Tesla    (magnetic field strength)&lt;br /&gt;
Newton   (force)&lt;br /&gt;
Watt     (power)&lt;br /&gt;
Pascal   (pressure)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By using basic SI-units formulae can be expressed in their simplest form.&lt;br /&gt;
Examples: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pressure = force / area&lt;br /&gt;
power    = potential * current&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Programming rules==&lt;br /&gt;
Primary rules:&lt;br /&gt;
* Use basic SI-units  as much as possible.&lt;br /&gt;
* Use of basic SI-units is implicit: variables like &#039;&#039;someLength, someTime, someVolume&#039;&#039; are assumed in SI-units.&lt;br /&gt;
* Variables in non-basic SI-units like &#039;&#039;nanometer, millisecond&#039;&#039; or &#039;&#039;liter&#039;&#039; should have explicit &#039;&#039;&#039;suffixes&#039;&#039;&#039; like &#039;&#039;someLength_nm, someTime_ms or someVolume_liter&#039;&#039;.&lt;br /&gt;
* Use of radians for angles is implicit. When using degrees use the suffix &amp;quot;_deg&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
Secondary rules: &lt;br /&gt;
* If an input interface has non-basic units, convert them to basic SI-units as soon as possible after you read them from the interface.&lt;br /&gt;
* If an output interface needs non-basic units, convert them from basic SI-units as late as possible before outputting them.&lt;br /&gt;
* If you need to deviate from the primary rules make it explicit with comments.&lt;br /&gt;
&lt;br /&gt;
examples:&lt;br /&gt;
 speed_kmh = distance_km / time_h&lt;br /&gt;
 x = sin(2*pi*angle_deg/360)&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
summary:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Basic SI-units: implicit (preferred)&lt;br /&gt;
Other units   : explicit by using suffixes&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4973</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4973"/>
		<updated>2026-09-16T10:40:54Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including RZ6 systems, LED controllers, motors, and head movement systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration.&lt;br /&gt;
&lt;br /&gt;
The programs are based on the EXP_framework, which is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4972</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4972"/>
		<updated>2026-09-16T10:34:26Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The EXP program software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Experimental_Software&amp;diff=4971</id>
		<title>Experimental Software</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Experimental_Software&amp;diff=4971"/>
		<updated>2026-09-16T10:33:50Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP programs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Biofysica toolbox==&lt;br /&gt;
*The [[Biofysica toolbox]] is the software repository on Gitlab for the Biophysics group.&lt;br /&gt;
&lt;br /&gt;
==EXP programs==&lt;br /&gt;
*[[EXP programs]] are MATLAB programs for each biophysics lab with a Tucker Davis RZ6 device. The programs can be used for a variety of sound and vision experiments.&lt;br /&gt;
&lt;br /&gt;
==BIOX==&lt;br /&gt;
*[[BIOX]] (BIOphysics eXperiment software) is a MATLAB software interface for the RZ6 multi I/O processor.&lt;br /&gt;
&lt;br /&gt;
==Matrixtest==&lt;br /&gt;
*[[Matrixtest]] is MATLAB software for testing word recognition under different circumstances.&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4970</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4970"/>
		<updated>2026-08-31T08:30:05Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays real time information during the experiment.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4969</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4969"/>
		<updated>2026-08-31T08:28:52Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in Matlab in the Object Oriented Programming (OOP) paradigm.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4968</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4968"/>
		<updated>2026-08-31T08:28:26Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of about 150 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4967</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4967"/>
		<updated>2026-08-31T08:28:11Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework. The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4966</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4966"/>
		<updated>2026-08-31T08:27:33Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files). The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
   TL_Program for the test lab&lt;br /&gt;
   PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
   EG_Program for the EEG/NIRS lab &lt;br /&gt;
   RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
   VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4965</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4965"/>
		<updated>2026-08-31T08:25:48Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files). The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/ gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
 TL_Program for the test lab&lt;br /&gt;
 PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
 EG_Program for the EEG/NIRS lab &lt;br /&gt;
 RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
 VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4964</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4964"/>
		<updated>2026-08-31T08:25:36Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files). The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/||gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
 TL_Program for the test lab&lt;br /&gt;
 PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
 EG_Program for the EEG/NIRS lab &lt;br /&gt;
 RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
 VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4963</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4963"/>
		<updated>2026-08-31T08:25:23Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files). The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/|gitlab]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
 TL_Program for the test lab&lt;br /&gt;
 PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
 EG_Program for the EEG/NIRS lab &lt;br /&gt;
 RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
 VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4962</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4962"/>
		<updated>2026-08-31T08:25:06Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files). The code is part of the biophysics toolbox on [https://gitlab.science.ru.nl/]&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
 TL_Program for the test lab&lt;br /&gt;
 PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
 EG_Program for the EEG/NIRS lab &lt;br /&gt;
 RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
 VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4961</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4961"/>
		<updated>2026-08-31T08:23:24Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files).&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
 TL_Program for the test lab&lt;br /&gt;
 PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
 EG_Program for the EEG/NIRS lab &lt;br /&gt;
 RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
 VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4960</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4960"/>
		<updated>2026-08-31T08:20:09Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The software is designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program has its own version of the program, but most of the code is shared in the form of the EXP_framework (about 150 files).&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
*TL_Program for the test lab&lt;br /&gt;
*PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
*EG_Program for the EEG/NIRS lab &lt;br /&gt;
*RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
*VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4959</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4959"/>
		<updated>2026-08-31T08:15:34Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
This resource contains the MATLAB source code for a modular system named EXP_programs, developed by Ruurd Lof for the DCN at Radboud University. The software is specifically designed to control biophysical experiments in various specialized environments, such as the Patient Lab, the Robot Arm Lab, and the NIRS/EEG facilities. The code defines an extensive structure of classes and functions for managing hardware, including LED controllers, sound cards, motors, and head-coil calibration systems. Additionally, the script incorporates logic for adaptive algorithms, stimulus generation, and the handling of real-time experimental data via various protocols. Detailed specifications for audiological equipment and loudspeakers are integrated directly into the code to ensure accurate calibration. Collectively, the system forms a robust framework for the automation and synchronization of scientific research into human perception and motor control.&lt;br /&gt;
&lt;br /&gt;
The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program is created by defining a gui and a few sub classes of certain classes in the EXP framework.&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
*TL_Program for the test lab&lt;br /&gt;
*PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
*EG_Program for the EEG/NIRS lab &lt;br /&gt;
*RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
*VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4958</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4958"/>
		<updated>2026-08-28T12:44:05Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* consistency check */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*When azimuth_deg + elevation_deg &amp;lt; 90° the circles have two intersections.&lt;br /&gt;
*When azimuth_deg + elevation_deg = 90° the circles have one intersection.&lt;br /&gt;
*When azimuth_deg + elevation_deg &amp;gt; 90° the circles have zero intersections.&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center and H, V and F are the horizontal, vertical and frontal distances in cartesian coordinates.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4957</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4957"/>
		<updated>2026-08-28T12:43:50Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* consistency check */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 When azimuth_deg + elevation_deg &amp;lt; 90° the circles have two intersections.&lt;br /&gt;
 When azimuth_deg + elevation_deg = 90° the circles have one intersection.&lt;br /&gt;
 When azimuth_deg + elevation_deg &amp;gt; 90° the circles have zero intersections.&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center and H, V and F are the horizontal, vertical and frontal distances in cartesian coordinates.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4956</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4956"/>
		<updated>2026-08-28T12:43:24Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* consistency check */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When azimuth_deg + elevation_deg &amp;lt; 90° the circles have two intersections.&lt;br /&gt;
When azimuth_deg + elevation_deg = 90° the circles have one intersection.&lt;br /&gt;
When azimuth_deg + elevation_deg &amp;gt; 90° the circles have zero intersections.&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center and H, V and F are the horizontal, vertical and frontal distances in cartesian coordinates.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4955</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4955"/>
		<updated>2026-08-28T12:40:50Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Transforming double polar to HVF coordinates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center and H, V and F are the horizontal, vertical and frontal distances in cartesian coordinates.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4954</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4954"/>
		<updated>2026-08-28T12:40:35Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Transforming Cartesian to double polar coordinates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4953</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4953"/>
		<updated>2026-08-28T12:39:51Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Transforming Cartesian to double polar coordinates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where H, V and F are the horizontal, vertical and frontal distances in cartesian coordinates.&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4952</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4952"/>
		<updated>2026-08-28T12:38:41Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Transforming double polar to HVF coordinates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Where radius is the distance to the center.&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4951</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4951"/>
		<updated>2026-08-28T12:37:30Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* azimuth */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then &lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
Azimuth = arcsin(d_FV/R).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4950</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4950"/>
		<updated>2026-08-28T12:36:27Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* elevation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then Azimuth = arcsin(d_FV/R).&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, then Elevation = arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4949</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4949"/>
		<updated>2026-08-28T12:36:15Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* azimuth */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, then Azimuth = arcsin(d_FV/R).&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, the Elevation is specified by arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4948</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4948"/>
		<updated>2026-08-28T12:29:59Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* elevation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, the Azimuth is specified by arcsin(d_FV/R).&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* If d_RF is the distance to the plane and R is the distance to a point from the center, the Elevation is specified by arcsin(d_RF/R).&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4947</id>
		<title>Coordinate systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=Coordinate_systems&amp;diff=4947"/>
		<updated>2026-08-28T12:29:37Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* azimuth */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
In the three dimensions of our world you can define different coordinate systems. In our auditory labs a subject is placed with his head in the center of the speaker setup (a sphere or semi-circle). We define the coordinate systems in this situation with respect to the default position of the head of the subject.&lt;br /&gt;
&lt;br /&gt;
Normally we are interested in the direction of a stimulus and we define the directions with the angles azimuth and elevation in a double polar coordinate system. This system is a non-conventional coordinate system that is not often used beyond auditory experiments. &lt;br /&gt;
&lt;br /&gt;
*Coordinates in 3 dimensions are normally described by triples e.g. [X, Y, Z] or [phi, theta, r]. &lt;br /&gt;
*Coordinates systems are defined with respect to the default gaze position in the experiment.&lt;br /&gt;
*When stimulus positions are specified, the coordinates are expressed in double polar coordinates. &lt;br /&gt;
*Our EMF head tracking system uses three orthogonal axis: Horizontal, Frontal, Vertical. We refer to them as H, F and V. &lt;br /&gt;
*For a fixed Cartesian coordinate system in the lab we will adopt the coordinate system &amp;quot;HFV&amp;quot;.&lt;br /&gt;
*Other fixed coordinate systems in the lab are Double Polar and Spherical coordinates.&lt;br /&gt;
*When we want to use a Cartesian coordinate system relative to the head we will adopt the medical coordinate system &amp;quot;RAS&amp;quot;.&lt;br /&gt;
*Equipment with IMU&#039;s can have use different definitions for Cartesian coordinates and we will refer to X, Y and Z for data in coordinates defined by a device which has yet to be converted to HFV or RAS coordinates.&lt;br /&gt;
*Our Gitkab\biofysica toolbox has classes and transformation functions for HFV, RAS, Double Polar and Spherical coordinate systems.&lt;br /&gt;
*The use of coordinate systems and transformations between coordinates systems should be made explicit in all documentation and programs.&lt;br /&gt;
&lt;br /&gt;
The Spherical Coordinate System is more standard and is widely used. When your are interested in the Spherical coordinate system you have to ask Wikipedia or other sources.&lt;br /&gt;
&lt;br /&gt;
==Cartesian coordinates in the lab==&lt;br /&gt;
For the lab we use the &amp;quot;HFV&amp;quot; coordinate system:&lt;br /&gt;
&lt;br /&gt;
*H stands for Horizontal and is positive to the right.&lt;br /&gt;
*F stands for Frontal and is positive in the forward direction.&lt;br /&gt;
*V stands for Vertical and is positive in the upward direction.&lt;br /&gt;
&lt;br /&gt;
The orientation of H, F van V are defined by the default position (looking straight ahead) of the subject (tested person) sitting on the experimental chair in the lab. The [0, 0, 0] position is right between the test persons ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: V = H x F&lt;br /&gt;
&lt;br /&gt;
==Medical Cartesian coordinates==&lt;br /&gt;
For a body (or head) a medical notation is often adopted:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
left (L) &lt;br /&gt;
right (R)&lt;br /&gt;
anterior (A)&lt;br /&gt;
posterior (P)&lt;br /&gt;
superior (S)&lt;br /&gt;
inferior (I)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For describing the position of the head of a person we will adopt the &#039;RAS&#039;-convention:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
R-axis: from left (-R) to right (+R)&lt;br /&gt;
A-axis: from back (-A) to front (+A)&lt;br /&gt;
S-axis: from bottom (-S) to top (+S)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin in this system is chosen again right between the ears.&lt;br /&gt;
&lt;br /&gt;
In terms of unit vectors: S = R x A&lt;br /&gt;
&lt;br /&gt;
==Double Polar coordinates==&lt;br /&gt;
The double polar coordinates are fixed in the lab. The coordinates are called azimuth , elevation and radius. The azimuth defines a semi-circle parallel to the FV-plane. The elevation defines a circle parallel to the RF-plane. The intersection of the azimuth circle and the elevation circle is the target point. Since there are two intersections (most of the time), the hemisphere of the intersection has to be specified in order to resolve the ambiguity (see left picture).&lt;br /&gt;
Often only elevation and azimuth is given, assuming the target is in the forward hemisphere and the radius is not relevant. &lt;br /&gt;
&lt;br /&gt;
[[file:Double_Polar.png|double polar coordinates]]&lt;br /&gt;
&lt;br /&gt;
*pictures: Azimuth and elevation determine two perpendicular circles.&lt;br /&gt;
===azimuth===&lt;br /&gt;
* Azimuth is the angle with the FV-plane.&lt;br /&gt;
* If d_FV is the distance to the plane and R is the distance to a point from the center, the Azimuth is specified by arcsin(d_FV/R).&lt;br /&gt;
* pi/2 &amp;lt;= azimuth &amp;lt;= pi/2 (or -90° &amp;lt;= azimuth &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===elevation===&lt;br /&gt;
* Elevation is the angle with the RF-plane&lt;br /&gt;
* pi/2 &amp;lt;= elevation&amp;lt;= pi/2 (or -90° &amp;lt;= elevation &amp;lt;= 90°)&lt;br /&gt;
&lt;br /&gt;
===radius===&lt;br /&gt;
* Radius is the distance from the origin to a target point.&lt;br /&gt;
* In our lab experiment the radius is not important and can be set to 1.&lt;br /&gt;
&lt;br /&gt;
===hemisphere===&lt;br /&gt;
[[file:Two_intersecting_rings.png|two intersecting rings]]&lt;br /&gt;
*Pictures: The stars mark the intersections of the circles. When the circles touch (only one intersection) the target lies in the HV-plane.&lt;br /&gt;
&lt;br /&gt;
* Hemisphere is +1 for a point in the forward hemisphere.&lt;br /&gt;
* Hemisphere is  0 for a point in the HV-plane (F=0).&lt;br /&gt;
* Hemisphere is -1 for a point in the backward hemisphere.&lt;br /&gt;
&lt;br /&gt;
===consistency check===&lt;br /&gt;
There is a constraint on azimuth and elevation:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
azimuth + elevation &amp;lt;= pi (or azimuth_deg + elevation_deg &amp;lt;= 90°)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming double polar to HVF coordinates===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
H = radius * sin(azimuth)&lt;br /&gt;
V = radius * sin(elevation)&lt;br /&gt;
F = hemisphere * sqrt(radius^2 - H^2 - V^2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Transforming Cartesian to double polar coordinates=== &lt;br /&gt;
In the origin we have  by definition azimuth = 0 and elevation = 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
radius     = norm([H, V, F])&lt;br /&gt;
azimuth    = arcsin(H/radius)    &lt;br /&gt;
elevation  = arcsin(V/radius)&lt;br /&gt;
hemisphere = sign(F);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Matlab==&lt;br /&gt;
===Angles===&lt;br /&gt;
Standard trigonometry functions in Matlab use radians as unit for angles. Inside your programs it is advised to use only radians in the code and convert to degrees when presenting values for angles on screen, or in an output file. When reading from screen or input file you should convert degrees to radians at the first assignment.&lt;br /&gt;
*When variables use degrees they should have the suffix &#039;&#039;&#039;_deg&#039;&#039;&#039; in the name.&lt;br /&gt;
*It is recommended to use the matlab conversion functions between radians and degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
angle     = deg2rad(angle_deg)&lt;br /&gt;
angle_deg = rad2deg(angle)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Trigonometric functions===&lt;br /&gt;
Matlab has all kind of standard trigonometric functions working with radians or with degrees. When degrees are used it is recommendable to add the suffix &amp;quot;_deg&amp;quot; to your angle variables.&lt;br /&gt;
&lt;br /&gt;
Standard trigonometric functions using radians:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sin(angle)&lt;br /&gt;
x = cos(angle)   &lt;br /&gt;
x = tan(angle)&lt;br /&gt;
angle = asin(x)&lt;br /&gt;
angle = acos(x)&lt;br /&gt;
angle = atan(x)&lt;br /&gt;
angle = atan2(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Standard trigoniometric functions using degrees:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x = sind(angle_deg)&lt;br /&gt;
x = cosd(angle_deg)   &lt;br /&gt;
x = tand(angle_deg)&lt;br /&gt;
angle_deg = asind(x)&lt;br /&gt;
angle_deg = acosd(x)&lt;br /&gt;
angle_deg = atand(x)&lt;br /&gt;
angle_deg = atan2d(y, x)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate system representations===&lt;br /&gt;
In the Gitlab in biofysica\utilities\coordinates\RAS_DP_SPH there are classes for the coordinates&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
coordinates_HVF.m&lt;br /&gt;
coordinates_HVF_withID.m&lt;br /&gt;
coordinates_RAS.m&lt;br /&gt;
coordinates_DP.m&lt;br /&gt;
coordinates_DP_withID.m&lt;br /&gt;
coordinates_SPH.m&lt;br /&gt;
coordinates_SPH_withID.m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The classes with suffix &amp;quot;_withID&amp;quot; are meant for relating coordinates to IDs of Leds or Speakers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;HVF coordinates&#039;&#039;&#039; are the coordinates fixed in the lab. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - right or H (in meters)&lt;br /&gt;
    - up or V (in meters)&lt;br /&gt;
    - forward or F (in meters)&lt;br /&gt;
In our auditory experiments the default position is the reference orientation and the origin is taken between the ears of the subject.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;RAS coordinates&#039;&#039;&#039; is the standard for coordinates relative to the head orientation. &lt;br /&gt;
It has the following fields:&lt;br /&gt;
    - right or R(in meters)&lt;br /&gt;
    - anterior or A (in meters)&lt;br /&gt;
    - superior or S(in meters)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Double Polar coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians)&lt;br /&gt;
    - elevation (in radians)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
    - hemisphere (+1, 0 or -1: stands for forward, in between or backward hemisphere)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Spherical coordinates&#039;&#039;&#039;&lt;br /&gt;
    - ID (optional)&lt;br /&gt;
    - azimuth (in radians: 0 to 2pi positive X-axis is 0)&lt;br /&gt;
    - elevation (in radians: -pi to pi positive Y-axis is 0)&lt;br /&gt;
    - radius (in meters)&lt;br /&gt;
&lt;br /&gt;
Example code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
right    = 0.5; % in meters&lt;br /&gt;
anterior = 0.5; % in meters&lt;br /&gt;
superior = 0.5; % in meters&lt;br /&gt;
&lt;br /&gt;
% create a stimulus position in RAS:&lt;br /&gt;
stimulusPos_RAS = coordinates_RAS(right, anterior, superior);&lt;br /&gt;
&lt;br /&gt;
% transform the stimulus position from RAS to double polar:&lt;br /&gt;
stimulusPos_DP = transform_RAS2DP(stimulusPos_RAS);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Coordinate transformations===&lt;br /&gt;
&lt;br /&gt;
====Lab coordinates: DP &amp;lt;==&amp;gt; HVF====&lt;br /&gt;
The biofysica repository has the following transformation functions:&lt;br /&gt;
&lt;br /&gt;
and conversion functions between coordinates:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
transform_HVF2DP&lt;br /&gt;
transform_DP2HVF&lt;br /&gt;
transform_device2RAS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They all have a single input parameter in the form of a struct or table and a single output parameter in the form of a table. Angles are always in radians.&lt;br /&gt;
* HVF2DP_withNetCalibrationFile (Field coil reading to Double Polar)&lt;br /&gt;
The HVF2DP has an extra parameter NetCalibrationFile, that should contains the filename of the latest calibration.&lt;br /&gt;
&lt;br /&gt;
====Device ==&amp;gt; RAS====&lt;br /&gt;
In order to transform device XYZ-coordinates to RAS-coordinates you have to specify a 3x3 transformation matrix.&lt;br /&gt;
&lt;br /&gt;
E.g. If the X-saxis is pointing to Superior, the Y-axis to Right and the Z-axis pointing to Anterior you get the following transformation matrix:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
XYZ2RASdefinition = [0, 1, 0;&lt;br /&gt;
                     0, 0 ,1;&lt;br /&gt;
                     1, 0, 0];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With the defined transformation matrix you can use the transform function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, XYZ2RASdefinition)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example is definition_EyeSeeCamSci_XYZ2RAS.m which defines the transformation matrix for the EyeSeeCamSci.&lt;br /&gt;
&lt;br /&gt;
====Built in Matlab functions for rotating Cartesian triples====&lt;br /&gt;
For rotations of Cartesian coordinates Matlab uses a 3x3 matrix working on the XYZ column vector.&lt;br /&gt;
For rotations around an axis there are functions that create these 3x3 matrices. It is important to know if the rotation axis is defined with respect to the room or with respect to a rotating device like a head tracker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In the biofysica toolbox you have the functions Rx, Ry and Rz. These functions generate rotation matrices.&lt;br /&gt;
Mx = Rx(angle1)&lt;br /&gt;
My = Ry(angle2)&lt;br /&gt;
Mz = Rz(angle3)&lt;br /&gt;
&lt;br /&gt;
In case the rotations are small (say smaller than 1 degree) the order is not important: &lt;br /&gt;
M = Mx * My * Mz&lt;br /&gt;
&lt;br /&gt;
When the rotation is done in multiple small steps you have:&lt;br /&gt;
M(i) = Mx(i) * My(i) * Mz(i)&lt;br /&gt;
&lt;br /&gt;
And for the total rotation you have two situations depending on the coordinate system in which Mx, My and Mz are defined.&lt;br /&gt;
&lt;br /&gt;
rotations in the device coordinates: M_total(i) = M(i) * M_total(i-1) &lt;br /&gt;
rotations in the room coordinates:   M_total(i) = M_total(i-1) * M(i) &lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
if you have the Aerospace Toolbox you can use rotx, roty and rotz (angles in degrees)&lt;br /&gt;
Mx = rotx(angle1_deg)&lt;br /&gt;
My = roty(angle2_deg)&lt;br /&gt;
Mz = rotz(angle3_deg)&lt;br /&gt;
--------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
You can perform a rotation by applying the rotation matrix to a column vector (point = [1;0;0])&lt;br /&gt;
newPoint = M * point;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Older biofysica functions====&lt;br /&gt;
N.B. These are not recommended for new code.&lt;br /&gt;
&lt;br /&gt;
Here are some earlier functions that are using different conventions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
varargout = azel2cart(AZ,EL,R)&lt;br /&gt;
azel      = cart2azel(x,y,z)&lt;br /&gt;
azel      = xyz2azel(x,y,z)&lt;br /&gt;
[PostRotAZ,PostRotEL] = rotate2d(azimuth,elevation,Beta)&lt;br /&gt;
[X,Y,Z] = pitch(X,Y,Z,Angle)&lt;br /&gt;
[X,Y,Z] = yaw(X,Y,Z,Angle)&lt;br /&gt;
&lt;br /&gt;
N.B. all angles are in degrees&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Stimulus position lookup tables===&lt;br /&gt;
Setups with different speaker and led positions have a lookup table for the stimulus positions in the form of an excel file. The excel file should have a sheet with the name &#039;DP&#039; for data in double polar coordinates. The sheet should have five columns with the headers &#039;ID&#039;, &#039;azimuth&#039;, &#039;elevation&#039;, &#039;radius&#039;, &#039;hemisphere&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
stimulusPos = readtable(fname, &#039;sheet&#039;,  &#039;DP&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The function &#039;readtable&#039; outputs a table with the named column headers that are accessable in the same way as fields of a struct.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ID = stimulusPos.ID;&lt;br /&gt;
azimuth = stimulusPos.azimuth;&lt;br /&gt;
etc....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Head tracking==&lt;br /&gt;
&lt;br /&gt;
===Field coil head tracking===&lt;br /&gt;
Field coil head tracking is a method for movement detection. A pickup coil mounted on the head of the subject is picking up modulated magnetic fields. Three lock-in amplifiers splits the signal from the head coil into three components, horizontal, vertical and frontal. These components are measured as voltages.&lt;br /&gt;
&lt;br /&gt;
The convention for head tracking directions (H,V,F) are related to gaze in the following way:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Horizontal: H = positive signal when looking right&lt;br /&gt;
Vertical:   V = positive signal when looking up&lt;br /&gt;
Frontal:    F = positive signal when looking forward&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Gitlab (biofysica\utilities\coordinates\HVF_RAS_DP_SPH\HVF field calibration) there is a function &#039;convert_HVFfieldValues2DP_withNetCalibration.m&#039; that uses a netcalibration file in order to transform the (H,V,F)-voltages into double polar coordinates.&lt;br /&gt;
&lt;br /&gt;
===Head tracker with IMU===&lt;br /&gt;
Each head tracker with an IMU has its own XYZ coordinate system. In order to transform this to RAS coordinates we have to use a device specific transformation matrix. In the biofysica toolbox there is a function for each device (definition_XYZ2RAS_&amp;lt;devicename&amp;gt;) that generates a struct with a description of the definition for the XYZ2RAS transformation and a transformation matrix. This struct can be readily used as the input for the function transform_XYZ2RAS.&lt;br /&gt;
&lt;br /&gt;
Here is an example of a transformation of XYZ coordinates to RAS coordinates of a head tracking device:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%get X, Y and Z from the device (X, Y and Z can be column arrays)&lt;br /&gt;
X = get_X_fromTheDevice;&lt;br /&gt;
Y = get_Y_fromTheDevice;&lt;br /&gt;
Z = get_Z_fromTheDevice;&lt;br /&gt;
&lt;br /&gt;
% create a XYZcoordinates object&lt;br /&gt;
XYZcoordinates = coordinates_XYZ(X,Y,Z);&lt;br /&gt;
&lt;br /&gt;
% transform to RAS coordinates&lt;br /&gt;
RAScoordinates = transform_XYZ2RAS(XYZcoordinates, definition_XYZ2RAS_devicename);&lt;br /&gt;
&lt;br /&gt;
% this is what you get&lt;br /&gt;
R = RAScoordinates.right&lt;br /&gt;
A = RAScoordinates.anterior&lt;br /&gt;
S = RAScoordinates.superior&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Conventions for expressing angles in text==&lt;br /&gt;
An angle is normally expressed in radians or degrees. &lt;br /&gt;
&lt;br /&gt;
One radian corresponds to the angle for which the arc (s) on a circle equals the radius (r), thus 1 rad = s/r = 1. In the SI standard 1 rad = 1 per definition, so rad is dimensionless. Therefore it is not necessary to explicitly use it. Only when confusion is possible you should mention it as the unit behind a value. &lt;br /&gt;
&lt;br /&gt;
The other convention for angles is the degree. The conversion between radians and degrees follows from the relation 360° = 2π rad. Note that the degree, with the symbol °, is not a unit of the SI. When expressing angles in degrees the use of the symbol ° is mandatory.&lt;br /&gt;
&lt;br /&gt;
When using trigonometric formulae you have to be aware that by default these functions use radians. If you want to use constants expressed in degrees you have to use the degree symbol °. The following expression are equivalent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
X and L in meters, angle in radians&lt;br /&gt;
&lt;br /&gt;
   X = L * sin(pi/2) &lt;br /&gt;
&lt;br /&gt;
is equivalent to: &lt;br /&gt;
&lt;br /&gt;
   X = L * sin(90°)&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
   angle = pi   + arcsin(Y/L) &lt;br /&gt;
&lt;br /&gt;
is equivalent to:&lt;br /&gt;
 &lt;br /&gt;
   angle = 180° + arcsin(Y/L) &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4946</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4946"/>
		<updated>2026-08-27T08:44:35Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Lab program example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
EXP programs are MATLAB programs for each auditory lab with an RZ6 DSP. The software is based on the EXP framework. The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The framework is a collection of classes and functions that are the basis for Lab programs. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program is created by defining a gui and a few sub classes of certain classes in the EXP framework.&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
*TL_Program for the test lab&lt;br /&gt;
*PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
*EG_Program for the EEG/NIRS lab &lt;br /&gt;
*RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
*VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    environment     = TL_environment;&lt;br /&gt;
    hardware        = TL_hardwareSystems(environment);                      &lt;br /&gt;
    experiment      = TL_experiment(environment, hardware);             &lt;br /&gt;
    recordings      = TL_recordingsHandler(environment, experiment);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardware, recordings, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, environment, experiment, hardware);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4945</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4945"/>
		<updated>2026-08-27T08:42:28Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* Lab program example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
EXP programs are MATLAB programs for each auditory lab with an RZ6 DSP. The software is based on the EXP framework. The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The framework is a collection of classes and functions that are the basis for Lab programs. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program is created by defining a gui and a few sub classes of certain classes in the EXP framework.&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
*TL_Program for the test lab&lt;br /&gt;
*PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
*EG_Program for the EEG/NIRS lab &lt;br /&gt;
*RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
*VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to each other. &lt;br /&gt;
 &lt;br /&gt;
    programPar      = TL_programParameters;&lt;br /&gt;
    hardwareSystems = TL_hardwareSystems(programPar);                      &lt;br /&gt;
    experiment      = TL_experiment(programPar);             &lt;br /&gt;
    trialRecordings = TL_recordingsHandler(programPar, experiment, hardwareSystems);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardwareSystems, trialRecordings, programPar, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, programPar, experiment, hardwareSystems);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
	<entry>
		<id>https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4944</id>
		<title>EXP programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.biophysics.science.ru.nl/index.php?title=EXP_programs&amp;diff=4944"/>
		<updated>2026-08-27T08:41:29Z</updated>

		<summary type="html">&lt;p&gt;Lof: /* EXP framework */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
EXP programs are MATLAB programs for each auditory lab with an RZ6 DSP. The software is based on the EXP framework. The EXP framework is a MATLAB toolbox developed by [[Ruurd Lof]]. The framework is a collection of classes and functions that are the basis for Lab programs. The toolbox is mainly programmed object oriented programming style. It is modular with respect to the hardware that can be used.&lt;br /&gt;
&lt;br /&gt;
Each lab program is created by defining a gui and a few sub classes of certain classes in the EXP framework.&lt;br /&gt;
&lt;br /&gt;
The following programs are available:&lt;br /&gt;
*TL_Program for the test lab&lt;br /&gt;
*PL_Program for the auditory perception lab (patient lab)&lt;br /&gt;
*EG_Program for the EEG/NIRS lab &lt;br /&gt;
*RA_Program for the auditory persuit lab (robot arm)&lt;br /&gt;
*VC_Program for the vestibular chair lab&lt;br /&gt;
&lt;br /&gt;
==EXP framework==&lt;br /&gt;
&lt;br /&gt;
The EXP framework consists of over 200 files and is written in the Object Oriented Programming (OOP) paradigm by Ruurd Lof.&lt;br /&gt;
&lt;br /&gt;
The main classes in the EXP framework are:&lt;br /&gt;
&lt;br /&gt;
    EXP_environment&lt;br /&gt;
    EXP_hardwareSystem&lt;br /&gt;
    EXP_experiment&lt;br /&gt;
    EXP_recordingsHandler &lt;br /&gt;
    EXP_experimentPlayer&lt;br /&gt;
    EXP_guiHandler&lt;br /&gt;
    EXP_gui&lt;br /&gt;
&lt;br /&gt;
*These EXP_ classes and a few others are the templates for building a lab specific program. &lt;br /&gt;
&lt;br /&gt;
*All programs use the same GUI that is always responsive and displays sounds, sound locations, led locations and acquisition results for every trial.&lt;br /&gt;
&lt;br /&gt;
*A .exp file specifies the whole experiment.&lt;br /&gt;
&lt;br /&gt;
*The program outputs a .mat file for every trial (and block) with a struct called &#039;trialInfo&#039;.&lt;br /&gt;
&lt;br /&gt;
*There is no need for the experimenter to do any Matlab programming.&lt;br /&gt;
&lt;br /&gt;
==Lab program example==&lt;br /&gt;
&lt;br /&gt;
An example of a Lab program is the TestLabProgram. All programs have the same basic structure:&lt;br /&gt;
&lt;br /&gt;
A few objects (TestLab classes are starting with TL_) are created in a fixed order and linked by passing references to the objects. &lt;br /&gt;
 &lt;br /&gt;
    programPar      = TL_programParameters;&lt;br /&gt;
    hardwareSystems = TL_hardwareSystems(programPar);                      &lt;br /&gt;
    experiment      = TL_experiment(programPar);             &lt;br /&gt;
    trialRecordings = TL_recordingsHandler(programPar, experiment, hardwareSystems);     &lt;br /&gt;
    player          = TL_experimentPlayer(hardwareSystems, trialRecordings, programPar, experiment);&lt;br /&gt;
    guiHandler      = TL_guiHandler(player, programPar, experiment, hardwareSystems);&lt;br /&gt;
&lt;br /&gt;
At last a GUI is launched with a link to the guihandler object.&lt;br /&gt;
    &lt;br /&gt;
    TL_Gui(guiHandler);&lt;/div&gt;</summary>
		<author><name>Lof</name></author>
	</entry>
</feed>