# Adjustable clickable stimuli in the Mouse component

**URL:** https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386
**Category:** Builder
**Created:** [April 18, 2021, 2:34pm UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386 "2021-04-18T14:34:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 18, 2021, 2:34pm UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/1 "2021-04-18T14:34:45Z")

</div>

This is a newbie question, so I hope someone can easily lend me a hand. I’m designing a practice trial for an experiment that presents two picture components (Left and Right). I want the participant to choose the correct answer from the two pictures, and if he doesn’t select the correct answer, that the program simply waits for him to correct the mistake and click the correct one.  
Half of the trials have the correct picture on the left, half on the right. So, I set a Mouse component in the Routine to End the routine with a valid click, but want to customize the “Clickable stimuli” so that it only registers the correct response from an Excel table column called “correct\_click”. I tried writing in the “Clickable stimuli” `$correct_click` and the same without the dollar sing, but it doesn’t register.  
Can someone tell me how to customize the Clickable stimuli so that the program uses the name taken from the excel column “correct\_click” and the Mousce component only registers that as a valid click?

---

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 18, 2021, 2:35pm UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/2 "2021-04-18T14:35:52Z")

</div>

Also, I forgot to add, the “correct\_click” column has the names of the picture components, so either “Left” or “Right”

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [April 18, 2021, 6:01pm UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/3 "2021-04-18T18:01:18Z")

</div>

What version of PsychoPy are you using?

Potentially useful thread

> [@How do I use a Mouse response in a Conditional task.?](https://discourse.psychopy.org/t/how-do-i-use-a-mouse-response-in-a-conditional-task/4807):
>
> OS(MAC OS High Sierra 10.13.5): PsychoPy version (2 PY3): I did a conditional task, and it is working very well. In this task, I present one stimulus at the top (A) and two at the bottom (B and C). The responses are “left” or “right” on the keyboard. If the response is correct, one “point” is added to a total\_correct and a message “correct” show on the screen, and if this score is bigger than a criterion in the excel file, it ends the training routine AB. It is working so far. My question is…

However, this is even closer

> [@Changing targets for mouse clicks](https://discourse.psychopy.org/t/changing-targets-for-mouse-clicks/19682/2):
>
> Hi, PsychoPy will interpret any values in condition files as literal values - e.g. the literal letter 'A', rather than the stimulus object called A. So you need to tell Python to interpret the variable as containing the name of an object, rather than as literal content. Fortunately Python is a dynamic language and allows you to do this via its eval() function. So in the “clickable stimuli” field, try putting this instead: eval(Target) Otherwise, I think you’re on track. EDIT: I just saw the …

---

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 19, 2021, 8:14am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/4 "2021-04-19T08:14:20Z")

</div>

Thank you! Yes, the second question is really close to what I need, but I was unable to use the `eval($correct_click)` in the clickable stimuli box. To be more precise, it starts the experiment, but when it gets to that routine, and I click (either the correct or the incorrect image) it gives this message:

```auto
for obj in eval(correct_click):
TypeError: 'ImageStim' object is not iterable
##### Experiment ended. #####

```

I tried the recommended code to stop the routine from the same thread and a similar problem happens.

To answer your first question, I’ve used an older version from two years ago, I’m using the latest version (v2021.1.4).

---

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 19, 2021, 9:08am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/5 "2021-04-19T09:08:51Z")

</div>

Update: that imagestim object is not iterable message has become a pervasive problem in my experiment ([After updating my PsychoPy to the latest (v2021.1.4), my experiment crashes](https://discourse.psychopy.org/t/after-updating-my-psychopy-to-the-latest-v2021-1-4-my-experiment-crashes/22401)), so I’m not sure if it’s related to this topic.

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [April 19, 2021, 9:08am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/6 "2021-04-19T09:08:56Z")

</div>

> [@judgeLionthink](#):
>
> `eval(correct_click)`

Try adding a comma after eval(correct\_click) so that PsychoPy interprets it as a list.

---

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 19, 2021, 9:14am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/7 "2021-04-19T09:14:32Z")

</div>

Doesn’t work. Gives this error (V1\_mis is the name of the mouse component):

```auto
if obj.contains(V1_mis):
AttributeError: 'str' object has no attribute 'contains'

```

EDIT: removed the quotes from the excel table (it’s left/right instead of “left”/“right”), and now the error message is:

```auto
for obj in eval(correct_click),:
  File "<string>", line 1, in <module>
NameError: name 'right' is not defined

```

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [April 19, 2021, 9:17am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/8 "2021-04-19T09:17:53Z")

</div>

Isn’t your component called Right not right?

---

<div class="post-metadata">

### Author: ![judgeLionthink](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/judgelionthink/32/15677_2.png) [@judgeLionthink](https://discourse.psychopy.org/u/judgeLionthink)
#### Post date: [April 19, 2021, 9:19am UTC](https://discourse.psychopy.org/t/adjustable-clickable-stimuli-in-the-mouse-component/22386/9 "2021-04-19T09:19:54Z")

</div>

Thank you! That fixed the problem 😃
