# Brush Respose Data

**URL:** https://discourse.psychopy.org/t/brush-respose-data/21343
**Category:** Builder
**Created:** [March 15, 2021, 8:22pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343 "2021-03-15T20:22:56Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![nebulaPerceptron](https://avatars.discourse-cdn.com/v4/letter/n/db5fbb/32.png) [@nebulaPerceptron](https://discourse.psychopy.org/u/nebulaPerceptron)
#### Post date: [March 15, 2021, 8:22pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/1 "2021-03-15T20:22:57Z")

</div>

**OS** Mac OS Sierra 10.12.6  
PsychoPy3 Experiment Builder v2021.1.2  
Python 3.6.8

**What are you trying to achieve?:**  
Trying to give a sound stimuli and take a response with **brush tool**

**What did you try to make it work?:**  
Trying to find a solution on this forum , tried to understand if I need to convert any data which is not in an image format to an image but also can not find an answer to that, also converted it to a python file and tried to read to find something about saving that data but could not understand by that way eigther…

**What specifically went wrong when you tried that?:**  
The experiment works but Can not see any brush response data saved anywhere

6.3845 WARNING Monitor specification not found. Creating a temporary one…  
2021-03-15 23:39:37.951 python[5853:79969] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/b3/s7y853057yzbys5whx9gvyyr0000gn/T/org.opensciencetools.psychopy.savedState

##### Experiment ended.

this appears on the console

I did search the path on the error and there are two .data and one .plist files but still can not find a solution about how to see brush component saved data

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [March 22, 2021, 10:28am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/2 "2021-03-22T10:28:59Z")

</div>

The Brush component is a tricky one as the data you’re likely to want is very much dependent on your experiment design. During the experiment, you can access the position of the Brush via:

```auto
myBrush.pointer.pos

```

to answer the question “is the Brush currently on this image/shape component?” you would do this:

```auto
myShape.contains(myBrush.pointer)

```

or get an array of all positions the brush has drawn in via:

```auto
myBrush.brushPos

```

and all of these you could use `trials.addData` to save them to the datafile.

but if you wanted to actually _see_ the response, the best way is to capture the window as an image at the end of the routine:

```auto
win.saveMovieFrames('data/myFilename.png')

```

---

<div class="post-metadata">

### Author: ![Gina\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gina_wang/32/34341_2.png) [@Gina\_Wang](https://discourse.psychopy.org/u/Gina_Wang)
#### Post date: [September 18, 2022, 9:23am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/3 "2022-09-18T09:23:37Z")

</div>

Hi, I try to save the png images of the result. But it continues showing that the win variable is not found. Do you know how can I solve it? Apprecitative of your time!

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [September 19, 2022, 7:53am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/4 "2022-09-19T07:53:56Z")

</div>

What tab in the :code: Code component did you put the code in? If `win` is not defined I’d guess it’s that the code is being executed too early

---

<div class="post-metadata">

### Author: ![Gina\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gina_wang/32/34341_2.png) [@Gina\_Wang](https://discourse.psychopy.org/u/Gina_Wang)
#### Post date: [September 20, 2022, 10:21pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/5 "2022-09-20T22:21:50Z")

</div>

HI, I just put win.saveMovieFrames(‘data/myFilename.png’) in the code component in each frame. I am wondering what kind of other actions do I need to include before using this function? Thank you so much!

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [September 21, 2022, 8:58am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/6 "2022-09-21T08:58:34Z")

</div>

It’s very strange for win not to exist by the time the each frame code is executed, could you share your psyexp file?

---

<div class="post-metadata">

### Author: ![Gina\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gina_wang/32/34341_2.png) [@Gina\_Wang](https://discourse.psychopy.org/u/Gina_Wang)
#### Post date: [September 25, 2022, 8:19am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/7 "2022-09-25T08:19:46Z")

</div>

Yes! Here is my experiment:  
[drawing1.psyexp](https://discourse.psychopy.org/uploads/short-url/vVyoavopPUc0vsAN9y9fkGzqgZR.psyexp) (62.1 KB)  
I put the win function in the line\_drawing\_task rountine.

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [September 26, 2022, 12:04pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/8 "2022-09-26T12:04:19Z")

</div>

Are you running this locally? Your :code: Code component has some JavaScript in the Python box:

```auto
psychoJS.eventManager.clearEvents('keyboard')

```

should be

```auto
keyResp.clearEvents()

```

and:

```auto
keys = psychoJS.eventManager.getKeys()

```

should be

```auto
keyResp.getKeys()

```

I’m not sure why the specific error you’re getting is that `win` doesn’t exist, but when running locally `psychoJS` certainly shouldn’t exist so that might expplain why it’s erroring.

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [September 26, 2022, 12:06pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/9 "2022-09-26T12:06:09Z")

</div>

Also I’d advise against saving the screen each frame - you’ll end up just overwriting the same image over and over which will slow down your experiment. If you only want the window at the end of the routine, it’s best to have the screenshot saving in the End Routine tab

---

<div class="post-metadata">

### Author: ![Gina\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gina_wang/32/34341_2.png) [@Gina\_Wang](https://discourse.psychopy.org/u/Gina_Wang)
#### Post date: [October 1, 2022, 3:45pm UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/10 "2022-10-01T15:45:58Z")

</div>

Sorry for the late response and thank you so much for your reply and help! Actually, I have run it online. Should it be the reason why the win does not work? The reason I saved each frame is that I want to save the response of each picture of participants’ drawing.

---

<div class="post-metadata">

### Author: ![TParsons](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/tparsons/32/8301_2.png) [@TParsons](https://discourse.psychopy.org/u/TParsons)
#### Post date: [October 12, 2022, 10:00am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/11 "2022-10-12T10:00:35Z")

</div>

To save each drawing I think you still want it to run at the end of the routine rather than each frame - as this will save after each repeat of the routine.

`win` not existing online makes sense! In PsychoJS it’s not called `win`, it’s called `psychoJS.window`

---

<div class="post-metadata">

### Author: ![Gina\_Wang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/gina_wang/32/34341_2.png) [@Gina\_Wang](https://discourse.psychopy.org/u/Gina_Wang)
#### Post date: [October 19, 2022, 6:48am UTC](https://discourse.psychopy.org/t/brush-respose-data/21343/12 "2022-10-19T06:48:06Z")

</div>

Okay. I will trouble shoot with it more later. Thank you so much for your suggestions!
