psychopy.org | Reference | Downloads | Github

Creating Blocks of Trials is not working

Hello everyone,

i am using the latest Psychopy version on windows 10. I tried to build a block design like the one in the demo. In the outer loop i have a header which then lists xlsx files beneath. In the inner loop, the demo uses
$header to then calsl the xlsx files from the outer loop.

So instead of calling the xlsx directly for the loop, i call $header which should give me random input from xlsx. 1-4. Problem is, that calling the xlsx with $header is not working. It say “header” is not defined.
Is this Block demo still up to date or did anything change?

I hope someone can help me with this.

Best regards,

Carina

Have you tried running the experiment anyway? I have a similar design, where the inner loop component says ‘conditions file’ not found, but when I run the experiment it behaves as expected, picking up the conditions file from a colomn in the block file.

It is not running. At first this morning it looked like it is running. But the inner loop failed to correctly perform what it should be doing. I tried to fix it, and now again i cannot run the experiment cause it says that a condition is not defined. It is defined within a file that should be opened thrpugh the outer loop.

outer loop:
header
file1.xlsx
file2.xlsx

inner loop
$header (should e.g. then be advised to call file1.xlsx right?)

Best

It seems to be a general definition problem. I get an error even without using an outer loop.
Saying that variable x is not defined. But it is defined…

Please can you show exactly how and where you are defining and using header?

Sure,
header is part of the outer loop.
header
1.csv
2.csv

In the inner loop, i tell psychopy to get the inputs for my sounds from $header.

So that the inner loop e.g. gets 1.csv from the outer loop and then uses a defined parameter from 1.csv for e.g. my sound_1

Is it clear what I am trying to do?

That explains what you want (a sound played in the inner loop defined by a parameter from an Excel loaded by the outer loop). However, to help you I’d need to see screen shots of loops/components and pasted code so I can see exactly how you have tried to achieve your goal.

Giving the exact error message helps too.

It´s either this

36.0220 EXP Imported blocks.xlsx as conditions, 4 conditions, 1 params
36.0304 EXP Imported target2.csv as conditions, 24 conditions, 6 params
36.0384 EXP Imported target2.csv as conditions, 24 conditions, 6 params
36.0465 EXP Imported target2.csv as conditions, 24 conditions, 6 params
36.0466 WARNING duplicate variable names: Zielton, randaud, tarrand, target, Sequenz, sound

sound_4 = sound.Sound(Zielton, secs=1.0, stereo=True, hamming=True,
NameError: name ‘Zielton’ is not defined

Experiment ended.

Or it does not give me the error message but is playing the sound too often.

That is the experiemtn setting and design:

blocks

![trial|440x332]

I think what I want to do is not possible. I wanted the outer loop, so blocks, to go over all the Parts 4 times. So going through everything (target, trial and deviant) and then repeating it with different inputs.

trial

I’m sure what you want it possible.

You currently have nReps for Blocks set to 0 so it won’t do anything.

Where is this code?

Do you mean this?

Initialize components for Routine “Target2”

Target2Clock = core.Clock()
sound_4 = sound.Sound(Zielton, secs=1.0, stereo=True, hamming=True,
name=‘sound_4’)
sound_4.setVolume(0.1)
key_resp_8 = keyboard.Keyboard()
text_8 = visual.TextStim(win=win, name=‘text_8’,
text=’\nDies ist der Zielton\n\n\nBestätigen Sie bitte mit “3” \n\n\n\n 3\n\n’,
font=‘Arial’,
pos=(0, 0), height=0.05, wrapWidth=None, ori=0,
color=‘white’, colorSpace=‘rgb’, opacity=1,
languageStyle=‘LTR’,
depth=-2.0);

I can’t see Target2 in your flow. However, if that is in a Begin Experiment tab of a code component then that’s before the variable Zielton is available. When you create a routine with a variable set to every repeat it gets initially set to undefined

1 Like

Okay thank you!