Thank you very much for your reply! I couldn’t send pictures to the forum, so I posted the code below. Because the materials are not organized yet, I will use one folder to refer to all the folders
in Begin routine:
import os
import random
global_sound = 0
file_path_Pnormal = 0
file_path_Pless = 0
file_path_Nnormal = 0
file_path_Nless = 0
**folder_path_Pnormal = “\fu”
folder_path_Pless = “\fu”
folder_path_Nnormal = “\fu”
folder_path_Nless = “\fu”
file_list_Pnormal = []
file_list_Pless = []
file_list_Nnormal = []
file_list_Nless = []
#P_normal
for root, dirs, files in os.walk(folder_path_Pnormal):
for file_name in files:
file_path_Pnormal = os.path.join(root, file_name)
file_list_Pnormal.append(file_path_Pnormal)
random.shuffle(file_list_Pnormal)
for file_path_Pnormal in file_list_Pnormal:
**print(file_path_Pnormal)
#P_less
for root, dirs, files in os.walk(folder_path_Pless):
for file_name in files:
file_path_Pless = os.path.join(root, file_name)
file_list_Pless.append(file_path_Pless)
random.shuffle(file_list_Pless)
for file_path_Pless in file_list_Pless:
**print(file_path_Pless)
#N_normal
for root, dirs, files in os.walk(folder_path_Nnormal):
for file_name in files:
file_path_Nnormal = os.path.join(root, file_name)
file_list_Nnormal.append(file_path_Nnormal)
random.shuffle(file_list_Nnormal)
for file_path_Nnormal in file_list_Nnormal:
**print(folder_path_Nnormal)
#N_less
for root, dirs, files in os.walk(folder_path_Nless):
for file_name in files:
file_path_Nless = os.path.join(root, file_name)
file_list_Nless.append(file_path_Nless)
random.shuffle(file_list_Nless)
for file_path_Nless in file_list_Nless:
**print(file_path_Nless)
in End routine
if text_dui_cuo.text ==‘√’:
if key_resp_que.keys == ‘f’:
global_sound = np.random.choice(file_path_Pnormal)
if key_resp_que.keys == ‘j’:
global_sound = np.random.choice(file_path_Pless)
if text_dui_cuo.text ==‘×’:
if key_resp_que.keys == ‘f’:
global_sound = np.random.choice(file_path_Nnormal)
if key_resp_que.keys == ‘j’:
global_sound = np.random.choice(file_path_Nless)
When you run this code, it displays an error:**
global_sound = np.random.choice(file_path_Pnormal)
File “mtrand.pyx”, line 909, in numpy.random.mtrand.RandomState.choice
ValueError: a must be greater than 0 unless no samples are taken
################ Experiment ended with exit code 1 [pid:12036]