# Generating stimulus patterns at the CLI

There is a command line tool called `zapit.utils.stimConfigPatternGenerator` for generating patterns of stimuli, like grids or crosses, at the command line. You can access doc text for the tool at the command line:

```
help zapit.utils.stimConfigPatternGenerator
```

This page show with plots how it works.&#x20;

#### Grid of points over V1 stimulating bilaterally

```matlab
zapit.utils.stimConfigPatternGenerator('myV1', [-2.75,-3.8], ...
                                       'num', [3,5], ...
                                       'patterns', [1,1.5], ...
                                       'bilateral',true)
```

<figure><img src="/files/MQbkBiP976CHJuu3bEYJ" alt=""><figcaption><p>Bilateral non-square grid over V1. In a single trial corresponding points on the two sides<br>will be stimulated. e.g. both points labelled "5" will be stimulated in one trial.</p></figcaption></figure>

The grids above are bilateral stimulation points. In other words, they constitute 15 different trials. All 15 points are not stimulated in a single trial. &#x20;

#### Square grid over V1 with independent stimulus conditions on the two sides

To create grids that are independent you need to generate the patterns in two steps. Note that second has `'overwrite', false` to allow the new points to be appended to the file created by the first step.&#x20;

```matlab
zapit.utils.stimConfigPatternGenerator('myV1', [-2.75,-3.8], ...
                                       'num',3, 'patterns', 1, ...
                                       'overwrite', true)
zapit.utils.stimConfigPatternGenerator('myV1', [2.75,-3.8], ...
                                       'num', 3, 'patterns', 1, ...
                                       'overwrite',false)
```

<figure><img src="/files/D2ZYqOvXygnZQBd4G4sq" alt=""><figcaption><p>Bilateral square grids over V1. In a single trial only one location is stimulated, unlike the bilateral<br>example above. e.g. Point "3" on the left is stimulated alone in one trial.</p></figcaption></figure>

#### Generate a variety of patterns

```matlab
zapit.utils.stimConfigPatternGenerator('myPattern', [3.55,-1.3], ...
                           'pattern','cross', 'num',3, 'patternsize',0.8, ...
                           'overwrite',true)

zapit.utils.stimConfigPatternGenerator('myPattern', [0.55,-2.5], ...
                           'pattern', 'APline', 'num',7, 'patternsize',2, ...
                           'overwrite',false, 'bilateral',true)

zapit.utils.stimConfigPatternGenerator('myPattern', [1.55,2.75], ...
                           'pattern', 'MLline', 'num',5, 'patternsize',1.5, ...
                           'overwrite',false, 'bilateral',true)

zapit.utils.stimConfigPatternGenerator('myPattern', [-3.5,0], ...
                            'pattern','cross', 'num',[3,5], 'patternsize', [0.75,1.5], ...
                            'overwrite',false)

```

<figure><img src="/files/nVAL2NzCF8OY9pQ4bv9H" alt=""><figcaption><p>The two crosses are independent. The AP and ML lines each contain points that are stimulated bilaterally.</p></figcaption></figure>

#### Generating plots of the stimulus locations

You can generate plots of the stimulus locations in one of two ways.

```matlab
zapit.utils.plotStimuli('myPattern.yml')
```

Or with the `'makePlot', true` parameter/value pair as an argumnent to the stimConfigPatternGenerator. These files can also be loaded into the stim editor GUI and modified.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://zapit.gitbook.io/user-guide/using-the-gui/generating-stimulus-patterns-at-the-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
