---
# System prepended metadata

title: SSI Mentorship meeting Wednesday 26th April 2023

---

# SSI Mentorship meeting Wednesday 26th April 2023

Coding project - visual experiment. Each trial consists of:
 - Indicator, specifying which side of the screen to focus on
 - Prompt, which instructs the paricipant to select a specific colour (task 1) or shape (task 2)
 - Stimuli - four stimuli are presented, and the participant must select the correct one (the "target").

Options:
 - psychtoolbox (Octave/MATLAB)
 - lab.js, or similar
 - PsychoPy 

## Implementation of online randomisation in python.

You could re-arrange/relabel your stimuli so that they can be distinguished from one another, e.g.:

```
stim\
  <colour>_<shape>_<number>.png
  
  -- OR use a directory structure --

  <colour>\
    <shape>\
       1.png
       2.png
       
  orange\
    square\1.png 2.png ...
    triangle\1.png 2.png ...
    circle\1.png 
```

You could then automatically scan your stimulus files to create a labelled stimulus data structure:

```python
stim = {
 'orange' : {
    'triangle' : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'square'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'circle'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
 },
  'yellow' : {
    'triangle' : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'square'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'circle'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
 },
  'green' : {
    'triangle' : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'square'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
    'circle'   : ['1.png', '2.png', '3.png', '4.png', '5.png'],
 },
}
```

Then you could randomly select stimuli as needed:

```python
import random

all_colours = list(stim.keys())

target_colour = random.choice(all_colours)

# list comprehension
non_target_colours = [c for c in all_colours if c != target_colour]

all_shapes = list(stim[target_colour].keys())

target_shape = random.choice(all_shapes)

target_candidates = stim[target_colour][target_shape]

# select the first orange triangle
stimfile = target_candidates[0]

# select a random orange triangle
stimfile = random.choice(target_candidates)
```

A basic experiment could just be to have a single block with e.g. 10 trials, where you just randomly choose a stimulus to present - your stimuli could just be a list:

```python
stim = ['1.png', '2.png', '3.png', '4.png', '5.png']

# run within each trial
current_stim = random.choice(stim)

# OR do this before any trial
trial_order = stim + stim
random.shuffle(trial_order)

for trial_number in range(10):
    current_stim = trial_order[i]
```

Tasks (both of us):
  - Play around and become more familiar with psychopy!