How to randomize separately two couples of variables (including images) from an Excel input data file?

Hi everyone! (I’m french so… my apologies for this wobbly english…)

I’m a full novice at PsychoPy, Python (and so on) and unfortunately, my first experiment on Psychopy is a little bit complex (for me). So, after multiple fails, I think that I need some help.

In my experiment, I have four variables stored in a single Excel file (images / emotional valence of images / words / emotional valence of words).
My goal is to display simultaneously 1 image and 1 word on the screen, in a way that:
→ images and words are associated in a complete aleatory manner
→ and that each image and each word still correctly linked with their own emotional valence in my output data file.

To do that, I create and randomize separately two combined lists which each contains all variables to obtain one unique random order for each combined list. And then, to associate image and word I just pick images from one combined list (first random order) and words from the second (different order). And to associate images+emotional valence and words+emotional valence I just log their values from the same combined list (where each couple were randomized together).

I precise that:
→ when I replace images by words to display, this code works perfectly. So, the problem seems to come from the image-specific code and not from the logic of the code-methodology itself.
→ and that I configure the display of words and images on the screen with a TEXT and IMAGE COMPONENT

1) First Code Component Part 1 ( BEGIN EXPERIMENT field ) :

# I import packages to read xlsx files, randmize lists, manipulate images
import xlrd, random, visual

# I precise random function to have one particular random order per subject

# I load my xlsx file containing images, words and 2 attributes
in_file = 'essai_image_psycho/essai_image_1.xlsx'

# I define the number of items that I will use in my entire experiment
num_items = 6

# I put the reference to increment 'mot' and 'imageLat' counters through the experiment
cur_mot = 0
cur_imageLat = 0

2) First Code Component Part 2 ( BEGIN ROUTINE field ) :
→ As I configure the display of my images in an Image Component, I don’t create a ‘visual.Window’ in my code and I don’t configure here the display of images (size, position…).
=> Is it still necessary to create such Window and put these information into the code? <=

→ Psychopy shows me an error message for the 19th row of the code (Syntax error n° 4205) when I try to fill my ‘combined lists’ with a loop. (no more details from psychopy)

# I read the file loaded before
inbook = xlrd.open_workbook(in_file)

#I precise which sheet to load through the file
insheet = inbook.sheet_by_index(0)

# I create empty lists for each variables 
imageLat = [] #this will contain images
valence_image = []
mot = []
valence_mot = []

# I loop the file to fill lists precising where are each values
for rowx in range(1,num_items+1):
    row = insheet.row_values(rowx)
    #I precise here that all values into the first row (taking by rowx ) are images
    # and I store them into the 'imageLat' list
    imageLat.append(visual.ImageStim(image = rowx[row[0]]))

# I create two combined lists
mot_order = [] #combined list to randomize the lists 'mot' and 'valence_mot' together
imageLat_order = [] #combined list to randomize 'imageLat' and 'valence_image' together

# I fill my combined lists (each combined list will contain values of all previous lists, I guess)
for i range(num_items):
# I randomize separatly each combined list to have two different random orders

3) Second Code Component Part 1( BEGIN ROUTINE field):
Honestly, I’m not convinced by what I want to do here…
Psychopy shows me an error message for the 1rst row (Syntax error n° 4205) with no more details again.

# (1) I define what I want to draw here: the image (value of imageLat list) corresponding to the
# current imageLat stored into the combined and randomized 'imageLat_order' list
# (2) I tell to psychopy that this object is an image (with the function '.image', I think...)
# (3) I tell him to draw this image (with the function '.draw()'  )

4) Second Code Component Part 2 (END ROUTINE field):

# I log all data that I need (and more)
thixExp.addData('image_lat', imageLat[imageLat_order[cur_imageLat]])
thisExp.addData('image_Lat_order', imageLat_order[cur_imageLat])
thisExp.addData('cur_image_lat', cur_imageLat)
thisExp.addData('valence_image', valence_image[imageLat_order[cur_imageLat]])
thisExp.addData('mot', mot[mot_order[cur_mot]])
thisExp.addData('mot_order', mot_order[cur_mot])
thisExp.addData('cur_mot', cur_mot)
thisExp.addData('valence_mot', valence_mot[mot_order[cur_mot]])

# I increment 'mot' and 'imageLat' counters to update the counters at each trial
cur_imageLat = cur_imageLat+1
cur_mot = cur_mot+1

I don’t know if I reach the goal, or if I still far away from it…
If anybody can help me, I would be deeply grateful!
Thank you, and have a good day! =D