> For the complete documentation index, see [llms.txt](https://zapit.gitbook.io/user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zapit.gitbook.io/user-guide/using-the-gui/sample-calibration.md).

# Sample Calibration

#### Registering the sample to stereotaxic space

The sample is registered interactively to stereotaxic space by placing an outline of the brain over the exposed skull. The outline is positioned using two reference points. The first point is always bregma. The second point can be user-selected via the `Ref AP` dropdown. Before initiating the calibration procedure, select a value you are happy with from this drop-down.&#x20;

{% hint style="warning" %}
To ensure accuracy it is necessary to use a stereotaxic frame to make a small mark on the skull corresponding to the location you have chosen for the Ref AP position. This way you have a second landmark in addition to bregma for performing the Sample Calibration step.&#x20;
{% endhint %}

Press `Calibrate Sample` and move the mouse over the image: a cyan outline of the brain will surround the mouse cursor. Click on bregma in the image to lock it to bregma of the outline. You will scale and orient the outline in the next step.

<figure><img src="/files/T48dRUeoKQppzOy6aPXO" alt=""><figcaption><p>Pressing "Calibrate Sample" brings up a cyan brain border that follows the mouse cursor. Click on bregma in the image to lock it to bregma of the outline. You will scale and orient the outline in the next step.</p></figcaption></figure>

A red marker will appear over bregma once the outline is placed. The outline will now rotate and scale as the mouse cursor moves. If you are not happy with your choice of bregma, you can shift-click anywhere over the image to remove it. Click on the second point (defined by Ref AP) and a confirmation dialog appears: clicking `Yes` will commit the border and the outline turns green; clicking `No` will remove the outline. You have now completed the sample calibration procedure. To redo it simply click `Calibrate Sample` again. The `Paint brain border` button can be used when you are bored or are trying to impress visitors to the lab.&#x20;

<figure><img src="/files/outL1eXlEOYmFlF7vMgy" alt=""><figcaption><p>The brain outline is freely rotated and scaled by moving the mouse cursor once bregma has been placed. </p></figcaption></figure>

#### Loading a stimulus config file

You will now load a stimulus configuration file. For the purpose of this example we will load the file `uniAndBilateral_5_conditions.yml` located in the `examples/example_stimulus_config_files` folder where Zapit is installed. If you don't know the install location, you can find it by typing the following command into the MATLAB command prompt. Load the file with `File` > `Load stim config` from the Zapit menu.

Previously loaded files appear in the `File` > `Load recent` menu for easier access.

```matlab
>> zapit.updater.getInstallPath

ans =

    '/Users/bob/Dropbox/MATLAB/ZapitOptostim/zapit/'
```

The stimulus config file that you loaded is a plain text file that defines inactivation locations for each condition, laser power, stimulus frequency, and the duration of the offset ramp at stimulus conclusion. You can open the files in a text editor but in the next section you will see how to create and edit them via Zapit's StimConfig Editor.&#x20;

#### Verifying the stimulus locations

The `Overlay stim sites` button will plot the locations of all stimulus sites as red circles. `Zap all coords` will cycle the beam rapidly between all stimulus locations. `Plot stim coords` button brings up a new window (e.g. as shown below) with the locations of each condition clearly described.

<figure><img src="/files/OllsoLW5ftvUlOXnUIsH" alt=""><figcaption><p>Stimulus coordinates in stereotaxic space.<br>The brain area borders are extracted from the<br>Allen Atlas.</p></figcaption></figure>

You can use the `Zap Site` button and associated drop-down menu to present a single stimulus condition at the laser power and repetition rate defined by the config file. Pressing `Zap Site` a second time will ramp down the stimulus and cease presentation. The `Paint area` button will use the laser to draw borders around the brain area(s) being stimulated in the selected trial. Use this option if bored or are trying to impress visitors to the lab.

<figure><img src="/files/7AnY9Fob0zy5qknUscez" alt=""><figcaption><p>"Zap Site" asks Zapit to start presenting the stimulus<br>indicated by the drop-down. Here the first site, which is<br>primary somatosensory cortex. The beam locations can<br>be made out in the image.</p></figcaption></figure>

The remaining buttons in the Calibrate Sample tab will be discussed in the[ ](broken://pages/zy9xdG5LYL0PmuG3yJY3)[Running Experiments](/user-guide/running-experiments/introduction-running-experiments.md) section.
